for (int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
.entity weaponentity = weaponentities[slot];
- entity oldwep = this.(weaponentity);
CL_SpawnWeaponentity(this, weaponentity);
- if(oldwep && oldwep.owner == this)
- this.(weaponentity).m_gunalign = oldwep.m_gunalign;
}
this.alpha = default_player_alpha;
this.colormod = '1 1 1' * autocvar_g_player_brightness;
if (CS(this).impulse) ImpulseCommands(this);
+ W_ResetGunAlign(this, CS(this).cvar_cl_gunalign);
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
.entity weaponentity = weaponentities[slot];
.int items_added;
.string shootfromfixedorigin;
+.bool dualwielding_prev;
bool PlayerThink(entity this)
{
if (game_stopped || intermission_running) {
stuffcmd(this, sprintf("\ncl_shootfromfixedorigin \"%s\"\n", autocvar_g_shootfromfixedorigin));
}
+ // reset gun alignment when dual wielding status changes
+ // to ensure guns are always aligned right and left
+ bool dualwielding = W_DualWielding(this);
+ if(this.dualwielding_prev != dualwielding)
+ {
+ W_ResetGunAlign(this, CS(this).cvar_cl_gunalign);
+ this.dualwielding_prev = dualwielding;
+ }
+
// LordHavoc: allow firing on move frames (sub-ticrate), this gives better timing on slow servers
//if(frametime)
{
return false;
}
+void W_ResetGunAlign(entity player, int preferred_alignment)
+{
+ if(W_DualWielding(player))
+ preferred_alignment = 3; // right align, the second gun will default to left
+
+ // clear current weapon slots' alignments so we can redo the calculations!
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ if (player.(weaponentity))
+ player.(weaponentity).m_gunalign = 0;
+ }
+
+ // now set the new values
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ if (player.(weaponentity))
+ player.(weaponentity).m_gunalign = W_GunAlign(player.(weaponentity), preferred_alignment);
+ }
+}
+
.bool hook_switchweapon;
void W_WeaponFrame(Player actor, .entity weaponentity)
void W_Reload(entity actor, .entity weaponentity, float sent_ammo_min, Sound sent_sound);
+void W_ResetGunAlign(entity player, int preferred_alignment);
+
void W_WeaponFrame(Player actor, .entity weaponentity);
float W_WeaponRateFactor(entity this);