mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-30 07:31:12 +00:00
- scriptified PowerLightAmp and PowerTorch.
- allow calling qualified super methods so skipping some levels is possible.
This commit is contained in:
parent
d2d6e5d486
commit
d207b571d9
5 changed files with 141 additions and 139 deletions
|
@ -903,110 +903,6 @@ void APowerMask::DoEffect ()
|
|||
}
|
||||
}
|
||||
|
||||
// Light-Amp Powerup ---------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(APowerLightAmp, false, false)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerLightAmp :: DoEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerLightAmp::DoEffect ()
|
||||
{
|
||||
Super::DoEffect ();
|
||||
|
||||
if (Owner->player != NULL && Owner->player->fixedcolormap < NUMCOLORMAPS)
|
||||
{
|
||||
if (!isBlinking())
|
||||
{
|
||||
Owner->player->fixedlightlevel = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Owner->player->fixedlightlevel = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerLightAmp :: EndEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerLightAmp::EndEffect ()
|
||||
{
|
||||
Super::EndEffect();
|
||||
if (Owner != NULL && Owner->player != NULL && Owner->player->fixedcolormap < NUMCOLORMAPS)
|
||||
{
|
||||
Owner->player->fixedlightlevel = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Torch Powerup -------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_CLASS(APowerTorch, false, false)
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerTorch :: Serialize
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerTorch::Serialize(FSerializer &arc)
|
||||
{
|
||||
Super::Serialize (arc);
|
||||
arc("newtorch", NewTorch)
|
||||
("newtorchdelta", NewTorchDelta);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerTorch :: DoEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void APowerTorch::DoEffect ()
|
||||
{
|
||||
if (Owner == NULL || Owner->player == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (EffectTics <= BLINKTHRESHOLD || Owner->player->fixedcolormap >= NUMCOLORMAPS)
|
||||
{
|
||||
Super::DoEffect ();
|
||||
}
|
||||
else
|
||||
{
|
||||
APowerup::DoEffect ();
|
||||
|
||||
if (!(level.time & 16) && Owner->player != NULL)
|
||||
{
|
||||
if (NewTorch != 0)
|
||||
{
|
||||
if (Owner->player->fixedlightlevel + NewTorchDelta > 7
|
||||
|| Owner->player->fixedlightlevel + NewTorchDelta < 0
|
||||
|| NewTorch == Owner->player->fixedlightlevel)
|
||||
{
|
||||
NewTorch = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Owner->player->fixedlightlevel += NewTorchDelta;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NewTorch = (pr_torch() & 7) + 1;
|
||||
NewTorchDelta = (NewTorch == Owner->player->fixedlightlevel) ?
|
||||
0 : ((NewTorch > Owner->player->fixedlightlevel) ? 1 : -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Speed Powerup -------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -105,25 +105,6 @@ public:
|
|||
virtual void DoEffect () override;
|
||||
};
|
||||
|
||||
class APowerLightAmp : public APowerup
|
||||
{
|
||||
DECLARE_CLASS (APowerLightAmp, APowerup)
|
||||
protected:
|
||||
virtual void DoEffect () override;
|
||||
virtual void EndEffect () override;
|
||||
};
|
||||
|
||||
class APowerTorch : public APowerLightAmp
|
||||
{
|
||||
DECLARE_CLASS (APowerTorch, APowerLightAmp)
|
||||
public:
|
||||
|
||||
virtual void Serialize(FSerializer &arc) override;
|
||||
protected:
|
||||
virtual void DoEffect () override;
|
||||
int NewTorch, NewTorchDelta;
|
||||
};
|
||||
|
||||
class APowerSpeed : public APowerup
|
||||
{
|
||||
DECLARE_CLASS (APowerSpeed, APowerup)
|
||||
|
|
|
@ -7450,7 +7450,28 @@ FxExpression *FxMemberFunctionCall::Resolve(FCompileContext& ctx)
|
|||
{
|
||||
cls = ccls;
|
||||
staticonly = true;
|
||||
goto isresolved;
|
||||
if (ccls->IsKindOf(RUNTIME_CLASS(PClass)))
|
||||
{
|
||||
auto clstype = dyn_cast<PClass>(ctx.Function->Variants[0].SelfClass);
|
||||
if (clstype != nullptr)
|
||||
{
|
||||
novirtual = clstype->IsDescendantOf(static_cast<PClass*>(ccls));
|
||||
if (novirtual)
|
||||
{
|
||||
bool error;
|
||||
PFunction *afd = FindClassMemberFunction(ccls, ctx.Class, MethodName, ScriptPosition, &error);
|
||||
if ((afd->Variants[0].Flags & VARF_Method) && (afd->Variants[0].Flags & VARF_Virtual))
|
||||
{
|
||||
staticonly = false;
|
||||
novirtual = true;
|
||||
delete Self;
|
||||
Self = new FxSelf(ScriptPosition);
|
||||
Self->ValueType = NewPointer(cls);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!novirtual) goto isresolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7684,6 +7705,8 @@ isresolved:
|
|||
}
|
||||
|
||||
if (staticonly && (afd->Variants[0].Flags & VARF_Method))
|
||||
{
|
||||
if (!novirtual || !(afd->Variants[0].Flags & VARF_Virtual))
|
||||
{
|
||||
auto clstype = dyn_cast<PClass>(ctx.Class);
|
||||
auto ccls = dyn_cast<PClass>(cls);
|
||||
|
@ -7701,6 +7724,7 @@ isresolved:
|
|||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (afd->Variants[0].Flags & VARF_Method)
|
||||
{
|
||||
|
|
|
@ -104,15 +104,112 @@ class PowerMask : PowerIronFeet native
|
|||
}
|
||||
}
|
||||
|
||||
class PowerLightAmp : Powerup native
|
||||
//===========================================================================
|
||||
//
|
||||
// LightAmp
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
class PowerLightAmp : Powerup
|
||||
{
|
||||
Default
|
||||
{
|
||||
Powerup.Duration -120;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerLightAmp :: DoEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
override void DoEffect ()
|
||||
{
|
||||
Super.DoEffect ();
|
||||
|
||||
let player = Owner.player;
|
||||
if (player != NULL && player.fixedcolormap < PlayerInfo.NUMCOLORMAPS)
|
||||
{
|
||||
if (!isBlinking())
|
||||
{
|
||||
player.fixedlightlevel = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.fixedlightlevel = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// APowerLightAmp :: EndEffect
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
override void EndEffect ()
|
||||
{
|
||||
Super.EndEffect();
|
||||
if (Owner != NULL && Owner.player != NULL && Owner.player.fixedcolormap < PlayerInfo.NUMCOLORMAPS)
|
||||
{
|
||||
Owner.player.fixedlightlevel = -1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PowerTorch : PowerLightAmp native {}
|
||||
//===========================================================================
|
||||
//
|
||||
// Torch
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
class PowerTorch : PowerLightAmp
|
||||
{
|
||||
int NewTorch, NewTorchDelta;
|
||||
|
||||
override void DoEffect ()
|
||||
{
|
||||
if (Owner == NULL || Owner.player == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
let player = Owner.player;
|
||||
if (EffectTics <= BLINKTHRESHOLD || player.fixedcolormap >= PlayerInfo.NUMCOLORMAPS)
|
||||
{
|
||||
Super.DoEffect ();
|
||||
}
|
||||
else
|
||||
{
|
||||
Powerup.DoEffect ();
|
||||
|
||||
if (!(level.time & 16) && Owner.player != NULL)
|
||||
{
|
||||
if (NewTorch != 0)
|
||||
{
|
||||
if (player.fixedlightlevel + NewTorchDelta > 7
|
||||
|| player.fixedlightlevel + NewTorchDelta < 0
|
||||
|| NewTorch == player.fixedlightlevel)
|
||||
{
|
||||
NewTorch = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.fixedlightlevel += NewTorchDelta;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
NewTorch = (random[torch]() & 7) + 1;
|
||||
NewTorchDelta = (NewTorch == Owner.player.fixedlightlevel) ?
|
||||
0 : ((NewTorch > player.fixedlightlevel) ? 1 : -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
|
|
|
@ -173,6 +173,10 @@ enum EPlayerState
|
|||
|
||||
struct PlayerInfo native // this is what internally is known as player_t
|
||||
{
|
||||
// technically engine constants but the only part of the playsim using them is the player.
|
||||
const NOFIXEDCOLORMAP = -1;
|
||||
const NUMCOLORMAPS = 32;
|
||||
|
||||
native PlayerPawn mo;
|
||||
native uint8 playerstate;
|
||||
native uint original_oldbuttons;
|
||||
|
|
Loading…
Reference in a new issue