X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fweaponsystem.qc;h=2f6fcb68d7213cbafc508343d377da932944ad0a;hb=35b5d15a47d8e309396453c03e36ac717789c600;hp=826bb2a5a7f8415ce2f41487d17ec2da56552a89;hpb=93774bce9081a9fc5eb72b30bf5fd54a9418664a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 826bb2a5a..2f6fcb68d 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -5,6 +5,7 @@ #include "../command/common.qh" #include "../mutators/_mod.qh" #include "../round_handler.qh" +#include "../resources.qh" #include #include #include @@ -393,10 +394,10 @@ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void( if (this) { - FOREACH_CLIENT(true, LAMBDA( + FOREACH_CLIENT(true, { if(it == actor || (IS_SPEC(it) && it.enemy == actor)) wframe_send(it, this, a, restartanim); - )); + }); } if ((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t) @@ -452,6 +453,23 @@ void W_WeaponFrame(Player actor, .entity weaponentity) } } + if(autocvar_g_weaponswitch_debug == 2 && weaponslot(weaponentity) > 0) + { + .entity wepe1 = weaponentities[0]; + entity wep1 = actor.(wepe1); + this.m_switchweapon = wep1.m_switchweapon; + entity store = IS_PLAYER(actor) ? PS(actor) : actor; + if(!(this.m_switchweapon.spawnflags & WEP_FLAG_DUALWIELD) && !(store.dual_weapons & wep1.m_switchweapon.m_wepset)) + { + this.m_weapon = WEP_Null; + this.m_switchingweapon = WEP_Null; + this.m_switchweapon = WEP_Null; + this.state = WS_CLEAR; + this.weaponname = ""; + return; + } + } + if (this.m_switchweapon == WEP_Null) { this.m_weapon = WEP_Null; @@ -501,7 +519,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity) this.clip_load = this.clip_size = 0; } - weapon_thinkf(actor, weaponentity, WFRAME_IDLE, newwep.switchdelay_raise, w_ready); + weapon_thinkf(actor, weaponentity, WFRAME_DONTCHANGE, newwep.switchdelay_raise, w_ready); break; } case WS_DROP: @@ -651,21 +669,22 @@ void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponenti w_ent.clip_load -= ammo_use; w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load; } - else if (wep.ammo_field != ammo_none) + else if (wep.ammo_type != RESOURCE_NONE) { - actor.(wep.ammo_field) -= ammo_use; - if (actor.(wep.ammo_field) < 0) + float ammo = GetResourceAmount(actor, wep.ammo_type); + if (ammo < ammo_use) { backtrace(sprintf( "W_DecreaseAmmo(%.2f): '%s' subtracted too much %s from '%s', resulting with '%.2f' left... " "Please notify Samual immediately with a copy of this backtrace!\n", ammo_use, wep.netname, - GetAmmoPicture(wep.ammo_field), + GetAmmoPicture(wep.ammo_type), actor.netname, - actor.(wep.ammo_field) + ammo )); } + SetResourceAmount(actor, wep.ammo_type, ammo - ammo_use); } } @@ -685,16 +704,17 @@ void W_ReloadedAndReady(Weapon thiswep, entity actor, .entity weaponentity, int w_ent.clip_load = w_ent.old_clip_load; // restore the ammo counter, in case we still had ammo in the weapon before reloading // if the gun uses no ammo, max out weapon load, else decrease ammo as we increase weapon load - if (!w_ent.reload_ammo_min || (actor.items & IT_UNLIMITED_WEAPON_AMMO) || wpn.ammo_field == ammo_none) + if (!w_ent.reload_ammo_min || (actor.items & IT_UNLIMITED_WEAPON_AMMO) || wpn.ammo_type == RESOURCE_NONE) { w_ent.clip_load = w_ent.reload_ammo_amount; } else { // make sure we don't add more ammo than we have - float load = min(w_ent.reload_ammo_amount - w_ent.clip_load, actor.(wpn.ammo_field)); + float ammo = GetResourceAmount(actor, wpn.ammo_type); + float load = min(w_ent.reload_ammo_amount - w_ent.clip_load, ammo); w_ent.clip_load += load; - actor.(wpn.ammo_field) -= load; + SetResourceAmount(actor, wpn.ammo_type, ammo - load); } w_ent.(weapon_load[w_ent.m_weapon.m_id]) = w_ent.clip_load; @@ -737,9 +757,9 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen if (this.clip_load >= this.reload_ammo_amount) return; // no ammo, so nothing to load - if (e.ammo_field != ammo_none) + if (e.ammo_type != RESOURCE_NONE) { - if (!actor.(e.ammo_field) && this.reload_ammo_min) + if (!GetResourceAmount(actor, e.ammo_type) && this.reload_ammo_min) { if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) {