X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fimpulse.qc;h=3fa3dc6c6fb263ee43874d7ab52a620ec2a7abee;hb=341b4c12077dfdb6a5a4c4245ceea1fbba7ed6b6;hp=5010d283711ff0e795ed3f146bb097b56cfbcd10;hpb=1b0decb9afb829407eae763b3053a122e2ae3de6;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/impulse.qc b/qcsrc/server/impulse.qc index 5010d2837..3fa3dc6c6 100644 --- a/qcsrc/server/impulse.qc +++ b/qcsrc/server/impulse.qc @@ -1,23 +1,22 @@ #include "impulse.qh" -#include "round_handler.qh" - -#include "bot/api.qh" - -#include "weapons/throwing.qh" -#include "command/common.qh" -#include "cheats.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; @@ -52,21 +51,26 @@ // weapon switching impulses -#define X(slot) \ - IMPULSE(weapon_group_##slot) \ +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_##slot.impulse; \ - return; \ - } \ - for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot) \ - { \ - .entity weaponentity = weaponentities[wepslot]; \ - W_NextWeaponOnImpulse(this, slot, weaponentity); \ - if(wepslot == 0 && autocvar_g_weaponswitch_debug != 1) \ - break; \ - } \ + weapon_group_handle(this, i, IMP_weapon_group_##i.impulse); \ } X(1) X(2) @@ -82,25 +86,30 @@ X(0) // custom order weapon cycling -#define X(slot, dir) \ - IMPULSE(weapon_priority_##slot##_##dir) \ +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_##slot##_##dir.impulse; \ - return; \ - } \ noref int prev = -1; \ noref int best = 0; \ noref int next = +1; \ - for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot) \ - { \ - .entity weaponentity = weaponentities[wepslot]; \ - W_CycleWeapon(this, CS(this).cvar_cl_weaponpriorities[slot], dir, weaponentity); \ - if(wepslot == 0 && autocvar_g_weaponswitch_debug != 1) \ - break; \ - } \ + weapon_priority_handle(this, dir, i, IMP_weapon_priority_##i##_##dir.impulse); \ } X(0, prev) X(1, prev) @@ -138,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(this, Weapons_from(WEP_FIRST + i), weaponentity); \ - if(slot == 0 && autocvar_g_weaponswitch_debug != 1) \ - break; \ - } \ + weapon_byid_handle(this, i, IMP_weapon_byid_##i.impulse); \ } X(0) X(1) @@ -194,7 +208,7 @@ IMPULSE(weapon_next_byid) .entity weaponentity = weaponentities[slot]; W_NextWeapon(this, 0, weaponentity); - if(slot == 0 && autocvar_g_weaponswitch_debug != 1) + if(autocvar_g_weaponswitch_debug != 1) break; } } @@ -212,7 +226,7 @@ IMPULSE(weapon_prev_byid) .entity weaponentity = weaponentities[slot]; W_PreviousWeapon(this, 0, weaponentity); - if(slot == 0 && autocvar_g_weaponswitch_debug != 1) + if(autocvar_g_weaponswitch_debug != 1) break; } } @@ -230,7 +244,7 @@ IMPULSE(weapon_next_bygroup) .entity weaponentity = weaponentities[slot]; W_NextWeapon(this, 1, weaponentity); - if(slot == 0 && autocvar_g_weaponswitch_debug != 1) + if(autocvar_g_weaponswitch_debug != 1) break; } } @@ -248,7 +262,7 @@ IMPULSE(weapon_prev_bygroup) .entity weaponentity = weaponentities[slot]; W_PreviousWeapon(this, 1, weaponentity); - if(slot == 0 && autocvar_g_weaponswitch_debug != 1) + if(autocvar_g_weaponswitch_debug != 1) break; } } @@ -266,7 +280,7 @@ IMPULSE(weapon_next_bypriority) .entity weaponentity = weaponentities[slot]; W_NextWeapon(this, 2, weaponentity); - if(slot == 0 && autocvar_g_weaponswitch_debug != 1) + if(autocvar_g_weaponswitch_debug != 1) break; } } @@ -284,7 +298,7 @@ IMPULSE(weapon_prev_bypriority) .entity weaponentity = weaponentities[slot]; W_PreviousWeapon(this, 2, weaponentity); - if(slot == 0 && autocvar_g_weaponswitch_debug != 1) + if(autocvar_g_weaponswitch_debug != 1) break; } } @@ -298,7 +312,7 @@ IMPULSE(weapon_last) .entity weaponentity = weaponentities[slot]; W_LastWeapon(this, weaponentity); - if(slot == 0 && autocvar_g_weaponswitch_debug != 1) + if(autocvar_g_weaponswitch_debug != 1) break; } } @@ -312,7 +326,7 @@ IMPULSE(weapon_best) .entity weaponentity = weaponentities[slot]; W_SwitchWeapon(this, w_getbestweapon(this, weaponentity), weaponentity); - if(slot == 0 && autocvar_g_weaponswitch_debug != 1) + if(autocvar_g_weaponswitch_debug != 1) break; } } @@ -321,13 +335,19 @@ IMPULSE(weapon_drop) { if (this.vehicle) return; if (IS_DEAD(this)) return; + bool is_dualwielding = W_DualWielding(this); for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { .entity weaponentity = weaponentities[slot]; - W_ThrowWeapon(this, weaponentity, W_CalculateProjectileVelocity(this, this.velocity, v_forward * 750, false), '0 0 0', true); - - if(slot == 0 && autocvar_g_weaponswitch_debug != 1) - break; + vector md = this.(weaponentity).movedir; + vector vecs = ((md.x > 0) ? md : '0 0 0'); + vector dv = v_right * -vecs.y; + if(!is_dualwielding) + dv = '0 0 0'; // don't override! + W_ThrowWeapon(this, weaponentity, W_CalculateProjectileVelocity(this, this.velocity, v_forward * 750, false), dv, true); + + if(autocvar_g_weaponswitch_debug == 2) + break; // in this mode, the off-hand weapon is selected based on the primary weapon, don't drop it twice! } } @@ -335,7 +355,7 @@ IMPULSE(weapon_reload) { if (this.vehicle) return; if (IS_DEAD(this)) return; - if (forbidWeaponUse(this)) return; + if (weaponLocked(this)) return; entity actor = this; for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) { @@ -344,7 +364,7 @@ IMPULSE(weapon_reload) w.wr_reload(w, actor, weaponentity); // allow reloading all active slots? - //if(slot == 0 && autocvar_g_weaponswitch_debug != 1) + //if(autocvar_g_weaponswitch_debug != 1) //break; } } @@ -508,7 +528,7 @@ IMPULSE(waypoint_here_here) IMPULSE(waypoint_here_crosshair) { - WarpZone_crosshair_trace(this); + WarpZone_crosshair_trace_plusvisibletriggers(this); entity wp = WaypointSprite_DeployFixed(WP_Here, false, this, trace_endpos, RADARICON_HERE); if (wp) WaypointSprite_Ping(wp); sprint(this, "HERE spawned at crosshair\n"); @@ -571,33 +591,3 @@ IMPULSE(waypoint_clear) } sprint(this, "all waypoints cleared\n"); } - -IMPULSE(navwaypoint_spawn) -{ - if (!autocvar_g_waypointeditor) return; - waypoint_spawn_fromeditor(this); -} - -IMPULSE(navwaypoint_remove) -{ - if (!autocvar_g_waypointeditor) return; - waypoint_remove_fromeditor(this); -} - -IMPULSE(navwaypoint_relink) -{ - if (!autocvar_g_waypointeditor) return; - waypoint_schedulerelinkall(); -} - -IMPULSE(navwaypoint_save) -{ - if (!autocvar_g_waypointeditor) return; - waypoint_saveall(); -} - -IMPULSE(navwaypoint_unreachable) -{ - if (!autocvar_g_waypointeditor) return; - waypoint_unreachable(this); -}