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:
|
2012-06-29 04:21:31 +00:00
|
|
|
int DoSpecialDamage (AActor *target, int damage, FName damagetype);
|
2006-02-24 04:48:15 +00:00
|
|
|
};
|
|
|
|
|
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;
|
2009-06-30 20:57:51 +00:00
|
|
|
fx->velx = source->velx >> 1;
|
|
|
|
fx->vely = source->vely >> 1;
|
|
|
|
fx->velz = source->velz >> 1;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
//
|
|
|
|
//===========================================================================
|
|
|
|
|
2012-06-29 04:21:31 +00:00
|
|
|
int ATelOtherFX1::DoSpecialDamage (AActor *target, int damage, FName damagetype)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
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 ();
|
2011-02-13 10:18:28 +00:00
|
|
|
P_ExecuteSpecial(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)
|
|
|
|
{
|
|
|
|
fixed_t destX,destY;
|
|
|
|
angle_t destAngle;
|
|
|
|
|
2012-07-08 01:43:47 +00:00
|
|
|
FMapThing *start = G_PickPlayerStart(0, PPS_FORCERANDOM | PPS_NOBLOCKINGCHECK);
|
|
|
|
destX = start->x;
|
|
|
|
destY = start->y;
|
|
|
|
destAngle = ANG45 * (start->angle/45);
|
2006-02-24 04:48:15 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|