mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-26 22:01:13 +00:00
ac86a535e7
This could cause problems with functions that take states as parameters but use them to set them internally instead of passing them through the A_Jump interface back to the caller, like A_Chase or A_LookEx. This required some quite significant refactoring because the entire state resolution logic had been baked into the compiler which turned out to be a major maintenance problem. Fixed this by adding a new builtin type 'statelabel'. This is an opaque identifier representing a state, with the actual data either directly encoded into the number for single label state or an index into a state information table. The state resolution is now the task of the called function as it should always have remained. Note, that this required giving back the 'action' qualifier to most state jumping functions. - refactored most A_Jump checkers to a two stage setup with a pure checker that returns a boolean and a scripted A_Jump wrapper, for some simpler checks the checker function was entirely omitted and calculated inline in the A_Jump function. It is strongly recommended to use the boolean checkers unless using an inline function invocation in a state as they lead to vastly clearer code and offer more flexibility. - let Min() and Max() use the OP_MIN and OP_MAX opcodes. Although these were present, these function were implemented using some grossly inefficient branching tests. - the DECORATE 'state' cast kludge will now actually call ResolveState because a state label is not a state and needs conversion.
328 lines
6 KiB
Text
328 lines
6 KiB
Text
|
|
// Bishop -------------------------------------------------------------------
|
|
|
|
class Bishop : Actor
|
|
{
|
|
int missilecount;
|
|
int bobstate;
|
|
|
|
Default
|
|
{
|
|
Health 130;
|
|
Radius 22;
|
|
Height 65;
|
|
Speed 10;
|
|
PainChance 110;
|
|
Monster;
|
|
+FLOAT +NOGRAVITY +NOBLOOD
|
|
+TELESTOMP
|
|
+DONTOVERLAP
|
|
+NOTARGETSWITCH
|
|
SeeSound "BishopSight";
|
|
AttackSound "BishopAttack";
|
|
PainSound "BishopPain";
|
|
DeathSound "BishopDeath";
|
|
ActiveSound "BishopActiveSounds";
|
|
Obituary"$OB_BISHOP";
|
|
}
|
|
|
|
States
|
|
{
|
|
Spawn:
|
|
BISH A 10 A_Look;
|
|
Loop;
|
|
See:
|
|
BISH A 2 A_Chase;
|
|
BISH A 2 A_BishopChase;
|
|
BISH A 2;
|
|
BISH B 2 A_BishopChase;
|
|
BISH B 2 A_Chase;
|
|
BISH B 2 A_BishopChase;
|
|
BISH A 1 A_BishopDecide;
|
|
Loop;
|
|
Blur:
|
|
BISH A 2 A_BishopDoBlur;
|
|
BISH A 4 A_BishopSpawnBlur;
|
|
Wait;
|
|
Pain:
|
|
BISH C 6 A_Pain;
|
|
BISH CCC 6 A_BishopPainBlur;
|
|
BISH C 0;
|
|
Goto See;
|
|
Missile:
|
|
BISH A 3 A_FaceTarget;
|
|
BISH DE 3 A_FaceTarget;
|
|
BISH F 3 A_BishopAttack;
|
|
BISH F 5 A_BishopAttack2;
|
|
Wait;
|
|
Death:
|
|
BISH G 6;
|
|
BISH H 6 Bright A_Scream;
|
|
BISH I 5 Bright A_NoBlocking;
|
|
BISH J 5 BRIGHT A_Explode(random[BishopBoom](25,40));
|
|
BISH K 5 Bright;
|
|
BISH LM 4 Bright;
|
|
BISH N 4 A_SpawnItemEx("BishopPuff", 0,0,40, 0,0,-0.5);
|
|
BISH O 4 A_QueueCorpse;
|
|
BISH P -1;
|
|
Stop;
|
|
Ice:
|
|
BISH X 5 A_FreezeDeath;
|
|
BISH X 1 A_FreezeDeathChunks;
|
|
Wait;
|
|
}
|
|
|
|
|
|
|
|
//============================================================================
|
|
//
|
|
// A_BishopAttack
|
|
//
|
|
//============================================================================
|
|
|
|
void A_BishopAttack()
|
|
{
|
|
if (!target)
|
|
{
|
|
return;
|
|
}
|
|
A_PlaySound (AttackSound, CHAN_BODY);
|
|
if (CheckMeleeRange())
|
|
{
|
|
int damage = random[BishopAttack](1, 8) * 4;
|
|
int newdam = target.DamageMobj (self, self, damage, 'Melee');
|
|
target.TraceBleed (newdam > 0 ? newdam : damage, self);
|
|
return;
|
|
}
|
|
missilecount = (random[BishopAttack]() & 3) + 5;
|
|
}
|
|
|
|
//============================================================================
|
|
//
|
|
// A_BishopAttack2
|
|
//
|
|
// Spawns one of a string of bishop missiles
|
|
//============================================================================
|
|
|
|
void A_BishopAttack2()
|
|
{
|
|
if (!target || !missilecount)
|
|
{
|
|
missilecount = 0;
|
|
SetState (SeeState);
|
|
return;
|
|
}
|
|
Actor mo = SpawnMissile (target, "BishopFX");
|
|
if (mo != null)
|
|
{
|
|
mo.tracer = target;
|
|
}
|
|
missilecount--;
|
|
return;
|
|
}
|
|
|
|
//============================================================================
|
|
//
|
|
// A_BishopDecide
|
|
//
|
|
//============================================================================
|
|
|
|
void A_BishopDecide()
|
|
{
|
|
if (random[BishopDecide]() >= 220)
|
|
{
|
|
SetStateLabel ("Blur");
|
|
}
|
|
}
|
|
|
|
//============================================================================
|
|
//
|
|
// A_BishopDoBlur
|
|
//
|
|
//============================================================================
|
|
|
|
void A_BishopDoBlur()
|
|
{
|
|
missilecount = (random[BishopDoBlur]() & 3) + 3; // Random number of blurs
|
|
if (random[BishopDoBlur]() < 120)
|
|
{
|
|
Thrust(11, Angle + 90);
|
|
}
|
|
else if (random[BishopDoBlur]() > 125)
|
|
{
|
|
Thrust(11, Angle - 90);
|
|
}
|
|
else
|
|
{ // Thrust forward
|
|
Thrust(11);
|
|
}
|
|
A_PlaySound ("BishopBlur", CHAN_BODY);
|
|
}
|
|
|
|
//============================================================================
|
|
//
|
|
// A_BishopSpawnBlur
|
|
//
|
|
//============================================================================
|
|
|
|
void A_BishopSpawnBlur()
|
|
{
|
|
if (!--missilecount)
|
|
{
|
|
Vel.XY = (0,0);// = Vel.Y = 0;
|
|
if (random[BishopSpawnBlur]() > 96)
|
|
{
|
|
SetState (SeeState);
|
|
}
|
|
else
|
|
{
|
|
SetState (MissileState);
|
|
}
|
|
}
|
|
Actor mo = Spawn ("BishopBlur", Pos, ALLOW_REPLACE);
|
|
if (mo)
|
|
{
|
|
mo.angle = angle;
|
|
}
|
|
}
|
|
|
|
//============================================================================
|
|
//
|
|
// A_BishopChase
|
|
//
|
|
//============================================================================
|
|
|
|
void A_BishopChase()
|
|
{
|
|
double newz = pos.z - BobSin(bobstate) / 2.;
|
|
bobstate = (bobstate + 4) & 63;
|
|
newz += BobSin(bobstate) / 2.;
|
|
SetZ(newz);
|
|
}
|
|
|
|
//============================================================================
|
|
//
|
|
// A_BishopPainBlur
|
|
//
|
|
//============================================================================
|
|
|
|
void A_BishopPainBlur()
|
|
{
|
|
if (random[BishopPainBlur]() < 64)
|
|
{
|
|
SetStateLabel ("Blur");
|
|
return;
|
|
}
|
|
double xo = random2[BishopPainBlur]() / 16.;
|
|
double yo = random2[BishopPainBlue]() / 16.;
|
|
double zo = random2[BishopPainBlue]() / 32.;
|
|
Actor mo = Spawn ("BishopPainBlur", Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
|
|
if (mo)
|
|
{
|
|
mo.angle = angle;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
extend class Actor
|
|
{
|
|
//============================================================================
|
|
//
|
|
// A_BishopMissileWeave (this function must be in Actor)
|
|
//
|
|
//============================================================================
|
|
|
|
void A_BishopMissileWeave()
|
|
{
|
|
A_Weave(2, 2, 2., 1.);
|
|
}
|
|
}
|
|
|
|
// Bishop puff --------------------------------------------------------------
|
|
|
|
class BishopPuff : Actor
|
|
{
|
|
Default
|
|
{
|
|
+NOBLOCKMAP +NOGRAVITY
|
|
RenderStyle "Translucent";
|
|
Alpha 0.6;
|
|
}
|
|
States
|
|
{
|
|
Spawn:
|
|
BISH QRST 5;
|
|
BISH UV 6;
|
|
BISH W 5;
|
|
Stop;
|
|
}
|
|
}
|
|
|
|
// Bishop pain blur ---------------------------------------------------------
|
|
|
|
class BishopPainBlur : Actor
|
|
{
|
|
Default
|
|
{
|
|
+NOBLOCKMAP +NOGRAVITY
|
|
RenderStyle "Translucent";
|
|
Alpha 0.6;
|
|
}
|
|
States
|
|
{
|
|
Spawn:
|
|
BISH C 8;
|
|
Stop;
|
|
}
|
|
}
|
|
|
|
// Bishop FX ----------------------------------------------------------------
|
|
|
|
class BishopFX : Actor
|
|
{
|
|
Default
|
|
{
|
|
Radius 10;
|
|
Height 6;
|
|
Speed 10;
|
|
Damage 1;
|
|
Projectile;
|
|
+SEEKERMISSILE
|
|
-ACTIVATEIMPACT -ACTIVATEPCROSS
|
|
+STRIFEDAMAGE
|
|
RenderStyle "Add";
|
|
DeathSound "BishopMissileExplode";
|
|
}
|
|
States
|
|
{
|
|
Spawn:
|
|
BPFX ABAB 1 Bright A_BishopMissileWeave;
|
|
BPFX B 0 Bright A_SeekerMissile(2,3);
|
|
Loop;
|
|
Death:
|
|
BPFX CDEF 4 Bright;
|
|
BPFX GH 3 Bright;
|
|
Stop;
|
|
}
|
|
}
|
|
|
|
// Bishop blur --------------------------------------------------------------
|
|
|
|
class BishopBlur : Actor
|
|
{
|
|
Default
|
|
{
|
|
+NOBLOCKMAP +NOGRAVITY
|
|
RenderStyle "Translucent";
|
|
Alpha 0.6;
|
|
}
|
|
States
|
|
{
|
|
Spawn:
|
|
BISH A 16;
|
|
BISH A 8 A_SetTranslucent(0.4);
|
|
Stop;
|
|
}
|
|
}
|
|
|