From 739bd5fcaf71d7bde22fa889fdbb7c203b3b55ce Mon Sep 17 00:00:00 2001 From: darkshade9 <8dino2@gmail.com> Date: Thu, 7 Sep 2023 22:21:44 -0400 Subject: [PATCH] Added CheckItem --- actionlite/g_items.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ actionlite/g_local.h | 1 + actionlite/g_spawn.cpp | 5 +++++ 3 files changed, 48 insertions(+) diff --git a/actionlite/g_items.cpp b/actionlite/g_items.cpp index bb077be..23aab5e 100644 --- a/actionlite/g_items.cpp +++ b/actionlite/g_items.cpp @@ -2382,3 +2382,45 @@ void SetItemNames() cs_index++; } } + +#define ITEM_SWITCH_COUNT 15 + +const char* sp_item[ITEM_SWITCH_COUNT][2] = { + {"weapon_machinegun", "weapon_MP5"}, + //{"weapon_supershotgun","weapon_HC"}, + {"weapon_bfg", "weapon_M4"}, + {"weapon_shotgun", "weapon_M3"}, + //{"weapon_grenadelauncher","weapon_M203"}, + {"weapon_chaingun", "weapon_Sniper"}, + {"weapon_rocketlauncher", "weapon_HC"}, + {"weapon_railgun", "weapon_Dual"}, + {"ammo_bullets", "ammo_clip"}, + {"ammo_rockets", "ammo_mag"}, + {"ammo_cells", "ammo_m4"}, + {"ammo_slugs", "ammo_sniper"}, + {"ammo_shells", "ammo_m3"}, + {"ammo_grenades", "weapon_Grenade"}, + {"ammo_box", "ammo_m3"}, + {"weapon_cannon", "weapon_HC"}, + {"weapon_sniper", "weapon_Sniper"} + +}; + +void CheckItem(edict_t* ent) +{ + int i; + + for (i = 0; i < ITEM_SWITCH_COUNT; i++) + { + //If it's a null entry, bypass it + if (!sp_item[i][0]) + continue; + //Do the passed ent and our list match? + if (strcmp(ent->classname, sp_item[i][0]) == 0) + { + //Yep. Replace the Q2 entity with our own. + ent->classname = sp_item[i][1]; + return; + } + } +} \ No newline at end of file diff --git a/actionlite/g_local.h b/actionlite/g_local.h index caf7aac..27299a2 100644 --- a/actionlite/g_local.h +++ b/actionlite/g_local.h @@ -2166,6 +2166,7 @@ void Compass_Update(edict_t *ent, bool first); // ACTION void DeadDropSpec(edict_t * ent); +void CheckItem(edict_t* ent); #define ITEM_INDEX(x) ((x)-itemlist) #define INV_AMMO(ent, num) ((ent)->client->pers.inventory[num]) #define GET_ITEM(num) (&itemlist[num]) diff --git a/actionlite/g_spawn.cpp b/actionlite/g_spawn.cpp index 7675738..23856d5 100644 --- a/actionlite/g_spawn.cpp +++ b/actionlite/g_spawn.cpp @@ -443,6 +443,7 @@ char ml_creator[101]; //AQ2:TNG END placedata_t locationbase[MAX_LOCATIONS_IN_BASE]; + /* =============== ED_CallSpawn @@ -462,6 +463,9 @@ void ED_CallSpawn(edict_t *ent) return; } + // zucc - BD's item replacement idea + CheckItem(ent); + // PGM - do this before calling the spawn function so it can be overridden. ent->gravityVector[0] = 0.0; ent->gravityVector[1] = 0.0; @@ -1569,6 +1573,7 @@ void SP_worldspawn(edict_t *ent) PrecacheItem(GetItemByIndex(IT_WEAPON_MK23)); + if (g_dm_random_items->integer) for (item_id_t i = static_cast(IT_NULL + 1); i < IT_TOTAL; i = static_cast(i + 1)) PrecacheItem(GetItemByIndex(i));