qzdoom-gpl/wadsrc/static/zscript/shared/sectoraction.txt

237 lines
4.4 KiB
Text
Raw Normal View History

2016-03-01 15:47:10 +00:00
2017-01-13 12:51:47 +00:00
class SectorAction : Actor
2016-03-01 15:47:10 +00:00
{
2017-01-13 12:51:47 +00:00
// self class uses health to define the activation type.
enum EActivation
{
SECSPAC_Enter = 1,
SECSPAC_Exit = 2,
SECSPAC_HitFloor = 4,
SECSPAC_HitCeiling = 8,
SECSPAC_Use = 16,
SECSPAC_UseWall = 32,
SECSPAC_EyesDive = 64,
SECSPAC_EyesSurface = 128,
SECSPAC_EyesBelowC = 256,
SECSPAC_EyesAboveC = 512,
SECSPAC_HitFakeFloor= 1024,
};
default
{
+NOBLOCKMAP
+NOSECTOR
+NOGRAVITY
+DONTSPLASH
}
2017-01-13 12:51:47 +00:00
override void OnDestroy ()
{
if (CurSector != null)
{
// Remove ourself from self CurSector's list of actions
if (CurSector.SecActTarget == self)
{
CurSector.SecActTarget = SectorAction(tracer);
}
else
{
Actor probe = CurSector.SecActTarget;
while (probe.tracer != self && probe.tracer != null)
{
probe = probe.tracer;
}
if (probe.tracer == self)
{
probe.tracer = tracer;
}
}
}
Super.OnDestroy();
}
override void BeginPlay ()
{
Super.BeginPlay ();
// Add ourself to self CurSector's list of actions
tracer = CurSector.SecActTarget;
CurSector.SecActTarget = self;
}
override void Activate (Actor source)
{
bDormant = false; // Projectiles cannot trigger
}
override void Deactivate (Actor source)
{
bDormant = true; // Projectiles can trigger
}
virtual bool TriggerAction (Actor triggerer, int activationType)
{
if ((activationType & health) && CanTrigger(triggerer))
{
return triggerer.A_CallSpecial(special, args[0], args[1], args[2], args[3], args[4]);
}
return false;
}
virtual bool CanTrigger (Actor triggerer)
{
return special &&
((triggerer.player && !bFriendly) ||
(bAmbush && triggerer.bActivateMCross) ||
(bDormant && triggerer.bActivatePCross));
}
2016-03-01 15:47:10 +00:00
}
2017-01-13 12:51:47 +00:00
// Triggered when entering CurSector -------------------------------------------
2016-03-01 15:47:10 +00:00
class SecActEnter : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_Enter;
}
2016-03-01 15:47:10 +00:00
}
2017-01-13 12:51:47 +00:00
// Triggered when leaving CurSector --------------------------------------------
2016-03-01 15:47:10 +00:00
class SecActExit : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_Exit;
}
2016-03-01 15:47:10 +00:00
}
2017-01-13 12:51:47 +00:00
// Triggered when hitting CurSector's floor ------------------------------------
2016-03-01 15:47:10 +00:00
class SecActHitFloor : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_HitFloor;
}
2016-03-01 15:47:10 +00:00
}
2017-01-13 12:51:47 +00:00
// Triggered when hitting CurSector's ceiling ----------------------------------
2016-03-01 15:47:10 +00:00
class SecActHitCeil : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_HitCeiling;
}
2016-03-01 15:47:10 +00:00
}
2017-01-13 12:51:47 +00:00
// Triggered when using inside CurSector ---------------------------------------
2016-03-01 15:47:10 +00:00
class SecActUse : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_Use;
}
2016-03-01 15:47:10 +00:00
}
2017-01-13 12:51:47 +00:00
// Triggered when using a CurSector's wall -------------------------------------
2016-03-01 15:47:10 +00:00
class SecActUseWall : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_UseWall;
}
2016-03-01 15:47:10 +00:00
}
// Triggered when eyes go below fake floor ----------------------------------
class SecActEyesDive : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_EyesDive;
}
2016-03-01 15:47:10 +00:00
}
// Triggered when eyes go above fake floor ----------------------------------
class SecActEyesSurface : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_EyesSurface;
}
2016-03-01 15:47:10 +00:00
}
// Triggered when eyes go below fake ceiling ----------------------------------
2016-03-01 15:47:10 +00:00
class SecActEyesBelowC : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_EyesBelowC;
}
2016-03-01 15:47:10 +00:00
}
// Triggered when eyes go above fake ceiling ----------------------------------
2016-03-01 15:47:10 +00:00
class SecActEyesAboveC : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_EyesAboveC;
}
2016-03-01 15:47:10 +00:00
}
// Triggered when hitting fake floor ----------------------------------
2016-03-01 15:47:10 +00:00
class SecActHitFakeFloor : SectorAction
2016-03-01 15:47:10 +00:00
{
Default
{
Health SECSPAC_HitFakeFloor;
}
2016-03-01 15:47:10 +00:00
}
2017-01-13 12:51:47 +00:00
//==========================================================================
//
// Music changer. Uses the sector action class to do its job
//
//==========================================================================
2016-03-01 15:47:10 +00:00
2017-01-13 12:51:47 +00:00
class MusicChanger : SectorAction
2016-03-01 15:47:10 +00:00
{
2017-01-13 12:51:47 +00:00
override bool TriggerAction (Actor triggerer, int activationType)
{
if (activationType & SECSPAC_Enter && triggerer.player != null)
{
if (triggerer.player.MUSINFOactor != self)
{
triggerer.player.MUSINFOactor = self;
triggerer.player.MUSINFOtics = 30;
}
}
return false;
}
override void PostBeginPlay()
{
// The music changer should consider itself activated if the player
// spawns in its sector as well as if it enters the sector during a P_TryMove.
Super.PostBeginPlay();
for (int i = 0; i < MAXPLAYERS; ++i)
{
if (playeringame[i] && players[i].mo && players[i].mo.CurSector == self.CurSector)
{
TriggerAction(players[i].mo, SECSPAC_Enter);
}
}
}
2016-03-01 15:47:10 +00:00
}
2017-01-13 12:51:47 +00:00