diff --git a/src/actor.h b/src/actor.h index 288eb3129..592dca47c 100644 --- a/src/actor.h +++ b/src/actor.h @@ -983,6 +983,8 @@ public: FNameNoInit PainType; FNameNoInit DeathType; + FNameNoInit TeleFogSourceType; + FNameNoInit TeleFogDestType; FState *SpawnState; FState *SeeState; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 49b4b983f..21078b3ec 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2680,18 +2680,10 @@ void P_NightmareRespawn (AActor *mobj) mo->PrevZ = z; // Do not interpolate Z position if we changed it since spawning. // spawn a teleport fog at old spot because of removal of the body? - mo = Spawn ("TeleportFog", mobj->x, mobj->y, mobj->z, ALLOW_REPLACE); - if (mo != NULL) - { - mo->z += TELEFOGHEIGHT; - } + P_SpawnTeleportFog(mobj, mobj->x, mobj->y, mobj->z + TELEFOGHEIGHT, true); // spawn a teleport fog at the new spot - mo = Spawn ("TeleportFog", x, y, z, ALLOW_REPLACE); - if (mo != NULL) - { - mo->z += TELEFOGHEIGHT; - } + P_SpawnTeleportFog(mobj, x, y, z + TELEFOGHEIGHT, false); // remove the old monster mobj->Destroy (); diff --git a/src/p_spec.h b/src/p_spec.h index 906a38a8c..4af527ca8 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -903,6 +903,7 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag); // // P_TELEPT // +void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool beforeTele = true, bool replace = true, bool setTarget = false); //Spawns teleport fog. Pass the actor to pluck TeleFogFromType and TeleFogToType. 'from' determines if this is the fog to spawn at the old position (true) or new (false). bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, bool useFog, bool sourceFog, bool keepOrientation, bool haltVelocity = true, bool keepHeight = false); bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, bool fog, bool sourceFog, bool keepOrientation, bool haltVelocity = true, bool keepHeight = false); bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse); diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 60308d8ed..d86a87672 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -74,19 +74,23 @@ void ATeleportFog::PostBeginPlay () // //========================================================================== -void P_SpawnTeleportFog(fixed_t x, fixed_t y, fixed_t z, int spawnid) +void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool beforeTele, bool replace, bool setTarget) { - const PClass *fog = P_GetSpawnableType(spawnid); + AActor *mo; + FNameNoInit tf = (beforeTele ? mobj->TeleFogSourceType : mobj->TeleFogDestType); - if (fog == NULL) + if (!tf) //If the actor doesn't have one, initialize the original. { - AActor *mo = Spawn ("TeleportFog", x, y, z + TELEFOGHEIGHT, ALLOW_REPLACE); + mo = Spawn(x, y, z, (replace ? ALLOW_REPLACE : NO_REPLACE)); } else { - AActor *mo = Spawn (fog, x, y, z, ALLOW_REPLACE); - if (mo != NULL) S_Sound(mo, CHAN_BODY, mo->SeeSound, 1.f, ATTN_NORM); + mo = Spawn(tf, x, y, z, (replace ? ALLOW_REPLACE : NO_REPLACE)); } + + if (mo != NULL && setTarget) + mo->target = mobj; + } // @@ -186,8 +190,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, if (sourceFog && !predicting) { fixed_t fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT; - AActor *fog = Spawn (oldx, oldy, oldz + fogDelta, ALLOW_REPLACE); - fog->target = thing; + P_SpawnTeleportFog(thing, oldx, oldy, oldz, true, true, true); //Passes the actor through which then pulls the TeleFog metadate types based on properties. } if (useFog) { @@ -195,9 +198,8 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, { fixed_t fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT; an = angle >> ANGLETOFINESHIFT; - AActor *fog = Spawn(x + 20 * finecosine[an], - y + 20 * finesine[an], thing->z + fogDelta, ALLOW_REPLACE); - fog->target = thing; + P_SpawnTeleportFog(thing, x + 20 * finecosine[an], y + 20 * finesine[an], thing->z + fogDelta, false, true, true); + } if (thing->player) { diff --git a/src/p_things.cpp b/src/p_things.cpp index 63173564c..a8a34c384 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -92,7 +92,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, angle_t angle, bool fog, mobj->angle = (angle != ANGLE_MAX ? angle : spot->angle); if (fog) { - Spawn (spot->x, spot->y, spot->z + TELEFOGHEIGHT, ALLOW_REPLACE); + P_SpawnTeleportFog(mobj, spot->x, spot->y, spot->z + TELEFOGHEIGHT, false); } if (mobj->flags & MF_SPECIAL) mobj->flags |= MF_DROPPED; // Don't respawn @@ -130,8 +130,8 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog) { if (fog) { - Spawn (x, y, z + TELEFOGHEIGHT, ALLOW_REPLACE); - Spawn (oldx, oldy, oldz + TELEFOGHEIGHT, ALLOW_REPLACE); + P_SpawnTeleportFog(source, x, y, z); + P_SpawnTeleportFog(source, oldx, oldy, oldz, false); } source->PrevX = x; source->PrevY = y; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 2a2da343e..2f6b74e90 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -2938,9 +2938,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) { ACTION_PARAM_START(1); ACTION_PARAM_INT(flags, 0); - bool oktorespawn = false; - + fixed_t oldx = self->x; + fixed_t oldy = self->y; + fixed_t oldz = self->z; self->flags |= MF_SOLID; self->height = self->GetDefault()->height; CALL_ACTION(A_RestoreSpecialPosition, self); @@ -2998,7 +2999,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn) if (flags & RSF_FOG) { - Spawn (self->x, self->y, self->z + TELEFOGHEIGHT, ALLOW_REPLACE); + P_SpawnTeleportFog(self, oldx, oldy, oldz, true); + P_SpawnTeleportFog(self, self->x, self->y, self->z, false); } if (self->CountsAsKill()) { @@ -5377,3 +5379,24 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Remove) } } +//=========================================================================== +// +// A_SetTeleFog +// +// Sets the teleport fog(s) for the calling actor. +// Takes a name of the classes for te source and destination. +//=========================================================================== + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SetTeleFog) +{ + ACTION_PARAM_START(2); + ACTION_PARAM_NAME(oldpos, 0); + ACTION_PARAM_NAME(newpos, 1); + + if (oldpos) + self->TeleFogSourceType = oldpos; + if (newpos) + self->TeleFogDestType = newpos; +} + + diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index b548d4ef6..427e64008 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1416,6 +1416,26 @@ DEFINE_PROPERTY(stamina, I, Actor) defaults->stamina = i; } +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(telefogsourcetype, S, Actor) +{ + PROP_STRING_PARM(str, 0); + if (!stricmp(str, "TeleportFog")) defaults->TeleFogSourceType = NAME_None; + else defaults->TeleFogSourceType = str; +} + +//========================================================================== +// +//========================================================================== +DEFINE_PROPERTY(telefogdesttype, S, Actor) +{ + PROP_STRING_PARM(str, 0); + if (!stricmp(str, "TeleportFog")) defaults->TeleFogDestType = NAME_None; + else defaults->TeleFogDestType = str; +} + //========================================================================== // // Special inventory properties diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 2f97c2a71..326f14d20 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -317,6 +317,7 @@ ACTOR Actor native //: Thinker action native A_GiveToSiblings(class itemtype, int amount = 0); action native A_TakeFromChildren(class itemtype, int amount = 0); action native A_TakeFromSiblings(class itemtype, int amount = 0); + action native A_SetTeleFog(name oldpos, name newpos); action native A_CheckSightOrRange(float distance, state label); action native A_CheckRange(float distance, state label);