Initial pickup state for weapon actor?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
BaronGasMask
Posts: 4
Joined: Sat Dec 26, 2020 12:12 pm
Graphics Processor: nVidia (Modern GZDoom)

Initial pickup state for weapon actor?

Post by BaronGasMask »

Hey all! Working on a .pk3 that features a reloading weapon (using WildWeasel's reloading weapon tutorial) and thought of a cute idea to handle initial mag-filling and give a little personality to the weapon. I was wondering if there's an actor state that can be added in DECORATE to give the weapon a short animation and reload on first pickup only? Basically something like:

Code: Select all

StateName:
				TNT1 A 0 A_JumpIfInventory("MyGun", "Ready") //If the player already has MyGun, then just go to Ready state as normal
				MGUN A 0 A_JumpIfInventory("45Round", 1, "ReloadWork") //If there's extra .45 rounds in inventory, auto-load them into MyGun
				MGUN B 2 //Reload cycle 1
            MGUN C 2 //Reload cycle 2
				Goto Ready
While I'm aware that there's a way to have the weapon full on initial pickup (seen here: viewtopic.php?f=39&t=56130) I thought that if I could add a way to define this state as on first pickup only, that could be kinda cool. Thoughts? Apologies, I'm very very new to modding of any kind so idk if this is actually a huge project haha.
Jarewill
 
 
Posts: 1855
Joined: Sun Jul 21, 2019 8:54 am

Re: Initial pickup state for weapon actor?

Post by Jarewill »

The only way to do this as far as I know is this:

Code: Select all

Ready:
    TNT1 A 0 A_JumpIfInventory("FirstLoad",1,"ReadyTrue") //So it happens only on first pickup when the player doesn't have this item
    TNT1 A 0 A_GiveInventory("FirstLoad",1) //Give the item now
    //Reload sequence
    Goto ReadyTrue //Go to the real Ready state
ReadyTrue:
    MGUN A 1 A_WeaponReady
    Loop

Actor FirstLoad : Inventory {Inventory.MaxAmount 1} //The item   
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: Initial pickup state for weapon actor?

Post by Matt »

For the other way, if you want it to work for the first time that particular weapon is picked up and not the first time the player picks up that kind of weapon, I recommend looking at this old tutorial.

I might want to suggest not doing this automatically, though, because there's nothing worse than accidentally running over a weapon in the middle of a firefight and not only being unable to shoot due to switching but also a reload sequence on top of that...
Post Reply

Return to “Scripting”