X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fimpulse.qc;h=be66fe968c2b6a2eadc8ac35b8390805ad519289;hb=a6423f485060d59253426c339add259c876ae6f6;hp=521c2223f7eab73582b4326fc2ba33e6cf73d66c;hpb=0394852103d5d410a54f14daa6fc698d0cdbd74f;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/impulse.qc b/qcsrc/server/impulse.qc index 521c2223f..be66fe968 100644 --- a/qcsrc/server/impulse.qc +++ b/qcsrc/server/impulse.qc @@ -1,26 +1,22 @@ #include "impulse.qh" -#include "round_handler.qh" - -#include "weapons/throwing.qh" -#include "command/common.qh" -#include "cheats.qh" -#include "client.qh" -#include "clientkill.qh" -#include "g_damage.qh" -#include "weapons/selection.qh" -#include "weapons/tracing.qh" -#include "weapons/weaponsystem.qh" #include - +#include +#include #include - -#include "../common/minigames/sv_minigames.qh" - +#include #include -#include "../common/vehicles/sv_vehicles.qh" - -#include "../common/mutators/mutator/waypoints/waypointsprites.qh" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include .entity vehicle; @@ -55,21 +51,26 @@ // weapon switching impulses +void weapon_group_handle(entity this, int number, int imp) +{ + if (IS_DEAD(this)) + { + this.impulse = imp; + return; + } + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + W_NextWeaponOnImpulse(this, number, weaponentity); + if(autocvar_g_weaponswitch_debug != 1) + break; + } +} + #define X(i) \ IMPULSE(weapon_group_##i) \ { \ - if (IS_DEAD(this)) \ - { \ - this.impulse = IMP_weapon_group_##i.impulse; \ - return; \ - } \ - for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) \ - { \ - .entity weaponentity = weaponentities[slot]; \ - W_NextWeaponOnImpulse(this, i, weaponentity); \ - if(autocvar_g_weaponswitch_debug != 1) \ - break; \ - } \ + weapon_group_handle(this, i, IMP_weapon_group_##i.impulse); \ } X(1) X(2) @@ -85,25 +86,30 @@ X(0) // custom order weapon cycling +void weapon_priority_handle(entity this, int dir, int number, int imp) +{ + if (this.vehicle) return; + if (IS_DEAD(this)) + { + this.impulse = imp; + return; + } + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + W_CycleWeapon(this, CS_CVAR(this).cvar_cl_weaponpriorities[number], dir, weaponentity); + if(autocvar_g_weaponswitch_debug != 1) + break; + } +} + #define X(i, dir) \ IMPULSE(weapon_priority_##i##_##dir) \ { \ - if (this.vehicle) return; \ - if (IS_DEAD(this)) \ - { \ - this.impulse = IMP_weapon_priority_##i##_##dir.impulse; \ - return; \ - } \ noref int prev = -1; \ noref int best = 0; \ noref int next = +1; \ - for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) \ - { \ - .entity weaponentity = weaponentities[slot]; \ - W_CycleWeapon(this, CS(this).cvar_cl_weaponpriorities[i], dir, weaponentity); \ - if(autocvar_g_weaponswitch_debug != 1) \ - break; \ - } \ + weapon_priority_handle(this, dir, i, IMP_weapon_priority_##i##_##dir.impulse); \ } X(0, prev) X(1, prev) @@ -141,22 +147,27 @@ X(9, next) // direct weapons +void weapon_byid_handle(entity this, int number, int imp) +{ + if (this.vehicle) return; + if (IS_DEAD(this)) + { + this.impulse = imp; + return; + } + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + W_SwitchWeapon_TryOthers(this, REGISTRY_GET(Weapons, WEP_FIRST + number), weaponentity); + if(autocvar_g_weaponswitch_debug != 1) + break; + } +} + #define X(i) \ IMPULSE(weapon_byid_##i) \ { \ - if (this.vehicle) return; \ - if (IS_DEAD(this)) \ - { \ - this.impulse = IMP_weapon_byid_##i.impulse; \ - return; \ - } \ - for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) \ - { \ - .entity weaponentity = weaponentities[slot]; \ - W_SwitchWeapon_TryOthers(this, REGISTRY_GET(Weapons, WEP_FIRST + i), weaponentity); \ - if(autocvar_g_weaponswitch_debug != 1) \ - break; \ - } \ + weapon_byid_handle(this, i, IMP_weapon_byid_##i.impulse); \ } X(0) X(1) @@ -370,87 +381,16 @@ void ImpulseCommands(entity this) if (timeout_status == TIMEOUT_ACTIVE) return; // don't allow any impulses while the game is paused - // allow only weapon change impulses when not in round time if (round_handler_IsActive() && !round_handler_IsRoundStarted()) { + // impulses forbidden while waiting for the start of a round #define X(id) case IMP_##id.impulse: switch (imp) { - X(weapon_group_0) - X(weapon_group_1) - X(weapon_group_2) - X(weapon_group_3) - X(weapon_group_4) - X(weapon_group_5) - X(weapon_group_6) - X(weapon_group_7) - X(weapon_group_8) - X(weapon_group_9) - X(weapon_next_byid) - X(weapon_prev_byid) - X(weapon_next_bygroup) - X(weapon_prev_bygroup) - X(weapon_next_bypriority) - X(weapon_prev_bypriority) - X(weapon_last) - X(weapon_best) + X(weapon_drop) X(weapon_reload) - X(weapon_priority_0_prev) - X(weapon_priority_1_prev) - X(weapon_priority_2_prev) - X(weapon_priority_3_prev) - X(weapon_priority_4_prev) - X(weapon_priority_5_prev) - X(weapon_priority_6_prev) - X(weapon_priority_7_prev) - X(weapon_priority_8_prev) - X(weapon_priority_9_prev) - X(weapon_priority_0_next) - X(weapon_priority_1_next) - X(weapon_priority_2_next) - X(weapon_priority_3_next) - X(weapon_priority_4_next) - X(weapon_priority_5_next) - X(weapon_priority_6_next) - X(weapon_priority_7_next) - X(weapon_priority_8_next) - X(weapon_priority_9_next) - X(weapon_priority_0_best) - X(weapon_priority_1_best) - X(weapon_priority_2_best) - X(weapon_priority_3_best) - X(weapon_priority_4_best) - X(weapon_priority_5_best) - X(weapon_priority_6_best) - X(weapon_priority_7_best) - X(weapon_priority_8_best) - X(weapon_priority_9_best) - X(weapon_byid_0) - X(weapon_byid_1) - X(weapon_byid_2) - X(weapon_byid_3) - X(weapon_byid_4) - X(weapon_byid_5) - X(weapon_byid_6) - X(weapon_byid_7) - X(weapon_byid_8) - X(weapon_byid_9) - X(weapon_byid_10) - X(weapon_byid_11) - X(weapon_byid_12) - X(weapon_byid_13) - X(weapon_byid_14) - X(weapon_byid_15) - X(weapon_byid_16) - X(weapon_byid_17) - X(weapon_byid_18) - X(weapon_byid_19) - X(weapon_byid_20) - X(weapon_byid_21) - X(weapon_byid_22) - X(weapon_byid_23) - break; - default: return; + X(use) + return; } #undef X }