Redid weapon pickup logic for the weapon API.
This commit is contained in:
parent
3265f76fb2
commit
c46a49261c
26 changed files with 269 additions and 68 deletions
|
@ -31,13 +31,13 @@ void item_pickup::touch(void)
|
|||
return;
|
||||
}
|
||||
|
||||
/*if (Weapons_IsPresent((player)other, id) == TRUE) {
|
||||
/* don't remove if AddItem fails */
|
||||
if (Weapons_AddItem((player)other, id) == FALSE) {
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
|
||||
Logging_Pickup(other, this, __NULL__);
|
||||
sound(other, CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM);
|
||||
Weapons_AddItem((player)other, id);
|
||||
|
||||
CBaseTrigger::UseTargets();
|
||||
|
||||
|
|
|
@ -40,11 +40,24 @@ w_eagle_precache(void)
|
|||
precache_sound("weapons/desert_eagle_sight.wav");
|
||||
precache_sound("weapons/desert_eagle_sight2.wav");
|
||||
}
|
||||
void
|
||||
w_eagle_pickup(void)
|
||||
|
||||
int
|
||||
w_eagle_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.eagle_mag = 7;
|
||||
|
||||
if (new) {
|
||||
pl.eagle_mag = 7;
|
||||
} else {
|
||||
if (pl.ammo_357 < 36) {
|
||||
pl.ammo_357 = bound(0, pl.ammo_357 + 7, 36);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -153,7 +166,7 @@ w_eagle_primary(void)
|
|||
pl.a_ammo1--;
|
||||
View_SetMuzzleflash(MUZZLE_SMALL);
|
||||
Weapons_ViewPunchAngle([-10,0,0]);
|
||||
|
||||
|
||||
if (pl.a_ammo1 <= 0) {
|
||||
Weapons_ViewAnimation(EAGLE_SHOOT_EMPTY);
|
||||
} else {
|
||||
|
|
|
@ -157,12 +157,10 @@ w_grapple_release(void)
|
|||
Weapons_ViewAnimation(BARN_IDLE1);
|
||||
pl.w_idle_next = 2.566667f;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
Weapons_ViewAnimation(BARN_IDLE2);
|
||||
pl.w_idle_next = 10.0f;
|
||||
break;
|
||||
|
||||
default:
|
||||
Weapons_ViewAnimation(BARN_IDLE3);
|
||||
pl.w_idle_next = 1.35f;
|
||||
|
|
|
@ -38,11 +38,23 @@ w_m249_precache(void)
|
|||
precache_sound("weapons/saw_reload2.wav");
|
||||
}
|
||||
|
||||
void
|
||||
w_m249_pickup(void)
|
||||
int
|
||||
w_m249_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.m249_mag = 50;
|
||||
|
||||
if (new) {
|
||||
pl.m249_mag = 50;
|
||||
} else {
|
||||
if (pl.ammo_556 < 200) {
|
||||
pl.ammo_556 = bound(0, pl.ammo_556 + 50, 200);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -24,13 +24,19 @@ enum
|
|||
PENGUIN_THROW
|
||||
};
|
||||
|
||||
void
|
||||
w_penguin_pickup(void)
|
||||
int
|
||||
w_penguin_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.ammo_penguin = bound(0, pl.ammo_penguin + 5, 10);
|
||||
|
||||
if (pl.ammo_penguin < 10) {
|
||||
pl.ammo_penguin = bound(0, pl.ammo_penguin + 5, 10);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -36,13 +36,20 @@ w_shockrifle_precache(void)
|
|||
precache_sound("weapons/shock_impact.wav");
|
||||
precache_sound("weapons/shock_recharge.wav");
|
||||
}
|
||||
void
|
||||
w_shockrifle_pickup(void)
|
||||
|
||||
int
|
||||
w_shockrifle_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.ammo_shock = 10;
|
||||
|
||||
/* only pick it up once */
|
||||
if (new) {
|
||||
pl.ammo_shock = 10;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -37,11 +37,23 @@ w_sniperrifle_precache(void)
|
|||
precache_sound("weapons/sniper_fire.wav");
|
||||
}
|
||||
|
||||
void
|
||||
w_sniperrifle_pickup(void)
|
||||
int
|
||||
w_sniperrifle_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.sniper_mag = 5;
|
||||
|
||||
if (new) {
|
||||
pl.sniper_mag = 5;
|
||||
} else {
|
||||
if (pl.ammo_762 < 15) {
|
||||
pl.ammo_762 = bound(0, pl.ammo_762 + 5, 15);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -71,13 +71,23 @@ w_sporelauncher_deathmsg(void)
|
|||
return "";
|
||||
}
|
||||
|
||||
void
|
||||
w_sporelauncher_pickup(void)
|
||||
int
|
||||
w_sporelauncher_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.sporelauncher_mag = bound(0, pl.sporelauncher_mag + 5, 5);
|
||||
|
||||
if (new) {
|
||||
pl.sporelauncher_mag = 5;
|
||||
} else {
|
||||
if (pl.ammo_spore < 20) {
|
||||
pl.ammo_spore = bound(0, pl.ammo_spore + 5, 20);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -81,12 +81,22 @@ void w_cannon_reload(void)
|
|||
pl.w_idle_next = 3.0f;
|
||||
}
|
||||
|
||||
void w_cannon_pickup(void)
|
||||
int w_cannon_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.cannon_mag = bound(0, pl.cannon_mag + 2, 2);
|
||||
|
||||
if (new) {
|
||||
pl.cannon_mag = 2;
|
||||
} else {
|
||||
if (pl.ammo_buckshot < 125) {
|
||||
pl.ammo_buckshot = bound(0, pl.ammo_buckshot + 2, 125);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_cannon_draw(void)
|
||||
|
|
|
@ -68,13 +68,14 @@ string w_dbs_deathmsg(void)
|
|||
return "";
|
||||
}
|
||||
|
||||
void
|
||||
w_dbs_pickup(void)
|
||||
int
|
||||
w_dbs_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.shotgun_mag = bound(0, pl.shotgun_mag + 8, 8);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -67,13 +67,14 @@ string w_sbs_deathmsg(void)
|
|||
return "";
|
||||
}
|
||||
|
||||
void
|
||||
w_sbs_pickup(void)
|
||||
int
|
||||
w_sbs_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.shotgun_mag = bound(0, pl.shotgun_mag + 8, 8);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -60,12 +60,22 @@ string w_crossbow_deathmsg(void)
|
|||
{
|
||||
return "";
|
||||
}
|
||||
void w_crossbow_pickup(void)
|
||||
int w_crossbow_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.crossbow_mag = bound(0, pl.crossbow_mag + 5, 5);
|
||||
|
||||
if (new) {
|
||||
pl.crossbow_mag = 5;
|
||||
} else {
|
||||
if (pl.ammo_bolt < 50) {
|
||||
pl.ammo_bolt = bound(0, pl.ammo_bolt + 5, 50);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
void w_crossbow_draw(void)
|
||||
{
|
||||
|
|
|
@ -54,12 +54,18 @@ string w_egon_deathmsg(void)
|
|||
return "";
|
||||
}
|
||||
|
||||
void w_egon_pickup(void)
|
||||
int w_egon_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.ammo_uranium = bound(0, pl.ammo_uranium +20, 100);
|
||||
|
||||
if (pl.ammo_uranium < 100) {
|
||||
pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, 100);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_egon_draw(void)
|
||||
|
|
|
@ -60,12 +60,18 @@ string w_gauss_deathmsg(void)
|
|||
return "";
|
||||
}
|
||||
|
||||
void w_gauss_pickup(void)
|
||||
int w_gauss_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.ammo_uranium = bound(0, pl.ammo_uranium +20, 100);
|
||||
player pl = (player)self;
|
||||
|
||||
if (pl.ammo_uranium < 100) {
|
||||
pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, 100);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_gauss_draw(void)
|
||||
|
|
|
@ -53,12 +53,22 @@ string w_glock_deathmsg(void)
|
|||
return "";
|
||||
}
|
||||
|
||||
void w_glock_pickup(void)
|
||||
int w_glock_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.glock_mag = bound(0, pl.glock_mag + 18, 18);
|
||||
|
||||
if (new) {
|
||||
pl.glock_mag = 18;
|
||||
} else {
|
||||
if (pl.ammo_9mm < 250) {
|
||||
pl.ammo_9mm = bound(0, pl.ammo_9mm + 18, 250);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_glock_draw(void)
|
||||
|
|
|
@ -56,14 +56,19 @@ string w_handgrenade_deathmsg(void)
|
|||
return "";
|
||||
}
|
||||
|
||||
void w_handgrenade_pickup(void)
|
||||
int w_handgrenade_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.ammo_handgrenade = bound(0, pl.ammo_handgrenade + 1, 10);
|
||||
#endif
|
||||
}
|
||||
player pl = (player)self;
|
||||
|
||||
if (pl.ammo_handgrenade < 10) {
|
||||
pl.ammo_handgrenade = bound(0, pl.ammo_handgrenade + 1, 10);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef SSQC
|
||||
void w_handgrenade_throw(void)
|
||||
|
|
|
@ -35,12 +35,18 @@ void w_hornetgun_precache(void)
|
|||
precache_sound("agrunt/ag_fire2.wav");
|
||||
precache_sound("agrunt/ag_fire3.wav");
|
||||
}
|
||||
void w_hornetgun_pickup(void)
|
||||
int w_hornetgun_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.ammo_hornet = 8;
|
||||
|
||||
/* only pick it up once */
|
||||
if (new) {
|
||||
pl.ammo_hornet = 8;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
void w_hornetgun_updateammo(player pl)
|
||||
{
|
||||
|
|
|
@ -40,10 +40,22 @@ void w_mp5_precache(void)
|
|||
precache_sound("weapons/glauncher.wav");
|
||||
}
|
||||
|
||||
void w_mp5_pickup(void)
|
||||
int w_mp5_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.mp5_mag = 25;
|
||||
|
||||
if (new) {
|
||||
pl.mp5_mag = 25;
|
||||
} else {
|
||||
if (pl.ammo_9mm < 250) {
|
||||
pl.ammo_9mm = bound(0, pl.ammo_9mm + 25, 250);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_mp5_updateammo(player pl)
|
||||
|
|
|
@ -36,10 +36,22 @@ void w_python_precache(void)
|
|||
precache_sound("weapons/357_shot2.wav");
|
||||
precache_sound("weapons/357_reload1.wav");
|
||||
}
|
||||
void w_python_pickup(void)
|
||||
int w_python_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.python_mag = 6;
|
||||
|
||||
if (new) {
|
||||
pl.python_mag = 6;
|
||||
} else {
|
||||
if (pl.ammo_357 < 36) {
|
||||
pl.ammo_357 = bound(0, pl.ammo_357 + 6, 36);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_python_updateammo(player pl)
|
||||
|
|
|
@ -56,12 +56,22 @@ string w_rpg_deathmsg(void)
|
|||
return "";
|
||||
}
|
||||
|
||||
void w_rpg_pickup(void)
|
||||
int w_rpg_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.rpg_mag = bound(0, pl.rpg_mag + 1, 1);
|
||||
|
||||
if (new) {
|
||||
pl.rpg_mag = 1;
|
||||
} else {
|
||||
if (pl.ammo_rocket < 5) {
|
||||
pl.ammo_rocket = bound(0, pl.ammo_rocket + 1, 5);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_rpg_draw(void)
|
||||
|
|
|
@ -57,12 +57,18 @@ void w_satchel_precache(void)
|
|||
precache_model("models/p_satchel.mdl");
|
||||
}
|
||||
|
||||
void w_satchel_pickup(void)
|
||||
int w_satchel_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.ammo_satchel = bound(0, pl.ammo_satchel + 1, 5);
|
||||
|
||||
if (pl.ammo_satchel < 5) {
|
||||
pl.ammo_satchel = bound(0, pl.ammo_satchel + 1, 5);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_satchel_draw(void)
|
||||
|
|
|
@ -65,12 +65,22 @@ string w_shotgun_deathmsg(void)
|
|||
return "";
|
||||
}
|
||||
|
||||
void w_shotgun_pickup(void)
|
||||
int w_shotgun_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.shotgun_mag = bound(0, pl.shotgun_mag + 8, 8);
|
||||
|
||||
if (new) {
|
||||
pl.shotgun_mag = 8;
|
||||
} else {
|
||||
if (pl.ammo_buckshot < 125) {
|
||||
pl.ammo_buckshot = bound(0, pl.ammo_buckshot + 8, 125);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_shotgun_draw(void)
|
||||
|
|
|
@ -24,12 +24,18 @@ enum
|
|||
SNARK_THROW
|
||||
};
|
||||
|
||||
void w_snark_pickup(void)
|
||||
int w_snark_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.ammo_snark = bound(0, pl.ammo_snark + 5, 10);
|
||||
|
||||
if (pl.ammo_snark < 10) {
|
||||
pl.ammo_snark = bound(0, pl.ammo_snark + 5, 10);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_snark_draw(void)
|
||||
|
|
|
@ -53,12 +53,18 @@ string w_tripmine_deathmsg(void)
|
|||
{
|
||||
return "";
|
||||
}
|
||||
void w_tripmine_pickup(void)
|
||||
int w_tripmine_pickup(int new)
|
||||
{
|
||||
#ifdef SSQC
|
||||
player pl = (player)self;
|
||||
pl.ammo_tripmine = bound(0, pl.ammo_tripmine + 1, 10);
|
||||
|
||||
if (pl.ammo_tripmine < 10) {
|
||||
pl.ammo_tripmine = bound(0, pl.ammo_tripmine + 1, 10);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void w_tripmine_draw(void)
|
||||
|
|
|
@ -239,19 +239,45 @@ void Weapons_SwitchBest(player pl)
|
|||
self = oldself;
|
||||
}
|
||||
|
||||
void Weapons_AddItem(player pl, int w)
|
||||
/* returns TRUE if weapon pickup gets removed from this world */
|
||||
int Weapons_AddItem(player pl, int w)
|
||||
{
|
||||
int value;
|
||||
entity oldself = self;
|
||||
self = pl;
|
||||
pl.g_items |= g_weapons[w].id;
|
||||
pl.activeweapon = w;
|
||||
|
||||
if (g_weapons[w].pickup != __NULL__) {
|
||||
g_weapons[w].pickup();
|
||||
/* in case programmer decided not to add a pickup callback */
|
||||
if (g_weapons[w].pickup == __NULL__) {
|
||||
if (pl.g_items & g_weapons[w].id) {
|
||||
/* already present, skip */
|
||||
value = FALSE;
|
||||
} else {
|
||||
/* new to our arsenal */
|
||||
pl.g_items |= g_weapons[w].id;
|
||||
value = TRUE;
|
||||
|
||||
/* it's new, so autoswitch? */
|
||||
pl.activeweapon = w;
|
||||
Weapons_Draw();
|
||||
}
|
||||
} else {
|
||||
/* Call team pickup */
|
||||
if (pl.g_items & g_weapons[w].id) {
|
||||
value = g_weapons[w].pickup(FALSE);
|
||||
} else {
|
||||
/* new to our arsenal */
|
||||
pl.g_items |= g_weapons[w].id;
|
||||
value = g_weapons[w].pickup(TRUE);
|
||||
|
||||
/* it's new, so autoswitch? */
|
||||
pl.activeweapon = w;
|
||||
Weapons_Draw();
|
||||
}
|
||||
}
|
||||
|
||||
Weapons_Draw();
|
||||
Weapons_RefreshAmmo(pl);
|
||||
self = oldself;
|
||||
return value;
|
||||
}
|
||||
|
||||
void Weapons_RemoveItem(player pl, int w)
|
||||
|
|
|
@ -32,7 +32,7 @@ typedef struct
|
|||
void() crosshair;
|
||||
|
||||
void() precache;
|
||||
void() pickup;
|
||||
int(int) pickup;
|
||||
void(player) updateammo;
|
||||
string() wmodel;
|
||||
string() pmodel;
|
||||
|
@ -55,7 +55,7 @@ void Weapons_SetModel(string);
|
|||
void Weapons_RefreshAmmo(player);
|
||||
void Weapons_InitItem(int);
|
||||
float Weapons_GetAim(int);
|
||||
void Weapons_AddItem(player, int);
|
||||
int Weapons_AddItem(player, int);
|
||||
void Weapons_RemoveItem(player, int);
|
||||
string Weapons_GetWorldmodel(int);
|
||||
void Weapons_UpdateAmmo(player, int, int, int);
|
||||
|
|
Loading…
Reference in a new issue