diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 545400b1c..ae2f19960 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index c4daae024..38f0a5130 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -1642,6 +1642,7 @@ void AInventory::DetachFromOwner () { } +IMPLEMENT_CLASS(AStateProvider) IMPLEMENT_CLASS (ACustomInventory) //=========================================================================== diff --git a/src/g_shared/a_pickups.h b/src/g_shared/a_pickups.h index 45676a214..6dc2d0bc5 100644 --- a/src/g_shared/a_pickups.h +++ b/src/g_shared/a_pickups.h @@ -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; diff --git a/src/scripting/thingdef.cpp b/src/scripting/thingdef.cpp index 182bfbd12..21f690f6c 100644 --- a/src/scripting/thingdef.cpp +++ b/src/scripting/thingdef.cpp @@ -99,11 +99,11 @@ void SetImplicitArgs(TArray *args, TArray *argflags, TArrayIsDescendantOf(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); } diff --git a/wadsrc/static/zscript/shared/inventory.txt b/wadsrc/static/zscript/shared/inventory.txt index fe60fdc1a..bf2f7e188 100644 --- a/wadsrc/static/zscript/shared/inventory.txt +++ b/wadsrc/static/zscript/shared/inventory.txt @@ -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 pufftype = "BulletPuff", float range = 0, float lifesteal = 0, int lifestealmax = 0, class armorbonustype = "ArmorBonus", sound MeleeSound = "", sound MissSound = ""); - /*inventory*/ action native void A_FireBullets(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", int flags = 1, float range = 0, class missile = "", float Spawnheight = 32, float Spawnofs_xy = 0); - /*inventory*/ action native void A_FireCustomMissile(class 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 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 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 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 pufftype = "BulletPuff", int flags = 0, float range = 0, float spread_xy = 2.8125, float spread_z = 0, float lifesteal = 0, int lifestealmax = 0, class 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 pufftype = "BulletPuff", float range = 0, float lifesteal = 0, int lifestealmax = 0, class armorbonustype = "ArmorBonus", sound MeleeSound = "", sound MissSound = ""); + action native void A_FireBullets(float spread_xy, float spread_z, int numbullets, int damageperbullet, class pufftype = "BulletPuff", int flags = 1, float range = 0, class missile = "", float Spawnheight = 32, float Spawnofs_xy = 0); + action native void A_FireCustomMissile(class 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 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 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 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 pufftype = "BulletPuff", int flags = 0, float range = 0, float spread_xy = 2.8125, float spread_z = 0, float lifesteal = 0, int lifestealmax = 0, class 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