2006-02-24 04:48:15 +00:00
|
|
|
//===========================================================================
|
|
|
|
// Korax Variables
|
|
|
|
// tracer last teleport destination
|
|
|
|
// special2 set if "below half" script not yet run
|
|
|
|
//
|
|
|
|
// Korax Scripts (reserved)
|
|
|
|
// 249 Tell scripts that we are below half health
|
|
|
|
// 250-254 Control scripts (254 is only used when less than half health)
|
|
|
|
// 255 Death script
|
|
|
|
//
|
|
|
|
// Korax TIDs (reserved)
|
|
|
|
// 245 Reserved for Korax himself
|
|
|
|
// 248 Initial teleport destination
|
|
|
|
// 249 Teleport destination
|
|
|
|
// 250-254 For use in respective control scripts
|
|
|
|
// 255 For use in death script (spawn spots)
|
|
|
|
//===========================================================================
|
|
|
|
|
2008-09-15 14:11:05 +00:00
|
|
|
/*
|
2006-02-24 04:48:15 +00:00
|
|
|
#include "actor.h"
|
|
|
|
#include "info.h"
|
|
|
|
#include "p_local.h"
|
|
|
|
#include "p_spec.h"
|
|
|
|
#include "s_sound.h"
|
|
|
|
#include "a_action.h"
|
|
|
|
#include "m_random.h"
|
|
|
|
#include "i_system.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"
|
2008-09-15 14:11:05 +00:00
|
|
|
*/
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
const int KORAX_SPIRIT_LIFETIME = 5*TICRATE/5; // 5 seconds
|
|
|
|
const int KORAX_COMMAND_HEIGHT = 120;
|
|
|
|
const int KORAX_COMMAND_OFFSET = 27;
|
|
|
|
|
|
|
|
const int KORAX_TID = 245;
|
|
|
|
const int KORAX_FIRST_TELEPORT_TID = 248;
|
|
|
|
const int KORAX_TELEPORT_TID = 249;
|
|
|
|
|
|
|
|
const int KORAX_DELTAANGLE = 85*ANGLE_1;
|
|
|
|
const int KORAX_ARM_EXTENSION_SHORT = 40;
|
|
|
|
const int KORAX_ARM_EXTENSION_LONG = 55;
|
|
|
|
|
|
|
|
const int KORAX_ARM1_HEIGHT = 108*FRACUNIT;
|
|
|
|
const int KORAX_ARM2_HEIGHT = 82*FRACUNIT;
|
|
|
|
const int KORAX_ARM3_HEIGHT = 54*FRACUNIT;
|
|
|
|
const int KORAX_ARM4_HEIGHT = 104*FRACUNIT;
|
|
|
|
const int KORAX_ARM5_HEIGHT = 86*FRACUNIT;
|
|
|
|
const int KORAX_ARM6_HEIGHT = 53*FRACUNIT;
|
|
|
|
|
|
|
|
const int KORAX_BOLT_HEIGHT = 48*FRACUNIT;
|
|
|
|
const int KORAX_BOLT_LIFETIME = 3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static FRandom pr_koraxchase ("KoraxChase");
|
|
|
|
static FRandom pr_kspiritinit ("KSpiritInit");
|
|
|
|
static FRandom pr_koraxdecide ("KoraxDecide");
|
|
|
|
static FRandom pr_koraxmissile ("KoraxMissile");
|
|
|
|
static FRandom pr_koraxcommand ("KoraxCommand");
|
|
|
|
static FRandom pr_kspiritweave ("KSpiritWeave");
|
|
|
|
static FRandom pr_kspiritseek ("KSpiritSeek");
|
|
|
|
static FRandom pr_kspiritroam ("KSpiritRoam");
|
2008-09-15 14:11:05 +00:00
|
|
|
static FRandom pr_kmissile ("SKoraxMissile");
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
void A_KoraxChase (AActor *);
|
|
|
|
void A_KoraxStep (AActor *);
|
|
|
|
void A_KoraxStep2 (AActor *);
|
|
|
|
void A_KoraxDecide (AActor *);
|
|
|
|
void A_KoraxBonePop (AActor *);
|
|
|
|
void A_KoraxMissile (AActor *);
|
|
|
|
void A_KoraxCommand (AActor *);
|
|
|
|
void A_KSpiritRoam (AActor *);
|
|
|
|
void A_KBolt (AActor *);
|
|
|
|
void A_KBoltRaise (AActor *);
|
|
|
|
|
2010-04-03 04:07:17 +00:00
|
|
|
void KoraxFire (AActor *actor, PClassActor *type, int arm);
|
2006-02-24 04:48:15 +00:00
|
|
|
void KSpiritInit (AActor *spirit, AActor *korax);
|
|
|
|
AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z,
|
2010-04-03 04:07:17 +00:00
|
|
|
AActor *source, AActor *dest, PClassActor *type);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
extern void SpawnSpiritTail (AActor *spirit);
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KoraxChase
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
AActor *spot;
|
|
|
|
|
2009-07-04 18:17:44 +00:00
|
|
|
if ((!self->special2) && (self->health <= (self->SpawnHealth()/2)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
FActorIterator iterator (KORAX_FIRST_TELEPORT_TID);
|
|
|
|
spot = iterator.Next ();
|
|
|
|
if (spot != NULL)
|
|
|
|
{
|
2016-01-29 02:36:06 +00:00
|
|
|
P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, TELF_SOURCEFOG | TELF_DESTFOG);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2012-02-26 03:36:05 +00:00
|
|
|
P_StartScript (self, NULL, 249, NULL, NULL, 0, 0);
|
2008-08-10 20:48:55 +00:00
|
|
|
self->special2 = 1; // Don't run again
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2010-02-12 06:04:57 +00:00
|
|
|
if (self->target == NULL)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
if (pr_koraxchase()<30)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->MissileState);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else if (pr_koraxchase()<30)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_VOICE, "KoraxActive", 1, ATTN_NONE);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Teleport away
|
2009-07-04 18:17:44 +00:00
|
|
|
if (self->health < (self->SpawnHealth()>>1))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
if (pr_koraxchase()<10)
|
|
|
|
{
|
|
|
|
FActorIterator iterator (KORAX_TELEPORT_TID);
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->tracer != NULL)
|
2006-02-24 04:48:15 +00:00
|
|
|
{ // Find the previous teleport destination
|
|
|
|
do
|
|
|
|
{
|
|
|
|
spot = iterator.Next ();
|
2008-08-10 20:48:55 +00:00
|
|
|
} while (spot != NULL && spot != self->tracer);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Go to the next teleport destination
|
|
|
|
spot = iterator.Next ();
|
2008-08-10 20:48:55 +00:00
|
|
|
self->tracer = spot;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (spot)
|
|
|
|
{
|
2016-01-29 02:36:06 +00:00
|
|
|
P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, TELF_SOURCEFOG | TELF_DESTFOG);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KoraxBonePop
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KoraxBonePop)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
AActor *mo;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// Spawn 6 spirits equalangularly
|
|
|
|
for (i = 0; i < 6; ++i)
|
|
|
|
{
|
2010-03-25 20:38:00 +00:00
|
|
|
mo = P_SpawnMissileAngle (self, PClass::FindActor("KoraxSpirit"), ANGLE_60*i, 5*FRACUNIT);
|
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
KSpiritInit (mo, self);
|
|
|
|
}
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2012-02-26 03:36:05 +00:00
|
|
|
P_StartScript (self, NULL, 255, NULL, NULL, 0, 0); // Death script
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// KSpiritInit
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void KSpiritInit (AActor *spirit, AActor *korax)
|
|
|
|
{
|
|
|
|
spirit->health = KORAX_SPIRIT_LIFETIME;
|
|
|
|
|
|
|
|
spirit->tracer = korax; // Swarm around korax
|
2012-07-11 02:50:13 +00:00
|
|
|
spirit->special2 = FINEANGLES/2 + pr_kspiritinit(8 << BOBTOFINESHIFT); // Float bob index
|
2006-02-24 04:48:15 +00:00
|
|
|
spirit->args[0] = 10; // initial turn value
|
|
|
|
spirit->args[1] = 0; // initial look angle
|
|
|
|
|
|
|
|
// Spawn a tail for spirit
|
|
|
|
SpawnSpiritTail (spirit);
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KoraxDecide
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KoraxDecide)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
if (pr_koraxdecide()<220)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->FindState("Attack"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
self->SetState (self->FindState("Command"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KoraxMissile
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KoraxMissile)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
static const struct { const char *type, *sound; } choices[6] =
|
|
|
|
{
|
|
|
|
{ "WraithFX1", "WraithMissileFire" },
|
|
|
|
{ "Demon1FX1", "DemonMissileFire" },
|
|
|
|
{ "Demon2FX1", "DemonMissileFire" },
|
|
|
|
{ "FireDemonMissile", "FireDemonAttack" },
|
|
|
|
{ "CentaurFX", "CentaurLeaderAttack" },
|
|
|
|
{ "SerpentFX", "CentaurLeaderAttack" }
|
|
|
|
};
|
|
|
|
|
|
|
|
int type = pr_koraxmissile()%6;
|
|
|
|
int i;
|
2010-04-03 04:07:17 +00:00
|
|
|
PClassActor *info;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_VOICE, "KoraxAttack", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2010-04-03 04:07:17 +00:00
|
|
|
info = PClass::FindActor(choices[type].type);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (info == NULL)
|
|
|
|
{
|
|
|
|
I_Error ("Unknown Korax missile: %s\n", choices[type].type);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fire all 6 missiles at once
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_WEAPON, choices[type].sound, 1, ATTN_NONE);
|
2006-02-24 04:48:15 +00:00
|
|
|
for (i = 0; i < 6; ++i)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
KoraxFire (self, info, i);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KoraxCommand
|
|
|
|
//
|
|
|
|
// Call action code scripts (250-254)
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KoraxCommand)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
2006-02-24 04:48:15 +00:00
|
|
|
angle_t ang;
|
|
|
|
int numcommands;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_VOICE, "KoraxCommand", 1, ATTN_NORM);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
// Shoot stream of lightning to ceiling
|
2008-08-10 20:48:55 +00:00
|
|
|
ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT;
|
2016-01-19 00:10:57 +00:00
|
|
|
fixedvec3 pos = self->Vec3Offset(
|
|
|
|
KORAX_COMMAND_OFFSET * finecosine[ang],
|
|
|
|
KORAX_COMMAND_OFFSET * finesine[ang],
|
|
|
|
KORAX_COMMAND_HEIGHT*FRACUNIT);
|
|
|
|
Spawn("KoraxBolt", pos, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2009-07-04 18:17:44 +00:00
|
|
|
if (self->health <= (self->SpawnHealth() >> 1))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
numcommands = 5;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numcommands = 4;
|
|
|
|
}
|
|
|
|
|
2012-02-26 03:36:05 +00:00
|
|
|
P_StartScript (self, NULL, 250+(pr_koraxcommand()%numcommands), NULL, NULL, 0, 0);
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// KoraxFire
|
|
|
|
//
|
|
|
|
// Arm projectiles
|
|
|
|
// arm positions numbered:
|
|
|
|
// 1 top left
|
|
|
|
// 2 middle left
|
|
|
|
// 3 lower left
|
|
|
|
// 4 top right
|
|
|
|
// 5 middle right
|
|
|
|
// 6 lower right
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2010-04-03 04:07:17 +00:00
|
|
|
void KoraxFire (AActor *actor, PClassActor *type, int arm)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
static const int extension[6] =
|
|
|
|
{
|
|
|
|
KORAX_ARM_EXTENSION_SHORT,
|
|
|
|
KORAX_ARM_EXTENSION_LONG,
|
|
|
|
KORAX_ARM_EXTENSION_LONG,
|
|
|
|
KORAX_ARM_EXTENSION_SHORT,
|
|
|
|
KORAX_ARM_EXTENSION_LONG,
|
|
|
|
KORAX_ARM_EXTENSION_LONG
|
|
|
|
};
|
|
|
|
static const fixed_t armheight[6] =
|
|
|
|
{
|
|
|
|
KORAX_ARM1_HEIGHT,
|
|
|
|
KORAX_ARM2_HEIGHT,
|
|
|
|
KORAX_ARM3_HEIGHT,
|
|
|
|
KORAX_ARM4_HEIGHT,
|
|
|
|
KORAX_ARM5_HEIGHT,
|
|
|
|
KORAX_ARM6_HEIGHT
|
|
|
|
};
|
|
|
|
|
|
|
|
angle_t ang;
|
2016-01-19 00:10:57 +00:00
|
|
|
|
|
|
|
ang = (actor->angle + (arm < 3 ? -KORAX_DELTAANGLE : KORAX_DELTAANGLE)) >> ANGLETOFINESHIFT;
|
|
|
|
fixedvec3 pos = actor->Vec3Offset(
|
|
|
|
extension[arm] * finecosine[ang],
|
|
|
|
extension[arm] * finesine[ang],
|
|
|
|
-actor->floorclip + armheight[arm]);
|
|
|
|
P_SpawnKoraxMissile (pos.x, pos.y, pos.z, actor, actor->target, type);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KSpiritWeave
|
2012-05-07 06:14:48 +00:00
|
|
|
// [BL] Was identical to CHolyWeave so lets just use that
|
2006-02-24 04:48:15 +00:00
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2012-05-07 06:14:48 +00:00
|
|
|
void CHolyWeave (AActor *actor, FRandom &pr_random);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KSpiritSeeker
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
void A_KSpiritSeeker (AActor *actor, angle_t thresh, angle_t turnMax)
|
|
|
|
{
|
|
|
|
int dir;
|
|
|
|
int dist;
|
|
|
|
angle_t delta;
|
|
|
|
angle_t angle;
|
|
|
|
AActor *target;
|
|
|
|
fixed_t newZ;
|
|
|
|
fixed_t deltaZ;
|
|
|
|
|
|
|
|
target = actor->tracer;
|
|
|
|
if (target == NULL)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
dir = P_FaceMobj (actor, target, &delta);
|
|
|
|
if (delta > thresh)
|
|
|
|
{
|
|
|
|
delta >>= 1;
|
|
|
|
if(delta > turnMax)
|
|
|
|
{
|
|
|
|
delta = turnMax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(dir)
|
|
|
|
{ // Turn clockwise
|
|
|
|
actor->angle += delta;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // Turn counter clockwise
|
|
|
|
actor->angle -= delta;
|
|
|
|
}
|
|
|
|
angle = actor->angle>>ANGLETOFINESHIFT;
|
2009-06-30 20:57:51 +00:00
|
|
|
actor->velx = FixedMul (actor->Speed, finecosine[angle]);
|
|
|
|
actor->vely = FixedMul (actor->Speed, finesine[angle]);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
if (!(level.time&15)
|
2016-01-19 00:10:57 +00:00
|
|
|
|| actor->Z() > target->Z()+(target->GetDefault()->height)
|
|
|
|
|| actor->Top() < target->Z())
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2016-01-19 00:10:57 +00:00
|
|
|
newZ = target->Z()+((pr_kspiritseek()*target->GetDefault()->height)>>8);
|
|
|
|
deltaZ = newZ-actor->Z();
|
2006-02-24 04:48:15 +00:00
|
|
|
if (abs(deltaZ) > 15*FRACUNIT)
|
|
|
|
{
|
|
|
|
if(deltaZ > 0)
|
|
|
|
{
|
|
|
|
deltaZ = 15*FRACUNIT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
deltaZ = -15*FRACUNIT;
|
|
|
|
}
|
|
|
|
}
|
2016-01-10 16:52:41 +00:00
|
|
|
dist = actor->AproxDistance (target) / actor->Speed;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (dist < 1)
|
|
|
|
{
|
|
|
|
dist = 1;
|
|
|
|
}
|
2009-06-30 20:57:51 +00:00
|
|
|
actor->velz = deltaZ/dist;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KSpiritRoam
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KSpiritRoam)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->health-- <= 0)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_VOICE, "SpiritDie", 1, ATTN_NORM);
|
|
|
|
self->SetState (self->FindState("Death"));
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->tracer)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
A_KSpiritSeeker (self, self->args[0]*ANGLE_1,
|
|
|
|
self->args[0]*ANGLE_1*2);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2012-05-07 06:14:48 +00:00
|
|
|
CHolyWeave(self, pr_kspiritweave);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (pr_kspiritroam()<50)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
S_Sound (self, CHAN_VOICE, "SpiritActive", 1, ATTN_NONE);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KBolt
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KBolt)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
// Countdown lifetime
|
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->Destroy ();
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KBoltRaise
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KBoltRaise)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2010-02-12 06:04:57 +00:00
|
|
|
PARAM_ACTION_PROLOGUE;
|
|
|
|
|
2006-02-24 04:48:15 +00:00
|
|
|
AActor *mo;
|
|
|
|
fixed_t z;
|
|
|
|
|
|
|
|
// Spawn a child upward
|
2016-01-19 00:10:57 +00:00
|
|
|
z = self->Z() + KORAX_BOLT_HEIGHT;
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if ((z + KORAX_BOLT_HEIGHT) < self->ceilingz)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
2016-01-19 00:10:57 +00:00
|
|
|
mo = Spawn("KoraxBolt", self->X(), self->Y(), z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (mo)
|
|
|
|
{
|
|
|
|
mo->special1 = KORAX_BOLT_LIFETIME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Maybe cap it off here
|
|
|
|
}
|
2010-02-12 06:04:57 +00:00
|
|
|
return 0;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// P_SpawnKoraxMissile
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z,
|
2010-04-03 04:07:17 +00:00
|
|
|
AActor *source, AActor *dest, PClassActor *type)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *th;
|
|
|
|
angle_t an;
|
|
|
|
int dist;
|
|
|
|
|
|
|
|
z -= source->floorclip;
|
2006-07-16 09:10:45 +00:00
|
|
|
th = Spawn (type, x, y, z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
th->target = source; // Originator
|
2016-01-10 19:46:26 +00:00
|
|
|
an = source->AngleXYTo(x, y, dest);
|
2006-02-24 04:48:15 +00:00
|
|
|
if (dest->flags & MF_SHADOW)
|
|
|
|
{ // Invisible target
|
2008-09-15 14:11:05 +00:00
|
|
|
an += pr_kmissile.Random2()<<21;
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
th->angle = an;
|
|
|
|
an >>= ANGLETOFINESHIFT;
|
2009-06-30 20:57:51 +00:00
|
|
|
th->velx = FixedMul (th->Speed, finecosine[an]);
|
|
|
|
th->vely = FixedMul (th->Speed, finesine[an]);
|
2016-01-10 16:52:41 +00:00
|
|
|
dist = dest->AproxDistance (x, y, source) / th->Speed;
|
2006-02-24 04:48:15 +00:00
|
|
|
if (dist < 1)
|
|
|
|
{
|
|
|
|
dist = 1;
|
|
|
|
}
|
2016-01-19 00:10:57 +00:00
|
|
|
th->velz = (dest->Z()-z+(30*FRACUNIT))/dist;
|
2013-03-21 03:06:04 +00:00
|
|
|
return (P_CheckMissileSpawn(th, source->radius) ? th : NULL);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|