]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/hook.qc
Merge branch 'master' into Mario/cts_respawn_clear
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / hook.qc
index 964877425420949fdcd06bcb1d1e7524c1efdadc..26c04ad4fa200f536252a5389b5dea089137932b 100644 (file)
@@ -85,7 +85,7 @@ void W_Hook_ExplodeThink(entity this)
        float dt, dmg_remaining_next, f;
 
        dt = time - this.teleport_time;
-       dmg_remaining_next = pow(bound(0, 1 - dt / this.dmg_duration, 1), this.dmg_power);
+       dmg_remaining_next = (bound(0, 1 - dt / this.dmg_duration, 1) ** this.dmg_power);
 
        f = this.dmg_last - dmg_remaining_next;
        this.dmg_last = dmg_remaining_next;
@@ -169,6 +169,7 @@ void W_Hook_Attack2(Weapon thiswep, entity actor, .entity weaponentity)
        gren.damageforcescale = WEP_CVAR_SEC(hook, damageforcescale);
        gren.event_damage = W_Hook_Damage;
        gren.damagedbycontents = true;
+       IL_PUSH(g_damagedbycontents, gren);
        gren.missile_flags = MIF_SPLASH | MIF_ARC;
 
        gren.velocity = '0 0 1' * WEP_CVAR_SEC(hook, speed);
@@ -251,7 +252,8 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
                     {
                         actor.ammo_fuel = 0;
                         actor.(weaponentity).hook_state |= HOOK_REMOVING;
-                        W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
+                        if(actor.(weaponentity).m_weapon != WEP_Null) // offhand
+                               W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
                     }
                 }
             }
@@ -280,13 +282,9 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity,
         actor.(weaponentity).hook_state &= ~HOOK_REMOVING;
     }
 }
-METHOD(Hook, wr_setup, void(entity thiswep, entity actor))
+METHOD(Hook, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
 {
-       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
-    {
-       .entity weaponentity = weaponentities[slot];
-       actor.(weaponentity).hook_state &= ~HOOK_WAITING_FOR_RELEASE;
-    }
+       actor.(weaponentity).hook_state &= ~HOOK_WAITING_FOR_RELEASE;
 }
 METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor, .entity weaponentity))
 {
@@ -379,7 +377,7 @@ void Draw_GrapplingHook(entity this)
 
        InterpolateOrigin_Do(this);
 
-       int s = viewmodels[this.cnt].m_gunalign - 1; //W_GunAlign(NULL, STAT(GUNALIGN));
+       int s = W_GunAlign(viewmodels[this.cnt], STAT(GUNALIGN)) - 1;
 
        switch(this.HookType)
        {
@@ -392,13 +390,16 @@ void Draw_GrapplingHook(entity this)
                        break;
        }
 
-       if((this.owner.sv_entnum == player_localentnum - 1) && autocvar_chase_active <= 0)
+       if((this.owner.sv_entnum == player_localentnum - 1))
        {
                switch(this.HookType)
                {
                        default:
                        case NET_ENT_CLIENT_HOOK:
-                               a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z;
+                               if(autocvar_chase_active > 0)
+                                       a = csqcplayer.origin;
+                               else
+                                       a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z;
                                b = this.origin;
                                break;
                        case NET_ENT_CLIENT_ARC_BEAM:
@@ -501,8 +502,12 @@ void Remove_GrapplingHook(entity this)
 {
        sound (this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM);
 
-       if(csqcplayer && csqcplayer.hook == this)
-               csqcplayer.hook = NULL;
+       for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+       {
+               entity wep = viewmodels[slot];
+               if(wep.hook == this)
+                       wep.hook = NULL;
+       }
 }
 
 NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew)