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 *);
|
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
void KoraxFire (AActor *actor, const PClass *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,
|
2006-05-10 02:40:43 +00:00
|
|
|
AActor *source, AActor *dest, const PClass *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
|
|
|
{
|
|
|
|
AActor *spot;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if ((!self->special2) && (self->health <= (self->GetDefault()->health/2)))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
FActorIterator iterator (KORAX_FIRST_TELEPORT_TID);
|
|
|
|
spot = iterator.Next ();
|
|
|
|
if (spot != NULL)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
P_Teleport (self, spot->x, spot->y, ONFLOORZ, spot->angle, true, true, false);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_StartScript (self, NULL, 249, NULL, 0, 0, 0, 0, 0, false);
|
|
|
|
self->special2 = 1; // Don't run again
|
2006-02-24 04:48:15 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (!self->target) return;
|
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
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->health < (self->GetDefault()->health>>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)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
P_Teleport (self, spot->x, spot->y, ONFLOORZ, spot->angle, true, true, false);
|
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
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
// Spawn 6 spirits equalangularly
|
|
|
|
for (i = 0; i < 6; ++i)
|
|
|
|
{
|
2008-08-10 20:48:55 +00:00
|
|
|
mo = P_SpawnMissileAngle (self, PClass::FindClass("KoraxSpirit"), ANGLE_60*i, 5*FRACUNIT);
|
|
|
|
if (mo) KSpiritInit (mo, self);
|
2006-02-24 04:48:15 +00:00
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_StartScript (self, NULL, 255, NULL, 0, 0, 0, 0, false, false); // Death script
|
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
|
|
|
|
spirit->special2 = 32+(pr_kspiritinit()&7); // Float bob index
|
|
|
|
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
|
|
|
{
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KoraxMissile
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KoraxMissile)
|
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;
|
2006-05-10 02:40:43 +00:00
|
|
|
const PClass *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
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
info = PClass::FindClass (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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// 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
|
|
|
{
|
|
|
|
fixed_t x,y,z;
|
|
|
|
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;
|
|
|
|
x = self->x + KORAX_COMMAND_OFFSET * finecosine[ang];
|
|
|
|
y = self->y + KORAX_COMMAND_OFFSET * finesine[ang];
|
|
|
|
z = self->z + KORAX_COMMAND_HEIGHT*FRACUNIT;
|
2008-08-08 15:18:23 +00:00
|
|
|
Spawn("KoraxBolt", x, y, z, ALLOW_REPLACE);
|
2006-02-24 04:48:15 +00:00
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
if (self->health <= (self->GetDefault()->health >> 1))
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
numcommands = 5;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
numcommands = 4;
|
|
|
|
}
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
P_StartScript (self, NULL, 250+(pr_koraxcommand()%numcommands),
|
2006-02-24 04:48:15 +00:00
|
|
|
NULL, 0, 0, 0, 0, false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// KoraxFire
|
|
|
|
//
|
|
|
|
// Arm projectiles
|
|
|
|
// arm positions numbered:
|
|
|
|
// 1 top left
|
|
|
|
// 2 middle left
|
|
|
|
// 3 lower left
|
|
|
|
// 4 top right
|
|
|
|
// 5 middle right
|
|
|
|
// 6 lower right
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2006-05-10 02:40:43 +00:00
|
|
|
void KoraxFire (AActor *actor, const PClass *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;
|
|
|
|
fixed_t x,y,z;
|
|
|
|
|
|
|
|
ang = (actor->angle + (arm < 3 ? -KORAX_DELTAANGLE : KORAX_DELTAANGLE))
|
|
|
|
>> ANGLETOFINESHIFT;
|
|
|
|
x = actor->x + extension[arm] * finecosine[ang];
|
|
|
|
y = actor->y + extension[arm] * finesine[ang];
|
|
|
|
z = actor->z - actor->floorclip + armheight[arm];
|
|
|
|
P_SpawnKoraxMissile (x, y, z, actor, actor->target, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KSpiritWeave
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KSpiritWeave)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
fixed_t newX, newY;
|
|
|
|
int weaveXY, weaveZ;
|
|
|
|
int angle;
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
weaveXY = self->special2>>16;
|
|
|
|
weaveZ = self->special2&0xFFFF;
|
|
|
|
angle = (self->angle+ANG90)>>ANGLETOFINESHIFT;
|
|
|
|
newX = self->x-FixedMul(finecosine[angle],
|
2006-02-24 04:48:15 +00:00
|
|
|
FloatBobOffsets[weaveXY]<<2);
|
2008-08-10 20:48:55 +00:00
|
|
|
newY = self->y-FixedMul(finesine[angle],
|
2006-02-24 04:48:15 +00:00
|
|
|
FloatBobOffsets[weaveXY]<<2);
|
|
|
|
weaveXY = (weaveXY+(pr_kspiritweave()%5))&63;
|
|
|
|
newX += FixedMul(finecosine[angle],
|
|
|
|
FloatBobOffsets[weaveXY]<<2);
|
|
|
|
newY += FixedMul(finesine[angle],
|
|
|
|
FloatBobOffsets[weaveXY]<<2);
|
2008-08-10 20:48:55 +00:00
|
|
|
P_TryMove(self, newX, newY, true);
|
|
|
|
self->z -= FloatBobOffsets[weaveZ]<<1;
|
2006-02-24 04:48:15 +00:00
|
|
|
weaveZ = (weaveZ+(pr_kspiritweave()%5))&63;
|
2008-08-10 20:48:55 +00:00
|
|
|
self->z += FloatBobOffsets[weaveZ]<<1;
|
|
|
|
self->special2 = weaveZ+(weaveXY<<16);
|
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;
|
|
|
|
actor->momx = FixedMul (actor->Speed, finecosine[angle]);
|
|
|
|
actor->momy = FixedMul (actor->Speed, finesine[angle]);
|
|
|
|
|
|
|
|
if (!(level.time&15)
|
|
|
|
|| actor->z > target->z+(target->GetDefault()->height)
|
|
|
|
|| actor->z+actor->height < target->z)
|
|
|
|
{
|
|
|
|
newZ = target->z+((pr_kspiritseek()*target->GetDefault()->height)>>8);
|
|
|
|
deltaZ = newZ-actor->z;
|
|
|
|
if (abs(deltaZ) > 15*FRACUNIT)
|
|
|
|
{
|
|
|
|
if(deltaZ > 0)
|
|
|
|
{
|
|
|
|
deltaZ = 15*FRACUNIT;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
deltaZ = -15*FRACUNIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
dist = P_AproxDistance (target->x-actor->x, target->y-actor->y);
|
|
|
|
dist = dist/actor->Speed;
|
|
|
|
if (dist < 1)
|
|
|
|
{
|
|
|
|
dist = 1;
|
|
|
|
}
|
|
|
|
actor->momz = deltaZ/dist;
|
|
|
|
}
|
|
|
|
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
|
|
|
{
|
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
|
|
|
}
|
2008-08-10 22:48:37 +00:00
|
|
|
CALL_ACTION(A_KSpiritWeave, self);
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KBolt
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KBolt)
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// A_KBoltRaise
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
2008-08-10 20:48:55 +00:00
|
|
|
DEFINE_ACTION_FUNCTION(AActor, A_KBoltRaise)
|
2006-02-24 04:48:15 +00:00
|
|
|
{
|
|
|
|
AActor *mo;
|
|
|
|
fixed_t z;
|
|
|
|
|
|
|
|
// Spawn a child upward
|
2008-08-10 20:48:55 +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
|
|
|
{
|
2008-08-10 20:48:55 +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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// P_SpawnKoraxMissile
|
|
|
|
//
|
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z,
|
2006-05-10 02:40:43 +00:00
|
|
|
AActor *source, AActor *dest, const PClass *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
|
|
|
|
an = R_PointToAngle2(x, y, dest->x, dest->y);
|
|
|
|
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;
|
|
|
|
th->momx = FixedMul (th->Speed, finecosine[an]);
|
|
|
|
th->momy = FixedMul (th->Speed, finesine[an]);
|
|
|
|
dist = P_AproxDistance (dest->x - x, dest->y - y);
|
|
|
|
dist = dist/th->Speed;
|
|
|
|
if (dist < 1)
|
|
|
|
{
|
|
|
|
dist = 1;
|
|
|
|
}
|
|
|
|
th->momz = (dest->z-z+(30*FRACUNIT))/dist;
|
|
|
|
return (P_CheckMissileSpawn(th) ? th : NULL);
|
|
|
|
}
|