X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fserver%2Fweapons%2Fweaponsystem.qc;h=29c4018bd23870f30c76f1639bfc21936803178b;hp=809db42710815711c3da5177035c0a1cc1affe2c;hb=4b1bbe437c643e20de07b3bebc8328ed06830b99;hpb=0f1ffe9c0565f1f1a0d6f58240760f227aa3ee99 diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 809db42710..29c4018bd2 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -3,9 +3,10 @@ #include "selection.qh" #include "../command/common.qh" -#include "../mutators/_mod.qh" +#include #include "../round_handler.qh" -#include "../resources.qh" +#include +#include #include #include #include @@ -178,6 +179,7 @@ void CL_SpawnWeaponentity(entity actor, .entity weaponentity) setthink(view, CL_Weaponentity_Think); view.nextthink = time; view.viewmodelforclient = actor; + view.draggable = drag_undraggable; setcefc(view, CL_Weaponentity_CustomizeEntityForClient); wepent_link(view); @@ -187,6 +189,7 @@ void CL_SpawnWeaponentity(entity actor, .entity weaponentity) entity exterior = actor.exteriorweaponentity = new(exteriorweaponentity); exterior.solid = SOLID_NOT; exterior.owner = actor; + exterior.draggable = drag_undraggable; exterior.weaponentity_fld = weaponentity; setorigin(exterior, '0 0 0'); setthink(exterior, CL_ExteriorWeaponentity_Think); @@ -317,6 +320,22 @@ void weapon_prepareattack_do(entity actor, .entity weaponentity, bool secondary, // dprint("resetting attack finished to ", ftos(time), "\n"); } ATTACK_FINISHED(actor, slot) = ATTACK_FINISHED(actor, slot) + attacktime * W_WeaponRateFactor(actor); + + if(autocvar_g_weaponswitch_debug_alternate && W_DualWielding(actor)) + { + for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot) + { + if(slot == wepslot) + continue; + .entity wepent = weaponentities[wepslot]; + if(actor.(wepent) && actor.(wepent).m_weapon != WEP_Null) + { + if (ATTACK_FINISHED(actor, wepslot) < time - actor.(wepent).weapon_frametime * 1.5) + ATTACK_FINISHED(actor, wepslot) = time; + ATTACK_FINISHED(actor, wepslot) = ATTACK_FINISHED(actor, wepslot) + (attacktime * W_WeaponRateFactor(actor)) * 0.5; + } + } + } } this.bulletcounter += 1; // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, slot)), "\n"); @@ -332,8 +351,6 @@ bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bo return false; } -void wframe_send(entity actor, entity weaponentity, vector a, bool restartanim); - /** * @param t defer thinking until time + t * @param func next think function @@ -430,12 +447,12 @@ bool forbidWeaponUse(entity player) void W_WeaponFrame(Player actor, .entity weaponentity) { - TC(Player, actor); - TC(PlayerState, PS(actor)); + TC(Player, actor); + TC(PlayerState, PS(actor)); entity this = actor.(weaponentity); if (frametime) this.weapon_frametime = frametime; - if (!this || actor.health < 1) return; // Dead player can't use weapons and injure impulse commands + if (!this || GetResourceAmount(actor, RESOURCE_HEALTH) < 1) return; // Dead player can't use weapons and injure impulse commands int button_atck = PHYS_INPUT_BUTTON_ATCK(actor); int button_atck2 = PHYS_INPUT_BUTTON_ATCK2(actor); @@ -559,7 +576,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity) // server framerate is very low and the weapon fire rate very high for (int c = 0; c < W_TICSPERFRAME; ++c) { - if (w != WEP_Null && !(actor.weapons & WepSet_FromWeapon(w))) + if (w != WEP_Null && !(STAT(WEAPONS, actor) & WepSet_FromWeapon(w))) { if (this.m_weapon == this.m_switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity); w = WEP_Null; @@ -576,7 +593,7 @@ void W_WeaponFrame(Player actor, .entity weaponentity) key_pressed = false; Weapon off = actor.offhand; - if (off && !(actor.weapons & WEPSET(HOOK))) + if (off && (!(STAT(WEAPONS, actor) & WEPSET(HOOK)) || off != OFFHAND_HOOK)) { if (off.offhand_think) off.offhand_think(off, actor, key_pressed); } @@ -597,8 +614,8 @@ void W_WeaponFrame(Player actor, .entity weaponentity) if (!block_weapon) { - Weapon e = this.m_weapon; - TC(Weapon, e); + Weapon e = this.m_weapon; + TC(Weapon, e); if (w != WEP_Null) { e.wr_think(e, actor, weaponentity, button_atck | (button_atck2 << 1)); @@ -660,9 +677,11 @@ void W_AttachToShotorg(entity actor, .entity weaponentity, entity flash, vector void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponentity) { - if (MUTATOR_CALLHOOK(W_DecreaseAmmo, actor, actor.(weaponentity))) return; + if (MUTATOR_CALLHOOK(W_DecreaseAmmo, actor, actor.(weaponentity), ammo_use)) return; if ((actor.items & IT_UNLIMITED_WEAPON_AMMO) && !wep.reloading_ammo) return; + ammo_use = M_ARGV(2, float); + entity w_ent = actor.(weaponentity); // if this weapon is reloadable, decrease its load. Else decrease the player's ammo @@ -678,7 +697,7 @@ void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use, .entity weaponenti { 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", + "Please notify the developers immediately with a copy of this backtrace!\n", ammo_use, wep.netname, GetAmmoPicture(wep.ammo_type), @@ -731,7 +750,7 @@ void W_ReloadedAndReady(Weapon thiswep, entity actor, .entity weaponentity, int void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sent_sound) { - TC(Sound, sent_sound); + TC(Sound, sent_sound); // set global values to work with entity this = actor.(weaponentity); Weapon e = this.m_weapon; @@ -741,8 +760,7 @@ void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sen this.reload_ammo_min = sent_ammo_min; this.reload_ammo_amount = e.reloading_ammo; this.reload_time = e.reloading_time; - if (actor.reload_sound) strunzone(actor.reload_sound); - actor.reload_sound = strzone(Sound_fixpath(sent_sound)); + strcpy(actor.reload_sound, Sound_fixpath(sent_sound)); // don't reload weapons that don't have the RELOADABLE flag if (!(e.spawnflags & WEP_FLAG_RELOADABLE))