Harmless projectile pushback

Archive of the old editing forum
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.
Locked
User avatar
Sebelino
Posts: 18
Joined: Sun May 28, 2017 3:53 pm

Harmless projectile pushback

Post by Sebelino »

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?
Nevander
Posts: 2254
Joined: Mon Jan 06, 2014 11:32 pm

Re: Harmless projectile pushback

Post by Nevander »

You could use a DamageType property.
User avatar
Sebelino
Posts: 18
Joined: Sun May 28, 2017 3:53 pm

Re: Harmless projectile pushback

Post by Sebelino »

Please elaborate. I know about damage types, but I have a hard time seeing how they could help here.
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: Harmless projectile pushback

Post by Matt »

In ZScript I might do something like: set +hittracer in the defaults, then somewhere in the death state explicitly modify the tracer's velocity:

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 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.
User avatar
Sebelino
Posts: 18
Joined: Sun May 28, 2017 3:53 pm

Re: Harmless projectile pushback

Post by Sebelino »

@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:

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;
    }
}
DECORATE:

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
  }
}
Locked

Return to “Editing (Archive)”