mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-10 14:51:51 +00:00
- made Weapon.CheckAmmo and Weapon.DepleteAmmo virtual on the script side.
This commit is contained in:
parent
35508bc8fb
commit
8e90386567
3 changed files with 36 additions and 6 deletions
|
@ -220,7 +220,21 @@ void AWeapon::MarkPrecacheSounds() const
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
bool AWeapon::CheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo, int ammocount)
|
||||
bool AWeapon::CheckAmmo(int fireMode, bool autoSwitch, bool requireAmmo, int ammocount)
|
||||
{
|
||||
IFVIRTUAL(AWeapon, CheckAmmo)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this, fireMode, autoSwitch, requireAmmo, ammocount };
|
||||
VMReturn ret;
|
||||
int retval;
|
||||
ret.IntAt(&retval);
|
||||
VMCall(func, params, 5, &ret, 1);
|
||||
return !!retval;
|
||||
}
|
||||
return CheckAmmo(fireMode, autoSwitch, requireAmmo, ammocount);
|
||||
}
|
||||
|
||||
bool AWeapon::DoCheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo, int ammocount)
|
||||
{
|
||||
int altFire;
|
||||
int count1, count2;
|
||||
|
@ -293,7 +307,7 @@ DEFINE_ACTION_FUNCTION(AWeapon, CheckAmmo)
|
|||
PARAM_BOOL(autoswitch);
|
||||
PARAM_BOOL_DEF(require);
|
||||
PARAM_INT_DEF(ammocnt);
|
||||
ACTION_RETURN_BOOL(self->CheckAmmo(mode, autoswitch, require, ammocnt));
|
||||
ACTION_RETURN_BOOL(self->DoCheckAmmo(mode, autoswitch, require, ammocnt));
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -306,7 +320,21 @@ DEFINE_ACTION_FUNCTION(AWeapon, CheckAmmo)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
bool AWeapon::DepleteAmmo (bool altFire, bool checkEnough, int ammouse)
|
||||
bool AWeapon::DepleteAmmo(bool altFire, bool checkEnough, int ammouse)
|
||||
{
|
||||
IFVIRTUAL(AWeapon, DepleteAmmo)
|
||||
{
|
||||
VMValue params[] = { (DObject*)this, AltFire, checkEnough, ammouse };
|
||||
VMReturn ret;
|
||||
int retval;
|
||||
ret.IntAt(&retval);
|
||||
VMCall(func, params, 4, &ret, 1);
|
||||
return !!retval;
|
||||
}
|
||||
return DoDepleteAmmo(altFire, checkEnough, ammouse);
|
||||
}
|
||||
|
||||
bool AWeapon::DoDepleteAmmo (bool altFire, bool checkEnough, int ammouse)
|
||||
{
|
||||
if (!((dmflags & DF_INFINITE_AMMO) || (Owner->FindInventory (PClass::FindActor(NAME_PowerInfiniteAmmo), true) != nullptr)))
|
||||
{
|
||||
|
@ -357,7 +385,7 @@ DEFINE_ACTION_FUNCTION(AWeapon, DepleteAmmo)
|
|||
PARAM_BOOL(altfire);
|
||||
PARAM_BOOL_DEF(checkenough);
|
||||
PARAM_INT_DEF(ammouse);
|
||||
ACTION_RETURN_BOOL(self->DepleteAmmo(altfire, checkenough, ammouse));
|
||||
ACTION_RETURN_BOOL(self->DoDepleteAmmo(altfire, checkenough, ammouse));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -142,7 +142,9 @@ public:
|
|||
EitherFire
|
||||
};
|
||||
bool CheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo=false, int ammocount = -1);
|
||||
bool DoCheckAmmo(int fireMode, bool autoSwitch, bool requireAmmo, int ammocount);
|
||||
bool DepleteAmmo (bool altFire, bool checkEnough=true, int ammouse = -1);
|
||||
bool DoDepleteAmmo(bool altFire, bool checkEnough, int ammouse);
|
||||
|
||||
enum
|
||||
{
|
||||
|
|
|
@ -78,8 +78,8 @@ class Weapon : StateProvider native
|
|||
Stop;
|
||||
}
|
||||
|
||||
native bool CheckAmmo(int fireMode, bool autoSwitch, bool requireAmmo = false, int ammocount = -1);
|
||||
native bool DepleteAmmo(bool altFire, bool checkEnough = true, int ammouse = -1);
|
||||
native virtual bool CheckAmmo(int fireMode, bool autoSwitch, bool requireAmmo = false, int ammocount = -1);
|
||||
native virtual bool DepleteAmmo(bool altFire, bool checkEnough = true, int ammouse = -1);
|
||||
|
||||
virtual State GetReadyState ()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue