(SOLVED) Consume ammo from a RIPPER attack
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!)
(SOLVED) Consume ammo from a RIPPER attack
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?
Can you think of any workarounds?
Last edited by Grey-Wolf on Tue Dec 03, 2019 9:44 pm, edited 1 time in total.
- 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
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...
Re: Consume ammo from a RIPPER attack
I lost you at "warps ahead"... Can you make an example please?
- 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
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?
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?
Re: Consume ammo from a RIPPER attack
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.
The hitscan solution seems interesting, but I'm not quite sure on how to do it.
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Consume ammo from a RIPPER attack
All that you need in case of hitscans is a custom puff like this one:And instead of RIPPER-projectiles just use short range piercing A_RailAttack for ex.
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
}
}
Re: Consume ammo from a RIPPER attack
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:
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?
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
}
}
Any ideas?
- Void Weaver
- Posts: 724
- Joined: Thu Dec 18, 2014 7:15 am
- Contact:
Re: Consume ammo from a RIPPER attack
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
Re: Consume ammo from a RIPPER attack
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?
Re: Consume ammo from a RIPPER attack
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.
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.