Animated weapon Raise

Tue Jan 11, 2022 11:04 pm

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.

Re: Animated weapon Raise

Wed Jan 12, 2022 8:30 am

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:
Code:
  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

Re: Animated weapon Raise

Wed Jan 12, 2022 8:55 am

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.

Re: Animated weapon Raise

Wed Jan 12, 2022 9:01 am

Crazzy tip from dumb modder:
I usually do all frames as Custom States. Every single one.

Code:
Ready:
FRAM ABCD A_WeaponReady
Loop


Becomes:
Code:
Ready:
ReadyLoop:
ReadyLoopA:
FRAM A A_WeaponReady
ReadyLoopB:
FRAM B A_WeaponReady
ReadyLoopC:
FRAM C A_WeaponReady
ReadyLoopD:
FRAM D A_WeaponReady
Goto ReadyLoop

Re: Animated weapon Raise

Wed Jan 12, 2022 12:00 pm

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).

Re: Animated weapon Raise

Thu Jan 13, 2022 9:15 pm

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...

Code:
   AltFire:
      FFTR A 0 A_JumpIf(waterlevel>= 2,"NoWay");
      FFTR A 0 A_JumpIfInventory("PyrolightLoaded",10,1);
      Goto Dryfire;


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?

Re: Animated weapon Raise

Fri Jan 14, 2022 6:58 am

I have no idea from that snippet, seeing the entire code would help to find the issue.

Re: Animated weapon Raise

Fri Jan 14, 2022 2:54 pm

Ah, ok. Its the basic code from Blade of Agony.

Spoiler:

Re: Animated weapon Raise

Fri Jan 14, 2022 4:40 pm

Here's the problem I think:
Code:
   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;

Re: Animated weapon Raise

Fri Jan 14, 2022 5:35 pm

Jarewill wrote:Here's the problem I think:
Code:
   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...

Re: Animated weapon Raise

Sat Jan 15, 2022 9:48 am

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:
      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  

Re: Animated weapon Raise

Sun Jan 16, 2022 1:52 am

...Or avoid using numbered jumps and make properly names states, which is reasonable better than numbered state jumps.

Re: Animated weapon Raise

Sun Jan 16, 2022 6:51 pm

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:
      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   


That actually worked pretty well. Thanks.

Re: Animated weapon Raise

Sat Jan 22, 2022 7:24 am

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.


If you want to do a completely custom raise animation, you can simply do this:
Code:
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


This is the simplest approach. Yes, it's totally fine to loop a 0-tic state with an A_Raise call, because that call contains an unconditional jump to Ready. There's no reason to add more state sequences and I recommend avoiding that.

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 A_WeaponOffset 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:
         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;


As for the pilot light, I recommend using A_Overlay and drawing it on a separate layer. You can then handle the delay on that layer.

Re: Animated weapon Raise

Mon Feb 07, 2022 12:16 pm

Jekyll Grim Payne wrote:
Code:
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

Hi, I'm also trying to make weapons with custom raise and lower animations.

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:
   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;

The deselect works but the select does not. There is a pause though so maybe it's playing off screen.

So then I tried it the other way you suggested
Code:
   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;

Now the select works but then the weapon freezes, can't fire and can't switch it for another weapon