From 83165dccbf345172464c677391b2dc530f277e1e Mon Sep 17 00:00:00 2001 From: jekyllgrim Date: Mon, 3 Jun 2024 12:25:12 +0300 Subject: [PATCH] Add damagesource --- src/playsim/actor.h | 1 + src/playsim/p_mobj.cpp | 4 ++++ src/scripting/vmthunks_actors.cpp | 1 + wadsrc/static/zscript/actors/actor.zs | 1 + 4 files changed, 7 insertions(+) diff --git a/src/playsim/actor.h b/src/playsim/actor.h index ebdfeebaa..34e5d7110 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -1233,6 +1233,7 @@ public: TObjPtr alternative; // (Un)Morphed actors stored here. Those with the MF_UNMORPHED flag are the originals. TObjPtr tracer; // Thing being chased/attacked for tracers TObjPtr master; // Thing which spawned this one (prevents mutual attacks) + TObjPtr damagesource; // [AA] Thing that fired a hitscan using this actor as a puff int tid; // thing identifier int special; // special diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index e004c4a46..df6661871 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -168,6 +168,7 @@ IMPLEMENT_POINTERS_START(AActor) IMPLEMENT_POINTER(target) IMPLEMENT_POINTER(lastenemy) IMPLEMENT_POINTER(tracer) + IMPLEMENT_POINTER(damagesource) IMPLEMENT_POINTER(goal) IMPLEMENT_POINTER(LastLookActor) IMPLEMENT_POINTER(Inventory) @@ -6286,6 +6287,9 @@ AActor *P_SpawnPuff (AActor *source, PClassActor *pufftype, const DVector3 &pos1 if ( puff && (puff->flags5 & MF5_PUFFGETSOWNER)) puff->target = source; + // [AA] Track the source of the attack unconditionally in a separate field. + puff->damagesource = source; + // Angle is the opposite of the hit direction (i.e. the puff faces the source.) puff->Angles.Yaw = hitdir + DAngle::fromDeg(180); diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 53fc0a062..527bd9178 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -2005,6 +2005,7 @@ DEFINE_FIELD(AActor, strafecount) DEFINE_FIELD(AActor, target) DEFINE_FIELD(AActor, master) DEFINE_FIELD(AActor, tracer) +DEFINE_FIELD(AActor, damagesource) DEFINE_FIELD(AActor, LastHeard) DEFINE_FIELD(AActor, lastenemy) DEFINE_FIELD(AActor, LastLookActor) diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 7a9a53929..eebfbe329 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -148,6 +148,7 @@ class Actor : Thinker native native Actor Target; native Actor Master; native Actor Tracer; + native Actor DamageSource; native Actor LastHeard; native Actor LastEnemy; native Actor LastLookActor;