- scriptified the weapon's state getter methods - as preparation for the fighter axe.

This commit is contained in:
Christoph Oelckers 2016-11-26 19:48:30 +01:00
parent 997e4a2ac4
commit e541c27622
5 changed files with 104 additions and 52 deletions

View file

@ -21,38 +21,6 @@ static FRandom pr_axeatk ("FAxeAtk");
// The Fighter's Axe --------------------------------------------------------
class AFWeapAxe : public AFighterWeapon
{
DECLARE_CLASS (AFWeapAxe, AFighterWeapon)
public:
FState *GetUpState ();
FState *GetDownState ();
FState *GetReadyState ();
FState *GetAtkState (bool hold);
};
IMPLEMENT_CLASS(AFWeapAxe, false, false)
FState *AFWeapAxe::GetUpState ()
{
return Ammo1->Amount ? FindState ("SelectGlow") : Super::GetUpState();
}
FState *AFWeapAxe::GetDownState ()
{
return Ammo1->Amount ? FindState ("DeselectGlow") : Super::GetDownState();
}
FState *AFWeapAxe::GetReadyState ()
{
return Ammo1->Amount ? FindState ("ReadyGlow") : Super::GetReadyState();
}
FState *AFWeapAxe::GetAtkState (bool hold)
{
return Ammo1->Amount ? FindState ("FireGlow") : Super::GetAtkState(hold);
}
//============================================================================
//
// A_FAxeCheckReady

View file

@ -335,12 +335,12 @@ public:
virtual bool Use (bool pickup);
virtual void Destroy() override;
virtual FState *GetUpState ();
virtual FState *GetDownState ();
virtual FState *GetReadyState ();
virtual FState *GetAtkState (bool hold);
virtual FState *GetAltAtkState (bool hold);
virtual FState *GetStateForButtonName (FName button);
FState *GetUpState ();
FState *GetDownState ();
FState *GetReadyState ();
FState *GetAtkState (bool hold);
FState *GetAltAtkState (bool hold);
FState *GetStateForButtonName (FName button);
virtual void PostMorphWeapon ();
virtual void EndPowerup ();

View file

@ -818,7 +818,16 @@ void AWeapon::CallEndPowerup()
FState *AWeapon::GetUpState ()
{
return FindState(NAME_Select);
IFVIRTUAL(AWeapon, GetUpState)
{
VMValue params[1] = { (DObject*)this };
VMReturn ret;
VMFrameStack stack;
FState *retval;
ret.PointerAt((void**)&retval);
stack.Call(func, params, 1, &ret, 1, nullptr);
return retval;
}
}
//===========================================================================
@ -829,7 +838,16 @@ FState *AWeapon::GetUpState ()
FState *AWeapon::GetDownState ()
{
return FindState(NAME_Deselect);
IFVIRTUAL(AWeapon, GetDownState)
{
VMValue params[1] = { (DObject*)this };
VMReturn ret;
VMFrameStack stack;
FState *retval;
ret.PointerAt((void**)&retval);
stack.Call(func, params, 1, &ret, 1, nullptr);
return retval;
}
}
//===========================================================================
@ -840,7 +858,16 @@ FState *AWeapon::GetDownState ()
FState *AWeapon::GetReadyState ()
{
return FindState(NAME_Ready);
IFVIRTUAL(AWeapon, GetReadyState)
{
VMValue params[1] = { (DObject*)this };
VMReturn ret;
VMFrameStack stack;
FState *retval;
ret.PointerAt((void**)&retval);
stack.Call(func, params, 1, &ret, 1, nullptr);
return retval;
}
}
//===========================================================================
@ -851,11 +878,16 @@ FState *AWeapon::GetReadyState ()
FState *AWeapon::GetAtkState (bool hold)
{
FState * state=NULL;
if (hold) state = FindState(NAME_Hold);
if (state == NULL) state = FindState(NAME_Fire);
return state;
IFVIRTUAL(AWeapon, GetAtkState)
{
VMValue params[2] = { (DObject*)this, hold };
VMReturn ret;
VMFrameStack stack;
FState *retval;
ret.PointerAt((void**)&retval);
stack.Call(func, params, 2, &ret, 1, nullptr);
return retval;
}
}
//===========================================================================
@ -866,11 +898,16 @@ FState *AWeapon::GetAtkState (bool hold)
FState *AWeapon::GetAltAtkState (bool hold)
{
FState * state=NULL;
if (hold) state = FindState(NAME_AltHold);
if (state == NULL) state = FindState(NAME_AltFire);
return state;
IFVIRTUAL(AWeapon, GetAltAtkState)
{
VMValue params[2] = { (DObject*)this, hold };
VMReturn ret;
VMFrameStack stack;
FState *retval;
ret.PointerAt((void**)&retval);
stack.Call(func, params, 2, &ret, 1, nullptr);
return retval;
}
}
//===========================================================================

View file

@ -1,7 +1,7 @@
// The Fighter's Axe --------------------------------------------------------
class FWeapAxe : FighterWeapon native
class FWeapAxe : FighterWeapon
{
Default
{
@ -79,6 +79,28 @@ class FWeapAxe : FighterWeapon native
FAXE A 1;
Goto ReadyGlow;
}
override State GetUpState ()
{
return Ammo1.Amount ? FindState ("SelectGlow") : Super.GetUpState();
}
override State GetDownState ()
{
return Ammo1.Amount ? FindState ("DeselectGlow") : Super.GetDownState();
}
override State GetReadyState ()
{
return Ammo1.Amount ? FindState ("ReadyGlow") : Super.GetReadyState();
}
override State GetAtkState (bool hold)
{
return Ammo1.Amount ? FindState ("FireGlow") : Super.GetAtkState(hold);
}
}
// Axe Puff -----------------------------------------------------------------

View file

@ -580,6 +580,31 @@ class Weapon : StateProvider native
return FindState('Ready');
}
virtual State GetUpState ()
{
return FindState('Select');
}
virtual State GetDownState ()
{
return FindState('Deselect');
}
virtual State GetAtkState (bool hold)
{
State s = null;
if (hold) s = FindState('Hold');
if (s == null) s = FindState('Fire');
return s;
}
virtual State GetAltAtkState (bool hold)
{
State s = null;
if (hold) s = FindState('AltHold');
if (s == null) s = FindState('AltFire');
return s;
}
native action void A_ZoomFactor(double scale = 1, int flags = 0);
native action void A_SetCrosshair(int xhair);