Animated weapon Raise
Moderator: GZDoom Developers
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!)
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!)
-
- Posts: 52
- Joined: Mon Mar 02, 2015 11:47 pm
Animated weapon Raise
I'm working on a Flamerthrower weapon for a Mod I'm working on, but I'm having trouble with some aspects. When selected, I want the flamer to raise into position and then for a pilot light to flash on. So far, all I've managed to get is a bit of the raise, the pilot light animation and then the raise finishes. Any help and insight with the scripting would be greatly appreciated.
-
-
- Posts: 1537
- Joined: Sun Jul 21, 2019 8:54 am
Re: Animated weapon Raise
What can be done, and what most mods do, is put the actual pickup animation in the Ready state and the actual Ready state in a separate state.
For example:
For example:
Code: Select all
Select:
SHTG A 1 A_Raise
Loop
Ready: //Pickup animation
SHTG ABCDCB 4
Goto Ready2
Ready2: //The actual Ready state, make all your other states (such as Fire) go here instead
SHTG A 1 A_WeaponReady
Loop
-
-
- Posts: 26472
- Joined: Tue Jul 15, 2003 4:58 pm
- Location: Scotland
Re: Animated weapon Raise
Which is, of course, a good method. But remember that any other state sequences that normally end with "goto ready" should have "goto ready2" instead, unless you want the animation to be repeated after firing etc.
-
- Posts: 677
- Joined: Mon Jan 16, 2006 8:53 pm
- Location: Rio de Janeiro - Brazil
Re: Animated weapon Raise
Crazzy tip from dumb modder:
I usually do all frames as Custom States. Every single one.
Becomes:
I usually do all frames as Custom States. Every single one.
Code: Select all
Ready:
FRAM ABCD A_WeaponReady
Loop
Code: Select all
Ready:
ReadyLoop:
ReadyLoopA:
FRAM A A_WeaponReady
ReadyLoopB:
FRAM B A_WeaponReady
ReadyLoopC:
FRAM C A_WeaponReady
ReadyLoopD:
FRAM D A_WeaponReady
Goto ReadyLoop
-
- Posts: 1987
- Joined: Mon Aug 11, 2003 1:50 pm
- Location: Waveney, United Kingdom
Re: Animated weapon Raise
It's been a long time since I looked at it due to an ongoing attack of RL, but the MaiowSpeak fake smartphone app in the Black Cats mod does this sort of thing. You are welcome to rip and mess about with the code from that 'weapon' if you like. (I will return to finish the mod, but until some distressing family matters are fully settled, my life isn't truly my own).
-
- Posts: 52
- Joined: Mon Mar 02, 2015 11:47 pm
Re: Animated weapon Raise
These solved my problem, thanks much. Now just have a new one.
https://youtu.be/_LZOzJLFSJ8
So I've run into a strange hiccup here where the Flamer gets stuck on one frame, but ONLY when the ammo count is 10 or less. I think this is the offending bit of code...
So now I can't figure out how to get it to return to the ready animation cycle when it has less than 10 ammo units. Any ideas?
https://youtu.be/_LZOzJLFSJ8
So I've run into a strange hiccup here where the Flamer gets stuck on one frame, but ONLY when the ammo count is 10 or less. I think this is the offending bit of code...
Code: Select all
AltFire:
FFTR A 0 A_JumpIf(waterlevel>= 2,"NoWay");
FFTR A 0 A_JumpIfInventory("PyrolightLoaded",10,1);
Goto Dryfire;
-
-
- Posts: 1537
- Joined: Sun Jul 21, 2019 8:54 am
Re: Animated weapon Raise
I have no idea from that snippet, seeing the entire code would help to find the issue.
-
- Posts: 52
- Joined: Mon Mar 02, 2015 11:47 pm
Re: Animated weapon Raise
Ah, ok. Its the basic code from Blade of Agony.
Spoiler:
-
-
- Posts: 1537
- Joined: Sun Jul 21, 2019 8:54 am
Re: Animated weapon Raise
Here's the problem I think:
Code: Select all
Ready2:
FFTR A 0 A_JumpIfInventory("PyrolightLoaded",10,4);
FFTR A 0 A_JumpIfInventory("FlameAmmo",1,2);
FFTR A 1 A_WeaponReady(WRF_NOSECONDARY); //<--- This....
Loop;
FFTR A 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_NOSECONDARY); //<--- ....And this states happen if the weapon has less than 10 ammo, and only show a single frame of animation
Loop;
-
- Posts: 52
- Joined: Mon Mar 02, 2015 11:47 pm
Re: Animated weapon Raise
Jarewill wrote:Here's the problem I think:Code: Select all
Ready2: FFTR A 0 A_JumpIfInventory("PyrolightLoaded",10,4); FFTR A 0 A_JumpIfInventory("FlameAmmo",1,2); FFTR A 1 A_WeaponReady(WRF_NOSECONDARY); //<--- This.... Loop; FFTR A 1 A_WeaponReady(WRF_ALLOWRELOAD|WRF_NOSECONDARY); //<--- ....And this states happen if the weapon has less than 10 ammo, and only show a single frame of animation Loop;
S̶o̶ ̶I̶ ̶d̶o̶n̶'̶t̶ ̶i̶m̶a̶g̶i̶n̶e̶ ̶t̶h̶a̶t̶ ̶s̶i̶m̶p̶l̶y̶ ̶r̶e̶m̶o̶v̶i̶n̶g̶ ̶t̶h̶e̶m̶ ̶w̶o̶u̶l̶d̶ ̶d̶o̶ ̶g̶o̶o̶d̶ ̶t̶h̶i̶n̶g̶s̶,̶ ̶s̶o̶ ̶c̶o̶u̶l̶d̶ ̶I̶ ̶p̶u̶t̶ ̶t̶h̶e̶ ̶4̶ ̶f̶r̶a̶m̶e̶s̶ ̶i̶n̶ ̶t̶h̶o̶s̶e̶ ̶s̶l̶o̶t̶s̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶l̶o̶o̶p̶?̶
Well, that got the animation into the place it needs, but disabled the secondary fire...
-
-
- Posts: 1537
- Joined: Sun Jul 21, 2019 8:54 am
Re: Animated weapon Raise
You might also need to edit the jump offsets.
So if you added 3 more frames of animation to each of the A_WeaponReady states, the first two jumps would look like this:
So if you added 3 more frames of animation to each of the A_WeaponReady states, the first two jumps would look like this:
Code: Select all
FFTR A 0 A_JumpIfInventory("PyrolightLoaded",10,10); //4 previous jump + 6 (3 + 3) added frames
FFTR A 0 A_JumpIfInventory("FlameAmmo",1,5); //2 previous jump + 3 added frames
-
- Posts: 1376
- Joined: Tue Oct 20, 2015 12:50 pm
- Graphics Processor: nVidia with Vulkan support
- Location: Kozolupy, Bohemia
Re: Animated weapon Raise
...Or avoid using numbered jumps and make properly names states, which is reasonable better than numbered state jumps.
-
- Posts: 52
- Joined: Mon Mar 02, 2015 11:47 pm
Re: Animated weapon Raise
That actually worked pretty well. Thanks.Jarewill wrote:You might also need to edit the jump offsets.
So if you added 3 more frames of animation to each of the A_WeaponReady states, the first two jumps would look like this:Code: Select all
FFTR A 0 A_JumpIfInventory("PyrolightLoaded",10,10); //4 previous jump + 6 (3 + 3) added frames FFTR A 0 A_JumpIfInventory("FlameAmmo",1,5); //2 previous jump + 3 added frames
-
-
- Posts: 962
- Joined: Mon Jul 21, 2008 4:08 am
- Preferred Pronouns: He/Him
- Graphics Processor: nVidia (Modern GZDoom)
Re: Animated weapon Raise
If you want to do a completely custom raise animation, you can simply do this:Ninlhil wrote:I'm working on a Flamerthrower weapon for a Mod I'm working on, but I'm having trouble with some aspects. When selected, I want the flamer to raise into position and then for a pilot light to flash on. So far, all I've managed to get is a bit of the raise, the pilot light animation and then the raise finishes. Any help and insight with the scripting would be greatly appreciated.
Code: Select all
Select:
FRAM ABCDEF 1; //this is meant to be your custom animation
TNT1 A 0 A_Raise;
wait; //this will loop the previous frame, resulting in instantl jump to Ready
Moreover, if your weapon is already at its default offsets (0,32), then you can simply call goto ready and do nothing else. Calling A_Raise is not a requirement.
Note, when the weapon is deselected, it's offset below the screen. You can use [wiki]A_WeaponOffset[/wiki] to move it any way you want around the screen. You can also use A_WeaponReady(WRF_NOFIRE) to let the player switch the weapon during the selection animation, like in vanilla.
Here's an example of a simple custom animation where the gun is moved from the side instead of raising vertically:
Code: Select all
Select:
TNT1 A 0 A_Weaponoffset(30.0,67.0); //move the gun to a fixed position at the bottom right
RIFN AAAAAAA 1
{
A_WeaponOffset(-4.0,-5.0,WOF_ADD); //move the gun up and left
A_WeaponReady(WRF_NOFIRE|WRF_NOBOB); //allow the player to interrupt the animation and select a different weapon
}
// At this point the sprite is already at 0, 32, so I don't need to call A_Raise, I simply move to Ready:
goto ready;
-
- Posts: 400
- Joined: Wed Dec 22, 2021 7:02 pm
- Graphics Processor: Intel (Modern GZDoom)
- Location: Medellin, Colombia
Re: Animated weapon Raise
Hi, I'm also trying to make weapons with custom raise and lower animations.Jekyll Grim Payne wrote:Code: Select all
Select: FRAM ABCDEF 1; //this is meant to be your custom animation TNT1 A 0 A_Raise; wait; //this will loop the previous frame, resulting in instantl jump to Ready
First issue with my weapons is that the sprites look perfect when I view them in Slade with HUD offsets, but in game they are much lower. I've found that if I put Weapon.YAdjust -32 in the defaults block then they look right in fullscreen but still way too low with a status bar. How to fix that?
So I tried following your example and animating them this way:
Code: Select all
Ready:
UWAA A 1 A_WeaponReady;
Loop;
Deselect:
UWAA ANO 4;
TNT1 ] 0 A_Lower;
wait;
Select:
UWAA ONA 4;
TNT1 ] 0 A_Raise;
wait;
So then I tried it the other way you suggested
Code: Select all
Ready:
UWAA A 1 A_WeaponReady;
Loop;
Deselect:
TNT1 ] 0 A_WeaponOffset(0,0);
UWAA ANO 8 A_WeaponReady(WRF_NOFIRE|WRF_NOBOB);
goto Ready;
Select:
TNT1 ] 0 A_WeaponOffset(0,0);
UWAA ONA 8 A_WeaponReady(WRF_NOFIRE|WRF_NOBOB);
goto Ready;