diff --git a/src/d_net.cpp b/src/d_net.cpp index 7163cdd55..fb7cac316 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2376,25 +2376,8 @@ void Net_DoCommand (int type, BYTE **stream, int player) break; case DEM_SPRAY: - { - FTraceResults trace; - - DAngle ang = players[player].mo->Angles.Yaw; - DAngle pitch = players[player].mo->Angles.Pitch; - double c = pitch.Cos(); - DVector3 vec(c * ang.Cos(), c * ang.Sin(), -pitch.Sin()); - - s = ReadString (stream); - - if (Trace (players[player].mo->PosPlusZ(players[player].mo->Height/2), players[player].mo->Sector, - vec, 172., 0, ML_BLOCKEVERYTHING, players[player].mo, trace, TRACE_NoSky)) - { - if (trace.HitType == TRACE_HitWall) - { - DImpactDecal::StaticCreate (s, trace.HitPos, trace.Line->sidedef[trace.Side], NULL); - } - } - } + s = ReadString(stream); + SprayDecal(players[player].mo, s); break; case DEM_PAUSE: diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index 3ad19741a..21f116b07 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -704,6 +704,24 @@ CCMD (spray) Net_WriteString (argv[1]); } +void SprayDecal(AActor *shooter, const char *name) +{ + FTraceResults trace; + + DAngle ang = shooter->Angles.Yaw; + DAngle pitch = shooter->Angles.Pitch; + double c = pitch.Cos(); + DVector3 vec(c * ang.Cos(), c * ang.Sin(), -pitch.Sin()); + + if (Trace(shooter->PosPlusZ(shooter->Height / 2), shooter->Sector, vec, 172., 0, ML_BLOCKEVERYTHING, shooter, trace, TRACE_NoSky)) + { + if (trace.HitType == TRACE_HitWall) + { + DImpactDecal::StaticCreate(name, trace.HitPos, trace.Line->sidedef[trace.Side], NULL); + } + } +} + DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t *sec, double x, double y, double z, DAngle angle, double tracedist, bool permanent) { if (tpl == NULL || (tpl = tpl->GetDecal()) == NULL) diff --git a/src/g_shared/a_sharedglobal.h b/src/g_shared/a_sharedglobal.h index c9d0d86ce..ea367dd3a 100644 --- a/src/g_shared/a_sharedglobal.h +++ b/src/g_shared/a_sharedglobal.h @@ -11,6 +11,7 @@ struct F3DFloor; class DBaseDecal; class DBaseDecal *ShootDecal(const FDecalTemplate *tpl, AActor *basisactor, sector_t *sec, double x, double y, double z, DAngle angle, double tracedist, bool permanent); +void SprayDecal(AActor *shooter, const char *name); class DBaseDecal : public DThinker { diff --git a/src/p_actionfunctions.cpp b/src/p_actionfunctions.cpp index 51e71cb3f..53fe2b6a0 100644 --- a/src/p_actionfunctions.cpp +++ b/src/p_actionfunctions.cpp @@ -6932,3 +6932,11 @@ DEFINE_ACTION_FUNCTION(AActor, SetCamera) } return 0; } + +DEFINE_ACTION_FUNCTION(AActor, A_SprayDecal) +{ + PARAM_SELF_PROLOGUE(AActor); + PARAM_STRING(name); + SprayDecal(self, name); + return 0; +} diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 926b03804..fdc9ddade 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -868,6 +868,7 @@ class Actor : Thinker native native bool A_SetVisibleRotation(double anglestart = 0, double angleend = 0, double pitchstart = 0, double pitchend = 0, int flags = 0, int ptr = AAPTR_DEFAULT); native void A_SetTranslation(name transname); native bool A_SetSize(double newradius, double newheight = -1, bool testpos = false); + native void A_SprayDecal(String name); native void A_RearrangePointers(int newtarget, int newmaster = AAPTR_DEFAULT, int newtracer = AAPTR_DEFAULT, int flags=0); native void A_TransferPointer(int ptr_source, int ptr_recepient, int sourcefield, int recepientfield=AAPTR_DEFAULT, int flags=0);