From 62b183277ee958dbf27d096f6a9bfb322d392bbe Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 5 Oct 2016 17:24:29 +1000 Subject: [PATCH] Unhardcode a few more 0 slot cases --- mutators.cfg | 16 -- qcsrc/client/view.qc | 11 -- .../gamemodes/gamemode/nexball/nexball.qc | 7 +- .../common/mutators/mutator/buffs/sv_buffs.qc | 37 +++- qcsrc/common/mutators/mutator/nix/sv_nix.qc | 21 +- qcsrc/common/mutators/mutator/overkill/hmg.qc | 4 +- qcsrc/common/mutators/mutator/overkill/rpc.qc | 2 +- .../mutators/mutator/overkill/sv_overkill.qc | 180 +++++------------- .../mutators/mutator/pinata/sv_pinata.qc | 22 ++- qcsrc/common/stats.qh | 2 - qcsrc/common/weapons/weapon/arc.qc | 2 + qcsrc/common/weapons/weapon/blaster.qc | 6 +- qcsrc/common/weapons/weapon/crylink.qc | 4 +- qcsrc/common/weapons/weapon/devastator.qc | 2 +- qcsrc/common/weapons/weapon/electro.qc | 6 +- qcsrc/common/weapons/weapon/fireball.qc | 4 +- qcsrc/common/weapons/weapon/hagar.qc | 4 +- qcsrc/common/weapons/weapon/hlac.qc | 2 +- qcsrc/common/weapons/weapon/machinegun.qc | 4 +- qcsrc/common/weapons/weapon/minelayer.qc | 2 +- qcsrc/common/weapons/weapon/mortar.qc | 4 +- qcsrc/common/weapons/weapon/porto.qc | 2 +- qcsrc/common/weapons/weapon/rifle.qc | 4 +- qcsrc/common/weapons/weapon/seeker.qc | 6 +- qcsrc/common/weapons/weapon/shockwave.qc | 4 +- qcsrc/common/weapons/weapon/shotgun.qc | 4 +- qcsrc/common/weapons/weapon/vaporizer.qc | 4 +- qcsrc/common/weapons/weapon/vortex.qc | 29 +-- qcsrc/server/bot/api.qh | 2 +- qcsrc/server/bot/default/aim.qc | 4 +- qcsrc/server/bot/default/aim.qh | 2 +- qcsrc/server/bot/null/bot_null.qc | 2 +- qcsrc/server/mutators/events.qh | 3 +- qcsrc/server/weapons/weaponsystem.qc | 2 +- 34 files changed, 173 insertions(+), 237 deletions(-) diff --git a/mutators.cfg b/mutators.cfg index 787ec7e3c..39b5480b2 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -50,22 +50,6 @@ set g_overkill_100h_anyway 1 set g_overkill_powerups_replace 1 set g_overkill_superguns_respawn_time 120 -set g_overkill_ammo_charge 0 -set g_overkill_ammo_charge_notice 1 -set g_overkill_ammo_charge_limit 1 -set g_overkill_ammo_charge_rate 0.5 -set g_overkill_ammo_charge_rate_vortex 0.5 -set g_overkill_ammo_charge_rate_machinegun 0.5 -set g_overkill_ammo_charge_rate_shotgun 0.5 -set g_overkill_ammo_charge_rate_hmg 0.25 -set g_overkill_ammo_charge_rate_rpc 1.5 -set g_overkill_ammo_decharge 0.1 -set g_overkill_ammo_decharge_machinegun 0.025 -set g_overkill_ammo_decharge_shotgun 0.15 -set g_overkill_ammo_decharge_vortex 0.2 -set g_overkill_ammo_decharge_rpc 1 -set g_overkill_ammo_decharge_hmg 0.01 - // ========= // vampire diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 98bd49dea..def064d49 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -1154,10 +1154,6 @@ void HUD_Crosshair(entity this) weapon_clipload = STAT(WEAPON_CLIPLOAD); weapon_clipsize = STAT(WEAPON_CLIPSIZE); - float ok_ammo_charge, ok_ammo_chargepool; - ok_ammo_charge = STAT(OK_AMMO_CHARGE); - ok_ammo_chargepool = STAT(OK_AMMO_CHARGEPOOL); - float vortex_charge, vortex_chargepool; vortex_charge = STAT(VORTEX_CHARGE); vortex_chargepool = STAT(VORTEX_CHARGEPOOL); @@ -1204,13 +1200,6 @@ void HUD_Crosshair(entity this) ring_rgb = wcross_color; ring_image = "gfx/crosshair_ring.tga"; } - else if (ok_ammo_charge) - { - ring_value = ok_ammo_chargepool; - ring_alpha = autocvar_crosshair_ring_reload_alpha; - ring_rgb = wcross_color; - ring_image = "gfx/crosshair_ring.tga"; - } else if(autocvar_crosshair_ring_reload && weapon_clipsize) // forces there to be only an ammo ring { ring_value = bound(0, weapon_clipload / weapon_clipsize, 1); diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index c26ef4619..29bdd265f 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -1025,8 +1025,11 @@ MUTATOR_HOOKFUNCTION(nb, PlayerSpawn) entity player = M_ARGV(0, entity); player.metertime = 0; - .entity weaponentity = weaponentities[0]; - player.(weaponentity).weapons = '0 0 0'; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + player.(weaponentity).weapons = '0 0 0'; + } if (nexball_mode & NBM_BASKETBALL) player.weapons |= WEPSET(NEXBALL); diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index b1fd56722..14f92145f 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -841,11 +841,15 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) }); } - .entity weaponentity = weaponentities[0]; // TODO: unhardcode - if(player.buffs & BUFF_AMMO.m_itemid) - if(player.(weaponentity).clip_size) - player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size; + { + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(player.(weaponentity).clip_size) + player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size; + } + } if((player.buffs & BUFF_INVISIBLE.m_itemid) && (player.oldbuffs & BUFF_INVISIBLE.m_itemid)) if(player.alpha != autocvar_g_buffs_invisible_alpha) @@ -872,9 +876,17 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) player.buff_ammo_prev_infitems = (player.items & IT_UNLIMITED_WEAPON_AMMO); player.items |= IT_UNLIMITED_WEAPON_AMMO; - if(player.(weaponentity).clip_load) - player.(weaponentity).buff_ammo_prev_clipload = player.(weaponentity).clip_load; - player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size; + if(player.buffs & BUFF_AMMO.m_itemid) + { + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(player.(weaponentity).clip_load) + player.(weaponentity).buff_ammo_prev_clipload = player.(weaponentity).clip_load; + if(player.(weaponentity).clip_size) + player.(weaponentity).clip_load = player.(weaponentity).(weapon_load[player.(weaponentity).m_switchweapon.m_id]) = player.(weaponentity).clip_size; + } + } } BUFF_ONREM(BUFF_AMMO) @@ -884,8 +896,15 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) else player.items &= ~IT_UNLIMITED_WEAPON_AMMO; - if(player.(weaponentity).buff_ammo_prev_clipload) - player.(weaponentity).clip_load = player.(weaponentity).buff_ammo_prev_clipload; + if(player.buffs & BUFF_AMMO.m_itemid) + { + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(player.(weaponentity).buff_ammo_prev_clipload) + player.(weaponentity).clip_load = player.(weaponentity).buff_ammo_prev_clipload; + } + } } BUFF_ONADD(BUFF_INVISIBLE) diff --git a/qcsrc/common/mutators/mutator/nix/sv_nix.qc b/qcsrc/common/mutators/mutator/nix/sv_nix.qc index 8067f791a..24fa435b4 100644 --- a/qcsrc/common/mutators/mutator/nix/sv_nix.qc +++ b/qcsrc/common/mutators/mutator/nix/sv_nix.qc @@ -63,9 +63,14 @@ REGISTER_MUTATOR(nix, cvar("g_nix") && !cvar("g_instagib") && !cvar("g_overkill" it.ammo_rockets = start_ammo_rockets; it.ammo_fuel = start_ammo_fuel; it.weapons = start_weapons; - .entity weaponentity = weaponentities[0]; // TODO: unhardcode - if(!client_hasweapon(it, it.(weaponentity).m_weapon, weaponentity, true, false)) - it.(weaponentity).m_switchweapon = w_getbestweapon(it, weaponentity); + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(it.(weaponentity).m_weapon == WEP_Null && slot != 0) + continue; + if(!client_hasweapon(it, it.(weaponentity).m_weapon, weaponentity, true, false)) + it.(weaponentity).m_switchweapon = w_getbestweapon(it, weaponentity); + } }); } @@ -215,14 +220,20 @@ void NIX_GiveCurrentWeapon(entity this) this.weapons |= WEPSET(BLASTER); this.weapons |= e.m_wepset; - .entity weaponentity = weaponentities[0]; // TODO: unhardcode Weapon w = Weapons_from(nix_weapon); - if(this.(weaponentity).m_switchweapon != w) + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(this.(weaponentity).m_weapon == WEP_Null && slot != 0) + continue; + + if(this.(weaponentity).m_switchweapon != w) if(!client_hasweapon(this, this.(weaponentity).m_switchweapon, weaponentity, true, false)) { if(client_hasweapon(this, w, weaponentity, true, false)) W_SwitchWeapon(this, w, weaponentity); } + } } MUTATOR_HOOKFUNCTION(nix, ForbidThrowCurrentWeapon) diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index e454f0dcc..caf96a67b 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -61,9 +61,9 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone METHOD(HeavyMachineGun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { if(vdist(actor.origin - actor.enemy.origin, <, 3000 - bound(0, skill, 10) * 200)) - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 0.001, false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); else - PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, 1000000, 0, 0.001, false); + PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); } METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index 54ae9d67e..62f517da6 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -112,7 +112,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep, entity actor, .entity wea METHOD(RocketPropelledChainsaw, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false); } METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) diff --git a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc index 20d2ee781..caabb2823 100644 --- a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc @@ -7,24 +7,14 @@ bool autocvar_g_overkill_powerups_replace; float autocvar_g_overkill_superguns_respawn_time; bool autocvar_g_overkill_100h_anyway; bool autocvar_g_overkill_100a_anyway; -bool autocvar_g_overkill_ammo_charge; -float autocvar_g_overkill_ammo_charge_notice; -float autocvar_g_overkill_ammo_charge_limit; .vector ok_deathloc; .float ok_spawnsys_timer; -.float ok_lastwep; +.Weapon ok_lastwep[MAX_WEAPONSLOTS]; .float ok_item; -.float ok_notice_time; -.float ammo_charge[Weapons_MAX]; -.float ok_use_ammocharge = _STAT(OK_AMMO_CHARGE); -.float ok_ammo_charge = _STAT(OK_AMMO_CHARGEPOOL); - .float ok_pauseregen_finished; -void(entity ent, float wep) ok_DecreaseCharge; - void ok_Initialize(); REGISTER_MUTATOR(ok, cvar("g_overkill") && !cvar("g_instagib") && !g_nexball && cvar_string("g_mod_balance") == "Overkill") @@ -41,60 +31,10 @@ REGISTER_MUTATOR(ok, cvar("g_overkill") && !cvar("g_instagib") && !g_nexball && } } -MUTATOR_HOOKFUNCTION(ok, W_DecreaseAmmo) -{ - entity actor = M_ARGV(0, entity); - if (actor.ok_use_ammocharge) - { - .entity weaponentity = weaponentities[0]; // TODO: unhardcode - ok_DecreaseCharge(actor, actor.(weaponentity).m_weapon.m_id); - return true; - } -} - -MUTATOR_HOOKFUNCTION(ok, W_Reload) -{ - entity actor = M_ARGV(0, entity); - return actor.ok_use_ammocharge; -} - void W_Blaster_Attack(entity, .entity, float, float, float, float, float, float, float, float, float, float); spawnfunc(weapon_hmg); spawnfunc(weapon_rpc); -void ok_DecreaseCharge(entity ent, int wep) -{ - if(!ent.ok_use_ammocharge) return; - - entity wepent = Weapons_from(wep); - - if (wepent == WEP_Null) return; // dummy - - ent.ammo_charge[wep] -= max(0, cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname))); -} - -void ok_IncreaseCharge(entity ent, int wep) -{ - entity wepent = Weapons_from(wep); - - if (wepent == WEP_Null) return; // dummy - - if(ent.ok_use_ammocharge) - if(!PHYS_INPUT_BUTTON_ATCK(ent)) // not while attacking? - ent.ammo_charge[wep] = min(autocvar_g_overkill_ammo_charge_limit, ent.ammo_charge[wep] + cvar(sprintf("g_overkill_ammo_charge_rate_%s", wepent.netname)) * frametime / W_TICSPERFRAME); -} - -float ok_CheckWeaponCharge(entity ent, int wep) -{ - if(!ent.ok_use_ammocharge) return true; - - entity wepent = Weapons_from(wep); - - if(wepent == WEP_Null) return false; // dummy - - return (ent.ammo_charge[wep] >= cvar(sprintf("g_overkill_ammo_decharge_%s", wepent.netname))); -} - MUTATOR_HOOKFUNCTION(ok, PlayerDamage_Calculate, CBC_ORDER_LAST) { entity frag_attacker = M_ARGV(1, entity); @@ -153,9 +93,12 @@ MUTATOR_HOOKFUNCTION(ok, PlayerDies) ok_DropItem(frag_target, targ); - .entity weaponentity = weaponentities[0]; // TODO: unhardcode + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; - frag_target.ok_lastwep = frag_target.(weaponentity).m_switchweapon.m_id; + frag_target.ok_lastwep[slot] = frag_target.(weaponentity).m_switchweapon; + } } MUTATOR_HOOKFUNCTION(ok, MonsterDropItem) @@ -206,23 +149,26 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink) return; entity player = M_ARGV(0, entity); - .entity weaponentity = weaponentities[0]; // TODO: unhardcode if(IS_DEAD(player) || !IS_PLAYER(player) || STAT(FROZEN, player)) return; - if(player.ok_lastwep) + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { - Weapon newwep = Weapons_from(player.ok_lastwep); - if(player.ok_lastwep == WEP_HMG.m_id) - newwep = WEP_MACHINEGUN; - if(player.ok_lastwep == WEP_RPC.m_id) - newwep = WEP_VORTEX; - player.(weaponentity).m_switchweapon = newwep; - player.ok_lastwep = 0; - } + .entity weaponentity = weaponentities[slot]; + entity thiswep = player.(weaponentity); - ok_IncreaseCharge(player, player.(weaponentity).m_weapon.m_id); + if(player.ok_lastwep[slot] && player.ok_lastwep[slot] != WEP_Null) + { + Weapon newwep = player.ok_lastwep[slot]; + if(player.ok_lastwep[slot] == WEP_HMG) + newwep = WEP_MACHINEGUN; + if(player.ok_lastwep[slot] == WEP_RPC) + newwep = WEP_VORTEX; + thiswep.m_switchweapon = newwep; + player.ok_lastwep[slot] = WEP_Null; + } + } if(PHYS_INPUT_BUTTON_ATCK2(player)) if(!forbidWeaponUse(player) || player.weapon_blocked) // allow if weapon is blocked @@ -231,44 +177,31 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink) player.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor(player); makevectors(player.v_angle); - Weapon oldwep = player.(weaponentity).m_weapon; - player.(weaponentity).m_weapon = WEP_BLASTER; - W_Blaster_Attack( - player, - weaponentity, - WEP_BLASTER.m_id | HITTYPE_SECONDARY, - WEP_CVAR_SEC(vaporizer, shotangle), - WEP_CVAR_SEC(vaporizer, damage), - WEP_CVAR_SEC(vaporizer, edgedamage), - WEP_CVAR_SEC(vaporizer, radius), - WEP_CVAR_SEC(vaporizer, force), - WEP_CVAR_SEC(vaporizer, speed), - WEP_CVAR_SEC(vaporizer, spread), - WEP_CVAR_SEC(vaporizer, delay), - WEP_CVAR_SEC(vaporizer, lifetime) - ); - player.(weaponentity).m_weapon = oldwep; - } - - player.weapon_blocked = false; - - player.ok_ammo_charge = player.ammo_charge[player.(weaponentity).m_weapon.m_id]; - - if(player.ok_use_ammocharge) - if(!ok_CheckWeaponCharge(player, player.(weaponentity).m_weapon.m_id)) - { - if(autocvar_g_overkill_ammo_charge_notice && time > player.ok_notice_time && PHYS_INPUT_BUTTON_ATCK(player) && IS_REAL_CLIENT(player) && player.(weaponentity).m_weapon == player.(weaponentity).m_switchweapon) + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { - //Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_OVERKILL_CHARGE); - player.ok_notice_time = time + 2; - play2(player, SND(DRYFIRE)); + .entity weaponentity = weaponentities[slot]; + + if(player.(weaponentity).m_weapon == WEP_Null && slot != 0) + continue; + + Weapon oldwep = player.(weaponentity).m_weapon; + player.(weaponentity).m_weapon = WEP_BLASTER; + W_Blaster_Attack( + player, + weaponentity, + WEP_BLASTER.m_id | HITTYPE_SECONDARY, + WEP_CVAR_SEC(vaporizer, shotangle), + WEP_CVAR_SEC(vaporizer, damage), + WEP_CVAR_SEC(vaporizer, edgedamage), + WEP_CVAR_SEC(vaporizer, radius), + WEP_CVAR_SEC(vaporizer, force), + WEP_CVAR_SEC(vaporizer, speed), + WEP_CVAR_SEC(vaporizer, spread), + WEP_CVAR_SEC(vaporizer, delay), + WEP_CVAR_SEC(vaporizer, lifetime) + ); + player.(weaponentity).m_weapon = oldwep; } - Weapon wpn = player.(weaponentity).m_weapon; - .entity weaponentity = weaponentities[0]; // TODO: unhardcode - if(player.(weaponentity).state != WS_CLEAR) - w_ready(wpn, player, weaponentity, PHYS_INPUT_BUTTON_ATCK(player) | (PHYS_INPUT_BUTTON_ATCK2(player) << 1)); - - player.weapon_blocked = true; } PHYS_INPUT_BUTTON_ATCK2(player) = false; @@ -278,19 +211,14 @@ MUTATOR_HOOKFUNCTION(ok, PlayerSpawn) { entity player = M_ARGV(0, entity); - if(autocvar_g_overkill_ammo_charge) - { - FOREACH(Weapons, it != WEP_Null, LAMBDA(player.ammo_charge[it.m_id] = autocvar_g_overkill_ammo_charge_limit)); - - player.ok_use_ammocharge = 1; - player.ok_notice_time = time; - } - else - player.ok_use_ammocharge = 0; - // if player changed their weapon while dead, don't switch to their death weapon if(player.impulse) - player.ok_lastwep = 0; + { + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + player.ok_lastwep[slot] = WEP_Null; + } + } player.ok_pauseregen_finished = time + 2; } @@ -357,16 +285,6 @@ MUTATOR_HOOKFUNCTION(ok, FilterItem) return true; } -MUTATOR_HOOKFUNCTION(ok, SpectateCopy) -{ - entity spectatee = M_ARGV(0, entity); - entity client = M_ARGV(1, entity); - .entity weaponentity = weaponentities[0]; // TODO: unhardcode - - client.ammo_charge[client.(weaponentity).m_weapon.m_id] = spectatee.ammo_charge[spectatee.(weaponentity).m_weapon.m_id]; - client.ok_use_ammocharge = spectatee.ok_use_ammocharge; -} - MUTATOR_HOOKFUNCTION(ok, SetStartItems) { WepSet ok_start_items = (WEPSET(MACHINEGUN) | WEPSET(VORTEX) | WEPSET(SHOTGUN)); diff --git a/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc b/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc index 387c1c359..ff942db31 100644 --- a/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc +++ b/qcsrc/common/mutators/mutator/pinata/sv_pinata.qc @@ -6,14 +6,20 @@ MUTATOR_HOOKFUNCTION(pinata, PlayerDies) { entity frag_target = M_ARGV(2, entity); - .entity weaponentity = weaponentities[0]; // TODO: unhardcode - - FOREACH(Weapons, it != WEP_Null, LAMBDA( - if(frag_target.weapons & WepSet_FromWeapon(it)) - if(frag_target.(weaponentity).m_switchweapon != it) - if(W_IsWeaponThrowable(frag_target, it.m_id)) - W_ThrowNewWeapon(frag_target, it.m_id, false, CENTER_OR_VIEWOFS(frag_target), randomvec() * 175 + '0 0 325', weaponentity); - )); + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + + if(frag_target.(weaponentity).m_weapon == WEP_Null && slot != 0) + continue; + + FOREACH(Weapons, it != WEP_Null, LAMBDA( + if(frag_target.weapons & WepSet_FromWeapon(it)) + if(frag_target.(weaponentity).m_switchweapon != it) + if(W_IsWeaponThrowable(frag_target, it.m_id)) + W_ThrowNewWeapon(frag_target, it.m_id, false, CENTER_OR_VIEWOFS(frag_target), randomvec() * 175 + '0 0 325', weaponentity); + )); + } return true; } diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 5cc278b04..2ecdd06ca 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -112,8 +112,6 @@ REGISTER_STAT(NADE_BONUS_SCORE, float) REGISTER_STAT(HEALING_ORB, float) REGISTER_STAT(HEALING_ORB_ALPHA, float) REGISTER_STAT(PLASMA, int) -REGISTER_STAT(OK_AMMO_CHARGE, float) -REGISTER_STAT(OK_AMMO_CHARGEPOOL, float) REGISTER_STAT(FROZEN, int) REGISTER_STAT(REVIVE_PROGRESS, float) REGISTER_STAT(ROUNDLOST, int) diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 7a703d3d0..3d011345b 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -742,6 +742,7 @@ METHOD(Arc, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim( actor, + weaponentity, WEP_CVAR(arc, beam_botaimspeed), 0, WEP_CVAR(arc, beam_botaimlifetime), @@ -752,6 +753,7 @@ METHOD(Arc, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim( actor, + weaponentity, 1000000, 0, 0.001, diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index a4a6699a3..cc2fedccf 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -159,12 +159,12 @@ METHOD(Blaster, wr_aim, void(entity thiswep, entity actor, .entity weaponentity) if(WEP_CVAR(blaster, secondary)) { if((random() * (WEP_CVAR_PRI(blaster, damage) + WEP_CVAR_SEC(blaster, damage))) > WEP_CVAR_PRI(blaster, damage)) - { PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR_SEC(blaster, speed), 0, WEP_CVAR_SEC(blaster, lifetime), false); } + { PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(blaster, speed), 0, WEP_CVAR_SEC(blaster, lifetime), false); } else - { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); } + { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); } } else - { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); } + { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); } } METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, .entity weaponentity, int fire)) diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 2ef356e35..e4d66ebe6 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -582,9 +582,9 @@ void W_Crylink_Attack2(Weapon thiswep, entity actor, .entity weaponentity) METHOD(Crylink, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { if(random() < 0.10) - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), false); else - PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR_SEC(crylink, speed), 0, WEP_CVAR_SEC(crylink, middle_lifetime), false); + PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(crylink, speed), 0, WEP_CVAR_SEC(crylink, middle_lifetime), false); } METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index b75ca6f02..13600aad3 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -418,7 +418,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity) METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { // aim and decide to fire if appropriate - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false); if(skill >= 2) // skill 0 and 1 bots won't detonate rockets! { // decide whether to detonate rockets diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 80314d5e6..86f327e1c 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -497,9 +497,9 @@ METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity) float shoot; if(WEP_CVAR_PRI(electro, speed)) - shoot = bot_aim(actor, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false); + shoot = bot_aim(actor, weaponentity, WEP_CVAR_PRI(electro, speed), 0, WEP_CVAR_PRI(electro, lifetime), false); else - shoot = bot_aim(actor, 1000000, 0, 0.001, false); + shoot = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); if(shoot) { @@ -509,7 +509,7 @@ METHOD(Electro, wr_aim, void(entity thiswep, entity actor, .entity weaponentity) } else { - if(bot_aim(actor, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true)) + if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(electro, speed), WEP_CVAR_SEC(electro, speed_up), WEP_CVAR_SEC(electro, lifetime), true)) { PHYS_INPUT_BUTTON_ATCK2(actor) = true; if(random() < 0.03) actor.bot_secondary_electromooth = 0; diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index a7dca49bf..8ccd57b68 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -370,7 +370,7 @@ METHOD(Fireball, wr_aim, void(entity thiswep, entity actor, .entity weaponentity PHYS_INPUT_BUTTON_ATCK2(actor) = false; if(actor.bot_primary_fireballmooth == 0) { - if(bot_aim(actor, WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), false)) + if(bot_aim(actor, weaponentity, WEP_CVAR_PRI(fireball, speed), 0, WEP_CVAR_PRI(fireball, lifetime), false)) { PHYS_INPUT_BUTTON_ATCK(actor) = true; if(random() < 0.02) actor.bot_primary_fireballmooth = 0; @@ -378,7 +378,7 @@ METHOD(Fireball, wr_aim, void(entity thiswep, entity actor, .entity weaponentity } else { - if(bot_aim(actor, WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), true)) + if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(fireball, speed), WEP_CVAR_SEC(fireball, speed_up), WEP_CVAR_SEC(fireball, lifetime), true)) { PHYS_INPUT_BUTTON_ATCK2(actor) = true; if(random() < 0.01) actor.bot_primary_fireballmooth = 1; diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index a8620e50b..cb4d365ad 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -452,9 +452,9 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int METHOD(Hagar, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { if(random()>0.15) - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false); else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming - PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false); + PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false); } METHOD(Hagar, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index d1b4286a2..010ca4fe8 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -214,7 +214,7 @@ void W_HLAC_Attack2_Frame(Weapon thiswep, entity actor, .entity weaponentity) METHOD(HLAC, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false); } METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 1d5ddeecc..7344ba9d0 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -257,9 +257,9 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit METHOD(MachineGun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { if(vdist(actor.origin - actor.enemy.origin, <, 3000 - bound(0, skill, 10) * 200)) - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 0.001, false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); else - PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, 1000000, 0, 0.001, false); + PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); } METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index b33ce2b19..0e1db0f1b 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -426,7 +426,7 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor, .entity weaponentit if(actor.(weaponentity).minelayer_mines >= WEP_CVAR(minelayer, limit)) PHYS_INPUT_BUTTON_ATCK(actor) = false; else - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(minelayer, speed), 0, WEP_CVAR(minelayer, lifetime), false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(minelayer, speed), 0, WEP_CVAR(minelayer, lifetime), false); if(skill >= 2) // skill 0 and 1 bots won't detonate mines! { // decide whether to detonate mines diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 9f1b4a749..d8cb2d069 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -315,7 +315,7 @@ METHOD(Mortar, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) PHYS_INPUT_BUTTON_ATCK2(actor) = false; if(actor.bot_secondary_grenademooth == 0) // WEAPONTODO: merge this into using WEP_CVAR_BOTH { - if(bot_aim(actor, WEP_CVAR_PRI(mortar, speed), WEP_CVAR_PRI(mortar, speed_up), WEP_CVAR_PRI(mortar, lifetime), true)) + if(bot_aim(actor, weaponentity, WEP_CVAR_PRI(mortar, speed), WEP_CVAR_PRI(mortar, speed_up), WEP_CVAR_PRI(mortar, lifetime), true)) { PHYS_INPUT_BUTTON_ATCK(actor) = true; if(random() < 0.01) actor.bot_secondary_grenademooth = 1; @@ -323,7 +323,7 @@ METHOD(Mortar, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) } else { - if(bot_aim(actor, WEP_CVAR_SEC(mortar, speed), WEP_CVAR_SEC(mortar, speed_up), WEP_CVAR_SEC(mortar, lifetime), true)) + if(bot_aim(actor, weaponentity, WEP_CVAR_SEC(mortar, speed), WEP_CVAR_SEC(mortar, speed_up), WEP_CVAR_SEC(mortar, lifetime), true)) { PHYS_INPUT_BUTTON_ATCK2(actor) = true; if(random() < 0.02) actor.bot_secondary_grenademooth = 0; diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index ba972bc55..eaa56e50c 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -303,7 +303,7 @@ METHOD(PortoLaunch, wr_aim, void(entity thiswep, entity actor, .entity weaponent PHYS_INPUT_BUTTON_ATCK(actor) = false; PHYS_INPUT_BUTTON_ATCK2(actor) = false; if(!WEP_CVAR(porto, secondary)) - if(bot_aim(actor, WEP_CVAR_PRI(porto, speed), 0, WEP_CVAR_PRI(porto, lifetime), false)) + if(bot_aim(actor, weaponentity, WEP_CVAR_PRI(porto, speed), 0, WEP_CVAR_PRI(porto, lifetime), false)) PHYS_INPUT_BUTTON_ATCK(actor) = true; } METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index a2122451e..37d8e0e23 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -151,7 +151,7 @@ METHOD(Rifle, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) actor.bot_secondary_riflemooth = 0; if(actor.bot_secondary_riflemooth == 0) { - if(bot_aim(actor, 1000000, 0, 0.001, false)) + if(bot_aim(actor, weaponentity, 1000000, 0, 0.001, false)) { PHYS_INPUT_BUTTON_ATCK(actor) = true; if(random() < 0.01) actor.bot_secondary_riflemooth = 1; @@ -159,7 +159,7 @@ METHOD(Rifle, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) } else { - if(bot_aim(actor, 1000000, 0, 0.001, false)) + if(bot_aim(actor, weaponentity, 1000000, 0, 0.001, false)) { PHYS_INPUT_BUTTON_ATCK2(actor) = true; if(random() < 0.03) actor.bot_secondary_riflemooth = 0; diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index bf60907e1..6cc78f576 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -618,11 +618,11 @@ METHOD(Seeker, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { if(WEP_CVAR(seeker, type) == 1) if(W_Seeker_Tagged_Info(actor, weaponentity, actor.enemy) != NULL) - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(seeker, missile_speed_max), 0, WEP_CVAR(seeker, missile_lifetime), false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, missile_speed_max), 0, WEP_CVAR(seeker, missile_lifetime), false); else - PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false); + PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false); else - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false); } METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index a57f15731..823aac11c 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -698,9 +698,9 @@ void W_Shockwave_Attack(entity actor, .entity weaponentity) METHOD(Shockwave, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { if(vdist(actor.origin - actor.enemy.origin, <=, WEP_CVAR(shockwave, melee_range))) - { PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, 1000000, 0, 0.001, false); } + { PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); } else - { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 0.001, false); } + { PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); } } METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 1fcc3336b..f6d730fcb 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -230,9 +230,9 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity METHOD(Shotgun, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { if(vdist(actor.origin - actor.enemy.origin, <=, WEP_CVAR_SEC(shotgun, melee_range))) - PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, 1000000, 0, 0.001, false); + PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); else - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 0.001, false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 0.001, false); } METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 5d17d62dc..7866f1b82 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -355,9 +355,9 @@ void W_RocketMinsta_Attack3 (entity actor, .entity weaponentity) METHOD(Vaporizer, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { if(actor.(thiswep.ammo_field) > 0) - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, 1000000, 0, 1, false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, 1000000, 0, 1, false); else - PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars + PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars } METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 1c98a7d5e..b3ba65c50 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -148,16 +148,23 @@ MUTATOR_HOOKFUNCTION(vortex_charge, GetPressedKeys) entity player = M_ARGV(0, entity); // WEAPONTODO - float xyspeed = vlen(vec2(player.velocity)); - .entity weaponentity = weaponentities[0]; // TODO: unhardcode - if (player.(weaponentity).m_weapon == WEP_VORTEX && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && xyspeed > WEP_CVAR(vortex, charge_minspeed)) - { - // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed - xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed)); - float f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed)); - // add the extra charge - player.(weaponentity).vortex_charge = min(1, player.(weaponentity).vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH); - } + if(!WEP_CVAR(vortex, charge) || !WEP_CVAR(vortex, charge_velocity_rate)) + return; + + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + + if (player.(weaponentity).m_weapon == WEP_VORTEX && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && vdist(vec2(player.velocity), >, WEP_CVAR(vortex, charge_minspeed))) + { + float xyspeed = vlen(vec2(player.velocity)); + // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed + xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed)); + float f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed)); + // add the extra charge + player.(weaponentity).vortex_charge = min(1, player.(weaponentity).vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH); + } + } } void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float issecondary) @@ -217,7 +224,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i METHOD(Vortex, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { - if(bot_aim(actor, 1000000, 0, 1, false)) + if(bot_aim(actor, weaponentity, 1000000, 0, 1, false)) PHYS_INPUT_BUTTON_ATCK(actor) = true; else { diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 64957b92e..7a43efa85 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -46,7 +46,7 @@ float skill; .float wpcost; .int wpflags; -bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshottime, float applygravity); +bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, float applygravity); void bot_clientconnect(entity this); void bot_clientdisconnect(entity this); void bot_cmdhelp(string scmd); diff --git a/qcsrc/server/bot/default/aim.qc b/qcsrc/server/bot/default/aim.qc index 46d177545..c278be915 100644 --- a/qcsrc/server/bot/default/aim.qc +++ b/qcsrc/server/bot/default/aim.qc @@ -323,7 +323,7 @@ vector bot_shotlead(vector targorigin, vector targvelocity, float shotspeed, flo return targorigin + targvelocity * (shotdelay + vlen(targorigin - shotorg) / shotspeed); } -bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity) +bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity) { float f, r, hf, distanceratio; vector v; @@ -339,8 +339,6 @@ bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshott hf = this.dphitcontentsmask; this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE; - .entity weaponentity = weaponentities[0]; // TODO: unhardcode - shotspeed *= W_WeaponSpeedFactor(this); shotspeedupward *= W_WeaponSpeedFactor(this); if (!shotspeed) diff --git a/qcsrc/server/bot/default/aim.qh b/qcsrc/server/bot/default/aim.qh index dfe10e265..e7c60758a 100644 --- a/qcsrc/server/bot/default/aim.qh +++ b/qcsrc/server/bot/default/aim.qh @@ -91,7 +91,7 @@ void bot_lagfunc(entity this, float t, float f1, float f2, entity e1, vector v1, float bot_shouldattack(entity this, entity targ); float bot_aimdir(entity this, vector v, float maxfiredeviation); -bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity); +bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, bool applygravity); float findtrajectorywithleading(vector org, vector m1, vector m2, entity targ, float shotspeed, float shotspeedupward, float maxtime, float shotdelay, entity ignore); vector bot_shotlead(vector targorigin, vector targvelocity, float shotspeed, float shotdelay); diff --git a/qcsrc/server/bot/null/bot_null.qc b/qcsrc/server/bot/null/bot_null.qc index b4102cb6c..68ae41670 100644 --- a/qcsrc/server/bot/null/bot_null.qc +++ b/qcsrc/server/bot/null/bot_null.qc @@ -1,7 +1,7 @@ #include "bot_null.qh" #if 0 -bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshottime, float applygravity) { return false; } +bool bot_aim(entity this, .entity weaponentity, float shotspeed, float shotspeedupward, float maxshottime, float applygravity) { return false; } void bot_clientconnect(entity this) { } void bot_clientdisconnect(entity this) { } void bot_cmdhelp(string scmd) { } diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 179faf1f6..232d2cfbe 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -366,7 +366,8 @@ MUTATOR_HOOKABLE(PlayerDamaged, EV_PlayerDamaged); * Called by W_DecreaseAmmo */ #define EV_W_DecreaseAmmo(i, o) \ - /** actor */ i(entity, MUTATOR_ARGV_0_entity) \ + /** actor */ i(entity, MUTATOR_ARGV_0_entity) \ + /** weapon entity */ i(entity, MUTATOR_ARGV_1_entity) \ /**/ MUTATOR_HOOKABLE(W_DecreaseAmmo, EV_W_DecreaseAmmo); diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index a99a3551b..1a223cec2 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -634,7 +634,7 @@ void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponentity) { - if (MUTATOR_CALLHOOK(W_DecreaseAmmo, actor)) return; + if (MUTATOR_CALLHOOK(W_DecreaseAmmo, actor, actor.(weaponentity))) return; if ((actor.items & IT_UNLIMITED_WEAPON_AMMO) && !wep.reloading_ammo) return; -- 2.39.2