mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 14:51:40 +00:00
Add Pre/PostTeleport virtuals, for special handling of actor teleportation.
This commit is contained in:
parent
53199e4553
commit
e0aa8db616
2 changed files with 26 additions and 0 deletions
|
@ -148,6 +148,19 @@ bool P_Teleport (AActor *thing, DVector3 pos, DAngle angle, int flags)
|
||||||
pos.Z = floorheight;
|
pos.Z = floorheight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// [MK] notify thing of incoming teleport, check for an early cancel
|
||||||
|
// if it returns false
|
||||||
|
{
|
||||||
|
int nocancel = 1;
|
||||||
|
IFVIRTUALPTR(thing, AActor, PreTeleport)
|
||||||
|
{
|
||||||
|
VMValue params[] = { thing, pos.X, pos.Y, pos.Z, angle.Degrees, flags };
|
||||||
|
VMReturn ret;
|
||||||
|
ret.IntAt(&nocancel);
|
||||||
|
VMCall(func, params, countof(params), &ret, 1);
|
||||||
|
}
|
||||||
|
if ( !nocancel ) return false;
|
||||||
|
}
|
||||||
if (!P_TeleportMove (thing, pos, false))
|
if (!P_TeleportMove (thing, pos, false))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -213,6 +226,14 @@ bool P_Teleport (AActor *thing, DVector3 pos, DAngle angle, int flags)
|
||||||
// killough 10/98: kill all bobbing velocity too
|
// killough 10/98: kill all bobbing velocity too
|
||||||
if (player) player->Vel.Zero();
|
if (player) player->Vel.Zero();
|
||||||
}
|
}
|
||||||
|
// [MK] notify thing of successful teleport
|
||||||
|
{
|
||||||
|
IFVIRTUALPTR(thing, AActor, PostTeleport)
|
||||||
|
{
|
||||||
|
VMValue params[] = { thing, pos.X, pos.Y, pos.Z, angle.Degrees, flags };
|
||||||
|
VMCall(func, params, countof(params), nullptr, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -588,6 +588,11 @@ class Actor : Thinker native
|
||||||
|
|
||||||
// called on getting a secret, return false to disable default "secret found" message/sound
|
// called on getting a secret, return false to disable default "secret found" message/sound
|
||||||
virtual bool OnGiveSecret(bool printmsg, bool playsound) { return true; }
|
virtual bool OnGiveSecret(bool printmsg, bool playsound) { return true; }
|
||||||
|
|
||||||
|
// called before and after triggering a teleporter
|
||||||
|
// return false in PreTeleport() to cancel the action early
|
||||||
|
virtual bool PreTeleport( Vector3 destpos, double destangle, int flags ) { return true; }
|
||||||
|
virtual void PostTeleport( Vector3 destpos, double destangle, int flags ) {}
|
||||||
|
|
||||||
native virtual bool OkayToSwitchTarget(Actor other);
|
native virtual bool OkayToSwitchTarget(Actor other);
|
||||||
native static class<Actor> GetReplacement(class<Actor> cls);
|
native static class<Actor> GetReplacement(class<Actor> cls);
|
||||||
|
|
Loading…
Reference in a new issue