From 11ac0c622b15f4a6c97c8a59dcba0611702d57da Mon Sep 17 00:00:00 2001 From: Christoph Oelckers <c.oelckers@users.noreply.github.com> Date: Fri, 25 Nov 2016 01:33:04 +0100 Subject: [PATCH] - fixed: The BFG needs to get its default ammo usage from the DehInfo struct. - fixed: State's fields need to be declared native. --- src/d_dehacked.cpp | 6 ++++ src/scripting/thingdef_data.cpp | 5 +++ wadsrc/static/zscript/base.txt | 41 +++++++++++++++--------- wadsrc/static/zscript/doom/weaponbfg.txt | 2 +- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 40e8e57028..679c8c1adf 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -214,6 +214,12 @@ DehInfo deh = 40, // BFG cells per shot }; +DEFINE_FIELD_X(DehInfo, DehInfo, MaxSoulsphere) +DEFINE_FIELD_X(DehInfo, DehInfo, ExplosionStyle) +DEFINE_FIELD_X(DehInfo, DehInfo, ExplosionAlpha) +DEFINE_FIELD_X(DehInfo, DehInfo, NoAutofreeze) +DEFINE_FIELD_X(DehInfo, DehInfo, BFGCells) + // Doom identified pickup items by their sprites. ZDoom prefers to use their // class type to identify them instead. To support the traditional Doom // behavior, for every thing touched by dehacked that has the MF_PICKUP flag, diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index 3d7a9d3e11..3f7f27e437 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -706,6 +706,11 @@ void InitThingdef() PField *levelf = new PField("level", lstruct, VARF_Native | VARF_Static, (intptr_t)&level); GlobalSymbols.AddSymbol(levelf); + // set up a variable for the DEH data + PStruct *dstruct = NewNativeStruct("DehInfo", nullptr); + PField *dehi = new PField("deh", dstruct, VARF_Native | VARF_Static, (intptr_t)&deh); + GlobalSymbols.AddSymbol(dehi); + // set up a variable for the global players array. PStruct *pstruct = NewNativeStruct("PlayerInfo", nullptr); pstruct->Size = sizeof(player_t); diff --git a/wadsrc/static/zscript/base.txt b/wadsrc/static/zscript/base.txt index 3eebceeb55..160c1c5145 100644 --- a/wadsrc/static/zscript/base.txt +++ b/wadsrc/static/zscript/base.txt @@ -92,23 +92,34 @@ struct LevelLocals native // level_info_t *info cannot be done yet. } +// a few values of this need to be readable by the play code. +// Most are handled at load time and are omitted here. +struct DehInfo native +{ + native int MaxSoulsphere; + native uint8 ExplosionStyle; + native double ExplosionAlpha; + native int NoAutofreeze; + native int BFGCells; +} + struct State native { - State NextState; - int sprite; - int16 Tics; - uint16 TicRange; - uint8 Frame; - uint8 UseFlags; - int Misc1; - int Misc2; - uint16 bSlow; - uint16 bFast; - bool bFullbright; - bool bNoDelay; - bool bSameFrame; - bool bCanRaise; - bool bDehacked; + native State NextState; + native int sprite; + native int16 Tics; + native uint16 TicRange; + native uint8 Frame; + native uint8 UseFlags; + native int Misc1; + native int Misc2; + native uint16 bSlow; + native uint16 bFast; + native bool bFullbright; + native bool bNoDelay; + native bool bSameFrame; + native bool bCanRaise; + native bool bDehacked; } struct Sector native diff --git a/wadsrc/static/zscript/doom/weaponbfg.txt b/wadsrc/static/zscript/doom/weaponbfg.txt index 1b96bfc29d..e83c5d8f6c 100644 --- a/wadsrc/static/zscript/doom/weaponbfg.txt +++ b/wadsrc/static/zscript/doom/weaponbfg.txt @@ -77,7 +77,7 @@ extend class StateProvider Weapon weap = player.ReadyWeapon; if (weap != null && invoker == weap && stateinfo != null && stateinfo.mStateType == STATE_Psprite) { - if (!weap.DepleteAmmo (weap.bAltFire, true, 1)) + if (!weap.DepleteAmmo (weap.bAltFire, true, deh.MaxSoulsphere/*BFGCells*/)) return; }