(Answered: ACS)[DECORATE] Adding an item/counter to an item.
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
-
DoomHobbyist
- Posts: 34
- Joined: Sat Feb 15, 2014 4:54 pm
(Answered: ACS)[DECORATE] Adding an item/counter to an item.
Hello folks, first time posting here, long time lurker.
Not sure if this should go under the 'How To...' topic, but I kind of want a direct answer.
I've been working on my own little hobby project for a couple of years now, on and off, but just ran into a bit of a snag:
I'm trying to make a box item that gives a couple of items that stock you up on ammo and items, while changing appearance dependant on how full that box is.
I've been making this SOLELY ON DECORATE, and considering I want to see how far I can go with it, I would like a solution that does not require the use of ACS.
Frankly what I did is make the item loop an infinite ammount of time that constantly adds '1' of a specific item until the inventory for that type is filled.
How would I make the item count how many times this line was parsed, until a certain threshhold, so it can switch sprites?
Not sure if this should go under the 'How To...' topic, but I kind of want a direct answer.
I've been working on my own little hobby project for a couple of years now, on and off, but just ran into a bit of a snag:
I'm trying to make a box item that gives a couple of items that stock you up on ammo and items, while changing appearance dependant on how full that box is.
I've been making this SOLELY ON DECORATE, and considering I want to see how far I can go with it, I would like a solution that does not require the use of ACS.
Frankly what I did is make the item loop an infinite ammount of time that constantly adds '1' of a specific item until the inventory for that type is filled.
How would I make the item count how many times this line was parsed, until a certain threshhold, so it can switch sprites?
Last edited by DoomHobbyist on Wed Feb 19, 2014 4:56 pm, edited 3 times in total.
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: Adding an item/counter to an item.
You could probably do that with [wiki=User_variable]user variables[/wiki], [wiki]A_SetUserVar[/wiki], and [wiki]A_JumpIf[/wiki].
-
DoomHobbyist
- Posts: 34
- Joined: Sat Feb 15, 2014 4:54 pm
Re: Adding an item/counter to an item.
Blue Shadow wrote:You could probably do that with [wiki=User_variable]user variables[/wiki], [wiki]A_SetUserVar[/wiki], and [wiki]A_JumpIf[/wiki].
Just to be clear, wouldn't the user calling it effectively be the player, not the box itself?
If so, then it would affect other boxes of the same type instead of 'this box' specificly, if you know what I mean.
Either way, I'll go ahead and program with this a little bit and see if I can get it rolling! Thanks a lot!
-
DoomHobbyist
- Posts: 34
- Joined: Sat Feb 15, 2014 4:54 pm
Re: Adding an item/counter to an item.
As I expected, this relies on the caller, whom is the player, and not the box itself. Thus it carries these results over to a different box as well as not being remembered in the item itself.
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: Adding an item/counter to an item.
I thought you wanted the box thing to do the iteration in order to change its sprites.
-
DoomHobbyist
- Posts: 34
- Joined: Sat Feb 15, 2014 4:54 pm
Re: Adding an item/counter to an item.
Well, you see, do you remember Immoral conduct / Don's Challenge for the EDGE engine?
Their items and ammunition boxes would only give you as many items as you could carry and then change appearance depending on how much you took, before vanishing after a specific treshhold.
For example:
The player has 3 grenades (but can carry 5), 96 pistol rounds (but can carry 120) and 20 shotgun shells (and can carry only 20)
The ammunition bag looks closed, but once interacted would change to look like it was opened, even if the player did not take anything.
In this scenario, the player was given 2 grenades.
The box only contained 15 pistol rounds and can no longer give pistol ammo on subsequent interactions.
The player had enough shells, so nothing was done on this count.
Using a calculation with total mass (e.g. total items in bag and total items taken), the bag's sprite would shift to put emphasis on it being a little more empty.
Once depleted fully, the bag would look empty and slowly fade out.
HOWEVER, when there are two boxes and the player does the above, then uses some pistol ammo and uses the other box, the count for that ammo box need ONLY AFFECT THAT BOX'S PISTOL ROUND COUNT, while the sprite changes to reflect that for itself.
I've done something similair, but then for weapons in use, and concidering there are not more instances of that weapon then the one you are carrying, I can attach this counter to the player.
However, doing it in the previously described scenario will cause any OTHER ammobag in the vicinity to also act like this once interacted with.
So how would I make the game remember this for one item, while also remembering it for another item of the same type?
English is not my native language, so I'm having a hard time explaining it.
Their items and ammunition boxes would only give you as many items as you could carry and then change appearance depending on how much you took, before vanishing after a specific treshhold.
For example:
The player has 3 grenades (but can carry 5), 96 pistol rounds (but can carry 120) and 20 shotgun shells (and can carry only 20)
The ammunition bag looks closed, but once interacted would change to look like it was opened, even if the player did not take anything.
In this scenario, the player was given 2 grenades.
The box only contained 15 pistol rounds and can no longer give pistol ammo on subsequent interactions.
The player had enough shells, so nothing was done on this count.
Using a calculation with total mass (e.g. total items in bag and total items taken), the bag's sprite would shift to put emphasis on it being a little more empty.
Once depleted fully, the bag would look empty and slowly fade out.
HOWEVER, when there are two boxes and the player does the above, then uses some pistol ammo and uses the other box, the count for that ammo box need ONLY AFFECT THAT BOX'S PISTOL ROUND COUNT, while the sprite changes to reflect that for itself.
I've done something similair, but then for weapons in use, and concidering there are not more instances of that weapon then the one you are carrying, I can attach this counter to the player.
However, doing it in the previously described scenario will cause any OTHER ammobag in the vicinity to also act like this once interacted with.
So how would I make the game remember this for one item, while also remembering it for another item of the same type?
English is not my native language, so I'm having a hard time explaining it.
- Demolisher
- Posts: 1749
- Joined: Mon Aug 11, 2008 12:59 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Winchester, VA
- Contact:
Re: [DECORATE] (Unanswered) Adding an item/counter to an ite
Due to the unresolved issue of user variables in CustomInventory items and weapons, you cannot use these reliably, but you can assign a unique TID to your CustomInventory item in its Spawn state. This TID can be stored... somewhere (I'd say ACS array, but...). When the player executes the Pickup state, call upon said TID with the ammo info, adjust it, and adjust the sprites based on it. I suppose you could spawn a dummy actor (+NoInteraction, Invisible, +NoSector) and store the information in 'it', and if you flag it right, it won't ever be an issue.
-
DoomHobbyist
- Posts: 34
- Joined: Sat Feb 15, 2014 4:54 pm
Re: [DECORATE] Adding an item/counter to an item.
Tell you the truth, if I had any idea how to use ACS, I would have done it that way 
How would you assign a TID to a newly 'created' object on pickup (or spawn) in Decorate? I thought this was only possible in ACS?
Are there any preexisting examples of this in ACS (or decorate)?
*I found http://zdoom.org/wiki/Dynamic_TID_Assigner *
I realise I can assign a TID +1 using spawn, but how would I make it spawn a new TID after a specific threshold etc. ?
How would you assign a TID to a newly 'created' object on pickup (or spawn) in Decorate? I thought this was only possible in ACS?
Are there any preexisting examples of this in ACS (or decorate)?
*I found http://zdoom.org/wiki/Dynamic_TID_Assigner *
I realise I can assign a TID +1 using spawn, but how would I make it spawn a new TID after a specific threshold etc. ?
-
Blue Shadow
- Posts: 5046
- Joined: Sun Nov 14, 2010 12:59 am
Re: [DECORATE] Adding an item/counter to an item.
I have been thinking about this, trying to come up with a solution for what you are asking, and in doing so, I wrote my own code for the whole box thing, which uses ACS and DECORATE (though there was more ACS than DECORATE
). Yes, it does use ACS, because it is easier and less of a headache this way. I'm not really sure if one can pull it off with DECORATE-only.
The box can be interacted with by "using" it, just like you would a door or a switch. It will stock you up with ammo depending on the amount available inside of it. The box will change appearance depending on the amount of ammo left in it. When it is completely empty, it will fade out and disappear from the game. You can have as many boxes in the map as you like. Each will preserve its inventory; there will be no conflict between the boxes.
The box can be interacted with by "using" it, just like you would a door or a switch. It will stock you up with ammo depending on the amount available inside of it. The box will change appearance depending on the amount of ammo left in it. When it is completely empty, it will fade out and disappear from the game. You can have as many boxes in the map as you like. Each will preserve its inventory; there will be no conflict between the boxes.
-
DoomHobbyist
- Posts: 34
- Joined: Sat Feb 15, 2014 4:54 pm
Re: [DECORATE] Adding an item/counter to an item.
Spoiler: old postYOU, sir, are a godsent, this worked for all of my variants, and I'm sure I can get some more stuff crammed in there, as well!
This works perfectly.
Though, that leaves the question, how would you do this in decorate? Is it even possible?
Well, I'm sure someone can answer that question, for now I'm off to plow through some more walls of coding!