X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fimpulse.qc;h=f425101792f88aee6b0f2ba781031e69973fe607;hp=2320eb830ef50db38913df89c96a724ce801080d;hb=c3df3269846f4e7c86b5e3058d83df08767854a2;hpb=865b6850172f0afde171d638656bef17fc49e336 diff --git a/qcsrc/server/impulse.qc b/qcsrc/server/impulse.qc index 2320eb830..f42510179 100644 --- a/qcsrc/server/impulse.qc +++ b/qcsrc/server/impulse.qc @@ -4,19 +4,24 @@ #include "weapons/throwing.qh" #include "command/common.qh" #include "cheats.qh" +#include "client.qh" #include "clientkill.qh" +#include "damage.qh" +#include #include "weapons/selection.qh" #include "weapons/tracing.qh" #include "weapons/weaponsystem.qh" +#include + #include -#include "../common/minigames/sv_minigames.qh" +#include #include -#include "../common/vehicles/sv_vehicles.qh" +#include -#include "../common/mutators/mutator/waypoints/waypointsprites.qh" +#include .entity vehicle; @@ -51,21 +56,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) @@ -81,25 +91,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(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) @@ -137,22 +152,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, Weapons_from(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) @@ -320,13 +340,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(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! } } @@ -507,7 +533,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");