#include "selection.qh"
#include "../command/common.qh"
-#include "../mutators/_mod.qh"
+#include <server/mutators/_mod.qh>
#include "../round_handler.qh"
-#include "../resources.qh"
+#include <server/cheats.qh>
+#include <server/resources.qh>
#include <common/t_items.qh>
#include <common/animdecide.qh>
#include <common/constants.qh>
setthink(view, CL_Weaponentity_Think);
view.nextthink = time;
view.viewmodelforclient = actor;
+ view.draggable = drag_undraggable;
setcefc(view, CL_Weaponentity_CustomizeEntityForClient);
wepent_link(view);
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);
// 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");
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
bool forbidWeaponUse(entity player)
{
- if (time < game_starttime && !autocvar_sv_ready_restart_after_countdown) return true;
+ if (time < game_starttime && !sv_ready_restart_after_countdown) return true;
if (player.player_blocked) return true;
if (game_stopped) return true;
if (STAT(FROZEN, player)) return true;
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);
// 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;
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);
}
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));
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
{
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),
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;
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))