- Added per-actor teleport fog modifications.

- New properties include TeleFogSourceType and TeleFogDestType.
- TeleFogSourceType is the fog left behind where the actor teleported away from.
- TeleFogDestType is the fog the actor sees when it arrives at its destination.
- Added A_SetTeleFog(<oldpos>,<newpos>) -- oldpos sets TeleFogSourceType, newpos sets TeleFogDestType.
This commit is contained in:
MajorCooke 2014-12-17 16:11:07 -06:00
parent 24f1bfae99
commit 30acb72006
8 changed files with 68 additions and 27 deletions

View file

@ -983,6 +983,8 @@ public:
FNameNoInit PainType; FNameNoInit PainType;
FNameNoInit DeathType; FNameNoInit DeathType;
FNameNoInit TeleFogSourceType;
FNameNoInit TeleFogDestType;
FState *SpawnState; FState *SpawnState;
FState *SeeState; FState *SeeState;

View file

@ -2680,18 +2680,10 @@ void P_NightmareRespawn (AActor *mobj)
mo->PrevZ = z; // Do not interpolate Z position if we changed it since spawning. 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? // spawn a teleport fog at old spot because of removal of the body?
mo = Spawn ("TeleportFog", mobj->x, mobj->y, mobj->z, ALLOW_REPLACE); P_SpawnTeleportFog(mobj, mobj->x, mobj->y, mobj->z + TELEFOGHEIGHT, true);
if (mo != NULL)
{
mo->z += TELEFOGHEIGHT;
}
// spawn a teleport fog at the new spot // spawn a teleport fog at the new spot
mo = Spawn ("TeleportFog", x, y, z, ALLOW_REPLACE); P_SpawnTeleportFog(mobj, x, y, z + TELEFOGHEIGHT, false);
if (mo != NULL)
{
mo->z += TELEFOGHEIGHT;
}
// remove the old monster // remove the old monster
mobj->Destroy (); mobj->Destroy ();

View file

@ -903,6 +903,7 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag);
// //
// P_TELEPT // 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 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_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); bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse);

View file

@ -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<ATeleportFog>(x, y, z, (replace ? ALLOW_REPLACE : NO_REPLACE));
} }
else else
{ {
AActor *mo = Spawn (fog, x, y, z, ALLOW_REPLACE); mo = Spawn(tf, x, y, z, (replace ? ALLOW_REPLACE : NO_REPLACE));
if (mo != NULL) S_Sound(mo, CHAN_BODY, mo->SeeSound, 1.f, ATTN_NORM);
} }
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) if (sourceFog && !predicting)
{ {
fixed_t fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT; fixed_t fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT;
AActor *fog = Spawn<ATeleportFog> (oldx, oldy, oldz + fogDelta, ALLOW_REPLACE); P_SpawnTeleportFog(thing, oldx, oldy, oldz, true, true, true); //Passes the actor through which then pulls the TeleFog metadate types based on properties.
fog->target = thing;
} }
if (useFog) 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; fixed_t fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT;
an = angle >> ANGLETOFINESHIFT; an = angle >> ANGLETOFINESHIFT;
AActor *fog = Spawn<ATeleportFog>(x + 20 * finecosine[an], P_SpawnTeleportFog(thing, x + 20 * finecosine[an], y + 20 * finesine[an], thing->z + fogDelta, false, true, true);
y + 20 * finesine[an], thing->z + fogDelta, ALLOW_REPLACE);
fog->target = thing;
} }
if (thing->player) if (thing->player)
{ {

View file

@ -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); mobj->angle = (angle != ANGLE_MAX ? angle : spot->angle);
if (fog) if (fog)
{ {
Spawn<ATeleportFog> (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) if (mobj->flags & MF_SPECIAL)
mobj->flags |= MF_DROPPED; // Don't respawn 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) if (fog)
{ {
Spawn<ATeleportFog> (x, y, z + TELEFOGHEIGHT, ALLOW_REPLACE); P_SpawnTeleportFog(source, x, y, z);
Spawn<ATeleportFog> (oldx, oldy, oldz + TELEFOGHEIGHT, ALLOW_REPLACE); P_SpawnTeleportFog(source, oldx, oldy, oldz, false);
} }
source->PrevX = x; source->PrevX = x;
source->PrevY = y; source->PrevY = y;

View file

@ -2938,9 +2938,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn)
{ {
ACTION_PARAM_START(1); ACTION_PARAM_START(1);
ACTION_PARAM_INT(flags, 0); ACTION_PARAM_INT(flags, 0);
bool oktorespawn = false; bool oktorespawn = false;
fixed_t oldx = self->x;
fixed_t oldy = self->y;
fixed_t oldz = self->z;
self->flags |= MF_SOLID; self->flags |= MF_SOLID;
self->height = self->GetDefault()->height; self->height = self->GetDefault()->height;
CALL_ACTION(A_RestoreSpecialPosition, self); CALL_ACTION(A_RestoreSpecialPosition, self);
@ -2998,7 +2999,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Respawn)
if (flags & RSF_FOG) if (flags & RSF_FOG)
{ {
Spawn<ATeleportFog> (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()) 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;
}

View file

@ -1416,6 +1416,26 @@ DEFINE_PROPERTY(stamina, I, Actor)
defaults->stamina = i; 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 // Special inventory properties

View file

@ -317,6 +317,7 @@ ACTOR Actor native //: Thinker
action native A_GiveToSiblings(class<Inventory> itemtype, int amount = 0); action native A_GiveToSiblings(class<Inventory> itemtype, int amount = 0);
action native A_TakeFromChildren(class<Inventory> itemtype, int amount = 0); action native A_TakeFromChildren(class<Inventory> itemtype, int amount = 0);
action native A_TakeFromSiblings(class<Inventory> itemtype, int amount = 0); action native A_TakeFromSiblings(class<Inventory> itemtype, int amount = 0);
action native A_SetTeleFog(name oldpos, name newpos);
action native A_CheckSightOrRange(float distance, state label); action native A_CheckSightOrRange(float distance, state label);
action native A_CheckRange(float distance, state label); action native A_CheckRange(float distance, state label);