From 5c8526dcd79e2bc974be0bfd2b9dab0abe12d2f9 Mon Sep 17 00:00:00 2001 From: Lemon-King Date: Sun, 15 Oct 2023 21:43:44 -0400 Subject: [PATCH] Next Release Prep --- resources/assets/zscript.zs | 5 +- .../hxdd/hexen2/weapons/assassingrenades.zs | 10 +- .../hxdd/hexen2/weapons/paladinpurifier.zs | 2 +- .../hxdd/hexen2/weapons/succubusacidrune.zs | 6 +- .../hxdd/hexen2/weapons/succubusfirestorm.zs | 6 +- .../hxdd/shared/inventory/progression.zs | 216 +++++++--------- resources/assets/zscript/lib/_lib.zs | 1 + resources/assets/zscript/lib/filejson.zs | 61 +++++ resources/assets/zscript/lib/lemonutil.zs | 34 +++ .../assets/zscript/lib/xgametranslation.zs | 234 ++++++++---------- .../menu/components/buttonplayerclass.zs | 8 +- resources/assets/zscript/menu/newgame.zs | 43 ++-- 12 files changed, 324 insertions(+), 302 deletions(-) create mode 100644 resources/assets/zscript/lib/filejson.zs diff --git a/resources/assets/zscript.zs b/resources/assets/zscript.zs index 96eca9b..d4af2d9 100644 --- a/resources/assets/zscript.zs +++ b/resources/assets/zscript.zs @@ -1,4 +1,3 @@ -version "4.10" +version "4.11" -#include "zscript/_hxdd.zs" -//#include "zscript_generated/_zscript_generated.zs" \ No newline at end of file +#include "zscript/_hxdd.zs" \ No newline at end of file diff --git a/resources/assets/zscript/actors/hxdd/hexen2/weapons/assassingrenades.zs b/resources/assets/zscript/actors/hxdd/hexen2/weapons/assassingrenades.zs index 6083d73..8ab1602 100644 --- a/resources/assets/zscript/actors/hxdd/hexen2/weapons/assassingrenades.zs +++ b/resources/assets/zscript/actors/hxdd/hexen2/weapons/assassingrenades.zs @@ -306,11 +306,11 @@ class AWeapGrenades_Grenade: Hexen2Projectile { if ((self.pos.z - self.floorz) <= 0.0 && frandom(0.0, 1.0) > 0.5) { Actor ex = Spawn("AWeapGrenades_Grenade_ExplodeFloor"); ex.SetOrigin((self.pos.x, self.pos.y, self.floorz + 64.0), false); - A_PlaySound("hexen2/weapons/explode", CHAN_WEAPON, 1.0); + A_StartSound("hexen2/weapons/explode", CHAN_WEAPON, 1.0); } else { Actor ex = Spawn("AWeapGrenades_Grenade_Explode"); ex.SetOrigin(self.pos, false); - A_PlaySound("hexen2/weapons/explode", CHAN_WEAPON, 0.5); + A_StartSound("hexen2/weapons/explode", CHAN_WEAPON, 0.5); } if (tracer) { @@ -396,18 +396,18 @@ class AWeapGrenades_SuperGrenade: Hexen2Projectile { ex = Spawn("AWeapGrenades_Grenade_SM_Explode"); } ex.SetOrigin(self.pos, false); - A_PlaySound("hexen2/weapons/explode", CHAN_WEAPON, 0.5); + A_StartSound("hexen2/weapons/explode", CHAN_WEAPON, 0.5); } } else { self.ex_damage = 70; if ((self.pos.z - self.floorz) == 0.0 && frandom(0.0, 1.0) > 0.25) { Actor ex = Spawn("AWeapGrenades_Grenade_ExplodeFloor"); ex.SetOrigin((self.pos.x, self.pos.y, self.floorz + 64.0), false); - A_PlaySound("hexen2/weapons/explode", CHAN_WEAPON, 1.0); + A_StartSound("hexen2/weapons/explode", CHAN_WEAPON, 1.0); } else { Actor ex = Spawn("AWeapGrenades_Grenade_Explode"); ex.SetOrigin(self.pos, false); - A_PlaySound("hexen2/weapons/explode", CHAN_WEAPON, 0.5); + A_StartSound("hexen2/weapons/explode", CHAN_WEAPON, 0.5); } } self.A_Explode(self.ex_damage, self.ex_damage * 0.75, 0, true); diff --git a/resources/assets/zscript/actors/hxdd/hexen2/weapons/paladinpurifier.zs b/resources/assets/zscript/actors/hxdd/hexen2/weapons/paladinpurifier.zs index 3885010..84e3a14 100644 --- a/resources/assets/zscript/actors/hxdd/hexen2/weapons/paladinpurifier.zs +++ b/resources/assets/zscript/actors/hxdd/hexen2/weapons/paladinpurifier.zs @@ -167,7 +167,7 @@ class PWeapPurifier: PaladinWeapon { } } weapon.AddRecoil(recoil); - A_PlaySound(sfx, CHAN_WEAPON, 0.5); + A_StartSound(sfx, CHAN_WEAPON, 0.5); SetCooldown(weapon, refire, 2); } } diff --git a/resources/assets/zscript/actors/hxdd/hexen2/weapons/succubusacidrune.zs b/resources/assets/zscript/actors/hxdd/hexen2/weapons/succubusacidrune.zs index af86e64..ec1f5aa 100644 --- a/resources/assets/zscript/actors/hxdd/hexen2/weapons/succubusacidrune.zs +++ b/resources/assets/zscript/actors/hxdd/hexen2/weapons/succubusacidrune.zs @@ -206,7 +206,7 @@ class SWeapAcidRune: SuccubusWeapon { refire = 0.7; sfx = "hexen2/succubus/acidpfir"; } - A_PlaySound(sfx, CHAN_WEAPON); + A_StartSound(sfx, CHAN_WEAPON); SetCooldown(weapon, refire, 2); } @@ -621,9 +621,9 @@ class SWeapAcidRune_AcidDrop: Hexen2Projectile { if (tracer) { tracer.DamageMobj(self, self, damage, "Normal"); - A_PlaySound("hexen2/succubus/acidhit", CHAN_WEAPON); + A_StartSound("hexen2/succubus/acidhit", CHAN_WEAPON); } else { - A_PlaySound("hexen2/succubus/dropfizz", CHAN_WEAPON); + A_StartSound("hexen2/succubus/dropfizz", CHAN_WEAPON); } if (pg) { diff --git a/resources/assets/zscript/actors/hxdd/hexen2/weapons/succubusfirestorm.zs b/resources/assets/zscript/actors/hxdd/hexen2/weapons/succubusfirestorm.zs index a3b9053..562cacb 100644 --- a/resources/assets/zscript/actors/hxdd/hexen2/weapons/succubusfirestorm.zs +++ b/resources/assets/zscript/actors/hxdd/hexen2/weapons/succubusfirestorm.zs @@ -200,7 +200,7 @@ class SWeapFireStorm: SuccubusWeapon { SWeapFireStorm_FlameStream(proj).isPowered = true; } weapon.AddRecoil(recoil); - A_PlaySound(sfx, CHAN_WEAPON, 0.5); + A_StartSound(sfx, CHAN_WEAPON, 0.5); SetCooldown(weapon, refire, 2); } @@ -452,7 +452,7 @@ class SWeapFireStorm_Burner: Actor { self.nextDamage--; if (self.nextDamage <= 0) { self.burnTarget.DamageMobj(self, self.target, random[swfs_burndmg](2,3), 'Fire'); - self.A_PlaySound("hexen2/raven/fire1", CHAN_WEAPON, 1); + self.A_StartSound("hexen2/raven/fire1", CHAN_WEAPON, 1); self.nextDamage = frandom(0.0, 0.5) * 35.0; } @@ -557,7 +557,7 @@ class SWeapFireStorm_Boom: Actor { self.attackCount--; if (self.attackCount <= 0.0) { - self.A_PlaySound("hexen2/succubus/flamend", CHAN_WEAPON, 0.5); + self.A_StartSound("hexen2/succubus/flamend", CHAN_WEAPON, 0.5); self.Destroy(); } } diff --git a/resources/assets/zscript/actors/hxdd/shared/inventory/progression.zs b/resources/assets/zscript/actors/hxdd/shared/inventory/progression.zs index ac7d5f1..4b2321f 100644 --- a/resources/assets/zscript/actors/hxdd/shared/inventory/progression.zs +++ b/resources/assets/zscript/actors/hxdd/shared/inventory/progression.zs @@ -118,47 +118,6 @@ class PlayerSheetJSON { Array stats_lookup; String xp_bonus_stat; - String GetString(HXDD_JsonObject jo, String key) { - HXDD_JsonElement type_elem = jo.get(key); - if (!type_elem) { - return ""; - } - HXDD_JsonString type_str = HXDD_JsonString(type_elem); - return type_str.s; - } - int GetInt(HXDD_JsonObject jo, String key) { - HXDD_JsonElement type_elem = jo.get(key); - if (!type_elem) { - return -1; - } - HXDD_JsonInt type_int = HXDD_JsonInt(type_elem); - return type_int.i; - } - double GetDouble(HXDD_JsonObject jo, String key) { - HXDD_JsonElement type_elem = jo.get(key); - if (!type_elem) { - return -1; - } - HXDD_JsonDouble type_double = HXDD_JsonDouble(type_elem); - return type_double.d; - } - HXDD_JsonArray GetArray(HXDD_JsonObject jo, String key) { - HXDD_JsonElement type_elem = jo.get(key); - if (!type_elem) { - return null; - } - HXDD_JsonArray type_arr = HXDD_JsonArray(type_elem); - return type_arr; - } - bool GetBool(HXDD_JsonObject jo, String key) { - HXDD_JsonElement type_elem = jo.get(key); - if (!type_elem) { - return false; - } - HXDD_JsonBool type_bool = HXDD_JsonBool(type_elem); - return type_bool.b; - } - int GetEnumFromArmorType(String type) { if (type == "ac" || type == "armor" || type == "armorclass" || type == "hexen" || type == "hx") { return PSAT_ARMOR_AC; @@ -205,110 +164,107 @@ class PlayerSheetJSON { self.hitpointTable.Copy(defaultHPTable); self.manaTable.Copy(defaultMPTable); - int lumpIndex = Wads.CheckNumForFullName(String.format("playersheets/%s.playersheet", file)); - console.printf("PlayerSheetJSON: Load %d", lumpIndex); - if (lumpIndex != -1) { - String lumpData = Wads.ReadLump(lumpIndex); - let json = HXDD_JSON.parse(lumpData, false); - if (json is "HXDD_JsonElement") { - HXDD_JsonObject jsonObject = HXDD_JsonObject(json); - if (jsonObject) { - console.printf("PlayerSheetJSON: Loaded %s!", file); - - String valPlayerClass = GetString(jsonObject, "class"); - String valArmorType = GetString(jsonObject, "armor_type"); - String valProgressionType = GetString(jsonObject, "progression_type"); - int valMaxLevel = GetInt(jsonObject, "max_level"); - String valAlignment = GetString(jsonObject, "alignment"); - bool valUseMaxHealthScaler = GetBool(jsonObject, "use_max_health_scaler"); - let valSkillModifier = GetArray(jsonObject, "skill_modifier"); - double valXPModifier = GetDouble(jsonObject, "xp_modifier"); - bool valHalveXPBeforeLevel4 = GetBool(jsonObject, "halve_xp_before_level_4"); - - let valExperienceTable = GetArray(jsonObject, "experience"); - let valHPTable = GetArray(jsonObject, "health"); - let valManaTable = GetArray(jsonObject, "mana"); - - // Dynamic User Defined Stats - HXDD_JsonObject objStats = HXDD_JsonObject(jsonObject.get("stats")); - if (objStats) { - Array keys; - objStats.GetKeysInto(keys); - - self.stats.Resize(keys.Size()); - self.stats_lookup.Resize(keys.Size()); - for (let i = 0; i < keys.Size(); i++) { - String key = keys[i]; - HXDD_JsonArray stat = GetArray(objStats, key); - if (stat) { - if (stat.arr.size() >= 2) { - PlayerSheetStat nStat = new ("PlayerSheetStat"); - nStat.name = key.MakeLower(); - nStat.table.Resize(stat.arr.Size()); - for (let i = 0; i < stat.arr.Size(); i++) { - nStat.table[i] = HXDD_JsonInt(stat.arr[i]).i; - } - //nStat.value = 0; - nStat.Roll(); - - self.stats[i] = nStat; - self.stats_lookup[i] = nStat.name; - } else { - console.printf("PlayerSheetJSON: Stat %s array must be 2 or higher. [start_low, start_high] or [start_low, start_high, level_low, level_high, level_max, stat_cap]", key); + FileJSON fJSON = new ("FileJSON"); + let success = fJSON.Open(String.format("playersheets/%s.playersheet", file)); + console.printf("PlayerSheetJSON: Load %d", fJSON.index); + if (success) { + HXDD_JsonObject jsonObject = HXDD_JsonObject(fJSON.json); + if (jsonObject) { + console.printf("PlayerSheetJSON: Loaded %s!", file); + + String valPlayerClass = FileJSON.GetString(jsonObject, "class"); + String valArmorType = FileJSON.GetString(jsonObject, "armor_type"); + String valProgressionType = FileJSON.GetString(jsonObject, "progression_type"); + int valMaxLevel = FileJSON.GetInt(jsonObject, "max_level"); + String valAlignment = FileJSON.GetString(jsonObject, "alignment"); + bool valUseMaxHealthScaler = FileJSON.GetBool(jsonObject, "use_max_health_scaler"); + let valSkillModifier = FileJSON.GetArray(jsonObject, "skill_modifier"); + double valXPModifier = FileJSON.GetDouble(jsonObject, "xp_modifier"); + bool valHalveXPBeforeLevel4 = FileJSON.GetBool(jsonObject, "halve_xp_before_level_4"); + + let valExperienceTable = FileJSON.GetArray(jsonObject, "experience"); + let valHPTable = FileJSON.GetArray(jsonObject, "health"); + let valManaTable = FileJSON.GetArray(jsonObject, "mana"); + + // Dynamic User Defined Stats + HXDD_JsonObject objStats = HXDD_JsonObject(jsonObject.get("stats")); + if (objStats) { + Array keys; + objStats.GetKeysInto(keys); + + self.stats.Resize(keys.Size()); + self.stats_lookup.Resize(keys.Size()); + for (let i = 0; i < keys.Size(); i++) { + String key = keys[i]; + HXDD_JsonArray stat = FileJSON.GetArray(objStats, key); + if (stat) { + if (stat.arr.size() >= 2) { + PlayerSheetStat nStat = new ("PlayerSheetStat"); + nStat.name = key.MakeLower(); + nStat.table.Resize(stat.arr.Size()); + for (let i = 0; i < stat.arr.Size(); i++) { + nStat.table[i] = HXDD_JsonInt(stat.arr[i]).i; } + //nStat.value = 0; + nStat.Roll(); + + self.stats[i] = nStat; + self.stats_lookup[i] = nStat.name; } else { - console.printf("PlayerSheetJSON: Failed to read stat %s at %d.", key, i); + console.printf("PlayerSheetJSON: Stat %s array must be 2 or higher. [start_low, start_high] or [start_low, start_high, level_low, level_high, level_max, stat_cap]", key); } + } else { + console.printf("PlayerSheetJSON: Failed to read stat %s at %d.", key, i); } } - String valXPStat = GetString(jsonObject, "xp_bonus_stat"); - if (self.stats_lookup.Find(valXPStat) != self.stats.Size()) { - self.xp_bonus_stat = valXPStat; - } + } + String valXPStat = FileJSON.GetString(jsonObject, "xp_bonus_stat"); + if (self.stats_lookup.Find(valXPStat) != self.stats.Size()) { + self.xp_bonus_stat = valXPStat; + } - let valUsesEventHandler = GetBool(jsonObject, "event_handler"); + let valUsesEventHandler = FileJSON.GetBool(jsonObject, "event_handler"); - // TODO: Setup Item Class Table Here for MultiClassItem Refactor + // TODO: Setup Item Class Table Here for MultiClassItem Refactor - self.PlayerClass = valPlayerClass.MakeLower(); - self.Alignment = valAlignment.MakeLower(); - self.ArmorType = GetEnumFromArmorType(valArmorType.MakeLower()); - self.ProgressionType = GetEnumFromProgressionType(valProgressionType.MakeLower()); + self.PlayerClass = valPlayerClass.MakeLower(); + self.Alignment = valAlignment.MakeLower(); + self.ArmorType = GetEnumFromArmorType(valArmorType.MakeLower()); + self.ProgressionType = GetEnumFromProgressionType(valProgressionType.MakeLower()); - self.UseMaxHealthScaler = valUseMaxHealthScaler; - self.HalveXPBeforeLevel4 = valHalveXPBeforeLevel4; - self.maxlevel = valMaxLevel; - self.experienceModifier = valXPModifier; + self.UseMaxHealthScaler = valUseMaxHealthScaler; + self.HalveXPBeforeLevel4 = valHalveXPBeforeLevel4; + self.maxlevel = valMaxLevel; + self.experienceModifier = valXPModifier; - self.UsesEventHandler = valUsesEventHandler; + self.UsesEventHandler = valUsesEventHandler; - if (valSkillModifier) { - if (defaultSkillMod.Size() < valSkillModifier.arr.Size()) { - self.skillmodifier.Resize(valSkillModifier.arr.Size()); - } - for (let i = 0; i < valSkillModifier.arr.Size(); i++) { - if (valSkillModifier.arr[i]) { - self.skillmodifier[i] = HXDD_JsonDouble(valSkillModifier.arr[i]).d; - } - } + if (valSkillModifier) { + if (defaultSkillMod.Size() < valSkillModifier.arr.Size()) { + self.skillmodifier.Resize(valSkillModifier.arr.Size()); } - self.experienceTable.Resize(valExperienceTable.arr.Size()); - for (let i = 0; i < valExperienceTable.arr.Size(); i++) { - self.experienceTable[i] = HXDD_JsonInt(valExperienceTable.arr[i]).i; + for (let i = 0; i < valSkillModifier.arr.Size(); i++) { + if (valSkillModifier.arr[i]) { + self.skillmodifier[i] = HXDD_JsonDouble(valSkillModifier.arr[i]).d; + } } + } + self.experienceTable.Resize(valExperienceTable.arr.Size()); + for (let i = 0; i < valExperienceTable.arr.Size(); i++) { + self.experienceTable[i] = HXDD_JsonInt(valExperienceTable.arr[i]).i; + } - if (valHPTable && valManaTable) { - self.hitpointTable.Resize(clamp(5, valHPTable.arr.Size(), 6)); - for (let i = 0; i < valHPTable.arr.Size(); i++) { - if (valHPTable.arr[i]) { - self.hitpointTable[i] = HXDD_JsonInt(valHPTable.arr[i]).i; - } + if (valHPTable && valManaTable) { + self.hitpointTable.Resize(clamp(5, valHPTable.arr.Size(), 6)); + for (let i = 0; i < valHPTable.arr.Size(); i++) { + if (valHPTable.arr[i]) { + self.hitpointTable[i] = HXDD_JsonInt(valHPTable.arr[i]).i; } - self.manaTable.Resize(clamp(5, valManaTable.arr.Size(), 6)); - for (let i = 0; i < valManaTable.arr.Size(); i++) { - if (valManaTable.arr[i]) { - self.manaTable[i] = HXDD_JsonInt(valManaTable.arr[i]).i; - } + } + self.manaTable.Resize(clamp(5, valManaTable.arr.Size(), 6)); + for (let i = 0; i < valManaTable.arr.Size(); i++) { + if (valManaTable.arr[i]) { + self.manaTable[i] = HXDD_JsonInt(valManaTable.arr[i]).i; } } } diff --git a/resources/assets/zscript/lib/_lib.zs b/resources/assets/zscript/lib/_lib.zs index 5f3070e..9a8a378 100644 --- a/resources/assets/zscript/lib/_lib.zs +++ b/resources/assets/zscript/lib/_lib.zs @@ -3,5 +3,6 @@ #include "zscript/lib/ZForms/Include.ZSC" #include "zscript/lib/Gutamatics/include.zsc" #include "zscript/lib/particles.zs" +#include "zscript/lib/filejson.zs" #include "zscript/lib/lemonutil.zs" #include "zscript/lib/xgametranslation.zs" \ No newline at end of file diff --git a/resources/assets/zscript/lib/filejson.zs b/resources/assets/zscript/lib/filejson.zs new file mode 100644 index 0000000..a6cf403 --- /dev/null +++ b/resources/assets/zscript/lib/filejson.zs @@ -0,0 +1,61 @@ + +class FileJSON { + int index; + HXDD_JsonElement json; + + static String GetString(HXDD_JsonObject jo, String key) { + HXDD_JsonElement type_elem = jo.get(key); + if (!type_elem) { + return ""; + } + HXDD_JsonString type_str = HXDD_JsonString(type_elem); + return type_str.s; + } + static int GetInt(HXDD_JsonObject jo, String key) { + HXDD_JsonElement type_elem = jo.get(key); + if (!type_elem) { + return -1; + } + HXDD_JsonInt type_int = HXDD_JsonInt(type_elem); + return type_int.i; + } + static double GetDouble(HXDD_JsonObject jo, String key) { + HXDD_JsonElement type_elem = jo.get(key); + if (!type_elem) { + return -1; + } + HXDD_JsonDouble type_double = HXDD_JsonDouble(type_elem); + return type_double.d; + } + static HXDD_JsonArray GetArray(HXDD_JsonObject jo, String key) { + HXDD_JsonElement type_elem = jo.get(key); + if (!type_elem) { + return null; + } + HXDD_JsonArray type_arr = HXDD_JsonArray(type_elem); + return type_arr; + } + static bool GetBool(HXDD_JsonObject jo, String key) { + HXDD_JsonElement type_elem = jo.get(key); + if (!type_elem) { + return false; + } + HXDD_JsonBool type_bool = HXDD_JsonBool(type_elem); + return type_bool.b; + } + + bool Open(String target) { + int lumpIndex = Wads.CheckNumForFullName(target); + if (lumpIndex != -1) { + String lumpData = Wads.ReadLump(lumpIndex); + let lumpJSON = HXDD_JSON.parse(lumpData, false); + if (lumpJSON is "HXDD_JsonElement") { + self.index = lumpIndex; + self.json = (HXDD_JsonElement)(lumpJSON); + return true; + } + console.printf("FileJSON: Failed to load data from file %s!", target); + } + return false; + } +} \ No newline at end of file diff --git a/resources/assets/zscript/lib/lemonutil.zs b/resources/assets/zscript/lib/lemonutil.zs index 7b74c5d..1a01e54 100644 --- a/resources/assets/zscript/lib/lemonutil.zs +++ b/resources/assets/zscript/lib/lemonutil.zs @@ -1,6 +1,40 @@ // https://zdoom.org/wiki/ZScript_actor_functions class LemonUtil { + // Used only with NEWGAME Menu + static int ClassNameToID(string className) { + Array classes = { + "HXDDCorvusPlayer", + "HXDDFighterPlayer", + "HXDDClericPlayer", + "HXDDMagePlayer", + "HX2PaladinPlayer", + "HX2ClericPlayer", + "HX2NecromancerPlayer", + "HX2AssassinPlayer", + "HX2SuccubusPlayer", + "H2CorvusPlayer" + }; + return classes.Find(className); + } + + // Used only with NEWGAME Menu + static string IDToClassName(int id) { + Array classes = { + "HXDDCorvusPlayer", + "HXDDFighterPlayer", + "HXDDClericPlayer", + "HXDDMagePlayer", + "HX2PaladinPlayer", + "HX2ClericPlayer", + "HX2NecromancerPlayer", + "HX2AssassinPlayer", + "HX2SuccubusPlayer", + "H2CorvusPlayer" + }; + return classes[id]; + } + static Class GetPlayerClass() { // Hardcoded for single player atm PlayerInfo p = players[0]; diff --git a/resources/assets/zscript/lib/xgametranslation.zs b/resources/assets/zscript/lib/xgametranslation.zs index 53aa1e8..1d4783f 100644 --- a/resources/assets/zscript/lib/xgametranslation.zs +++ b/resources/assets/zscript/lib/xgametranslation.zs @@ -30,73 +30,60 @@ class XGameTranslation { Array xclass; // player class actor swaps Array xswap; - String GetString(HXDD_JsonObject jo, String key) { - HXDD_JsonElement type_elem = jo.get(key); - if (!type_elem) { - return ""; - } - HXDD_JsonString type_str = HXDD_JsonString(type_elem); - return type_str.s; - } - HXDD_JsonArray GetArray(HXDD_JsonObject jo, String key) { - HXDD_JsonElement type_elem = jo.get(key); - if (!type_elem) { - return null; - } - HXDD_JsonArray type_arr = HXDD_JsonArray(type_elem); - return type_arr; + void Init() { + self.CreateDoomEdNums(); + self.CreateSpawnNums(); + + self.CreateXClassTranslation(); + self.CreateXSwapTranslation(); } - void Init() { + void CreateDoomEdNums() { self.LoadFromJSON("doomednums"); - self.LoadFromJSON("spawnnums"); + } - CreateXClassTranslation(); - CreateXSwapTranslation(); + void CreateSpawnNums() { + self.LoadFromJSON("spawnnums"); } void LoadFromJSON(String group) { - int lumpIndex = Wads.CheckNumForFullName(String.format("xgt/%s.xgt", group)); - if (lumpIndex == -1) { - // try json - lumpIndex = Wads.CheckNumForFullName(String.format("xgt/%s.json", group)); + FileJSON fJSON = new ("FileJSON"); + let success = fJSON.Open(String.format("xgt/%s.xgt", group)); + if (!success) { + success = fJSON.Open(String.format("xgt/%s.json", group)); } - if (lumpIndex != -1) { - String lumpData = Wads.ReadLump(lumpIndex); - let json = HXDD_JSON.parse(lumpData, false); - if (json is "HXDD_JsonElement") { - let jsonArray = HXDD_JsonArray(json); + if (success) { + let jsonArray = HXDD_JsonArray(fJSON.json); - XGT_Group targetGroup; - if (group == "doomednums") { - self.DoomEdNums = new("XGT_Group"); - targetGroup = self.DoomEdNums; - } else if (group == "spawnnums") { - self.SpawnNums = new("XGT_Group"); - targetGroup = self.SpawnNums; - } else { - console.printf("XGameTranslation: Unknown group [%s]!", group); - return; - } - for (let i = 0; i < jsonArray.Size(); i++) { - HXDD_JsonObject jo = HXDD_JsonObject(jsonArray.arr[i]); - if (jo) { - String valDoom = ""; - String valHeretic = ""; - String valHexen = ""; + XGT_Group targetGroup; + if (group == "doomednums") { + self.DoomEdNums = new("XGT_Group"); + targetGroup = self.DoomEdNums; + } else if (group == "spawnnums") { + self.SpawnNums = new("XGT_Group"); + targetGroup = self.SpawnNums; + } else { + console.printf("XGameTranslation: Unknown group [%s]!", group); + return; + } + for (let i = 0; i < jsonArray.Size(); i++) { + HXDD_JsonObject jo = HXDD_JsonObject(jsonArray.arr[i]); + if (jo) { + String valDoom = ""; + String valHeretic = ""; + String valHexen = ""; - valDoom = GetString(jo, "Doom"); - valHeretic = GetString(jo, "Heretic"); - valHexen = GetString(jo, "Hexen"); - targetGroup.Doom.Push(valDoom); - targetGroup.Heretic.Push(valHeretic); - targetGroup.Hexen.Push(valHexen); - } + valDoom = FileJSON.GetString(jo, "Doom"); + valHeretic = FileJSON.GetString(jo, "Heretic"); + valHexen = FileJSON.GetString(jo, "Hexen"); + targetGroup.Doom.Push(valDoom); + targetGroup.Heretic.Push(valHeretic); + targetGroup.Hexen.Push(valHexen); } - targetGroup.size = targetGroup.Doom.Size(); - } else { - console.printf("XGameTranslation: Failed to load actor groups from JSON!"); } + targetGroup.size = targetGroup.Doom.Size(); + } else { + console.printf("XGameTranslation Error: Group [%s] could not be found!", group); } } @@ -177,48 +164,42 @@ class XGameTranslation { void CreateXClassTranslation() { String playerClassName = LemonUtil.GetPlayerClassName(); - int lumpIndex = Wads.CheckNumForFullName(String.format("playersheets/%s.playersheet", playerClassName)); - if (lumpIndex == -1) { - // try json - lumpIndex = Wads.CheckNumForFullName(String.format("playersheets/%s.json", playerClassName)); - } - //console.printf("XGameTranslation.XClass: Load playersheets/%s.playersheet %d", playerClassName, lumpIndex); - if (lumpIndex != -1) { - String lumpData = Wads.ReadLump(lumpIndex); - let json = HXDD_JSON.parse(lumpData, false); - if (json is "HXDD_JsonElement") { - HXDD_JsonObject jsonObject = HXDD_JsonObject(json); - if (jsonObject) { - - // Class Item Swap List Generation - HXDD_JsonObject objClassItems = HXDD_JsonObject(jsonObject.get("xgame")); - if (objClassItems) { - Array keys; - objClassItems.GetKeysInto(keys); + FileJSON fJSON = new ("FileJSON"); + let success = fJSON.Open(String.format("playersheets/%s.playersheet", playerClassName)); + if (!success) { + success = fJSON.Open(String.format("playersheets/%s.json", playerClassName)); + } + if (success) { + console.printf("XGameTranslation.XClass: Load playersheets/%s.playersheet %d", playerClassName, fJSON.index); + // Class Item Swap List Generation + HXDD_JsonObject json = HXDD_JsonObject(fJSON.json); + String ver = FileJSON.GetString(json, "version"); + HXDD_JsonObject objClassItems = HXDD_JsonObject(json.get("xgame")); + if (objClassItems) { + Array keys; + objClassItems.GetKeysInto(keys); - self.xclass.Resize(keys.Size()); - for (let i = 0; i < keys.Size(); i++) { - String key = keys[i]; - String valClassItem = GetString(objClassItems, key); - if (valClassItem) { - Array nClassItems; - valClassItem.Split(nClassItems, ","); - for (let n = 0; n < nClassItems.Size(); n++) { - nClassItems[n].Replace(" ", ""); - } - self.xclass[i] = new ("XTranslationActors"); - self.xclass[i].list.Copy(nClassItems); - //for (let j = 0; j < self.xclass[i].list.Size(); j++) { - // console.printf("XGameTranslation %s", self.xclass[i].list[j]); - //} - self.xclass[i].key = key; - //console.printf("XGameTranslation.XClass Lookup: %s, Class Item: %s", key, valClassItem); - } - } - } - } - } + self.xclass.Resize(keys.Size()); + for (let i = 0; i < keys.Size(); i++) { + String key = keys[i]; + String valClassItem = FileJSON.GetString(objClassItems, key); + if (valClassItem) { + Array nClassItems; + valClassItem.Split(nClassItems, ","); + for (let n = 0; n < nClassItems.Size(); n++) { + nClassItems[n].Replace(" ", ""); + } + self.xclass[i] = new ("XTranslationActors"); + self.xclass[i].list.Copy(nClassItems); + //for (let j = 0; j < self.xclass[i].list.Size(); j++) { + // console.printf("XGameTranslation %s", self.xclass[i].list[j]); + //} + self.xclass[i].key = key; + //console.printf("XGameTranslation.XClass Lookup: %s, Class Item: %s", key, valClassItem); + } + } + } } } @@ -243,43 +224,36 @@ class XGameTranslation { } void CreateXSwapTranslation() { - int lumpIndex = Wads.CheckNumForFullName("xgt/xswap.xgt"); - if (lumpIndex == -1) { - // try json - lumpIndex = Wads.CheckNumForFullName("xgt/xswap.json"); + FileJSON fJSON = new ("FileJSON"); + let success = fJSON.Open("xgt/xswap.xgt"); + if (!success) { + success = fJSON.Open("xgt/xswap.json"); } - - if (lumpIndex != -1) { - String lumpData = Wads.ReadLump(lumpIndex); - let json = HXDD_JSON.parse(lumpData, false); - if (json is "HXDD_JsonElement") { - HXDD_JsonObject jsonObject = HXDD_JsonObject(json); - if (jsonObject) { - String ver = GetString(jsonObject, "version"); - //if (ver) { - // console.printf("XGameTranslation.CreateXSwapTranslation: Target Version %s", ver); - //} - HXDD_JsonArray arrListItems = HXDD_JsonArray(jsonObject.get("list")); - if (arrListItems) { - int size = arrListItems.Size(); - self.xswap.Resize(size); - for (let i = 0; i < size; i++) { - HXDD_JsonObject objListItem = HXDD_JsonObject(arrListItems.Get(i)); - if (objListItem) { - String valKey = GetString(objListItem, "key"); - //String valCategory = GetString(objListItem, "category"); - //HXDD_JsonArray valLabels = GetArray(objListItem, "labels"); - HXDD_JsonArray valActors = GetArray(objListItem, "actors"); - if (valKey && valActors) { - let newXSwap = new ("XTranslationActors"); - newXSwap.key = valKey; - newXSwap.list.Resize(valActors.Size()); - for (int j = 0; j < valActors.Size(); j++) { - newXSwap.list[j] = HXDD_JsonString(valActors.get(j)).s; - } - self.xswap[i] = newXSwap; - } + if (success) { + HXDD_JsonObject json = HXDD_JsonObject(fJSON.json); + String ver = FileJSON.GetString(json, "version"); + //if (ver) { + // console.printf("XGameTranslation.CreateXSwapTranslation: Target Version %s", ver); + //} + HXDD_JsonArray arrListItems = HXDD_JsonArray(json.get("list")); + if (arrListItems) { + int size = arrListItems.Size(); + self.xswap.Resize(size); + for (let i = 0; i < size; i++) { + HXDD_JsonObject objListItem = HXDD_JsonObject(arrListItems.Get(i)); + if (objListItem) { + String valKey = FileJSON.GetString(objListItem, "key"); + //String valCategory = GetString(objListItem, "category"); + //HXDD_JsonArray valLabels = GetArray(objListItem, "labels"); + HXDD_JsonArray valActors = FileJSON.GetArray(objListItem, "actors"); + if (valKey && valActors) { + let newXSwap = new ("XTranslationActors"); + newXSwap.key = valKey; + newXSwap.list.Resize(valActors.Size()); + for (int j = 0; j < valActors.Size(); j++) { + newXSwap.list[j] = HXDD_JsonString(valActors.get(j)).s; } + self.xswap[i] = newXSwap; } } } diff --git a/resources/assets/zscript/menu/components/buttonplayerclass.zs b/resources/assets/zscript/menu/components/buttonplayerclass.zs index d4b807d..f1f181e 100644 --- a/resources/assets/zscript/menu/components/buttonplayerclass.zs +++ b/resources/assets/zscript/menu/components/buttonplayerclass.zs @@ -8,7 +8,7 @@ class ButtonPlayerClass ui { Array imgClassWalk; - void Create(HXDD_ZF_Frame parent, HXDD_ZF_Handler handler, vector2 location, double scale, String name, int classid, String pathBackground, Array images) { + void Create(HXDD_ZF_Frame parent, HXDD_ZF_Handler handler, vector2 location, double scale, String name, string className, String pathBackground, Array images) { tick = 0; self.imgClassWalk.Copy(images); @@ -55,7 +55,7 @@ class ButtonPlayerClass ui { (0, 0), (112 * scale, 136 * scale), cmdHandler: handler, - command: String.format("%d", classid), + command: className, hover: hoverOutline, click: hoverOutline ); @@ -72,7 +72,7 @@ class ButtonPlayerClass ui { } - void CreateHX2(HXDD_ZF_Frame parent, HXDD_ZF_Handler handler, vector2 location, double scale, String name, int classid, String pathBackground) { + void CreateHX2(HXDD_ZF_Frame parent, HXDD_ZF_Handler handler, vector2 location, double scale, String name, string className, String pathBackground) { HXDD_ZF_Frame frameChrClass = HXDD_ZF_Frame.create( location, (112 * scale, 130 * scale) @@ -101,7 +101,7 @@ class ButtonPlayerClass ui { (22 * scale, 0), (68 * scale, 114 * scale), cmdHandler: handler, - command: String.format("%d", classid), + command: className, hover: hoverOutline, click: hoverOutline ); diff --git a/resources/assets/zscript/menu/newgame.zs b/resources/assets/zscript/menu/newgame.zs index 683a096..0e11d81 100644 --- a/resources/assets/zscript/menu/newgame.zs +++ b/resources/assets/zscript/menu/newgame.zs @@ -40,9 +40,8 @@ class ZFPreGameSetupHandler : HXDD_ZF_Handler { LemonUtil.CVAR_SetInt("hxdd_waterstyle", menu.selectedTextureStyleWater); LemonUtil.CVAR_SetInt("hxdd_sludgestyle", menu.selectedTextureStyleSludge); LemonUtil.CVAR_SetInt("hxdd_icestyle", menu.selectedTextureStyleIce); - Menu.SetMenu("EpisodeMenu", menu.selectedClass); // Class Selection Response - Menu.SetMenu("SkillMenu", menu.selectedEpisode); // Episode Selection Response - Menu.SetMenu("StartGame", menu.selectedSkill); // Skill Selection Response (Starts Game), Use StartgameConfirm for Nightmare skills + Console.printf("Episode #%d", menu.selectedEpisode); + Menu.StartGameDirect(true, false, menu.selectedClass, menu.selectedEpisode, menu.selectedSkill); } } } @@ -53,9 +52,7 @@ class ZFClassSelectHandler : HXDD_ZF_Handler { override void buttonClickCommand(HXDD_ZF_Button caller, Name command) { if (menu.frame.getPosX() == 0) { Menu.MenuSound("menu/choose"); - String cmd = command; - int choice = cmd.ToInt(); - menu.selectedClass = choice; + menu.selectedClass = command; menu.time = 0; menu.lastPosX = menu.frame.getPosX(); menu.desiredPosX = -1920; @@ -71,13 +68,13 @@ class ZFGameOptionsHandler : HXDD_ZF_Handler { ZFPreGameSetup menu; ZFGameOptions optMenu; override void dropdownChanged(HXDD_ZF_DropdownList caller, Name command) { + console.printf("Command %s", command); String cmd = command; + cmd = cmd.MakeLower(); // hack for episode command somehow returning as capitalized (localization?) if (cmd == "episode") { - String choice = command; menu.selectedEpisode = caller.getSelection(); - elementHoverChanged(caller, command, false); + elementHoverChanged(caller, cmd, false); } else if (cmd == "skill") { - String choice = command; menu.selectedSkill = caller.getSelection(); } else if (cmd == "hxdd_gamemode") { menu.selectedGameMode = caller.getSelection(); @@ -96,7 +93,7 @@ class ZFGameOptionsHandler : HXDD_ZF_Handler { } else if (cmd.IndexOf("xswap") != -1) { // handle xswap cvars console.printf("%s %d", cmd, caller.getSelection()); - LemonUtil.CVAR_SetInt(command, caller.getSelection()); + LemonUtil.CVAR_SetInt(cmd, caller.getSelection()); } } @@ -197,20 +194,20 @@ class ZFPlayerClassSelection ui { Array imagesCorvus = {"sprites/PLAYA1.png", "sprites/PLAYB1.png", "sprites/PLAYC1.png", "sprites/PLAYD1.png"}; btnClassCorvus = new("ButtonPlayerClass"); - btnClassCorvus.Create(frame, cmdHandlerClassSelect, (hereticPosY, classLineX), 1.5, "Corvus", 0, "graphics/M_HBOX.png", imagesCorvus); + btnClassCorvus.Create(frame, cmdHandlerClassSelect, (hereticPosY, classLineX), 1.5, "Corvus", "HXDDHereticPlayer", "graphics/M_HBOX.png", imagesCorvus); double hexenPosY = 1920 - 450 - (144 * 2.5) + ((144 * 2.5 * 0.5) - (112 * 1.5 * 0.5)); Array imagesFighter = {"graphics/M_FWALK1.png", "graphics/M_FWALK2.png", "graphics/M_FWALK3.png", "graphics/M_FWALK4.png"}; btnClassFighter = new("ButtonPlayerClass"); - btnClassFighter.Create(frame, cmdHandlerClassSelect, (hexenPosY - 200, classLineX), 1.5, "Fighter", 1, "graphics/M_FBOX.png", imagesFighter); + btnClassFighter.Create(frame, cmdHandlerClassSelect, (hexenPosY - 200, classLineX), 1.5, "Fighter", "HXDDFighterPlayer", "graphics/M_FBOX.png", imagesFighter); Array imagesCleric = {"graphics/M_CWALK1.png", "graphics/M_CWALK2.png", "graphics/M_CWALK3.png", "graphics/M_CWALK4.png"}; btnClassCleric = new("ButtonPlayerClass"); - btnClassCleric.Create(frame, cmdHandlerClassSelect, (hexenPosY, classLineX), 1.5, "Cleric", 2, "graphics/M_CBOX.png", imagesCleric); + btnClassCleric.Create(frame, cmdHandlerClassSelect, (hexenPosY, classLineX), 1.5, "Cleric", "HXDDClericPlayer", "graphics/M_CBOX.png", imagesCleric); Array imagesMage = {"graphics/M_MWALK1.png", "graphics/M_MWALK2.png", "graphics/M_MWALK3.png", "graphics/M_MWALK4.png"}; btnClassMage = new("ButtonPlayerClass"); - btnClassMage.Create(frame, cmdHandlerClassSelect, (hexenPosY + 200, classLineX), 1.5, "Mage", 3, "graphics/M_MBOX.png", imagesMage); + btnClassMage.Create(frame, cmdHandlerClassSelect, (hexenPosY + 200, classLineX), 1.5, "Mage", "HXDDMagePlayer", "graphics/M_MBOX.png", imagesMage); // Cvar hxdd_installed_hexen2 is located in cvarinfo.installed_hexen2 bool cvarHexII = LemonUtil.CVAR_GetBool('hxdd_installed_hexen2', false); @@ -218,20 +215,20 @@ class ZFPlayerClassSelection ui { // display Hexen II classes double classLineXOffset = (136 * 1.5) + 50; btnClassAssassin = new("ButtonPlayerClass"); - btnClassAssassin.CreateHX2(frame, cmdHandlerClassSelect, (hexenPosY - 320, classLineX + classLineXOffset), 1.5, "Paladin", 4, "graphics/netp1.png"); + btnClassAssassin.CreateHX2(frame, cmdHandlerClassSelect, (hexenPosY - 320, classLineX + classLineXOffset), 1.5, "Paladin", "HX2PaladinPlayer", "graphics/netp1.png"); btnClassCrusader = new("ButtonPlayerClass"); - btnClassCrusader.CreateHX2(frame, cmdHandlerClassSelect, (hexenPosY - 160, classLineX + classLineXOffset), 1.5, "Crusader", 5, "graphics/netp2.png"); + btnClassCrusader.CreateHX2(frame, cmdHandlerClassSelect, (hexenPosY - 160, classLineX + classLineXOffset), 1.5, "Crusader", "HX2CrusaderPlayer", "graphics/netp2.png"); btnClassNecromancer = new("ButtonPlayerClass"); - btnClassNecromancer.CreateHX2(frame, cmdHandlerClassSelect, (hexenPosY, classLineX + classLineXOffset), 1.5, "Necromancer", 6, "graphics/netp3.png"); + btnClassNecromancer.CreateHX2(frame, cmdHandlerClassSelect, (hexenPosY, classLineX + classLineXOffset), 1.5, "Necromancer", "HX2NecromancerPlayer", "graphics/netp3.png"); btnClassPaladin = new("ButtonPlayerClass"); - btnClassPaladin.CreateHX2(frame, cmdHandlerClassSelect, (hexenPosY + 160, classLineX + classLineXOffset), 1.5, "Assassin", 7, "graphics/netp4.png"); + btnClassPaladin.CreateHX2(frame, cmdHandlerClassSelect, (hexenPosY + 160, classLineX + classLineXOffset), 1.5, "Assassin", "HX2AssassinPlayer", "graphics/netp4.png"); // Cvar hxdd_installed_hexen2_expansion is located in cvarinfo.installed_hexen2_expansion bool cvarHexII_EX = LemonUtil.CVAR_GetBool('hxdd_installed_hexen2_expansion', false); if (cvarHexII_EX) { // display Hexen II Expansion classes btnClassSuccubus = new("ButtonPlayerClass"); - btnClassSuccubus.CreateHX2(frame, cmdHandlerClassSelect, (hexenPosY + 320, classLineX + classLineXOffset), 1.5, "Demoness", 8, "graphics/netp5.png"); + btnClassSuccubus.CreateHX2(frame, cmdHandlerClassSelect, (hexenPosY + 320, classLineX + classLineXOffset), 1.5, "Demoness", "HX2SuccubusPlayer", "graphics/netp5.png"); } } } @@ -469,7 +466,7 @@ class ZFGameOptions ui { listEpisodes.items.push("Hexen: Modder Test Map"); } DropDownCombo ddl_Episodes = new ("DropDownCombo"); - ddl_Episodes.Create(optionArea, (0, 25), (optionArea.GetWidth() - 32, 50), "Episode", listEpisodes, parent.selectedEpisode, "episode", cmdHandler); + ddl_Episodes.Create(optionArea, (0, 25), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_HEADER_EPISODE"), listEpisodes, parent.selectedEpisode, "episode", cmdHandler); self.ddl_Difficulty = new ("DropDownCombo"); self.ddl_Difficulty.Create(optionArea, (0, 25 + 75), (optionArea.GetWidth() - 32, 50), Stringtable.Localize("$MNU_HEADER_SKILLSELECTION"), listClassDifficulty[0], parent.selectedSkill, "skill", cmdHandler); @@ -534,7 +531,7 @@ class ZFGameOptions ui { } void Refresh() { - int selected = parent.selectedClass; + int selected = LemonUtil.ClassNameToID(parent.selectedClass); if (selected > listClassDifficulty.Size() - 1) { selected = 0; } @@ -628,7 +625,7 @@ class ZFGameOptions ui { class ZFPreGameSetup : HXDD_ZF_GenericMenu { // Player Selection - int selectedClass; + string selectedClass; int selectedEpisode; int selectedSkill; @@ -666,7 +663,7 @@ class ZFPreGameSetup : HXDD_ZF_GenericMenu { override void init(Menu parent) { Super.init(parent); - selectedClass = 0; + selectedClass = "corvus"; selectedEpisode = 0; selectedSkill = 2;