Double Ammo Issue "An actor that adds BOTH types of ammo at the same time."
#1 Posted 17 June 2020 - 07:06 PM
I've made an ammo type that adds ammo for both the Shrinker and Expander at the same time. Only problem is, lets say the Shrinker is at full, I can't gain ammo for the other weapon, which is the Expander in this case. If one ammo type is full, the sprite has no effect on the other ammo type.
Does anyone have a suggestion?
This post has been edited by HELLMOUSE: 17 June 2020 - 07:08 PM
#2 Posted 17 June 2020 - 08:55 PM
#3 Posted 22 June 2020 - 03:12 PM
#4 Posted 22 June 2020 - 07:03 PM
ife player[].gotweapon SHRINKER_WEAPON 1 ife player[].gotweapon GROW_WEAPON 1 ifge player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON ifge player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON break setplayer[].gotweapon SHRINKER_WEAPON 1 setplayer[].gotweapon GROW_WEAPON 1 addammo SHRINKER_WEAPON 10 addammo GROW_WEAPON 10
Instead of "addammo", use this:
ifge player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON ifge player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON break addammo SHRINKER_WEAPON CRYSTALAMMOAMOUNT addammo GROW_WEAPON GROWCRYSTALAMMOAMOUNT
#6 Posted 25 June 2020 - 06:11 PM
Fox, on 22 June 2020 - 07:03 PM, said:
ife player[].gotweapon SHRINKER_WEAPON 1 ife player[].gotweapon GROW_WEAPON 1 ifge player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON ifge player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON break setplayer[].gotweapon SHRINKER_WEAPON 1 setplayer[].gotweapon GROW_WEAPON 1 addammo SHRINKER_WEAPON 10 addammo GROW_WEAPON 10
Hmm, I'm not sure if I need this part.
Fox, on 22 June 2020 - 07:03 PM, said:
ifge player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON ifge player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON break addammo SHRINKER_WEAPON CRYSTALAMMOAMOUNT addammo GROW_WEAPON GROWCRYSTALAMMOAMOUNT
This part looks like what I'm talking about. I've tested it, but I still have the same problem. If one is maxed, then Duke doesn't pick up the sprite. You're still using "addammo" which seems to be preventing him from using the object. Even without "addammo" it doesn't work, because there is no way to add anything.
I'm wondering if there is a way to load Duke's ammo amount and the amounts of the power-ups into "vars" and add them together. I did notice some math operations and ways to access the player's structs. Again, I'm not sure of the syntax and some of the commands don't have anything.
Thanks for the advice though.
#7 Posted 25 June 2020 - 07:10 PM
#8 Posted 11 July 2020 - 09:46 PM
// MY THING - the Doulbe Ammo (BOOTHER) gamevar SHRINK_STAT 0 1 // used to report what the player has gamevar SHRINK_AMMO_ADDIT 0 2 // used to add player number and ammo in the sprite gamevar SHRINK_SUBIT 0 2 // used for unused shrinker to transfer to dark exp gamevar SHRINK_AMMO_TRANS 0 2 // used for unused shrinker to transfer to dark exp gamevar DARKEXP_STAT 0 1 gamevar DARKEXP_AMMO_ADDIT 0 2 gamevar DARKEXP_SUBIT 0 2 // used for unused dark exp to transfer to shrinker gamevar DARKEXP_AMMO_TRANS 0 2 // used for unused dark exp to transfer to shrinker gamevar BOOTHER_AMOUNT 0 2 // this is set by each type of BOOTHER actor and is only declared here.
State, BOOTHER_MATH, that is called for the Double Ammo actor (BOOTHER).
This state handles:
1) adding to both ammo types
2) adding to either of the ammo types if the other is full
3) preventing either of the ammo types from exceeding the maximum
4) and allows the transfer of either ammo to the other if one of them is or becomes full.
// MY THING state BOOTHER_MATH getplayer[THISACTOR].ammo_amount 6 SHRINK_AMMO_ADDIT // load what player has addvarvar SHRINK_AMMO_ADDIT BOOTHER_AMOUNT // add ammo amount to what player has (SHRINK.. + ..AMOUNT) getplayer[THISACTOR].ammo_amount 11 DARKEXP_AMMO_ADDIT addvarvar DARKEXP_AMMO_ADDIT BOOTHER_AMOUNT setplayer[THISACTOR].ammo_amount 6 SHRINK_AMMO_ADDIT // actual update ammo for player with new value setplayer[THISACTOR].ammo_amount 11 DARKEXP_AMMO_ADDIT getplayer[THISACTOR].ammo_amount 6 SHRINK_STAT // what does the player have now? ifvarg SHRINK_STAT MAXSHRINKERAMMO // if ammo over the max then... { setvarvar SHRINK_SUBIT SHRINK_STAT // puts what the player has into mem subvar SHRINK_SUBIT MAXSHRINKERAMMO // figures out what the remaining ammo is addvarvar DARKEXP_AMMO_TRANS SHRINK_SUBIT // puts the ramaining ammo into mem getplayer[THISACTOR].ammo_amount 11 DARKEXP_STAT // get what the player has addvarvar DARKEXP_AMMO_TRANS DARKEXP_STAT // adds what remaining ammo is to what player has setplayer[THISACTOR].ammo_amount 6 MAXSHRINKERAMMO // set to max - no over setplayer[THISACTOR].ammo_amount 11 DARKEXP_AMMO_TRANS // give player the remaining ammo getplayer[THISACTOR].ammo_amount 11 DARKEXP_STAT // get what the player has now ifvarg DARKEXP_STAT MAXGROWAMMO // What happens if the other ammo type is full from the transfer? setplayer[THISACTOR].ammo_amount 11 MAXGROWAMMO // This stops the program from repeating another transfer with the } // code below. getplayer[THISACTOR].ammo_amount 11 DARKEXP_STAT ifvarg DARKEXP_STAT MAXGROWAMMO { setvarvar DARKEXP_SUBIT DARKEXP_STAT subvar DARKEXP_SUBIT MAXGROWAMMO addvarvar SHRINK_AMMO_TRANS DARKEXP_SUBIT getplayer[THISACTOR].ammo_amount 6 SHRINK_STAT addvarvar SHRINK_AMMO_TRANS SHRINK_STAT setplayer[THISACTOR].ammo_amount 6 SHRINK_AMMO_TRANS setplayer[THISACTOR].ammo_amount 11 MAXGROWAMMO getplayer[THISACTOR].ammo_amount 6 SHRINK_STAT ifvarg SHRINK_STAT MAXSHRINKERAMMO setplayer[THISACTOR].ammo_amount 6 MAXSHRINKERAMMO } ends
The code for the Double Ammo actor (BOOTHER: BOOTHER5).
// code from Trooper Dan appendevent EVENT_SPAWN ifactor BOOTHER5 sizeat 32 32 endevent // code from Trooper Dan // MY THING actor BOOTHER5 fall cstat 2048 setvar BOOTHER_AMOUNT 5 ifmove RESPAWN_ACTOR_FLAG state respawnit else ifp pshrunk nullop else ifp palive ifpdistl RETRIEVEDISTANCE ifcount 6 ifcanseetarget { getplayer[THISACTOR].ammo_amount 6 SHRINK_STAT // load player ammo into mem getplayer[THISACTOR].ammo_amount 11 DARKEXP_STAT ifvarl SHRINK_STAT MAXSHRINKERAMMO // if player has less than max { state BOOTHER_MATH quote 125 ifspawnedby BOOTHER5 state getcode else state quikget } else ifvarl DARKEXP_STAT MAXGROWAMMO { state BOOTHER_MATH quote 125 ifspawnedby BOOTHER5 state getcode else state quikget } } enda
This post has been edited by HELLMOUSE: 11 July 2020 - 10:09 PM
#9 Posted 12 July 2020 - 09:36 AM
Trooper Dan, on 17 June 2020 - 08:55 PM, said:
Thanks for the direction. Accessing the ammo_amount array inside the player struct seems to be the best way to do it. The only problem is an ammo type can go over the max limit. I did fix this and gave the actors the ability to transfer the ammo into the other type if one fills-up. I kind of made the Shrinker and Dark Expander ammo types arguably obsolete since my Double Ammo actors take care of both and will automatically add ammo to the other if one is full.
I'm not sure if there is a more efficient way to do this but this mess works. That's why I made a state, so I wouldn't have to code it for each BOOTHER actor. There's also a gamevar that I used to set the amount of ammo, for both types, to be added from each variation of the actor.
Maybe I could make a "hyper ammo" actor that goes beyond the max limits using these:
gamevars
gamevar commands
get<struct>[THISACTOR].<struct member / array> <member in array> <gamevar>
set<struct>[THISACTOR].<struct member / array> <member in array> <gamevar>
...just a thought since accessing the player structure bypasses certain rules.
This post has been edited by HELLMOUSE: 12 July 2020 - 09:38 AM
#10 Posted 13 July 2020 - 11:24 AM
Fox, on 22 June 2020 - 07:03 PM, said:
ife player[].gotweapon SHRINKER_WEAPON 1 ife player[].gotweapon GROW_WEAPON 1 ifge player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON ifge player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON break setplayer[].gotweapon SHRINKER_WEAPON 1 setplayer[].gotweapon GROW_WEAPON 1 addammo SHRINKER_WEAPON 10 addammo GROW_WEAPON 10
Instead of "addammo", use this:
ifge player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON ifge player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON break addammo SHRINKER_WEAPON CRYSTALAMMOAMOUNT addammo GROW_WEAPON GROWCRYSTALAMMOAMOUNT
This won't work because the problem is addammo.
This should work. (Untested though, I'm unable to verify if it compiles at this time, but the answer should at least be extremely close to this)
For addweapon:
// Check if we have the weapons and we're full on ammo for both, if so, break. ife player[].gotweapon SHRINKER_WEAPON 1 ife player[].gotweapon GROW_WEAPON 1 ifge player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON ifge player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON break // Grant the weapon setplayer[].gotweapon SHRINKER_WEAPON 1 setplayer[].gotweapon GROW_WEAPON 1 // Add ammo directly to structs addvar player[].ammo_amount SHRINKER_WEAPON 10 addvar player[].ammo_amount GROW_WEAPON 10 // If ammo exceeds maximum after adding, clamp. ifg player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON setvarvar player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON ifg player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON setvarvar player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON
Addammo:
// Check if we have full ammo for both, if so, break. ifge player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON ifge player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON break // Add ammo directly to structs addvar player[].ammo_amount SHRINKER_WEAPON 10 addvar player[].ammo_amount GROW_WEAPON 10 // If ammo exceeds maximum after adding, clamp. ifg player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON setvarvar player[].ammo_amount SHRINKER_WEAPON player[].max_ammo_amount SHRINKER_WEAPON ifg player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON setvarvar player[].ammo_amount GROW_WEAPON player[].max_ammo_amount GROW_WEAPON
This post has been edited by Striker: 13 July 2020 - 11:34 AM
#11 Posted 14 July 2020 - 07:10 PM
So if you are looking for a double ammo actor then here it is. Remember, it also transfers ammo to the other type when one fills up. I think that my solution may be useful for anyone who has this idea. I've tested it in every possible situation and it does work perfectly.
#12 Posted 25 July 2020 - 05:45 PM
Double Ammo.TXT (7.34K)
Number of downloads: 139
I only have declaration, tile declaration, and actor code for the BOOTHER5 in the Double Ammo attachment.
Here are the pictures I made in EditArt
Double_Ammo_Pics.zip (7.14K)
Number of downloads: 146
What do these actors do again?
1) Give ammo for the Shrinker and Expander at the same time
2) Transfer the ammo to the other type if one is full
3) Saves the remaining ammo Duke does not need by storing it in a gamevar
---- The actor will not disappear until all the ammo for both are gone. No waste of ammo.
4) Outputs exactly what Duke is receiving in a HUD message
Thanks Trooper Dan, Fox, and Striker for the help!
By the way, the word Boother is Hellmouse for double functional charge and multi-compatible battery unit. It's a rough translation but that's what it does. Mono-compatible would only charge one weapon at a time and not save any energy for the other. Multi-compatible can do both at the same time. Double functional charge just means it holds two types of energy.
This post has been edited by HELLMOUSE: 25 July 2020 - 05:46 PM