- Added AStateProvider class which is used to define the special action function behavior of weapons and custom inventorys. The class itself does not do anything, but the compiler will use it to set up the action function prototypes differently which in turn will be used to do type checking during code generation.

This commit is contained in:
Christoph Oelckers 2016-10-15 15:10:48 +02:00
parent 32a3f57a54
commit 091da92819
5 changed files with 63 additions and 53 deletions

View file

@ -1461,6 +1461,7 @@ source_group("Scripting\\Decorate" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_D
source_group("Scripting\\ZScript" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/zscript/.+" FILES ${CMAKE_CURRENT_BINARY_DIR}/zcc-parse.c ${CMAKE_CURRENT_BINARY_DIR}/zcc-parse.h)
source_group("Scripting\\Code Generation" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/codegeneration/.+")
source_group("Scripting\\VM" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/vm/.+")
source_group("Scripting" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/scripting/.+")
source_group("Shared Game" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/g_shared/.+")
source_group("Versioning" FILES version.h win32/zdoom.rc)
source_group("Xlat" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/xlat/.+" FILES ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c ${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.h)

View file

@ -1642,6 +1642,7 @@ void AInventory::DetachFromOwner ()
{
}
IMPLEMENT_CLASS(AStateProvider)
IMPLEMENT_CLASS (ACustomInventory)
//===========================================================================

View file

@ -226,10 +226,15 @@ private:
static const char *StaticLastMessage;
};
// CustomInventory: Supports the Use, Pickup, and Drop states from 96x
class ACustomInventory : public AInventory
class AStateProvider : public AInventory
{
DECLARE_CLASS (ACustomInventory, AInventory)
DECLARE_CLASS(AStateProvider, AInventory)
};
// CustomInventory: Supports the Use, Pickup, and Drop states from 96x
class ACustomInventory : public AStateProvider
{
DECLARE_CLASS (ACustomInventory, AStateProvider)
public:
// This is used when an inventory item's use state sequence is executed.
@ -281,9 +286,9 @@ public:
int SlotPriority;
};
class AWeapon : public AInventory
class AWeapon : public AStateProvider
{
DECLARE_CLASS_WITH_META(AWeapon, AInventory, PClassWeapon)
DECLARE_CLASS_WITH_META(AWeapon, AStateProvider, PClassWeapon)
HAS_OBJECT_POINTERS
public:
DWORD WeaponFlags;

View file

@ -99,11 +99,11 @@ void SetImplicitArgs(TArray<PType *> *args, TArray<DWORD> *argflags, TArray<FNam
if (args != nullptr)
{
// Special treatment for weapons and CustomInventorys: 'self' is not the defining class but the actual user of the item, so this pointer must be of type 'Actor'
/* if (cls->IsDescendantOf(RUNTIME_CLASS(AStateProvider)))
if (cls->IsDescendantOf(RUNTIME_CLASS(AStateProvider)))
{
args->Insert(0, RUNTIME_CLASS(AActor)); // this must go in before the real pointer to the containing class.
}
else*/
else
{
args->Push(cls);
}

View file

@ -10,50 +10,49 @@ class Inventory : Actor native
Inventory.PickupMessage "$TXT_DEFAULTPICKUPMSG";
}
// functions that can be used from weapons and CustomInventory. These require that 'self' is of type class and be treated as such in the scripts.
/*inventory*/ action native state A_JumpIfNoAmmo(state label);
/*inventory*/ action native void A_CustomPunch(int damage, bool norandom = false, int flags = CPF_USEAMMO, class<Actor> pufftype = "BulletPuff", float range = 0, float lifesteal = 0, int lifestealmax = 0, class<BasicArmorBonus> armorbonustype = "ArmorBonus", sound MeleeSound = "", sound MissSound = "");
/*inventory*/ action native void A_FireBullets(float spread_xy, float spread_z, int numbullets, int damageperbullet, class<Actor> pufftype = "BulletPuff", int flags = 1, float range = 0, class<Actor> missile = "", float Spawnheight = 32, float Spawnofs_xy = 0);
/*inventory*/ action native void A_FireCustomMissile(class<Actor> missiletype, float angle = 0, bool useammo = true, float spawnofs_xy = 0, float spawnheight = 0, int flags = 0, float pitch = 0);
/*inventory*/ action native void A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = "", color color2 = "", int flags = 0, float maxdiff = 0, class<Actor> pufftype = "BulletPuff", float spread_xy = 0, float spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class<Actor> spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270, int limit = 0);
/*inventory*/ action native void A_Light(int extralight);
/*inventory*/ action native void A_Light0();
/*inventory*/ action native void A_Light1();
/*inventory*/ action native void A_Light2();
/*inventory*/ action native void A_LightInverse();
/*inventory*/ action native void A_WeaponReady(int flags = 0);
/*inventory*/ action native void A_Lower();
/*inventory*/ action native void A_Raise();
/*inventory*/ action native void A_FirePistol();
/*inventory*/ action native void A_FireShotgun();
/*inventory*/ action native void A_FireShotgun2();
/*inventory*/ action native void A_OpenShotgun2();
/*inventory*/ action native void A_LoadShotgun2();
/*inventory*/ action native void A_CloseShotgun2();
/*inventory*/ action native void A_FireCGun();
/*inventory*/ action native void A_FireSTGrenade(class<Actor> grenadetype = "Grenade");
/*inventory*/ action native void A_FireMissile();
/*inventory*/ action native void A_FirePlasma();
/*inventory*/ action native void A_FireRailgun();
/*inventory*/ action native void A_FireRailgunLeft();
/*inventory*/ action native void A_FireRailgunRight();
/*inventory*/ action native void A_RailWait();
/*inventory*/ action native void A_BFGsound();
/*inventory*/ action native void A_FireBFG();
/*inventory*/ action native void A_FireOldBFG();
/*inventory*/ action native void A_ReFire(state flash = "");
/*inventory*/ action native void A_ClearReFire();
/*inventory*/ action native void A_CheckReload();
/*inventory*/ action native void A_GunFlash(state flash = "", int flags = 0);
/*inventory*/ action native void A_Saw(sound fullsound = "weapons/sawfull", sound hitsound = "weapons/sawhit", int damage = 2, class<Actor> pufftype = "BulletPuff", int flags = 0, float range = 0, float spread_xy = 2.8125, float spread_z = 0, float lifesteal = 0, int lifestealmax = 0, class<BasicArmorBonus> armorbonustype = "ArmorBonus");
/*inventory*/ action native state A_CheckForReload(int counter, state label, bool dontincrement = false);
/*inventory*/ action native void A_ResetReloadCounter();
action native state A_JumpIfNoAmmo(state label);
action native void A_CustomPunch(int damage, bool norandom = false, int flags = CPF_USEAMMO, class<Actor> pufftype = "BulletPuff", float range = 0, float lifesteal = 0, int lifestealmax = 0, class<BasicArmorBonus> armorbonustype = "ArmorBonus", sound MeleeSound = "", sound MissSound = "");
action native void A_FireBullets(float spread_xy, float spread_z, int numbullets, int damageperbullet, class<Actor> pufftype = "BulletPuff", int flags = 1, float range = 0, class<Actor> missile = "", float Spawnheight = 32, float Spawnofs_xy = 0);
action native void A_FireCustomMissile(class<Actor> missiletype, float angle = 0, bool useammo = true, float spawnofs_xy = 0, float spawnheight = 0, int flags = 0, float pitch = 0);
action native void A_RailAttack(int damage, int spawnofs_xy = 0, bool useammo = true, color color1 = "", color color2 = "", int flags = 0, float maxdiff = 0, class<Actor> pufftype = "BulletPuff", float spread_xy = 0, float spread_z = 0, float range = 0, int duration = 0, float sparsity = 1.0, float driftspeed = 1.0, class<Actor> spawnclass = "none", float spawnofs_z = 0, int spiraloffset = 270, int limit = 0);
action native void A_Light(int extralight);
action native void A_Light0();
action native void A_Light1();
action native void A_Light2();
action native void A_LightInverse();
action native void A_WeaponReady(int flags = 0);
action native void A_Lower();
action native void A_Raise();
action native void A_FirePistol();
action native void A_FireShotgun();
action native void A_FireShotgun2();
action native void A_OpenShotgun2();
action native void A_LoadShotgun2();
action native void A_CloseShotgun2();
action native void A_FireCGun();
action native void A_FireSTGrenade(class<Actor> grenadetype = "Grenade");
action native void A_FireMissile();
action native void A_FirePlasma();
action native void A_FireRailgun();
action native void A_FireRailgunLeft();
action native void A_FireRailgunRight();
action native void A_RailWait();
action native void A_BFGsound();
action native void A_FireBFG();
action native void A_FireOldBFG();
action native void A_ReFire(state flash = "");
action native void A_ClearReFire();
action native void A_CheckReload();
action native void A_GunFlash(state flash = "", int flags = 0);
action native void A_Saw(sound fullsound = "weapons/sawfull", sound hitsound = "weapons/sawhit", int damage = 2, class<Actor> pufftype = "BulletPuff", int flags = 0, float range = 0, float spread_xy = 2.8125, float spread_z = 0, float lifesteal = 0, int lifestealmax = 0, class<BasicArmorBonus> armorbonustype = "ArmorBonus");
action native state A_CheckForReload(int counter, state label, bool dontincrement = false);
action native void A_ResetReloadCounter();
// These are regular functions for the item itself.
action native void A_RestoreSpecialPosition();
action native void A_RestoreSpecialDoomThing();
action native void A_RestoreSpecialThing1();
action native void A_RestoreSpecialThing2();
private action native void A_RestoreSpecialPosition();
private action native void A_RestoreSpecialDoomThing();
private action native void A_RestoreSpecialThing1();
private action native void A_RestoreSpecialThing2();
States
{
@ -78,6 +77,10 @@ class Inventory : Actor native
}
}
class StateProvider : Inventory native
{
}
class ScoreItem : Inventory native
{
Default
@ -151,7 +154,7 @@ class DehackedPickup : Inventory native {}
class FakeInventory : Inventory native {}
class CustomInventory : Inventory native {}
class CustomInventory : StateProvider native {}
class Health : Inventory native
{
@ -448,7 +451,7 @@ class PuzzleItem : Inventory native
}
}
class Weapon : Inventory native
class Weapon : StateProvider native
{
Default
{
@ -466,11 +469,11 @@ class Weapon : Inventory native
Stop;
}
/*inventory*/ action native void A_ZoomFactor(float scale = 1, int flags = 0);
action native void A_ZoomFactor(float scale = 1, int flags = 0);
const ZOOM_INSTANT = 1;
const ZOOM_NOSCALETURNING = 2;
/*inventory*/ action native void A_SetCrosshair(int xhair);
action native void A_SetCrosshair(int xhair);
}
class WeaponGiver : Weapon native