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 "p_enemy.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "a_sharedglobal.h"
|
2008-04-05 12:14:33 +00:00
|
|
|
#include "sbar.h"
|
2008-04-08 08:53:42 +00:00
|
|
|
#include "a_morph.h"
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
static FRandom pr_morphmonst ("MorphMonster");
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// FUNC P_MorphPlayer
|
|
|
|
//
|
|
|
|
// Returns true if the player gets turned into a chicken/pig.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2008-04-12 15:31:18 +00:00
|
|
|
bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, int duration, int style, const PClass *enter_flash, const PClass *exit_flash)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AInventory *item;
|
|
|
|
APlayerPawn *morphed;
|
|
|
|
APlayerPawn *actor;
|
|
|
|
|
|
|
|
actor = p->mo;
|
|
|
|
if (actor == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (actor->flags3 & MF3_DONTMORPH)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-04-12 15:31:18 +00:00
|
|
|
if ((p->mo->flags2 & MF2_INVULNERABLE) && ((p != activator) || (!(style & MORPH_WHENINVULNERABLE))))
|
|
|
|
{ // Immune when invulnerable unless this is a power we activated
|
2006-02-24 04:48:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (p->morphTics)
|
|
|
|
{ // Player is already a beast
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (p->health <= 0)
|
|
|
|
{ // Dead players cannot morph
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (spawntype == NULL)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2006-10-27 03:03:34 +00:00
|
|
|
if (!spawntype->IsDescendantOf (RUNTIME_CLASS(APlayerPawn)))
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-04-05 12:14:33 +00:00
|
|
|
if (spawntype == p->mo->GetClass())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-07-16 09:10:45 +00:00
|
|
|
morphed = static_cast<APlayerPawn *>(Spawn (spawntype, actor->x, actor->y, actor->z, NO_REPLACE));
|
2008-03-12 16:27:47 +00:00
|
|
|
DObject::StaticPointerSubstitution (actor, morphed);
|
2006-02-24 04:48:15 +00:00
|
|
|
morphed->angle = actor->angle;
|
|
|
|
morphed->target = actor->target;
|
|
|
|
morphed->tracer = actor;
|
|
|
|
p->PremorphWeapon = p->ReadyWeapon;
|
|
|
|
morphed->special2 = actor->flags & ~MF_JUSTHIT;
|
|
|
|
morphed->player = p;
|
|
|
|
if (actor->renderflags & RF_INVISIBLE)
|
|
|
|
{
|
|
|
|
morphed->special2 |= MF_JUSTHIT;
|
|
|
|
}
|
2008-05-21 01:30:00 +00:00
|
|
|
if (morphed->ViewHeight > p->viewheight && p->deltaviewheight == 0)
|
|
|
|
{ // If the new view height is higher than the old one, start moving toward it.
|
|
|
|
p->deltaviewheight = p->GetDeltaViewHeight();
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
morphed->flags |= actor->flags & (MF_SHADOW|MF_NOGRAVITY);
|
|
|
|
morphed->flags2 |= actor->flags2 & MF2_FLY;
|
|
|
|
morphed->flags3 |= actor->flags3 & MF3_GHOST;
|
2008-04-08 08:53:42 +00:00
|
|
|
Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->x, actor->y, actor->z + TELEFOGHEIGHT, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
actor->player = NULL;
|
|
|
|
actor->flags &= ~(MF_SOLID|MF_SHOOTABLE);
|
|
|
|
actor->flags |= MF_UNMORPHED;
|
|
|
|
actor->renderflags |= RF_INVISIBLE;
|
2008-04-08 08:53:42 +00:00
|
|
|
p->morphTics = (duration) ? duration : MORPHTICS;
|
2008-04-05 12:14:33 +00:00
|
|
|
|
|
|
|
// [MH] Used by SBARINFO to speed up face drawing
|
|
|
|
p->MorphedPlayerClass = 0;
|
|
|
|
for (unsigned int i = 1; i < PlayerClasses.Size (); i++)
|
|
|
|
{
|
|
|
|
if (PlayerClasses[i].Type == spawntype)
|
|
|
|
{
|
|
|
|
p->MorphedPlayerClass = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-04-08 08:53:42 +00:00
|
|
|
|
|
|
|
p->MorphStyle = style;
|
|
|
|
p->MorphExitFlash = (exit_flash) ? exit_flash : RUNTIME_CLASS(ATeleportFog);
|
2006-02-24 04:48:15 +00:00
|
|
|
p->health = morphed->health;
|
2006-07-13 10:17:56 +00:00
|
|
|
p->mo = morphed;
|
2006-02-24 04:48:15 +00:00
|
|
|
p->momx = p->momy = 0;
|
|
|
|
morphed->ObtainInventory (actor);
|
|
|
|
// Remove all armor
|
2006-04-11 16:27:41 +00:00
|
|
|
for (item = morphed->Inventory; item != NULL; )
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AInventory *next = item->Inventory;
|
|
|
|
if (item->IsKindOf (RUNTIME_CLASS(AArmor)))
|
|
|
|
{
|
2007-03-14 01:48:19 +00:00
|
|
|
if (item->IsKindOf (RUNTIME_CLASS(AHexenArmor)))
|
|
|
|
{
|
|
|
|
// Set the HexenArmor slots to 0, except the class slot.
|
|
|
|
AHexenArmor *hxarmor = static_cast<AHexenArmor *>(item);
|
|
|
|
hxarmor->Slots[0] = 0;
|
|
|
|
hxarmor->Slots[1] = 0;
|
|
|
|
hxarmor->Slots[2] = 0;
|
|
|
|
hxarmor->Slots[3] = 0;
|
|
|
|
hxarmor->Slots[4] = spawntype->Meta.GetMetaFixed (APMETA_Hexenarmor0);
|
|
|
|
}
|
|
|
|
else if (item->ItemFlags & IF_KEEPDEPLETED)
|
|
|
|
{
|
|
|
|
// Set depletable armor to 0 (this includes BasicArmor).
|
|
|
|
item->Amount = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
item->Destroy ();
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
item = next;
|
|
|
|
}
|
|
|
|
morphed->ActivateMorphWeapon ();
|
|
|
|
if (p->camera == actor)
|
|
|
|
{
|
|
|
|
p->camera = morphed;
|
|
|
|
}
|
2006-07-13 10:17:56 +00:00
|
|
|
morphed->ScoreIcon = actor->ScoreIcon; // [GRB]
|
2008-04-05 12:14:33 +00:00
|
|
|
|
|
|
|
// [MH]
|
|
|
|
// If the player that was morphed is the one
|
|
|
|
// taking events, set up the face, if any;
|
|
|
|
// this is only needed for old-skool skins
|
|
|
|
// and for the original DOOM status bar.
|
|
|
|
if ((p == &players[consoleplayer]) &&
|
|
|
|
(strcmp(spawntype->Meta.GetMetaString (APMETA_Face), "None") != 0))
|
|
|
|
{
|
|
|
|
StatusBar->SetFace(&skins[p->MorphedPlayerClass]);
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// FUNC P_UndoPlayerMorph
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
bool P_UndoPlayerMorph (player_t *player, bool force)
|
|
|
|
{
|
|
|
|
AWeapon *beastweap;
|
|
|
|
APlayerPawn *mo;
|
|
|
|
AActor *pmo;
|
|
|
|
angle_t angle;
|
|
|
|
|
|
|
|
pmo = player->mo;
|
2008-04-14 18:51:05 +00:00
|
|
|
// [MH]
|
|
|
|
// Checks pmo as well; the PowerMorph destroyer will
|
|
|
|
// try to unmorph the player; if the destroyer runs
|
|
|
|
// because the level or game is ended while morphed,
|
|
|
|
// by the time it gets executed the morphed player
|
|
|
|
// pawn instance may have already been destroyed.
|
|
|
|
if (pmo == NULL || pmo->tracer == NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2008-03-12 02:56:11 +00:00
|
|
|
mo = barrier_cast<APlayerPawn *>(pmo->tracer);
|
2006-02-24 04:48:15 +00:00
|
|
|
mo->SetOrigin (pmo->x, pmo->y, pmo->z);
|
|
|
|
mo->flags |= MF_SOLID;
|
|
|
|
pmo->flags &= ~MF_SOLID;
|
|
|
|
if (!force && P_TestMobjLocation (mo) == false)
|
|
|
|
{ // Didn't fit
|
|
|
|
mo->flags &= ~MF_SOLID;
|
|
|
|
pmo->flags |= MF_SOLID;
|
|
|
|
player->morphTics = 2*TICRATE;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
pmo->player = NULL;
|
|
|
|
|
2006-06-27 23:49:45 +00:00
|
|
|
mo->ObtainInventory (pmo);
|
2008-03-12 16:27:47 +00:00
|
|
|
DObject::StaticPointerSubstitution (pmo, mo);
|
2006-02-24 04:48:15 +00:00
|
|
|
mo->angle = pmo->angle;
|
|
|
|
mo->player = player;
|
|
|
|
mo->reactiontime = 18;
|
|
|
|
mo->flags = pmo->special2 & ~MF_JUSTHIT;
|
|
|
|
mo->momx = 0;
|
|
|
|
mo->momy = 0;
|
|
|
|
player->momx = 0;
|
|
|
|
player->momy = 0;
|
|
|
|
mo->momz = pmo->momz;
|
|
|
|
if (!(pmo->special2 & MF_JUSTHIT))
|
|
|
|
{
|
|
|
|
mo->renderflags &= ~RF_INVISIBLE;
|
|
|
|
}
|
|
|
|
mo->flags = (mo->flags & ~(MF_SHADOW|MF_NOGRAVITY)) | (pmo->flags & (MF_SHADOW|MF_NOGRAVITY));
|
|
|
|
mo->flags2 = (mo->flags2 & ~MF2_FLY) | (pmo->flags2 & MF2_FLY);
|
|
|
|
mo->flags3 = (mo->flags3 & ~MF3_GHOST) | (pmo->flags3 & MF3_GHOST);
|
|
|
|
|
2008-04-08 08:53:42 +00:00
|
|
|
const PClass *exit_flash = player->MorphExitFlash;
|
2008-04-15 23:03:28 +00:00
|
|
|
bool correctweapon = !!(player->MorphStyle & MORPH_LOSEACTUALWEAPON);
|
2008-04-08 08:53:42 +00:00
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
player->morphTics = 0;
|
2008-04-06 17:33:43 +00:00
|
|
|
player->MorphedPlayerClass = 0;
|
2008-04-08 08:53:42 +00:00
|
|
|
player->MorphStyle = 0;
|
|
|
|
player->MorphExitFlash = NULL;
|
2006-07-13 10:17:56 +00:00
|
|
|
player->viewheight = mo->ViewHeight;
|
2006-02-24 04:48:15 +00:00
|
|
|
AInventory *level2 = mo->FindInventory (RUNTIME_CLASS(APowerWeaponLevel2));
|
|
|
|
if (level2 != NULL)
|
|
|
|
{
|
|
|
|
level2->Destroy ();
|
|
|
|
}
|
|
|
|
player->health = mo->health = mo->GetDefault()->health;
|
|
|
|
player->mo = mo;
|
|
|
|
if (player->camera == pmo)
|
|
|
|
{
|
|
|
|
player->camera = mo;
|
|
|
|
}
|
2008-04-05 12:14:33 +00:00
|
|
|
|
|
|
|
// [MH]
|
|
|
|
// If the player that was morphed is the one
|
|
|
|
// taking events, reset up the face, if any;
|
|
|
|
// this is only needed for old-skool skins
|
|
|
|
// and for the original DOOM status bar.
|
|
|
|
if ((player == &players[consoleplayer]) &&
|
|
|
|
(strcmp(pmo->GetClass()->Meta.GetMetaString (APMETA_Face), "None") != 0))
|
|
|
|
{
|
|
|
|
// Assume root-level base skin to begin with
|
|
|
|
size_t skinindex = 0;
|
|
|
|
// If a custom skin was in use, then reload it
|
|
|
|
// or else the base skin for the player class.
|
|
|
|
if ((unsigned int)player->userinfo.skin >= PlayerClasses.Size () &&
|
|
|
|
(size_t)player->userinfo.skin < numskins)
|
|
|
|
{
|
|
|
|
skinindex = player->userinfo.skin;
|
|
|
|
}
|
|
|
|
else if (PlayerClasses.Size () > 1)
|
|
|
|
{
|
|
|
|
const PClass *whatami = player->mo->GetClass();
|
|
|
|
for (unsigned int i = 0; i < PlayerClasses.Size (); ++i)
|
|
|
|
{
|
|
|
|
if (PlayerClasses[i].Type == whatami)
|
|
|
|
{
|
|
|
|
skinindex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusBar->SetFace(&skins[skinindex]);
|
|
|
|
}
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
angle = mo->angle >> ANGLETOFINESHIFT;
|
2008-04-08 08:53:42 +00:00
|
|
|
Spawn(exit_flash, pmo->x + 20*finecosine[angle], pmo->y + 20*finesine[angle], pmo->z + TELEFOGHEIGHT, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
beastweap = player->ReadyWeapon;
|
|
|
|
if (player->PremorphWeapon != NULL)
|
|
|
|
{
|
|
|
|
player->PremorphWeapon->PostMorphWeapon ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
player->ReadyWeapon = player->PendingWeapon = NULL;
|
|
|
|
}
|
2008-04-15 22:17:30 +00:00
|
|
|
if (correctweapon)
|
|
|
|
{ // Better "lose morphed weapon" semantics
|
|
|
|
const PClass *morphweapon = PClass::FindClass (mo->MorphWeapon);
|
|
|
|
if (morphweapon != NULL && morphweapon->IsDescendantOf (RUNTIME_CLASS(AWeapon)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-04-15 22:17:30 +00:00
|
|
|
AWeapon *OriginalMorphWeapon = static_cast<AWeapon *>(mo->FindInventory (morphweapon));
|
|
|
|
if ((OriginalMorphWeapon != NULL) && (OriginalMorphWeapon->GivenAsMorphWeapon))
|
|
|
|
{ // You don't get to keep your morphed weapon.
|
|
|
|
if (OriginalMorphWeapon->SisterWeapon != NULL)
|
|
|
|
{
|
|
|
|
OriginalMorphWeapon->SisterWeapon->Destroy ();
|
|
|
|
}
|
|
|
|
OriginalMorphWeapon->Destroy ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else // old behaviour (not really useful now)
|
|
|
|
{ // Assumptions made here are no longer valid
|
|
|
|
if (beastweap != NULL)
|
|
|
|
{ // You don't get to keep your morphed weapon.
|
|
|
|
if (beastweap->SisterWeapon != NULL)
|
|
|
|
{
|
|
|
|
beastweap->SisterWeapon->Destroy ();
|
|
|
|
}
|
|
|
|
beastweap->Destroy ();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
pmo->tracer = NULL;
|
|
|
|
pmo->Destroy ();
|
2007-03-14 01:48:19 +00:00
|
|
|
// Restore playerclass armor to its normal amount.
|
|
|
|
AHexenArmor *hxarmor = mo->FindInventory<AHexenArmor>();
|
|
|
|
if (hxarmor != NULL)
|
|
|
|
{
|
|
|
|
hxarmor->Slots[4] = mo->GetClass()->Meta.GetMetaFixed (APMETA_Hexenarmor0);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// FUNC P_MorphMonster
|
|
|
|
//
|
|
|
|
// Returns true if the monster gets turned into a chicken/pig.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2008-04-08 08:53:42 +00:00
|
|
|
bool P_MorphMonster (AActor *actor, const PClass *spawntype, int duration, int style, const PClass *enter_flash, const PClass *exit_flash)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2006-08-17 00:19:26 +00:00
|
|
|
AMorphedMonster *morphed;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-08-17 00:19:26 +00:00
|
|
|
if (actor->player || spawntype == NULL ||
|
2006-02-24 04:48:15 +00:00
|
|
|
actor->flags3 & MF3_DONTMORPH ||
|
2006-08-17 00:19:26 +00:00
|
|
|
!(actor->flags3 & MF3_ISMONSTER) ||
|
|
|
|
!spawntype->IsDescendantOf (RUNTIME_CLASS(AMorphedMonster)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-08-17 00:19:26 +00:00
|
|
|
morphed = static_cast<AMorphedMonster *>(Spawn (spawntype, actor->x, actor->y, actor->z, NO_REPLACE));
|
2008-03-12 16:27:47 +00:00
|
|
|
DObject::StaticPointerSubstitution (actor, morphed);
|
2006-02-24 04:48:15 +00:00
|
|
|
morphed->tid = actor->tid;
|
|
|
|
morphed->angle = actor->angle;
|
2006-08-17 00:19:26 +00:00
|
|
|
morphed->UnmorphedMe = actor;
|
2006-04-11 16:27:41 +00:00
|
|
|
morphed->alpha = actor->alpha;
|
|
|
|
morphed->RenderStyle = actor->RenderStyle;
|
|
|
|
|
2008-04-08 08:53:42 +00:00
|
|
|
morphed->UnmorphTime = level.time + ((duration) ? duration : MORPHTICS) + pr_morphmonst();
|
|
|
|
morphed->MorphStyle = style;
|
|
|
|
morphed->MorphExitFlash = (exit_flash) ? exit_flash : RUNTIME_CLASS(ATeleportFog);
|
2006-08-17 00:19:26 +00:00
|
|
|
morphed->FlagsSave = actor->flags & ~MF_JUSTHIT;
|
2006-02-24 04:48:15 +00:00
|
|
|
//morphed->special = actor->special;
|
|
|
|
//memcpy (morphed->args, actor->args, sizeof(actor->args));
|
|
|
|
morphed->CopyFriendliness (actor, true);
|
|
|
|
morphed->flags |= actor->flags & MF_SHADOW;
|
|
|
|
morphed->flags3 |= actor->flags3 & MF3_GHOST;
|
|
|
|
if (actor->renderflags & RF_INVISIBLE)
|
|
|
|
{
|
2006-08-17 00:19:26 +00:00
|
|
|
morphed->FlagsSave |= MF_JUSTHIT;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
morphed->AddToHash ();
|
|
|
|
actor->RemoveFromHash ();
|
|
|
|
actor->tid = 0;
|
|
|
|
actor->flags &= ~(MF_SOLID|MF_SHOOTABLE);
|
|
|
|
actor->flags |= MF_UNMORPHED;
|
|
|
|
actor->renderflags |= RF_INVISIBLE;
|
2008-04-08 08:53:42 +00:00
|
|
|
Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->x, actor->y, actor->z + TELEFOGHEIGHT, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// FUNC P_UpdateMorphedMonster
|
|
|
|
//
|
|
|
|
// Returns true if the monster unmorphs.
|
|
|
|
//
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
2006-08-17 00:19:26 +00:00
|
|
|
bool P_UpdateMorphedMonster (AMorphedMonster *beast)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *actor;
|
|
|
|
|
2006-08-17 00:19:26 +00:00
|
|
|
if (beast->UnmorphTime == 0 ||
|
|
|
|
beast->UnmorphTime > level.time ||
|
|
|
|
beast->UnmorphedMe == NULL ||
|
2006-02-24 04:48:15 +00:00
|
|
|
beast->flags3 & MF3_STAYMORPHED)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2006-08-17 00:19:26 +00:00
|
|
|
actor = beast->UnmorphedMe;
|
2006-02-24 04:48:15 +00:00
|
|
|
actor->SetOrigin (beast->x, beast->y, beast->z);
|
|
|
|
actor->flags |= MF_SOLID;
|
|
|
|
beast->flags &= ~MF_SOLID;
|
|
|
|
if (P_TestMobjLocation (actor) == false)
|
|
|
|
{ // Didn't fit
|
|
|
|
actor->flags &= ~MF_SOLID;
|
|
|
|
beast->flags |= MF_SOLID;
|
2006-08-17 00:19:26 +00:00
|
|
|
beast->UnmorphTime = level.time + 5*TICRATE; // Next try in 5 seconds
|
2006-02-24 04:48:15 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
actor->angle = beast->angle;
|
|
|
|
actor->target = beast->target;
|
|
|
|
actor->FriendPlayer = beast->FriendPlayer;
|
2006-08-17 00:19:26 +00:00
|
|
|
actor->flags = beast->FlagsSave & ~MF_JUSTHIT;
|
2006-02-24 04:48:15 +00:00
|
|
|
actor->flags = (actor->flags & ~(MF_FRIENDLY|MF_SHADOW)) | (beast->flags & (MF_FRIENDLY|MF_SHADOW));
|
|
|
|
actor->flags3 = (actor->flags3 & ~(MF3_NOSIGHTCHECK|MF3_HUNTPLAYERS|MF3_GHOST))
|
|
|
|
| (beast->flags3 & (MF3_NOSIGHTCHECK|MF3_HUNTPLAYERS|MF3_GHOST));
|
|
|
|
actor->flags4 = (actor->flags4 & ~MF4_NOHATEPLAYERS) | (beast->flags4 & MF4_NOHATEPLAYERS);
|
2006-08-17 00:19:26 +00:00
|
|
|
if (!(beast->FlagsSave & MF_JUSTHIT))
|
2006-02-24 04:48:15 +00:00
|
|
|
actor->renderflags &= ~RF_INVISIBLE;
|
|
|
|
actor->health = actor->GetDefault()->health;
|
|
|
|
actor->momx = beast->momx;
|
|
|
|
actor->momy = beast->momy;
|
|
|
|
actor->momz = beast->momz;
|
|
|
|
actor->tid = beast->tid;
|
|
|
|
actor->special = beast->special;
|
|
|
|
memcpy (actor->args, beast->args, sizeof(actor->args));
|
|
|
|
actor->AddToHash ();
|
2006-08-17 00:19:26 +00:00
|
|
|
beast->UnmorphedMe = NULL;
|
2008-03-12 16:27:47 +00:00
|
|
|
DObject::StaticPointerSubstitution (beast, actor);
|
2008-04-08 08:53:42 +00:00
|
|
|
const PClass *exit_flash = beast->MorphExitFlash;
|
2006-02-24 04:48:15 +00:00
|
|
|
beast->Destroy ();
|
2008-04-08 08:53:42 +00:00
|
|
|
Spawn(exit_flash, beast->x, beast->y, beast->z + TELEFOGHEIGHT, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-08-17 09:54:42 +00:00
|
|
|
// Base class for morphing projectiles --------------------------------------
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2006-08-17 09:54:42 +00:00
|
|
|
IMPLEMENT_STATELESS_ACTOR(AMorphProjectile, Any, -1, 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
PROP_Damage (1)
|
|
|
|
PROP_Flags (MF_NOBLOCKMAP|MF_MISSILE|MF_DROPOFF|MF_NOGRAVITY)
|
|
|
|
PROP_Flags2 (MF2_NOTELEPORT)
|
|
|
|
END_DEFAULTS
|
|
|
|
|
2006-08-17 09:54:42 +00:00
|
|
|
int AMorphProjectile::DoSpecialDamage (AActor *target, int damage)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-04-08 08:53:42 +00:00
|
|
|
const PClass *morph_flash = PClass::FindClass (MorphFlash);
|
|
|
|
const PClass *unmorph_flash = PClass::FindClass (UnMorphFlash);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (target->player)
|
|
|
|
{
|
2008-04-08 08:53:42 +00:00
|
|
|
const PClass *player_class = PClass::FindClass (PlayerClass);
|
2008-04-12 15:31:18 +00:00
|
|
|
P_MorphPlayer (NULL, target->player, player_class, Duration, MorphStyle, morph_flash, unmorph_flash);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-08 08:53:42 +00:00
|
|
|
const PClass *monster_class = PClass::FindClass (MonsterClass);
|
|
|
|
P_MorphMonster (target, monster_class, Duration, MorphStyle, morph_flash, unmorph_flash);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2006-08-17 09:54:42 +00:00
|
|
|
void AMorphProjectile::Serialize (FArchive &arc)
|
2006-08-17 00:19:26 +00:00
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
2008-04-08 08:53:42 +00:00
|
|
|
arc << PlayerClass << MonsterClass << Duration << MorphStyle << MorphFlash << UnMorphFlash;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-17 00:19:26 +00:00
|
|
|
// Morphed Monster (you must subclass this to do something useful) ---------
|
|
|
|
|
|
|
|
IMPLEMENT_POINTY_CLASS (AMorphedMonster)
|
|
|
|
DECLARE_POINTER (UnmorphedMe)
|
|
|
|
END_POINTERS
|
|
|
|
|
|
|
|
BEGIN_STATELESS_DEFAULTS (AMorphedMonster, Any, -1, 0)
|
|
|
|
PROP_Flags (MF_SOLID|MF_SHOOTABLE)
|
2006-08-17 09:54:42 +00:00
|
|
|
PROP_Flags2 (MF2_MCROSS|MF2_FLOORCLIP|MF2_PASSMOBJ|MF2_PUSHWALL)
|
2006-08-17 00:19:26 +00:00
|
|
|
PROP_Flags3 (MF3_DONTMORPH|MF3_ISMONSTER)
|
|
|
|
END_DEFAULTS
|
|
|
|
|
|
|
|
void AMorphedMonster::Serialize (FArchive &arc)
|
|
|
|
{
|
|
|
|
Super::Serialize (arc);
|
2008-04-08 08:53:42 +00:00
|
|
|
arc << UnmorphedMe << UnmorphTime << MorphStyle << MorphExitFlash << FlagsSave;
|
2006-08-17 00:19:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void AMorphedMonster::Destroy ()
|
|
|
|
{
|
|
|
|
if (UnmorphedMe != NULL)
|
|
|
|
{
|
|
|
|
UnmorphedMe->Destroy ();
|
|
|
|
}
|
|
|
|
Super::Destroy ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMorphedMonster::Die (AActor *source, AActor *inflictor)
|
|
|
|
{
|
|
|
|
// Dead things don't unmorph
|
2007-07-12 15:15:57 +00:00
|
|
|
flags3 |= MF3_STAYMORPHED;
|
2006-08-17 00:19:26 +00:00
|
|
|
Super::Die (source, inflictor);
|
|
|
|
if (UnmorphedMe != NULL && (UnmorphedMe->flags & MF_UNMORPHED))
|
|
|
|
{
|
|
|
|
UnmorphedMe->health = health;
|
|
|
|
UnmorphedMe->Die (source, inflictor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AMorphedMonster::Tick ()
|
|
|
|
{
|
|
|
|
if (!P_UpdateMorphedMonster (this))
|
|
|
|
{
|
|
|
|
Super::Tick ();
|
|
|
|
}
|
|
|
|
}
|