how to make a life drain gun?(regen heath, cause damage)

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!)
User avatar
Wolfbrf
Posts: 115
Joined: Sat May 07, 2016 2:36 pm

how to make a life drain gun?(regen heath, cause damage)

Post by Wolfbrf »

ok, i want to make a vampire like weapon, this gun can drain life(cause damage) and give some heath for the player.

its possible to do using only "pain state"?(A_TakeFromTarget/A_GiveToTarget).
thanks.

if someone know a monster/gun similat a it, please tel me, and i can study the codes.
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed

Re: how to make a life drain gun?(regen heath, cause damage)

Post by wildweasel »

There are two ways I can think of to do this. The first is having the gun give a [wiki]Classes:PowerDrain[/wiki] when equipped or attacking, since it needs to be a gun. If it were a melee attack, [wiki]A_CustomPunch[/wiki] has a life steal property built right in, of which there seems to be no close equivalent for projectile and hitscan attacks.
User avatar
Wolfbrf
Posts: 115
Joined: Sat May 07, 2016 2:36 pm

Re: how to make a life drain gun?(regen heath, cause damage)

Post by Wolfbrf »

powerdrain seem to work for me.

i thinked about pain state.

////

pain.lifedrain:
POSS G 3 A_pain
POSS G 1 A_GiveToTarget(heath)
goto ready

////
also, the bullet/projectile has "damagetype "lifedrain", or something like it.

powerdrain help a lot, thanks
User avatar
amv2k9
Posts: 2178
Joined: Sun Jan 10, 2010 4:05 pm
Location: Southern California

Re: how to make a life drain gun?(regen heath, cause damage)

Post by amv2k9 »

Code: Select all

ACTOR VampirePuff:BulletPuff
{
 +PUFFGETSOWNER
 States
 {
 XDeath:
  TNT1 A 0 A_GiveToTarget("HealthBonus")
  PUFF ABCDE 3 BRIGHT
  Stop
 }
}
The +PUFFGETSOWNER flag sets the puff's target to be the player who shot it. We use the XDeath state to give the HealthBonus because then the puff will only give health when it hits a bleeding target (assuming you only want it to give health when it hits a bleeding target).
Okgo5555
Posts: 80
Joined: Thu Mar 23, 2017 11:18 am

Re: how to make a life drain gun?(regen heath, cause damage)

Post by Okgo5555 »

So, give power drain for just the duration of the states? This would apply to the death state of the projectile as well, correct?

Return to “Scripting”