Animated weapon Raise

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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

Animated weapon Raise

Postby Ninlhil » 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.
Ninlhil
 
Joined: 02 Mar 2015

Re: Animated weapon Raise

Postby Jarewill » 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 allExpand view
  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
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Animated weapon Raise

Postby Enjay » 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.
User avatar
Enjay
Everyone is a moon, and has a dark side which he never shows to anybody. Twain
 
 
 
Joined: 15 Jul 2003
Location: Scotland

Re: Animated weapon Raise

Postby Logan MTM » Wed Jan 12, 2022 9:01 am

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

Code: Select allExpand view
Ready:
FRAM ABCD A_WeaponReady
Loop


Becomes:
Code: Select allExpand view
Ready:
ReadyLoop:
ReadyLoopA:
FRAM A A_WeaponReady
ReadyLoopB:
FRAM B A_WeaponReady
ReadyLoopC:
FRAM C A_WeaponReady
ReadyLoopD:
FRAM D A_WeaponReady
Goto ReadyLoop
User avatar
Logan MTM
I can see you...
 
Joined: 16 Jan 2006
Location: Rio de Janeiro - Brazil

Re: Animated weapon Raise

Postby MartinHowe » 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).
User avatar
MartinHowe
In space, no-one can hear you KILL an ALIEN
 
Joined: 11 Aug 2003
Location: Waveney, United Kingdom

Re: Animated weapon Raise

Postby Ninlhil » 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: Select allExpand view
   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?
Ninlhil
 
Joined: 02 Mar 2015

Re: Animated weapon Raise

Postby Jarewill » Fri Jan 14, 2022 6:58 am

I have no idea from that snippet, seeing the entire code would help to find the issue.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Animated weapon Raise

Postby Ninlhil » Fri Jan 14, 2022 2:54 pm

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

Spoiler:
Ninlhil
 
Joined: 02 Mar 2015

Re: Animated weapon Raise

Postby Jarewill » Fri Jan 14, 2022 4:40 pm

Here's the problem I think:
Code: Select allExpand view
   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;
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Animated weapon Raise

Postby Ninlhil » Fri Jan 14, 2022 5:35 pm

Jarewill wrote:Here's the problem I think:
Code: Select allExpand view
   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...
Ninlhil
 
Joined: 02 Mar 2015

Re: Animated weapon Raise

Postby Jarewill » 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: Select allExpand view
      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  
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Animated weapon Raise

Postby ramon.dexter » 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.
User avatar
ramon.dexter
rudebwoy
 
Joined: 20 Oct 2015
Location: Kozolupy, Bohemia
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Animated weapon Raise

Postby Ninlhil » 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: Select allExpand view
      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.
Ninlhil
 
Joined: 02 Mar 2015


Return to Scripting

Who is online

Users browsing this forum: No registered users and 2 guests