Harmless projectile pushback
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Harmless projectile pushback
Monster A fires a projectile at monster B. Is it possible to make monster B get pushed back without any damage with DECORATE/ACS/ZScript?
Re: Harmless projectile pushback
You could use a DamageType property.
Re: Harmless projectile pushback
Please elaborate. I know about damage types, but I have a hard time seeing how they could help here.
- 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: Harmless projectile pushback
In ZScript I might do something like: set +hittracer in the defaults, then somewhere in the death state explicitly modify the tracer's velocity:Getting the projectile's movement direction at the time of impact without screwing with Tick() stuff can be done with A_FaceMovementDirection() in the projectile's spawn state, and you can just add (cos(pitch)*cos(angle),cos(pitch)*sin(angle),sin(pitch))*[whatever you want your number to be] to the tracer's velocity.
Getting the victim's movement direction so you can have a relative impact velocity gets a bit trickier. It's still basic math, just a lot more trouble than it's worth most of the time.
Code: Select all
class dimpball:doomimpball replaces doomimpball{
default{
+hittracer
damagefunction(0);
}
states{
death:
BAL1 A 0{
if(tracer){
vector3 tpos=tracer.pos+(0,0,tracer.height*0.5);
vector3 opos=pos+(0,0,height*0.5);
tracer.vel+=(tpos-opos).unit() //get vector from middle of ball to middle of victim
/max(1,tracer.mass*0.01) //have it affected by mass
*20; //or whatever you want the number to be
}
}goto super::death;
}
}
Getting the victim's movement direction so you can have a relative impact velocity gets a bit trickier. It's still basic math, just a lot more trouble than it's worth most of the time.
Re: Harmless projectile pushback
@Vaecrius: Thank you! I am liking ZScript so far.
I ended up with the following code, where fire-type projectiles will bounce between two fire-reflecting monsters for all eternity, with a harmless pushback for every bounce:
ZSCRIPT.txt:
DECORATE:
I ended up with the following code, where fire-type projectiles will bounce between two fire-reflecting monsters for all eternity, with a harmless pushback for every bounce:
ZSCRIPT.txt:
Code: Select all
class RepelAgi : doomimpball {
default{
+hittracer
speed 30;
damagefunction(5);
damagetype "Fire";
}
states{
death:
BAL1 A 0{
if(tracer){
vector3 tpos=tracer.pos+(0,0,tracer.height*0.5);
vector3 opos=pos+(0,0,height*0.5);
tracer.vel+=(tpos-opos).unit() / max(1,tracer.mass*0.01) * 40;
}
}goto super::death;
}
}
Code: Select all
actor PyroJack : Fatso replaces Fatso
{
...
PainChance "Fire", 255
DamageFactor "Fire", 0
States {
...
Pain.Fire:
PYRJ A 0 A_SetTranslation("Repel")
PYRJ A 0 A_FaceTarget
PYRJ A 1 A_PlaySound("demon/repel")
PYRJ A 2 A_CustomMissile("RepelAgi", 32)
goto See
}
}