From 14fc5516a840f051337ae6fb7e0a39cf0fffd8f3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 20 Apr 2010 11:03:31 +0000 Subject: [PATCH] - Extended ACS's 'n' print format specifier to allow printing some other info than the player's name. It will use negative indices for this. Currently supported strings are level name, level lump name and skill name. - Extended skill definitions so that printable name and image lump name are separate fields so that a printable name can be specified for Doom, too. SVN r2294 (trunk) --- src/g_level.h | 3 ++- src/g_skill.cpp | 32 ++++++++++++++++++++++----- src/m_menu.cpp | 13 ++++++++--- src/p_acs.cpp | 33 +++++++++++++++++++++++++++- wadsrc/static/language.enu | 19 ++++++++++++++++ wadsrc/static/mapinfo/chex.txt | 5 +++++ wadsrc/static/mapinfo/doomcommon.txt | 5 +++++ wadsrc/static/mapinfo/strife.txt | 5 +++++ 8 files changed, 105 insertions(+), 10 deletions(-) diff --git a/src/g_level.h b/src/g_level.h index 58ddf9d5c..d23536383 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -538,6 +538,7 @@ enum ESkillProperty SKILLP_NoPain }; int G_SkillProperty(ESkillProperty prop); +const char * G_SkillName(); typedef TMap SkillMenuNames; @@ -558,8 +559,8 @@ struct FSkillInfo int SpawnFilter; int ACSReturn; FString MenuName; + FString PicName; SkillMenuNames MenuNamesForPlayerClass; - bool MenuNameIsLump; bool MustConfirm; FString MustConfirmText; char Shortcut; diff --git a/src/g_skill.cpp b/src/g_skill.cpp index a91e38264..424b69a47 100644 --- a/src/g_skill.cpp +++ b/src/g_skill.cpp @@ -35,12 +35,14 @@ #include #include "doomstat.h" +#include "d_player.h" #include "g_level.h" #include "g_game.h" #include "gi.h" #include "templates.h" #include "v_font.h" #include "m_fixed.h" +#include "gstrings.h" TArray AllSkills; int DefaultSkill = -1; @@ -70,7 +72,6 @@ void FMapInfoParser::ParseSkill () skill.Aggressiveness = FRACUNIT; skill.SpawnFilter = 0; skill.ACSReturn = 0; - skill.MenuNameIsLump = false; skill.MustConfirm = false; skill.Shortcut = 0; skill.TextColor = ""; @@ -185,7 +186,6 @@ void FMapInfoParser::ParseSkill () ParseAssign(); sc.MustGetString (); skill.MenuName = sc.String; - skill.MenuNameIsLump = false; } else if (sc.Compare("PlayerClassName")) { @@ -200,8 +200,7 @@ void FMapInfoParser::ParseSkill () { ParseAssign(); sc.MustGetString (); - skill.MenuName = sc.String; - skill.MenuNameIsLump = true; + skill.PicName = sc.String; } else if (sc.Compare("MustConfirm")) { @@ -364,6 +363,29 @@ int G_SkillProperty(ESkillProperty prop) return 0; } +//========================================================================== +// +// +// +//========================================================================== + +const char * G_SkillName() +{ + const char *name = AllSkills[gameskill].MenuName; + + player_t *player = &players[consoleplayer]; + const char *playerclass = player->mo->GetClass()->Meta.GetMetaString(APMETA_DisplayName); + + if (playerclass != NULL) + { + FString * pmnm = AllSkills[gameskill].MenuNamesForPlayerClass.CheckKey(playerclass); + if (pmnm != NULL) name = *pmnm; + } + + if (*name == '$') name = GStrings(name+1); + return name; +} + //========================================================================== // @@ -402,8 +424,8 @@ FSkillInfo &FSkillInfo::operator=(const FSkillInfo &other) SpawnFilter = other.SpawnFilter; ACSReturn = other.ACSReturn; MenuName = other.MenuName; + PicName = other.PicName; MenuNamesForPlayerClass = other.MenuNamesForPlayerClass; - MenuNameIsLump = other.MenuNameIsLump; MustConfirm = other.MustConfirm; MustConfirmText = other.MustConfirmText; Shortcut = other.Shortcut; diff --git a/src/m_menu.cpp b/src/m_menu.cpp index 802477a3d..dfa04cd30 100644 --- a/src/m_menu.cpp +++ b/src/m_menu.cpp @@ -477,9 +477,16 @@ void M_StartupSkillMenu(const char *playerclass) { FSkillInfo &skill = AllSkills[i]; - SkillSelectMenu[i].name = skill.MenuName; - SkillSelectMenu[i].fulltext = !skill.MenuNameIsLump; - SkillSelectMenu[i].alphaKey = skill.MenuNameIsLump? skill.Shortcut : tolower(SkillSelectMenu[i].name[0]); + if (skill.PicName.Len() != 0) + { + SkillSelectMenu[i].name = skill.PicName; + SkillSelectMenu[i].fulltext = false; + } + else + { + SkillSelectMenu[i].name = skill.MenuName; + SkillSelectMenu[i].fulltext = true; + } SkillSelectMenu[i].textcolor = skill.GetTextColor(); SkillSelectMenu[i].alphaKey = skill.Shortcut; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 5c681a4d2..c8afb1f26 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3351,6 +3351,13 @@ int DLevelScript::CallFunction(int argCount, int funcIndex, SDWORD *args) return 0; } +enum +{ + PRINTNAME_LEVELNAME = -1, + PRINTNAME_LEVEL = -2, + PRINTNAME_SKILL = -3, +}; + #define NEXTWORD (LittleLong(*pc++)) #define NEXTBYTE (fmt==ACS_LittleEnhanced?getbyte(pc):NEXTWORD) @@ -4804,7 +4811,31 @@ int DLevelScript::RunScript () { player_t *player = NULL; - if (STACK(1) == 0 || (unsigned)STACK(1) > MAXPLAYERS) + if (STACK(1) < 0) + { + switch (STACK(1)) + { + case PRINTNAME_LEVELNAME: + work += level.LevelName; + break; + + case PRINTNAME_LEVEL: + work += level.mapname; + break; + + case PRINTNAME_SKILL: + work += G_SkillName(); + break; + + default: + work += ' '; + break; + } + sp--; + break; + + } + else if (STACK(1) == 0 || (unsigned)STACK(1) > MAXPLAYERS) { if (activator) { diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 53d74a483..2f23edc2e 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -1232,6 +1232,25 @@ TXT_RANDOMGOODBYE_1 = "Bye!"; TXT_RANDOMGOODBYE_2 = "Thanks, bye!"; TXT_RANDOMGOODBYE_3 = "See you later!"; +// Skills: + +SKILL_BABY = "I'm too young to die"; +SKILL_EASY = "Hey, not too rough"; +SKILL_NORMAL = "Hurt me plenty"; +SKILL_HARD = "Ultra-Violence"; +SKILL_NIGHTMARE = "NIGHTMARE!"; + +CSKILL_BABY = "Easy does it"; +CSKILL_EASY = "Not so sticky"; +CSKILL_NORMAL = "Gobs of goo"; +CSKILL_HARD = "Extreme Ooze"; +CSKILL_NIGHTMARE = "Super Slimey!"; + +SSKILL_BABY = "Training"; +SSKILL_EASY = "Rookie"; +SSKILL_NORMAL = "Veteran"; +SSKILL_HARD = "Elite"; +SSKILL_NIGHTMARE = "Bloodbath"; // Menu MNU_NEWGAME = "NEW GAME"; diff --git a/wadsrc/static/mapinfo/chex.txt b/wadsrc/static/mapinfo/chex.txt index edfbc8a46..036d2af89 100644 --- a/wadsrc/static/mapinfo/chex.txt +++ b/wadsrc/static/mapinfo/chex.txt @@ -51,6 +51,7 @@ skill baby EasyBossBrain SpawnFilter = Baby PicName = "M_JKILL" + Name = "$CSKILL_BABY" Key = "i" } @@ -59,6 +60,7 @@ skill easy EasyBossBrain SpawnFilter = Easy PicName = "M_ROUGH" + Name = "$CSKILL_EASY" Key = "h" } @@ -66,6 +68,7 @@ skill normal { SpawnFilter = Normal PicName = "M_HURT" + Name = "$CSKILL_NORMAL" Key = "h" } @@ -73,6 +76,7 @@ skill hard { SpawnFilter = Hard PicName = "M_ULTRA" + Name = "$CSKILL_HARD" Key = "u" } @@ -85,6 +89,7 @@ skill nightmare SpawnFilter = Nightmare PicName = "M_NMARE" MustConfirm = "$CNIGHTMARE" + Name = "$CSKILL_NIGHTMARE" Key = "n" } diff --git a/wadsrc/static/mapinfo/doomcommon.txt b/wadsrc/static/mapinfo/doomcommon.txt index 4aeee99ad..3de271756 100644 --- a/wadsrc/static/mapinfo/doomcommon.txt +++ b/wadsrc/static/mapinfo/doomcommon.txt @@ -50,6 +50,7 @@ skill baby EasyBossBrain SpawnFilter = Baby PicName = "M_JKILL" + Name = "$SKILL_BABY" Key = "i" } @@ -58,6 +59,7 @@ skill easy EasyBossBrain SpawnFilter = Easy PicName = "M_ROUGH" + Name = "$SKILL_EASY" Key = "h" } @@ -66,6 +68,7 @@ skill normal SpawnFilter = Normal PicName = "M_HURT" Key = "h" + Name = "$SKILL_NORMAL" DefaultSkill } @@ -73,6 +76,7 @@ skill hard { SpawnFilter = Hard PicName = "M_ULTRA" + Name = "$SKILL_HARD" Key = "u" } @@ -84,6 +88,7 @@ skill nightmare RespawnTime = 12 SpawnFilter = Nightmare PicName = "M_NMARE" + Name = "$SKILL_NIGHTMARE" MustConfirm Key = "n" } diff --git a/wadsrc/static/mapinfo/strife.txt b/wadsrc/static/mapinfo/strife.txt index 7495c860b..6c213d81e 100644 --- a/wadsrc/static/mapinfo/strife.txt +++ b/wadsrc/static/mapinfo/strife.txt @@ -52,6 +52,7 @@ skill baby EasyBossBrain SpawnFilter = Baby PicName = "M_JKILL" + Name = "$SSKILL_BABY" Key = "t" } @@ -59,6 +60,7 @@ skill easy { SpawnFilter = Easy PicName = "M_ROUGH" + Name = "$SSKILL_EASY" Key = "r" } @@ -66,6 +68,7 @@ skill normal { SpawnFilter = Normal PicName = "M_HURT" + Name = "$SSKILL_NORMAL" Key = "v" DefaultSkill } @@ -74,6 +77,7 @@ skill hard { SpawnFilter = Hard PicName = "M_ULTRA" + Name = "$SSKILL_HARD" Key = "e" } @@ -85,6 +89,7 @@ skill nightmare RespawnTime = 16 SpawnFilter = Nightmare PicName = "M_NMARE" + Name = "$SSKILL_NIGHTMARE" Key = "b" }