]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_hook.qc
Merge branch 'master' into mirceakitsune/damage_effects
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_hook.qc
index 4ce665dc7d7fe74e4312e66917224b92ca470384..6feacc7d5ef01c2478800e277e25677348cef085 100644 (file)
@@ -13,12 +13,6 @@ REGISTER_WEAPON(HOOK, w_hook, IT_CELLS|IT_FUEL, 0, WEP_FLAG_CANCLIMB | WEP_TYPE_
 .float hook_time_hooked;
 .float hook_time_fueldecrease;
 
-void W_Hook_SetAmmoCounter()
-{
-       // this weapon doesn't have a reload system, so always set the clip to 0 when switching to it
-       self.clip_load = self.clip_size = 0; // also keeps crosshair ammo from displaying
-}
-
 void W_Hook_ExplodeThink (void)
 {
        float dt, dmg_remaining_next, f;
@@ -29,7 +23,7 @@ void W_Hook_ExplodeThink (void)
        f = self.dmg_last - dmg_remaining_next;
        self.dmg_last = dmg_remaining_next;
 
-       RadiusDamage (self, self.owner, self.dmg * f, self.dmg_edge * f, self.dmg_radius, self.owner, self.dmg_force * f, self.projectiledeathtype, world);
+       RadiusDamage (self, self.realowner, self.dmg * f, self.dmg_edge * f, self.dmg_radius, self.realowner, self.dmg_force * f, self.projectiledeathtype, world);
        self.projectiledeathtype |= HITTYPE_BOUNCE;
        //RadiusDamage (self, world, self.dmg * f, self.dmg_edge * f, self.dmg_radius, world, self.dmg_force * f, self.projectiledeathtype, world);
 
@@ -58,6 +52,20 @@ void W_Hook_Explode2 (void)
        self.movetype = MOVETYPE_NONE;
 }
 
+void W_Hook_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+{
+       if (self.health <= 0)
+               return;
+               
+       if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
+               return; // g_projectiles_damage says to halt    
+       
+       self.health = self.health - damage;
+       
+       if (self.health <= 0)
+               W_PrepareExplosionByDamage(self.realowner, W_Hook_Explode2);
+}
+
 void W_Hook_Touch2 (void)
 {
        PROJECTILE_TOUCH;
@@ -66,14 +74,13 @@ void W_Hook_Touch2 (void)
 
 void W_Hook_Attack2()
 {
-       local entity gren;
+       entity gren;
 
-       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-               W_DecreaseAmmo(ammo_cells, autocvar_g_balance_hook_secondary_ammo, FALSE);
-       W_SetupShot (self, FALSE, 4, "weapons/hookbomb_fire.wav", CHAN_WEAPON, autocvar_g_balance_hook_secondary_damage);
+       W_DecreaseAmmo(ammo_cells, autocvar_g_balance_hook_secondary_ammo, FALSE);
+       W_SetupShot (self, FALSE, 4, "weapons/hookbomb_fire.wav", CH_WEAPON_A, autocvar_g_balance_hook_secondary_damage);
 
        gren = spawn ();
-       gren.owner = self;
+       gren.owner = gren.realowner = self;
        gren.classname = "hookbomb";
        gren.bot_dodge = TRUE;
        gren.bot_dodgerating = autocvar_g_balance_hook_secondary_damage;
@@ -87,6 +94,12 @@ void W_Hook_Attack2()
        gren.think = adaptor_think2use_hittype_splash;
        gren.use = W_Hook_Explode2;
        gren.touch = W_Hook_Touch2;
+       
+       gren.takedamage = DAMAGE_YES;
+       gren.health = autocvar_g_balance_hook_secondary_health;
+       gren.damageforcescale = autocvar_g_balance_hook_secondary_damageforcescale;
+       gren.event_damage = W_Hook_Damage;
+       gren.damagedbycontents = TRUE;
 
        gren.velocity = '0 0 1' * autocvar_g_balance_hook_secondary_speed;
        if(autocvar_g_projectiles_newton_style)
@@ -132,8 +145,7 @@ float w_hook(float req)
                        if (time > self.hook_refire)
                        if (weapon_prepareattack(0, -1))
                        {
-                               if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-                                       W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_hook_primary_fuel, FALSE);
+                               W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_hook_primary_fuel, FALSE);
                                self.hook_state |= HOOK_FIRING;
                                weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hook_primary_animtime, w_ready);                         
                        }
@@ -151,7 +163,7 @@ float w_hook(float req)
                if(self.hook)
                {
                        // if hooked, no bombs, and increase the timer
-                       self.hook_refire = max(self.hook_refire, time + autocvar_g_balance_hook_primary_refire);
+                       self.hook_refire = max(self.hook_refire, time + autocvar_g_balance_hook_primary_refire * W_WeaponRateFactor());
 
                        // hook also inhibits health regeneration, but only for 1 second
                        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
@@ -234,7 +246,7 @@ float w_hook(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_HOOK);
-               W_Hook_SetAmmoCounter();
+               self.current_ammo = ammo_fuel;
                self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
        }
        else if (req == WR_CHECKAMMO1)
@@ -253,7 +265,7 @@ float w_hook(float req)
                self.hook_refire = time;
        }
        return TRUE;
-};
+}
 #endif
 #ifdef CSQC
 float w_hook(float req)
@@ -264,7 +276,7 @@ float w_hook(float req)
                org2 = w_org + w_backoff * 2;
                pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
                if(!w_issilent)
-                       sound(self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
+                       sound(self, CH_SHOTS, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
        }
        else if(req == WR_PRECACHE)
        {