From 4f573b15715f53ab185df660532869f364cc4156 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Thu, 10 Mar 2022 18:59:25 -0800 Subject: [PATCH] Give all weapons an .isempty and .type definition to help the botlib AI a little more --- src/shared/w_crossbow.qc | 20 +++++++++++++++++++- src/shared/w_crowbar.qc | 13 +++++++++++++ src/shared/w_egon.qc | 19 +++++++++++++++++++ src/shared/w_gauss.qc | 19 +++++++++++++++++++ src/shared/w_glock.qc | 19 +++++++++++++++++++ src/shared/w_handgrenade.qc | 19 +++++++++++++++++++ src/shared/w_hornetgun.qc | 16 +++++++++++++++- src/shared/w_mp5.qc | 19 +++++++++++++++++++ src/shared/w_python.qc | 19 +++++++++++++++++++ src/shared/w_rpg.qc | 21 ++++++++++++++++++++- src/shared/w_satchel.qc | 19 +++++++++++++++++++ src/shared/w_shotgun.qc | 19 +++++++++++++++++++ src/shared/w_snark.qc | 19 +++++++++++++++++++ src/shared/w_tripmine.qc | 19 +++++++++++++++++++ 14 files changed, 257 insertions(+), 3 deletions(-) diff --git a/src/shared/w_crossbow.qc b/src/shared/w_crossbow.qc index 4394341..8014379 100644 --- a/src/shared/w_crossbow.qc +++ b/src/shared/w_crossbow.qc @@ -379,10 +379,26 @@ w_crossbow_hudpic(int selected, vector pos, float a) #endif } +int +w_crossbow_isempty(void) +{ + player pl = (player)self; + + if (pl.crossbow_mag <= 0 && pl.ammo_bolt <= 0) + return 1; + + return 0; +} + +weapontype_t w_crossbow_type(void) +{ + return WPNTYPE_RANGED; +} + weapon_t w_crossbow = { .name = "crossbow", - .id = ITEM_CROSSBOW, + .id = ITEM_CROSSBOW, .slot = 2, .slot_pos = 2, .weight = 10, @@ -400,6 +416,8 @@ weapon_t w_crossbow = .pmodel = w_crossbow_pmodel, .deathmsg = w_crossbow_deathmsg, .aimanim = w_crossbow_aimanim, + .isempty = w_crossbow_isempty, + .type = w_crossbow_type, .hudpic = w_crossbow_hudpic }; diff --git a/src/shared/w_crowbar.qc b/src/shared/w_crowbar.qc index 76312c8..fb1a896 100644 --- a/src/shared/w_crowbar.qc +++ b/src/shared/w_crowbar.qc @@ -204,6 +204,17 @@ w_crowbar_hudpic(int selected, vector pos, float a) #endif } +int +w_crowbar_isempty(void) +{ + return 0; +} + +weapontype_t w_crowbar_type(void) +{ + return WPNTYPE_CLOSE; +} + weapon_t w_crowbar = { .name = "crowbar", @@ -225,6 +236,8 @@ weapon_t w_crowbar = .pmodel = w_crowbar_pmodel, .deathmsg = w_crowbar_deathmsg, .aimanim = w_crowbar_aimanim, + .isempty = w_crowbar_isempty, + .type = w_crowbar_type, .hudpic = w_crowbar_hudpic }; diff --git a/src/shared/w_egon.qc b/src/shared/w_egon.qc index 79eaec4..1da0a61 100644 --- a/src/shared/w_egon.qc +++ b/src/shared/w_egon.qc @@ -287,6 +287,23 @@ void w_egon_hudpic(int selected, vector pos, float a) #endif } +int +w_egon_isempty(void) +{ + player pl = (player)self; + + if (pl.ammo_uranium <= 0) + return 1; + + return 0; +} + +weapontype_t +w_egon_type(void) +{ + return WPNTYPE_RANGED; +} + weapon_t w_egon = { .name = "egon", @@ -309,6 +326,8 @@ weapon_t w_egon = .deathmsg = w_egon_deathmsg, .aimanim = w_egon_aimanim, .hudpic = w_egon_hudpic, + .isempty = w_egon_isempty, + .type = w_egon_type, .predraw = w_egon_postdraw }; diff --git a/src/shared/w_gauss.qc b/src/shared/w_gauss.qc index ca17abe..7bfd8f8 100644 --- a/src/shared/w_gauss.qc +++ b/src/shared/w_gauss.qc @@ -363,6 +363,23 @@ void w_gauss_hudpic(int selected, vector pos, float a) #endif } +int +w_gauss_isempty(void) +{ + player pl = (player)self; + + if (pl.ammo_uranium <= 0) + return 1; + + return 0; +} + +weapontype_t +w_gauss_type(void) +{ + return WPNTYPE_RANGED; +} + weapon_t w_gauss = { .name = "gauss", @@ -384,6 +401,8 @@ weapon_t w_gauss = .pmodel = w_gauss_pmodel, .deathmsg = w_gauss_deathmsg, .aimanim = w_gauss_aimanim, + .isempty = w_gauss_isempty, + .type = w_gauss_type, .hudpic = w_gauss_hudpic }; diff --git a/src/shared/w_glock.qc b/src/shared/w_glock.qc index bc97530..e65425c 100644 --- a/src/shared/w_glock.qc +++ b/src/shared/w_glock.qc @@ -388,6 +388,23 @@ w_glock_hudpic(int selected, vector pos, float a) #endif } +int +w_glock_isempty(void) +{ + player pl = (player)self; + + if (pl.glock_mag <= 0 && pl.ammo_9mm <= 0) + return 1; + + return 0; +} + +weapontype_t +w_glock_type(void) +{ + return WPNTYPE_RANGED; +} + weapon_t w_glock = { .name = "9mmhandgun", @@ -409,6 +426,8 @@ weapon_t w_glock = .pmodel = w_glock_pmodel, .deathmsg = w_glock_deathmsg, .aimanim = w_glock_aimanim, + .isempty = w_glock_isempty, + .type = w_glock_type, .hudpic = w_glock_hudpic }; diff --git a/src/shared/w_handgrenade.qc b/src/shared/w_handgrenade.qc index e55cf04..b3911ab 100644 --- a/src/shared/w_handgrenade.qc +++ b/src/shared/w_handgrenade.qc @@ -244,6 +244,23 @@ w_handgrenade_hudpic(int selected, vector pos, float a) #endif } +int +w_handgrenade_isempty(void) +{ + player pl = (player)self; + + if (pl.ammo_handgrenade <= 0) + return 1; + + return 0; +} + +weapontype_t +w_handgrenade_type(void) +{ + return WPNTYPE_THROW; +} + weapon_t w_handgrenade = { .name = "grenade", @@ -265,6 +282,8 @@ weapon_t w_handgrenade = .pmodel = w_handgrenade_pmodel, .deathmsg = w_handgrenade_deathmsg, .aimanim = w_handgrenade_aimanim, + .isempty = w_handgrenade_isempty, + .type = w_handgrenade_type, .hudpic = w_handgrenade_hudpic }; diff --git a/src/shared/w_hornetgun.qc b/src/shared/w_hornetgun.qc index 17096d3..447b72c 100644 --- a/src/shared/w_hornetgun.qc +++ b/src/shared/w_hornetgun.qc @@ -301,10 +301,22 @@ w_hornetgun_hudpic(int selected, vector pos, float a) #endif } +int +w_hornetgun_isempty(void) +{ + return 0; +} + +weapontype_t +w_hornetgun_type(void) +{ + return WPNTYPE_RANGED; +} + weapon_t w_hornetgun = { .name = "hornet", - .id = ITEM_HORNETGUN, + .id = ITEM_HORNETGUN, .slot = 3, .slot_pos = 3, .weight = 10, @@ -322,6 +334,8 @@ weapon_t w_hornetgun = .pmodel = w_hornetgun_pmodel, .deathmsg = w_hornetgun_deathmsg, .aimanim = w_hornetgun_aimanim, + .isempty = w_hornetgun_isempty, + .type = w_hornetgun_type, .hudpic = w_hornetgun_hudpic }; diff --git a/src/shared/w_mp5.qc b/src/shared/w_mp5.qc index 7060ec1..52589f0 100644 --- a/src/shared/w_mp5.qc +++ b/src/shared/w_mp5.qc @@ -384,6 +384,23 @@ w_mp5_hudpic(int selected, vector pos, float a) #endif } +int +w_mp5_isempty(void) +{ + player pl = (player)self; + + if (pl.mp5_mag <= 0 && pl.ammo_9mm <= 0 && pl.ammo_m203_grenade <= 0) + return 1; + + return 0; +} + +weapontype_t +w_mp5_type(void) +{ + return WPNTYPE_RANGED; +} + weapon_t w_mp5 = { .name = "9mmAR", @@ -405,6 +422,8 @@ weapon_t w_mp5 = .pmodel = w_mp5_pmodel, .deathmsg = w_mp5_deathmsg, .aimanim = w_mp5_aimanim, + .isempty = w_mp5_isempty, + .type = w_mp5_type, .hudpic = w_mp5_hudpic }; diff --git a/src/shared/w_python.qc b/src/shared/w_python.qc index 9dee9d4..7fea7c8 100644 --- a/src/shared/w_python.qc +++ b/src/shared/w_python.qc @@ -340,6 +340,23 @@ w_python_hudpic(int selected, vector pos, float a) #endif } +int +w_python_isempty(void) +{ + player pl = (player)self; + + if (pl.python_mag <= 0 && pl.ammo_357 <= 0) + return 1; + + return 0; +} + +weapontype_t +w_python_type(void) +{ + return WPNTYPE_RANGED; +} + weapon_t w_python = { .name = "357", @@ -361,6 +378,8 @@ weapon_t w_python = .pmodel = w_python_pmodel, .deathmsg = w_python_deathmsg, .aimanim = w_python_aimanim, + .isempty = w_python_isempty, + .type = w_python_type, .hudpic = w_python_hudpic }; diff --git a/src/shared/w_rpg.qc b/src/shared/w_rpg.qc index 19aff01..709a257 100644 --- a/src/shared/w_rpg.qc +++ b/src/shared/w_rpg.qc @@ -338,10 +338,27 @@ void w_rpg_hud(void) #endif } +int +w_rpg_isempty(void) +{ + player pl = (player)self; + + if (pl.rpg_mag <= 0 && pl.ammo_rocket <= 0) + return 1; + + return 0; +} + +weapontype_t +w_rpg_type(void) +{ + return WPNTYPE_RANGED; +} + weapon_t w_rpg = { .name = "rpg_rocket", - .id = ITEM_RPG, + .id = ITEM_RPG, .slot = 3, .slot_pos = 0, .weight = 20, @@ -359,6 +376,8 @@ weapon_t w_rpg = .pmodel = w_rpg_pmodel, .deathmsg = w_rpg_deathmsg, .aimanim = w_rpg_aimanim, + .isempty = w_rpg_isempty, + .type = w_rpg_type, .hudpic = w_rpg_hudpic }; diff --git a/src/shared/w_satchel.qc b/src/shared/w_satchel.qc index 3565ad1..b2b4c51 100644 --- a/src/shared/w_satchel.qc +++ b/src/shared/w_satchel.qc @@ -309,6 +309,23 @@ w_satchel_hudpic(int selected, vector pos, float a) #endif } +int +w_satchel_isempty(void) +{ + player pl = (player)self; + + if (pl.satchel_chg <= 0) + return 1; + + return 0; +} + +weapontype_t +w_satchel_type(void) +{ + return WPNTYPE_THROW; +} + weapon_t w_satchel = { .name = "satchel", @@ -330,6 +347,8 @@ weapon_t w_satchel = .pmodel = w_satchel_pmodel, .deathmsg = w_satchel_deathmsg, .aimanim = w_satchel_aimanim, + .isempty = w_satchel_isempty, + .type = w_satchel_type, .hudpic = w_satchel_hudpic }; diff --git a/src/shared/w_shotgun.qc b/src/shared/w_shotgun.qc index facf42a..05048c0 100644 --- a/src/shared/w_shotgun.qc +++ b/src/shared/w_shotgun.qc @@ -397,6 +397,23 @@ w_shotgun_hudpic(int selected, vector pos, float a) #endif } +int +w_shotgun_isempty(void) +{ + player pl = (player)self; + + if (pl.shotgun_mag <= 0 && pl.ammo_buckshot <= 0) + return 1; + + return 0; +} + +weapontype_t +w_shotgun_type(void) +{ + return WPNTYPE_RANGED; +} + weapon_t w_shotgun = { .name = "shotgun", @@ -418,6 +435,8 @@ weapon_t w_shotgun = .pmodel = w_shotgun_pmodel, .deathmsg = w_shotgun_deathmsg, .aimanim = w_shotgun_aimanim, + .isempty = w_shotgun_isempty, + .type = w_shotgun_type, .hudpic = w_shotgun_hudpic }; diff --git a/src/shared/w_snark.qc b/src/shared/w_snark.qc index 342c867..7b73267 100644 --- a/src/shared/w_snark.qc +++ b/src/shared/w_snark.qc @@ -319,6 +319,23 @@ void w_snark_hudpic(int selected, vector pos, float a) #endif } +int +w_snark_isempty(void) +{ + player pl = (player)self; + + if (pl.ammo_snark <= 0) + return 1; + + return 0; +} + +weapontype_t +w_snark_type(void) +{ + return WPNTYPE_RANGED; +} + weapon_t w_snark = { .name = "snark", @@ -340,6 +357,8 @@ weapon_t w_snark = .pmodel = w_snark_pmodel, .deathmsg = w_snark_deathmsg, .aimanim = w_snark_aimanim, + .isempty = w_snark_isempty, + .type = w_snark_type, .hudpic = w_snark_hudpic }; diff --git a/src/shared/w_tripmine.qc b/src/shared/w_tripmine.qc index 421a9d3..a217204 100644 --- a/src/shared/w_tripmine.qc +++ b/src/shared/w_tripmine.qc @@ -375,6 +375,23 @@ w_tripmine_hudpic(int selected, vector pos, float a) #endif } +int +w_tripmine_isempty(void) +{ + player pl = (player)self; + + if (pl.ammo_tripmine <= 0) + return 1; + + return 0; +} + +weapontype_t +w_tripmine_type(void) +{ + return WPNTYPE_CLOSE; +} + weapon_t w_tripmine = { .name = "tripmine", @@ -396,6 +413,8 @@ weapon_t w_tripmine = .pmodel = w_tripmine_pmodel, .deathmsg = w_tripmine_deathmsg, .aimanim = w_tripmine_aimanim, + .isempty = w_tripmine_isempty, + .type = w_tripmine_type, .hudpic = w_tripmine_hudpic };