REGISTER_WEAPON(
/* WEP_##id */ FIREBALL,
/* function */ w_fireball,
-/* ammotype */ ammo_none, // WEAPONTODO
+/* ammotype */ ammo_none,
/* impulse */ 9,
/* flags */ WEP_FLAG_SUPERWEAPON | WEP_TYPE_SPLASH,
/* rating */ BOT_PICKUP_RATING_MID,
e.weapons = result;
}
-string W_Name(float weaponid)
+string W_Name(float weaponid) // WEAPONTODO: make into a macro
{
return (get_weaponinfo(weaponid)).message;
}
-
-float W_AmmoItemCode(float wpn)
-{
- return (get_weaponinfo(wpn)).items & IT_AMMO; // WEAPONTODO
-}
if(autocvar_g_pickup_items == 0)
return FALSE;
if(g_weaponarena)
- if(self.weapons || (self.items & IT_AMMO))
+ if(self.weapons || (self.items & IT_AMMO)) // no item or ammo pickups in weaponarena
return FALSE;
}
return TRUE;
}
-floatfield Item_CounterField(float it)
-{
- switch(it)
- {
- case IT_SHELLS: return ammo_shells;
- case IT_NAILS: return ammo_nails;
- case IT_ROCKETS: return ammo_rockets;
- case IT_CELLS: return ammo_cells;
- case IT_FUEL: return ammo_fuel;
- case IT_5HP: return health;
- case IT_25HP: return health;
- case IT_HEALTH: return health;
- case IT_ARMOR_SHARD: return armorvalue;
- case IT_ARMOR: return armorvalue;
- // add more things here (health, armor)
- default: error("requested item has no counter field");
- }
-#ifdef GMQCC
- // should never happen
- return health;
-#endif
-}
-
-string Item_CounterFieldName(float it)
-{
- switch(it)
- {
- case IT_SHELLS: return "shells";
- case IT_NAILS: return "nails";
- case IT_ROCKETS: return "rockets";
- case IT_CELLS: return "cells";
- case IT_FUEL: return "fuel";
-
- // add more things here (health, armor)
- default: error("requested item has no counter field name");
- }
-#ifdef GMQCC
- // should never happen
- return string_null;
-#endif
-}
-
/*
float Item_Customize()
{
{
entity e;
float t;
- var .float ammofield;
string s;
entity oldself;
float i, j;
if(!self.superweapons_finished)
self.superweapons_finished = autocvar_g_balance_superweapons_time;
+ // if we don't already have ammo, give us some ammo
+ if(!self.(e.current_ammo))
+ {
+ switch(e.current_ammo)
+ {
+ case ammo_shells: self.ammo_shells = cvar("g_pickup_shells_weapon"); break;
+ case ammo_nails: self.ammo_nails = cvar("g_pickup_nails_weapon"); break;
+ case ammo_rockets: self.ammo_rockets = cvar("g_pickup_rockets_weapon"); break;
+ case ammo_cells: self.ammo_cells = cvar("g_pickup_cells_weapon"); break;
+ case ammo_fuel: self.ammo_fuel = cvar("g_pickup_fuel_weapon"); break;
+ }
+ }
+
+ print(sprintf("defaultspawnfunc: current ammo count: %f\n", self.(e.current_ammo)));
+
+ #if 0
if(e.items)
{
for(i = 0, j = 1; i < 24; ++i, j *= 2)
}
}
}
+ #endif
// pickup anyway
if(g_pickup_weapons_anyway)
string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo)
{
entity oldself, wep;
- float wa, thisammo, i, j;
+ float thisammo, i;
string s;
- var .float ammofield;
+ var .float ammofield = (get_weaponinfo(wpn)).current_ammo;
wep = spawn();
}
}
- wa = W_AmmoItemCode(wpn);
- if(wa == 0)
+ //wa = W_AmmoItemCode(wpn);
+ if(ammofield == ammo_none)
{
oldself = self;
self = wep;
return string_null;
if(doreduce && g_weapon_stay == 2)
{
- for(i = 0, j = 1; i < 24; ++i, j *= 2)
+ // if our weapon is loaded, give its load back to the player
+ if(self.(weapon_load[self.weapon]) > 0)
{
- if(wa & j)
- {
- ammofield = Item_CounterField(j);
-
- // if our weapon is loaded, give its load back to the player
- if(self.(weapon_load[self.weapon]) > 0)
- {
- own.ammofield += self.(weapon_load[self.weapon]);
- self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
- }
-
- wep.ammofield = 0;
- }
+ own.ammofield += self.(weapon_load[self.weapon]);
+ self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
}
+
+ wep.ammofield = 0;
}
else if(doreduce)
{
- for(i = 0, j = 1; i < 24; ++i, j *= 2)
+ // if our weapon is loaded, give its load back to the player
+ if(self.(weapon_load[self.weapon]) > 0)
+ {
+ own.ammofield += self.(weapon_load[self.weapon]);
+ self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
+ }
+
+ // stuff
+ thisammo = min(own.ammofield, wep.ammofield);
+ wep.ammofield = thisammo;
+ own.ammofield -= thisammo;
+
+ //print(sprintf("W_ThrowNewWeapon: wep ammo count: %f, own ammo count: %f, thisammo = %f\n", wep.ammofield, own.ammofield, thisammo));
+
+ switch(ammofield)
{
- if(wa & j)
- {
- ammofield = Item_CounterField(j);
-
- // if our weapon is loaded, give its load back to the player
- if(self.(weapon_load[self.weapon]) > 0)
- {
- own.ammofield += self.(weapon_load[self.weapon]);
- self.(weapon_load[self.weapon]) = -1; // schedule the weapon for reloading
- }
-
- thisammo = min(own.ammofield, wep.ammofield);
- wep.ammofield = thisammo;
- own.ammofield -= thisammo;
- s = strcat(s, " and ", ftos(thisammo), " ", Item_CounterFieldName(j));
- }
+ case ammo_shells: s = sprintf("%s and %d shells", s, thisammo); break;
+ case ammo_nails: s = sprintf("%s and %d nails", s, thisammo); break;
+ case ammo_rockets: s = sprintf("%s and %d rockets", s, thisammo); break;
+ case ammo_cells: s = sprintf("%s and %d cells", s, thisammo); break;
+ case ammo_fuel: s = sprintf("%s and %d fuel", s, thisammo); break;
}
+
s = substring(s, 5, -1);
}
wep.glowmod = own.weaponentity_glowmod;
float W_IsWeaponThrowable(float w)
{
- float wa;
-
if (!autocvar_g_pickup_items)
return 0;
if (g_weaponarena)
if(w == 0)
return 0;
- wa = W_AmmoItemCode(w);
if(start_weapons & WepSet_FromWeapon(w))
{
// start weapons that take no ammo can't be dropped (this prevents dropping the laser, as long as it continues to use no ammo)
if(start_items & IT_UNLIMITED_WEAPON_AMMO)
return 0;
- if(wa == 0)
+ if((get_weaponinfo(w)).current_ammo == ammo_none)
return 0;
}
self.switchingweapon = 0;
self.weaponentity.state = WS_CLEAR;
self.weaponname = "";
- self.items &= ~IT_AMMO;
+ //self.items &= ~IT_AMMO;
return;
}
self.switchingweapon = self.switchweapon;
entity newwep = get_weaponinfo(self.switchweapon);
- self.items &= ~IT_AMMO;
- self.items = self.items | (newwep.items & IT_AMMO);
+ //self.items &= ~IT_AMMO;
+ //self.items = self.items | (newwep.items & IT_AMMO);
// the two weapon entities will notice this has changed and update their models
self.weapon = self.switchweapon;
bprint("\{1}^1ERROR: undefined weapon think function for ", self.netname, "\n");
}
}
-
-#if 0
- if (self.items & IT_CELLS)
- self.currentammo = self.ammo_cells;
- else if (self.items & IT_ROCKETS)
- self.currentammo = self.ammo_rockets;
- else if (self.items & IT_NAILS)
- self.currentammo = self.ammo_nails;
- else if (self.items & IT_SHELLS)
- self.currentammo = self.ammo_shells;
- else
- self.currentammo = 1;
-#endif
}
void W_AttachToShotorg(entity flash, vector offset)