X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fimpulse.qc;h=3477c0c88dea665063cb73332b1898a09a9d8600;hb=b91b5fdf11727a5cf30abfea6967fe5f487697f7;hp=2d30b4c7aed825b830ccb38530ee34afdf336b27;hpb=93ea212d8c60d8c3e897f8b5b613ee112f88aa37;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/impulse.qc b/qcsrc/server/impulse.qc index 2d30b4c7a..3477c0c88 100644 --- a/qcsrc/server/impulse.qc +++ b/qcsrc/server/impulse.qc @@ -56,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) @@ -86,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) @@ -142,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, 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)