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 "gi.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "m_random.h"
|
2008-09-14 23:54:38 +00:00
|
|
|
#include "doomstat.h"
|
2012-07-08 01:43:47 +00:00
|
|
|
#include "g_game.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_tele ("TeleportSelf");
|
|
|
|
|
|
|
|
// Teleport (self) ----------------------------------------------------------
|
|
|
|
|
|
|
|
class AArtiTeleport : public AInventory
|
|
|
|
{
|
2008-08-07 20:16:07 +00:00
|
|
|
DECLARE_CLASS (AArtiTeleport, AInventory)
|
2006-02-24 04:48:15 +00:00
|
|
|
public:
|
|
|
|
bool Use (bool pickup);
|
|
|
|
};
|
|
|
|
|
2008-08-07 20:16:07 +00:00
|
|
|
IMPLEMENT_CLASS (AArtiTeleport)
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
bool AArtiTeleport::Use (bool pickup)
|
|
|
|
{
|
|
|
|
fixed_t destX;
|
|
|
|
fixed_t destY;
|
|
|
|
angle_t destAngle;
|
|
|
|
|
|
|
|
if (deathmatch)
|
|
|
|
{
|
|
|
|
unsigned int selections = deathmatchstarts.Size ();
|
|
|
|
unsigned int i = pr_tele() % 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);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-07-08 02:18:15 +00:00
|
|
|
FPlayerStart *start = G_PickPlayerStart(int(Owner->player - players));
|
2012-07-08 01:43:47 +00:00
|
|
|
destX = start->x;
|
|
|
|
destY = start->y;
|
|
|
|
destAngle = ANG45 * (start->angle/45);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
P_Teleport (Owner, destX, destY, ONFLOORZ, destAngle, true, true, false);
|
2008-04-12 15:31:18 +00:00
|
|
|
bool canlaugh = true;
|
|
|
|
if (Owner->player->morphTics && (Owner->player->MorphStyle & MORPH_UNDOBYCHAOSDEVICE))
|
|
|
|
{ // Teleporting away will undo any morph effects (pig)
|
2009-09-18 05:46:15 +00:00
|
|
|
if (!P_UndoPlayerMorph (Owner->player, Owner->player, MORPH_UNDOBYCHAOSDEVICE)
|
|
|
|
&& (Owner->player->MorphStyle & MORPH_FAILNOLAUGH))
|
2008-04-12 15:31:18 +00:00
|
|
|
{
|
|
|
|
canlaugh = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (canlaugh)
|
|
|
|
{ // Full volume laugh
|
|
|
|
S_Sound (Owner, CHAN_VOICE, "*evillaugh", 1, ATTN_NONE);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// FUNC P_AutoUseChaosDevice
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool P_AutoUseChaosDevice (player_t *player)
|
|
|
|
{
|
2010-03-24 02:49:37 +00:00
|
|
|
AInventory *arti = player->mo->FindInventory(PClass::FindActor("ArtiTeleport"));
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (arti != NULL)
|
|
|
|
{
|
|
|
|
player->mo->UseInventory (arti);
|
|
|
|
player->health = player->mo->health = (player->health+1)/2;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|