diff --git a/src/game/g_items.c b/src/game/g_items.c index 192f41613..54eee47d3 100644 --- a/src/game/g_items.c +++ b/src/game/g_items.c @@ -37,9 +37,131 @@ #include "common/h2rand.h" #include "header/g_itemstats.h" +#define ITEM_COOP_ONLY 1 +#define ITEM_NO_DROP 2 + #define HEALTH_IGNORE_MAX 1 #define HEALTH_TIMED 2 +qboolean Pickup_Weapon(edict_t *ent, edict_t *other); +void Use_Weapon(edict_t *ent, gitem_t *inv); +void Use_Weapon2(edict_t *ent, gitem_t *inv); +void Drop_Weapon(edict_t *ent, gitem_t *inv); + +void Weapon_Blaster(edict_t *ent); +void Weapon_Shotgun(edict_t *ent); +void Weapon_SuperShotgun(edict_t *ent); +void Weapon_Machinegun(edict_t *ent); +void Weapon_Chaingun(edict_t *ent); +void Weapon_HyperBlaster(edict_t *ent); +void Weapon_RocketLauncher(edict_t *ent); +void Weapon_Grenade(edict_t *ent); +void Weapon_GrenadeLauncher(edict_t *ent); +void Weapon_Railgun(edict_t *ent); +void Weapon_BFG(edict_t *ent); +void Weapon_ChainFist(edict_t *ent); +void Weapon_Disintegrator(edict_t *ent); +void Weapon_ETF_Rifle(edict_t *ent); +void Weapon_Heatbeam(edict_t *ent); +void Weapon_Prox(edict_t *ent); +void Weapon_Tesla(edict_t *ent); +void Weapon_ProxLauncher(edict_t *ent); + +void Weapon_Ionripper(edict_t *ent); +void Weapon_Phalanx(edict_t *ent); +void Weapon_Trap(edict_t *ent); + +static gitem_armor_t jacketarmor_info = {25, 50, .30, .00, ARMOR_JACKET}; +static gitem_armor_t combatarmor_info = {50, 100, .60, .30, ARMOR_COMBAT}; +static gitem_armor_t bodyarmor_info = {100, 200, .80, .60, ARMOR_BODY}; + +static int jacket_armor_index; +static int combat_armor_index; +static int body_armor_index; +static int power_screen_index; +static int power_shield_index; + +void Use_Quad(edict_t *ent, gitem_t *item); +void Use_QuadFire(edict_t *ent, gitem_t *item); + +static int quad_drop_timeout_hack; +static int quad_fire_drop_timeout_hack; + +/* ====================================================================== */ + +gitem_t * +GetItemByIndex(int index) +{ + gitem_t* p_itemlist = playerExport->GetPlayerItems(); + + if ((index == 0) || (index >= game.num_items)) + { + return NULL; + } + + return &p_itemlist[index]; +} + +gitem_t * +FindItemByClassname(char *classname) +{ + int i; + gitem_t *it; + gitem_t* p_itemlist = playerExport->GetPlayerItems(); + + if (!classname) + { + return NULL; + } + + it = p_itemlist; + + for (i = 0; i < game.num_items; i++, it++) + { + if (!it->classname) + { + continue; + } + + if (!Q_stricmp(it->classname, classname)) + { + return it; + } + } + + return NULL; +} + +gitem_t * +FindItem(char *pickup_name) +{ + int i; + gitem_t *it; + gitem_t* p_itemlist = playerExport->GetPlayerItems(); + + if (!pickup_name) + { + return NULL; + } + + it = p_itemlist; + + for (i = 0; i < game.num_items; i++, it++) + { + if (!it->pickup_name) + { + continue; + } + + if (!Q_stricmp(it->pickup_name, pickup_name)) + { + return it; + } + } + + return NULL; +} + #define ITEM_COOP_ONLY 1 #define ITEM_NO_DROP 2 @@ -55,12 +177,10 @@ RespawnedThink(edict_t *ent) // ent->svflags |= SVF_NOCLIENT; } -// ************************************************************************************************ -// DoRespawn -// --------- -// ************************************************************************************************ +/* ====================================================================== */ -void DoRespawn(edict_t *ent) +void +DoRespawn(edict_t *ent) { if(ent->team) { @@ -1631,7 +1751,7 @@ Pickup for the Tornado defensive spell. // Initialise game variables. // ******************************************************************************************** - game.num_items=playerExport->GetPlayerItemsCount(); + game.num_items = playerExport->GetPlayerItemsCount(); } /* diff --git a/src/game/g_spawn.c b/src/game/g_spawn.c index dfe8c1faa..a5dc54178 100644 --- a/src/game/g_spawn.c +++ b/src/game/g_spawn.c @@ -29,6 +29,12 @@ #include "savegame/tables/spawnfunc_decs.h" #include "header/g_skeletons.h" +#define LEG_WAIT_TIME 1 +#define MAX_LEGSFRAME 23 + +#define SPAWNGROW_LIFESPAN 0.3 +#define STEPSIZE 18 + typedef struct { const char *name; @@ -295,12 +301,23 @@ ED_CallSpawn(edict_t *ent) return; } - /* check item spawn functions */ - if((item = IsItem(ent))) + ent->gravityVector[0] = 0.0; + ent->gravityVector[1] = 0.0; + ent->gravityVector[2] = -1.0; + + if (!strcmp(ent->classname, "weapon_nailgun")) { - SpawnItem(ent, item); + ent->classname = (FindItem("ETF Rifle"))->classname; + } - return; + if (!strcmp(ent->classname, "ammo_nails")) + { + ent->classname = (FindItem("Flechettes"))->classname; + } + + if (!strcmp(ent->classname, "weapon_heatbeam")) + { + ent->classname = (FindItem("Plasma Beam"))->classname; } /* search dynamic definitions */ @@ -328,6 +345,14 @@ ED_CallSpawn(edict_t *ent) } } + /* check item spawn functions */ + if((item = IsItem(ent))) + { + SpawnItem(ent, item); + + return; + } + /* check normal spawn functions */ s = StaticSpawnSearch(ent->classname); if (s) @@ -1066,7 +1091,7 @@ SP_worldspawn(edict_t *ent) // Set configstrings for items. - SetItemNames (); + SetItemNames(); if (st.nextmap) strcpy (level.nextmap, st.nextmap);