(SOLVED) Consume ammo from a RIPPER attack

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!)
Post Reply
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

(SOLVED) Consume ammo from a RIPPER attack

Post by Grey-Wolf »

So, I got this weapon here. Its alt attack has the ripper flag, and I want it to only consume ammo if the attack hits something (it's a melee weapon so the "ammo" is actually durability). I would usually put the "takefromtarget" command in the death state of the attack, but as you know, the ripper flag messes things up in terms of targets and tracers.

Can you think of any workarounds?
Last edited by Grey-Wolf on Tue Dec 03, 2019 9:44 pm, edited 1 time in total.
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: Consume ammo from a RIPPER attack

Post by Matt »

Is there some kind of "OnRip" function in ZS? If not, one possible hack that comes to mind is to use an xdeath state where the projectile warps ahead by vel, then resets its +missile flag and goes to its spawn state...
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Consume ammo from a RIPPER attack

Post by Grey-Wolf »

I lost you at "warps ahead"... Can you make an example please?
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: Consume ammo from a RIPPER attack

Post by Matt »

Actually, forget what I said, without a virtual OnRip() function what I'm trying to do can only be very roughly approximated by a gross hack involving bounce states, unless you want to replicate all the usual projectile checks in ZS that are in the native code.

The other possibility is to spawn a new missile at the old velocity just a little bit ahead, but I don't want to think too hard about that.


EDIT: reading your post again... why not use a hitscan for the melee attack, then check if the hitscan connects and deplete ammo using that?
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Consume ammo from a RIPPER attack

Post by Grey-Wolf »

The possibility of spawning a second missile is something even my simple mind can understand, so I'll take that path if I can't get anything better to work.

The hitscan solution seems interesting, but I'm not quite sure on how to do it.
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: Consume ammo from a RIPPER attack

Post by Void Weaver »

All that you need in case of hitscans is a custom puff like this one:

Code: Select all

ACTOR DurabilityPuff : BulletPuff
{
+PUFFGETSOWNER //Now Puff's TARGET is its shooter
+PUFFONACTORS //To be sure that Puff will hit bleeding actors
States
{
XDeath: //Will goes into this state as soon as it have PUFFONACTORS while hit a some bleeding actor
TNT1 A 0 {bALLOWPARTICLES=0;} //To disable spawning of grey particles when hit bleeding actor; equal to A_ChangeFlag("ALLOWPARTICLES",0)
TNT1 A 0 A_TakeFromTarget("your_ammo_('duration')_item",<amount>)
Stop //Or play rest custom sprite animation further
}
}
And instead of RIPPER-projectiles just use short range piercing A_RailAttack for ex.
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Consume ammo from a RIPPER attack

Post by Grey-Wolf »

Thanks, very helpful!

Now I'm having another problem, somewhat related. I want the axe to spawn a broken version of itself when thrown. I edited the projectile like so:

Code: Select all

ACTOR ThrownAxe
{
	Radius 8
	Height 8
	Speed 30
	Damage (random(150, 160))
	+MISSILE
	+FORCEXYBILLBOARD
	-NOGRAVITY
	+NOEXTREMEDEATH
	+SKYEXPLODE
	+NOEXTREMEDEATH
	+THRUSPECIES
	+BLOODSPLATTER
	Species "Marines"
	Gravity 1.0
	scale 0.5
	States
	{
	Spawn:
		AXET ABCDEFGH 2
		Loop
	Death:	
	XDeath:
		TNT1 A 0
		TNT1 A 0 A_Jumpifintargetinventory("AxeDurability", 1, 2)		
		TNT1 A 0 A_spawnItem("BrokenAxe")	
		TNT1 A 0 A_spawnItem("Axe")	
		Stop
	}
}
But for some reason, the "jumpifintargetinventory" command is completely skipped or ignored, and if I throw the axe it just spawns both items, even if durability IS depleted.
Any ideas?
User avatar
Void Weaver
Posts: 724
Joined: Thu Dec 18, 2014 7:15 am
Contact:

Re: Consume ammo from a RIPPER attack

Post by Void Weaver »

IIUYC, then 'Stop' (or something else) should separate both spawn variants:

Code: Select all

XDeath:
      TNT1 A 0
      TNT1 A 0 A_Jumpifintargetinventory("AxeDurability", 1, 2)      
      TNT1 A 0 A_spawnItem("BrokenAxe")
      Stop
      TNT1 A 0 A_spawnItem("Axe")
      Stop
User avatar
Grey-Wolf
Posts: 179
Joined: Sun Jul 15, 2018 4:59 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Consume ammo from a RIPPER attack

Post by Grey-Wolf »

It actually worked, so thank you! But out of curiosity... why didn't it work before? It was like the jump was completely ignored since if the jump was actually made, the broken axe spawn command would've been skipped, and then after the normal axe spawn, the "stop" was there. So what's the math behind this?
Jarewill
 
 
Posts: 1854
Joined: Sun Jul 21, 2019 8:54 am

Re: Consume ammo from a RIPPER attack

Post by Jarewill »

Since it was lacking a 'stop' there, it spawned both axes.
However that only explains why both broken and normal axes were spawned if there was no durability left.
But if it really spawned both axes if there was durability, then I have no clue.
Post Reply

Return to “Scripting”