From 384f4fe7cea52be6a09b97455071e2a11858e3c7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 14 Nov 2016 18:31:12 +0100 Subject: [PATCH] - added a 'DefaultStateUsage' property so that this setting can be properly set up for the classes that can inject states into other actors. --- src/info.cpp | 1 + src/info.h | 1 + src/scripting/codegeneration/codegen.cpp | 2 + src/scripting/thingdef_properties.cpp | 9 ++++ wadsrc/static/zscript/actor.txt | 1 + wadsrc/static/zscript/shared/inventory.txt | 63 ++++++++++++---------- 6 files changed, 49 insertions(+), 28 deletions(-) diff --git a/src/info.cpp b/src/info.cpp index 83b455fb4..e771108c3 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -285,6 +285,7 @@ void PClassActor::DeriveData(PClass *newclass) assert(newclass->IsKindOf(RUNTIME_CLASS(PClassActor))); PClassActor *newa = static_cast(newclass); + newa->DefaultStateUsage = DefaultStateUsage; newa->Obituary = Obituary; newa->HitObituary = HitObituary; newa->DeathHeight = DeathHeight; diff --git a/src/info.h b/src/info.h index 86d653fe4..0b7d4dfc3 100644 --- a/src/info.h +++ b/src/info.h @@ -271,6 +271,7 @@ public: PClassActor *Replacee; int NumOwnedStates; BYTE GameFilter; + uint8_t DefaultStateUsage; // state flag defaults for blocks without a qualifier. WORD SpawnID; WORD ConversationID; SWORD DoomEdNum; diff --git a/src/scripting/codegeneration/codegen.cpp b/src/scripting/codegeneration/codegen.cpp index 89b3a81a3..24da14321 100644 --- a/src/scripting/codegeneration/codegen.cpp +++ b/src/scripting/codegeneration/codegen.cpp @@ -6121,6 +6121,7 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx) case NAME_Name: case NAME_Color: case NAME_Sound: + case NAME_State: if (CheckArgSize(MethodName, ArgList, 1, 1, ScriptPosition)) { PType *type = @@ -6130,6 +6131,7 @@ FxExpression *FxFunctionCall::Resolve(FCompileContext& ctx) MethodName == NAME_Float ? TypeFloat64 : MethodName == NAME_Double ? TypeFloat64 : MethodName == NAME_Name ? TypeName : + MethodName == NAME_State ? TypeState : MethodName == NAME_Color ? TypeColor : (PType*)TypeSound; func = new FxTypeCast(ArgList[0], type, true, true); diff --git a/src/scripting/thingdef_properties.cpp b/src/scripting/thingdef_properties.cpp index 45d78557c..7faab937b 100644 --- a/src/scripting/thingdef_properties.cpp +++ b/src/scripting/thingdef_properties.cpp @@ -533,6 +533,15 @@ DEFINE_PROPERTY(skip_super, 0, Actor) ResetBaggage (&bag, RUNTIME_CLASS(AActor)); } +//========================================================================== +// for internal use only - please do not document! +//========================================================================== +DEFINE_PROPERTY(defaultstateusage, I, Actor) +{ + PROP_INT_PARM(use, 0); + static_cast(bag.Info)->DefaultStateUsage = use; + +} //========================================================================== // //========================================================================== diff --git a/wadsrc/static/zscript/actor.txt b/wadsrc/static/zscript/actor.txt index 441db62f3..c55c7cd3a 100644 --- a/wadsrc/static/zscript/actor.txt +++ b/wadsrc/static/zscript/actor.txt @@ -45,6 +45,7 @@ class Actor : Thinker native StencilColor "00 00 00"; VisibleAngles 0, 0; VisiblePitch 0, 0; + DefaultStateUsage SUF_ACTOR|SUF_OVERLAY; } // Functions diff --git a/wadsrc/static/zscript/shared/inventory.txt b/wadsrc/static/zscript/shared/inventory.txt index e38ddbdb1..9bc99cefb 100644 --- a/wadsrc/static/zscript/shared/inventory.txt +++ b/wadsrc/static/zscript/shared/inventory.txt @@ -88,9 +88,9 @@ class ScoreItem : Inventory native Default { Height 10; - +COUNTITEM; + +COUNTITEM Inventory.Amount 1; - +Inventory.ALWAYSPICKUP; + +Inventory.ALWAYSPICKUP } } @@ -98,7 +98,7 @@ class Ammo : Inventory native { Default { - +INVENTORY.KEEPDEPLETED; + +INVENTORY.KEEPDEPLETED Inventory.PickupSound "misc/ammo_pkup"; } } @@ -119,7 +119,7 @@ class BasicArmor : Armor native { Default { - +Inventory.KEEPDEPLETED; + +Inventory.KEEPDEPLETED } } @@ -127,8 +127,8 @@ class BasicArmorBonus : Armor native { Default { - +Inventory.AUTOACTIVATE; - +Inventory.ALWAYSPICKUP; + +Inventory.AUTOACTIVATE + +Inventory.ALWAYSPICKUP Inventory.MaxAmount 0; Armor.SavePercent 33.335; } @@ -147,8 +147,8 @@ class HexenArmor : Armor native { Default { - +Inventory.KEEPDEPLETED; - +Inventory.UNDROPPABLE; + +Inventory.KEEPDEPLETED + +Inventory.UNDROPPABLE } } @@ -156,7 +156,13 @@ class DehackedPickup : Inventory native {} class FakeInventory : Inventory native {} -class CustomInventory : StateProvider native {} +class CustomInventory : StateProvider native +{ + Default + { + DefaultStateUsage SUF_ACTOR|SUF_OVERLAY|SUF_ITEM; + } +} class Health : Inventory native { @@ -173,7 +179,7 @@ class HealthPickup : Inventory native Default { Inventory.DefMaxAmount; - +INVENTORY.INVBAR; + +INVENTORY.INVBAR } } @@ -192,8 +198,8 @@ class PowerupGiver : Inventory native Default { Inventory.DefMaxAmount; - +INVENTORY.INVBAR; - +INVENTORY.FANCYPICKUPSOUND; + +INVENTORY.INVBAR + +INVENTORY.FANCYPICKUPSOUND Inventory.PickupSound "misc/p_pkup"; } } @@ -215,7 +221,7 @@ class PowerStrength : Powerup native { Powerup.Duration 1; Powerup.Color "ff 00 00", 0.5; - +INVENTORY.HUBPOWER; + +INVENTORY.HUBPOWER } } @@ -245,7 +251,7 @@ class PowerShadow : PowerInvisibility { Default { - +INVENTORY.HUBPOWER; + +INVENTORY.HUBPOWER Powerup.Duration -55; Powerup.Strength 75; Powerup.Mode "Cumulative"; @@ -267,7 +273,7 @@ class PowerMask : PowerIronFeet native { Powerup.Duration -80; Powerup.Color "00 00 00", 0; - +INVENTORY.HUBPOWER; + +INVENTORY.HUBPOWER Inventory.Icon "I_MASK"; } } @@ -287,7 +293,7 @@ class PowerFlight : Powerup native Default { Powerup.Duration -60; - +INVENTORY.HUBPOWER; + +INVENTORY.HUBPOWER } } @@ -297,7 +303,7 @@ class PowerWeaponLevel2 : Powerup native { Powerup.Duration -40; Inventory.Icon "SPINBK0"; - +INVENTORY.NOTELEPORTFREEZE; + +INVENTORY.NOTELEPORTFREEZE } } @@ -308,7 +314,7 @@ class PowerSpeed : Powerup native Powerup.Duration -45; Speed 1.5; Inventory.Icon "SPBOOT0"; - +INVENTORY.NOTELEPORTFREEZE; + +INVENTORY.NOTELEPORTFREEZE } } @@ -318,8 +324,8 @@ class PlayerSpeedTrail native { Default { - +NOBLOCKMAP; - +NOGRAVITY; + +NOBLOCKMAP + +NOGRAVITY Alpha 0.6; RenderStyle "Translucent"; } @@ -339,7 +345,7 @@ class PowerTargeter : Powerup native Default { Powerup.Duration -160; - +INVENTORY.HUBPOWER; + +INVENTORY.HUBPOWER } States { @@ -374,7 +380,7 @@ class PowerScanner : Powerup native Default { Powerup.Duration -80; - +INVENTORY.HUBPOWER; + +INVENTORY.HUBPOWER } } @@ -445,8 +451,8 @@ class PuzzleItem : Inventory native { Default { - +NOGRAVITY; - +INVENTORY.INVBAR; + +NOGRAVITY + +INVENTORY.INVBAR Inventory.DefMaxAmount; Inventory.UseSound "PuzzleSuccess"; Inventory.PickupSound "misc/i_pkup"; @@ -462,7 +468,8 @@ class Weapon : StateProvider native Weapon.BobSpeed 1.0; Weapon.BobRangeX 1.0; Weapon.BobRangeY 1.0; - +WEAPONSPAWN; + +WEAPONSPAWN + DefaultStateUsage SUF_ACTOR|SUF_OVERLAY|SUF_ITEM; } States { @@ -491,9 +498,9 @@ class WeaponHolder : Inventory native { Default { - +NOBLOCKMAP; - +NOSECTOR; - +INVENTORY.UNDROPPABLE; + +NOBLOCKMAP + +NOSECTOR + +INVENTORY.UNDROPPABLE } }