2008-09-15 14:11:05 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "info.h"
|
|
|
|
#include "a_pickups.h"
|
|
|
|
#include "a_artifacts.h"
|
|
|
|
#include "gstrings.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "p_lnspec.h"
|
|
|
|
#include "m_random.h"
|
2008-08-10 20:48:55 +00:00
|
|
|
#include "thingdef/thingdef.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "g_level.h"
|
|
|
|
#include "doomstat.h"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
#define TELEPORT_LIFE 1
|
|
|
|
|
|
|
|
static FRandom pr_telestarts ("TeleStarts");
|
|
|
|
static FRandom pr_teledm ("TeleDM");
|
|
|
|
|
|
|
|
void A_TeloSpawnA (AActor *);
|
|
|
|
void A_TeloSpawnB (AActor *);
|
|
|
|
void A_TeloSpawnC (AActor *);
|
|
|
|
void A_TeloSpawnD (AActor *);
|
|
|
|
void A_CheckTeleRing (AActor *);
|
|
|
|
void P_TeleportToPlayerStarts (AActor *victim);
|
|
|
|
void P_TeleportToDeathmatchStarts (AActor *victim);
|
|
|
|
|
|
|
|
// Teleport Other Artifact --------------------------------------------------
|
|
|
|
|
|
|
|
class AArtiTeleportOther : public AInventory
|
|
|
|
{
|
2008-08-09 17:43:14 +00:00
|
|
|
DECLARE_CLASS (AArtiTeleportOther, AInventory)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
bool Use (bool pickup);
|
|
|
|
};
|
|
|
|
|
2008-08-09 17:43:14 +00:00
|
|
|
IMPLEMENT_CLASS (AArtiTeleportOther)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Teleport Other FX --------------------------------------------------------
|
|
|
|
|
|
|
|
class ATelOtherFX1 : public AActor
|
|
|
|
{
|
2008-08-09 17:43:14 +00:00
|
|
|
DECLARE_CLASS (ATelOtherFX1, AActor)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
int DoSpecialDamage (AActor *target, int damage);
|
|
|
|
};
|
|
|
|
|
2008-08-09 17:43:14 +00:00
|
|
|
IMPLEMENT_CLASS (ATelOtherFX1)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-09 17:43:14 +00:00
|
|
|
static void TeloSpawn (AActor *source, const char *type)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *fx;
|
|
|
|
|
2006-07-16 09:10:45 +00:00
|
|
|
fx = Spawn (type, source->x, source->y, source->z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (fx)
|
|
|
|
{
|
|
|
|
fx->special1 = TELEPORT_LIFE; // Lifetime countdown
|
|
|
|
fx->angle = source->angle;
|
|
|
|
fx->target = source->target;
|
|
|
|
fx->momx = source->momx >> 1;
|
|
|
|
fx->momy = source->momy >> 1;
|
|
|
|
fx->momz = source->momz >> 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_TeloSpawnA)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
TeloSpawn (self, "TelOtherFX2");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_TeloSpawnB)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
TeloSpawn (self, "TelOtherFX3");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_TeloSpawnC)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
TeloSpawn (self, "TelOtherFX4");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_TeloSpawnD)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
TeloSpawn (self, "TelOtherFX5");
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_CheckTeleRing)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->special1-- <= 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->FindState(NAME_Death));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Activate Teleport Other
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
bool AArtiTeleportOther::Use (bool pickup)
|
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
|
|
|
|
mo = P_SpawnPlayerMissile (Owner, RUNTIME_CLASS(ATelOtherFX1));
|
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->target = Owner;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// Perform Teleport Other
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
int ATelOtherFX1::DoSpecialDamage (AActor *target, int damage)
|
|
|
|
{
|
|
|
|
if ((target->flags3 & MF3_ISMONSTER || target->player != NULL) &&
|
|
|
|
!(target->flags2 & MF2_BOSS) &&
|
|
|
|
!(target->flags3 & MF3_NOTELEOTHER))
|
|
|
|
{
|
|
|
|
if (target->player)
|
|
|
|
{
|
|
|
|
if (deathmatch)
|
|
|
|
P_TeleportToDeathmatchStarts (target);
|
|
|
|
else
|
|
|
|
P_TeleportToPlayerStarts (target);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// If death action, run it upon teleport
|
|
|
|
if (target->flags3 & MF3_ISMONSTER && target->special)
|
|
|
|
{
|
|
|
|
target->RemoveFromHash ();
|
|
|
|
LineSpecials[target->special] (NULL, level.flags & LEVEL_ACTOWNSPECIAL
|
2008-03-12 02:56:11 +00:00
|
|
|
? target : (AActor *)(this->target), false, target->args[0], target->args[1],
|
2006-02-24 04:48:15 +00:00
|
|
|
target->args[2], target->args[3], target->args[4]);
|
|
|
|
target->special = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send all monsters to deathmatch spots
|
|
|
|
P_TeleportToDeathmatchStarts (target);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// P_TeleportToPlayerStarts
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void P_TeleportToPlayerStarts (AActor *victim)
|
|
|
|
{
|
|
|
|
int i,selections=0;
|
|
|
|
fixed_t destX,destY;
|
|
|
|
angle_t destAngle;
|
|
|
|
|
|
|
|
for (i = 0; i < MAXPLAYERS;i++)
|
|
|
|
{
|
|
|
|
if (!playeringame[i]) continue;
|
|
|
|
selections++;
|
|
|
|
}
|
|
|
|
i = pr_telestarts() % selections;
|
2008-05-08 08:06:26 +00:00
|
|
|
destX = playerstarts[i].x;
|
|
|
|
destY = playerstarts[i].y;
|
2006-02-24 04:48:15 +00:00
|
|
|
destAngle = ANG45 * (playerstarts[i].angle/45);
|
|
|
|
P_Teleport (victim, destX, destY, ONFLOORZ, destAngle, true, true, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
//
|
|
|
|
// P_TeleportToDeathmatchStarts
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
void P_TeleportToDeathmatchStarts (AActor *victim)
|
|
|
|
{
|
|
|
|
unsigned int i, selections;
|
|
|
|
fixed_t destX,destY;
|
|
|
|
angle_t destAngle;
|
|
|
|
|
|
|
|
selections = deathmatchstarts.Size ();
|
|
|
|
if (selections > 0)
|
|
|
|
{
|
|
|
|
i = pr_teledm() % selections;
|
2008-05-08 08:06:26 +00:00
|
|
|
destX = deathmatchstarts[i].x;
|
|
|
|
destY = deathmatchstarts[i].y;
|
2006-02-24 04:48:15 +00:00
|
|
|
destAngle = ANG45 * (deathmatchstarts[i].angle/45);
|
|
|
|
P_Teleport (victim, destX, destY, ONFLOORZ, destAngle, true, true, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
P_TeleportToPlayerStarts (victim);
|
|
|
|
}
|
|
|
|
}
|