From 898b0d679d6d33eba1286723ba9f526dc0d2aed5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 27 Dec 2010 16:14:26 +0000 Subject: [PATCH] - added a new 'playertype' command for SBARINFO that checks by class type not display name. - fixed: Status bar display for Hexen's fourth weapons only worked when they were obtained by picking up the weapon pieces. SVN r3080 (trunk) --- src/g_shared/sbarinfo_commands.cpp | 57 +++++++++++++- src/p_doors.cpp | 119 ++++++++++++++++++++--------- wadsrc/static/sbarinfo/hexen.txt | 91 ++++++++++------------ 3 files changed, 178 insertions(+), 89 deletions(-) diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index fcc5a6e1ef..c63b009e5d 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -2660,6 +2660,58 @@ class CommandPlayerClass : public SBarInfoCommandFlowControl //////////////////////////////////////////////////////////////////////////////// +class CommandPlayerType : public SBarInfoCommandFlowControl +{ + public: + CommandPlayerType(SBarInfo *script) : SBarInfoCommandFlowControl(script) + { + } + + void Parse(FScanner &sc, bool fullScreenOffsets) + { + sc.MustGetToken(TK_Identifier); + do + { + bool foundClass = false; + const PClass *cls = PClass::FindClass(sc.String); + if (cls != NULL) + { + foundClass = true; + classes.Push(cls); + } + /* + if(!foundClass) + sc.ScriptError("Unkown PlayerClass '%s'.", sc.String); + */ + if(!sc.CheckToken(',')) + break; + } + while(sc.CheckToken(TK_Identifier)); + SBarInfoCommandFlowControl::Parse(sc, fullScreenOffsets); + } + void Tick(const SBarInfoMainBlock *block, const DSBarInfo *statusBar, bool hudChanged) + { + SBarInfoCommandFlowControl::Tick(block, statusBar, hudChanged); + + if(statusBar->CPlayer->cls == NULL) + return; //No class so we can not continue + + for(unsigned int i = 0;i < classes.Size();i++) + { + if (statusBar->CPlayer->cls->IsDescendantOf(classes[i])) + { + SetTruth(true, block, statusBar); + return; + } + } + SetTruth(false, block, statusBar); + } + protected: + TArray classes; +}; + +//////////////////////////////////////////////////////////////////////////////// + class CommandHasWeaponPiece : public SBarInfoCommandFlowControl { public: @@ -3082,7 +3134,7 @@ static const char *SBarInfoCommandNames[] = "drawmugshot", "drawselectedinventory", "drawinventorybar", "drawbar", "drawgem", "drawshader", "drawstring", "drawkeybar", - "gamemode", "playerclass", "aspectratio", + "gamemode", "playerclass", "playertype", "aspectratio", "isselected", "usesammo", "usessecondaryammo", "hasweaponpiece", "inventorybarnotvisible", "weaponammo", "ininventory", "alpha", @@ -3095,7 +3147,7 @@ enum SBarInfoCommands SBARINFO_DRAWMUGSHOT, SBARINFO_DRAWSELECTEDINVENTORY, SBARINFO_DRAWINVENTORYBAR, SBARINFO_DRAWBAR, SBARINFO_DRAWGEM, SBARINFO_DRAWSHADER, SBARINFO_DRAWSTRING, SBARINFO_DRAWKEYBAR, - SBARINFO_GAMEMODE, SBARINFO_PLAYERCLASS, SBARINFO_ASPECTRATIO, + SBARINFO_GAMEMODE, SBARINFO_PLAYERCLASS, SBARINFO_PLAYERTYPE, SBARINFO_ASPECTRATIO, SBARINFO_ISSELECTED, SBARINFO_USESAMMO, SBARINFO_USESSECONDARYAMMO, SBARINFO_HASWEAPONPIECE, SBARINFO_INVENTORYBARNOTVISIBLE, SBARINFO_WEAPONAMMO, SBARINFO_ININVENTORY, SBARINFO_ALPHA, @@ -3126,6 +3178,7 @@ SBarInfoCommand *SBarInfoCommandFlowControl::NextCommand(FScanner &sc) case SBARINFO_ASPECTRATIO: return new CommandAspectRatio(script); case SBARINFO_ISSELECTED: return new CommandIsSelected(script); case SBARINFO_PLAYERCLASS: return new CommandPlayerClass(script); + case SBARINFO_PLAYERTYPE: return new CommandPlayerType(script); case SBARINFO_HASWEAPONPIECE: return new CommandHasWeaponPiece(script); case SBARINFO_WEAPONAMMO: return new CommandWeaponAmmo(script); case SBARINFO_ININVENTORY: return new CommandInInventory(script); diff --git a/src/p_doors.cpp b/src/p_doors.cpp index 557928c557..c01abab6ac 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -36,6 +36,12 @@ #include "sc_man.h" #include "cmdlib.h" +//============================================================================ +// +// VERTICAL DOORS +// +//============================================================================ + IMPLEMENT_CLASS (DDoor) DDoor::DDoor () @@ -55,14 +61,12 @@ void DDoor::Serialize (FArchive &arc) << m_LightTag; } - -// -// VERTICAL DOORS -// - +//============================================================================ // // T_VerticalDoor // +//============================================================================ + void DDoor::Tick () { EResult res; @@ -215,7 +219,12 @@ void DDoor::Tick () } } +//============================================================================ +// // [RH] DoorSound: Plays door sound depending on direction and speed +// +//============================================================================ + void DDoor::DoorSound (bool raise) const { int choice; @@ -309,10 +318,12 @@ DDoor::DDoor (sector_t *sector) { } -// [RH] Merged EV_VerticalDoor and EV_DoLockedDoor into EV_DoDoor -// and made them more general to support the new specials. - +//============================================================================ +// // [RH] SpawnDoor: Helper function for EV_DoDoor +// +//============================================================================ + DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTag) : DMovingCeiling (sec), m_Type (type), m_Speed (speed), m_TopWait (delay), m_LightTag (lightTag) @@ -371,6 +382,13 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, fixed_t speed, int delay, int lightTa m_OldFloorDist = sec->floorplane.d; } +//============================================================================ +// +// [RH] Merged EV_VerticalDoor and EV_DoLockedDoor into EV_DoDoor +// and made them more general to support the new specials. +// +//============================================================================ + bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing, int tag, int speed, int delay, int lock, int lightTag) { @@ -464,10 +482,12 @@ bool EV_DoDoor (DDoor::EVlDoor type, line_t *line, AActor *thing, return rtn; } - +//============================================================================ // // Spawn a door that closes after 30 seconds // +//============================================================================ + void P_SpawnDoorCloseIn30 (sector_t *sec) { fixed_t height; @@ -487,18 +507,56 @@ void P_SpawnDoorCloseIn30 (sector_t *sec) door->m_LightTag = 0; } +//============================================================================ // // Spawn a door that opens after 5 minutes // +//============================================================================ + void P_SpawnDoorRaiseIn5Mins (sector_t *sec) { sec->special = 0; new DDoor (sec, DDoor::doorRaiseIn5Mins, 2*FRACUNIT, TICRATE*30/7, 0); } -// EV_SlidingDoor : slide a door horizontally -// (animate midtexture, then set noblocking line) + +//============================================================================ // +// animated doors +// +//============================================================================ + +IMPLEMENT_CLASS (DAnimatedDoor) + +DAnimatedDoor::DAnimatedDoor () +{ +} + +DAnimatedDoor::DAnimatedDoor (sector_t *sec) + : DMovingCeiling (sec) +{ +} + +void DAnimatedDoor::Serialize (FArchive &arc) +{ + Super::Serialize (arc); + + arc << m_Line1 << m_Line2 + << m_Frame + << m_Timer + << m_BotDist + << m_Status + << m_Speed + << m_Delay + << m_DoorAnim + << m_SetBlocking1 << m_SetBlocking2; +} + +//============================================================================ +// +// Starts a closing action on an animated door +// +//============================================================================ bool DAnimatedDoor::StartClosing () { @@ -528,6 +586,12 @@ bool DAnimatedDoor::StartClosing () return true; } +//============================================================================ +// +// +// +//============================================================================ + void DAnimatedDoor::Tick () { if (m_DoorAnim == NULL) @@ -624,31 +688,11 @@ void DAnimatedDoor::Tick () } } -IMPLEMENT_CLASS (DAnimatedDoor) - -DAnimatedDoor::DAnimatedDoor () -{ -} - -DAnimatedDoor::DAnimatedDoor (sector_t *sec) - : DMovingCeiling (sec) -{ -} - -void DAnimatedDoor::Serialize (FArchive &arc) -{ - Super::Serialize (arc); - - arc << m_Line1 << m_Line2 - << m_Frame - << m_Timer - << m_BotDist - << m_Status - << m_Speed - << m_Delay - << m_DoorAnim - << m_SetBlocking1 << m_SetBlocking2; -} +//============================================================================ +// +// +// +//============================================================================ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay, FDoorAnimation *anim) : DMovingCeiling (sec) @@ -706,7 +750,8 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay, //============================================================================ // -// EV_SlidingDoor +// EV_SlidingDoor : slide a door horizontally +// (animate midtexture, then set noblocking line) // //============================================================================ diff --git a/wadsrc/static/sbarinfo/hexen.txt b/wadsrc/static/sbarinfo/hexen.txt index 635cb650f8..e7a4c6c40e 100755 --- a/wadsrc/static/sbarinfo/hexen.txt +++ b/wadsrc/static/sbarinfo/hexen.txt @@ -114,29 +114,26 @@ statusbar Normal drawimage "ARMCLS", 255, 178; drawnumber 2, HUDFONT_RAVEN, untranslated, armorclass, 275, 176, 1; - playerclass Cleric + playertype ClericPlayer { drawimage "WPSLOT1", 190, 162; - hasweaponpiece CWeapWraithverge, 1 + ininventory CWeapWraithverge { - drawimage "WPIECEC1", 190, 162; + drawimage "WPFULL1", 190, 162; } - hasweaponpiece CWeapWraithverge, 2 - { - drawimage "WPIECEC2", 212, 162; - } - hasweaponpiece CWeapWraithverge, 3 - { - drawimage "WPIECEC3", 225, 162; - } - hasweaponpiece CWeapWraithverge, 1 + else { + hasweaponpiece CWeapWraithverge, 1 + { + drawimage "WPIECEC1", 190, 162; + } hasweaponpiece CWeapWraithverge, 2 { - hasweaponpiece CWeapWraithverge, 3 - { - drawimage "WPFULL1", 190, 162; - } + drawimage "WPIECEC2", 212, 162; + } + hasweaponpiece CWeapWraithverge, 3 + { + drawimage "WPIECEC3", 225, 162; } } @@ -145,29 +142,26 @@ statusbar Normal else drawgem translatable, interpolate(6), "CHAIN2", "LIFEGMC2", -23, 49, 15, 30, 193; } - else playerclass Mage + else playertype MagePlayer { drawimage "WPSLOT2", 190, 162; - hasweaponpiece MWeapBloodscourge, 1 + ininventory MWeapBloodscourge { - drawimage "WPIECEM1", 190, 162; + drawimage "WPFULL2", 190, 162; } - hasweaponpiece MWeapBloodscourge, 2 - { - drawimage "WPIECEM2", 205, 162; - } - hasweaponpiece MWeapBloodscourge, 3 - { - drawimage "WPIECEM3", 224, 162; - } - hasweaponpiece MWeapBloodscourge, 1 + else { + hasweaponpiece MWeapBloodscourge, 1 + { + drawimage "WPIECEM1", 190, 162; + } hasweaponpiece MWeapBloodscourge, 2 { - hasweaponpiece MWeapBloodscourge, 3 - { - drawimage "WPFULL2", 190, 162; - } + drawimage "WPIECEM2", 205, 162; + } + hasweaponpiece MWeapBloodscourge, 3 + { + drawimage "WPIECEM3", 224, 162; } } @@ -179,26 +173,23 @@ statusbar Normal else { drawimage "WPSLOT0", 190, 162; - hasweaponpiece FWeapQuietus, 1 + ininventory FWeapQuietus { - drawimage "WPIECEF1", 190, 162; + drawimage "WPFULL0", 190, 162; } - hasweaponpiece FWeapQuietus, 2 - { - drawimage "WPIECEF2", 225, 162; - } - hasweaponpiece FWeapQuietus, 3 - { - drawimage "WPIECEF3", 234, 162; - } - hasweaponpiece FWeapQuietus, 1 + else { + hasweaponpiece FWeapQuietus, 1 + { + drawimage "WPIECEF1", 190, 162; + } hasweaponpiece FWeapQuietus, 2 { - hasweaponpiece FWeapQuietus, 3 - { - drawimage "WPFULL0", 190, 162; - } + drawimage "WPIECEF2", 225, 162; + } + hasweaponpiece FWeapQuietus, 3 + { + drawimage "WPIECEF3", 234, 162; } } @@ -222,21 +213,21 @@ statusbar Automap drawimage hexenarmor amulet, "ARMSLOT4", 243, 164; // Also draw the life gem here - playerclass Fighter + playertype FighterPlayer { gamemode singleplayer drawgem interpolate(6), "CHAIN", "LIFEGMF2", -23, 49, 15, 30, 193; else drawgem translatable, interpolate(6), "CHAIN", "LIFEGMF2", -23, 49, 15, 30, 193; } - else playerclass Cleric + else playertype ClericPlayer { gamemode singleplayer drawgem interpolate(6), "CHAIN2", "LIFEGMC2", -23, 49, 15, 30, 193; else drawgem translatable, interpolate(6), "CHAIN2", "LIFEGMC2", -23, 49, 15, 30, 193; } - else playerclass Mage + else playertype MagePlayer { gamemode singleplayer drawgem interpolate(6), "CHAIN3", "LIFEGMM2", -23, 49, 15, 30, 193;