]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_hook.qc
Merge remote-tracking branch 'origin/divVerent/allow-override-item-model'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_hook.qc
index 70fe77814de201e42e9f583d1e7b49c3da89e8a2..695ac381fe55afcaeb750f2890e313addb6ef915 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(HOOK, w_hook, IT_CELLS|IT_FUEL, 0, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "hookgun", "hook", "Grappling Hook");
+REGISTER_WEAPON(HOOK, w_hook, IT_CELLS|IT_FUEL, 0, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "hookgun", "hook", _("Grappling Hook"))
 #else
 #ifdef SVQC
 .float dmg;
@@ -23,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);
 
@@ -41,17 +41,31 @@ void W_Hook_Explode2 (void)
 
        self.think = W_Hook_ExplodeThink;
        self.nextthink = time;
-       self.dmg = cvar("g_balance_hook_secondary_damage");
-       self.dmg_edge = cvar("g_balance_hook_secondary_edgedamage");
-       self.dmg_radius = cvar("g_balance_hook_secondary_radius");
-       self.dmg_force = cvar("g_balance_hook_secondary_force");
-       self.dmg_power = cvar("g_balance_hook_secondary_power");
-       self.dmg_duration = cvar("g_balance_hook_secondary_duration");
+       self.dmg = autocvar_g_balance_hook_secondary_damage;
+       self.dmg_edge = autocvar_g_balance_hook_secondary_edgedamage;
+       self.dmg_radius = autocvar_g_balance_hook_secondary_radius;
+       self.dmg_force = autocvar_g_balance_hook_secondary_force;
+       self.dmg_power = autocvar_g_balance_hook_secondary_power;
+       self.dmg_duration = autocvar_g_balance_hook_secondary_duration;
        self.teleport_time = time;
        self.dmg_last = 1;
        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;
@@ -60,39 +74,46 @@ void W_Hook_Touch2 (void)
 
 void W_Hook_Attack2()
 {
-       local entity gren;
+       entity gren;
 
-       if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-               self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_secondary_ammo");
-       W_SetupShot (self, FALSE, 4, "weapons/hookbomb_fire.wav", cvar("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 = cvar("g_balance_hook_secondary_damage");
+       gren.bot_dodgerating = autocvar_g_balance_hook_secondary_damage;
        gren.movetype = MOVETYPE_TOSS;
        PROJECTILE_MAKETRIGGER(gren);
        gren.projectiledeathtype = WEP_HOOK | HITTYPE_SECONDARY;
        setorigin(gren, w_shotorg);
        setsize(gren, '0 0 0', '0 0 0');
 
-       gren.nextthink = time + cvar("g_balance_hook_secondary_lifetime");
+       gren.nextthink = time + autocvar_g_balance_hook_secondary_lifetime;
        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' * cvar("g_balance_hook_secondary_speed");
-       if(cvar("g_projectiles_newton_style"))
+       gren.velocity = '0 0 1' * autocvar_g_balance_hook_secondary_speed;
+       if(autocvar_g_projectiles_newton_style)
                gren.velocity = gren.velocity + self.velocity;
 
-       gren.gravity = cvar("g_balance_hook_secondary_gravity");
+       gren.gravity = autocvar_g_balance_hook_secondary_gravity;
        //W_SetupProjectileVelocity(gren); // just falling down!
 
        gren.angles = '0 0 0';
        gren.flags = FL_PROJECTILE;
 
        CSQCProjectile(gren, TRUE, PROJECTILE_HOOKBOMB, TRUE);
+
+       other = gren; MUTATOR_CALLHOOK(EditProjectile);
 }
 
 void spawnfunc_weapon_hook (void)
@@ -124,42 +145,41 @@ float w_hook(float req)
                        if (time > self.hook_refire)
                        if (weapon_prepareattack(0, -1))
                        {
-                               if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
-                                       self.ammo_fuel = self.ammo_fuel - cvar("g_balance_hook_primary_fuel");
+                               W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_hook_primary_fuel, FALSE);
                                self.hook_state |= HOOK_FIRING;
-                               weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready);                          
+                               weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hook_primary_animtime, w_ready);                         
                        }
                }
 
                if (self.BUTTON_ATCK2)
                {
-                       if (weapon_prepareattack(1, cvar("g_balance_hook_secondary_refire")))
+                       if (weapon_prepareattack(1, autocvar_g_balance_hook_secondary_refire))
                        {
                                W_Hook_Attack2();
-                               weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_hook_secondary_animtime"), w_ready);
+                               weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hook_secondary_animtime, w_ready);
                        }
                }
 
                if(self.hook)
                {
                        // if hooked, no bombs, and increase the timer
-                       self.hook_refire = max(self.hook_refire, time + cvar("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)
-                               self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_fuel_regen"));
+                               self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
                }
 
                if(self.hook && self.hook.state == 1)
                {
-                       hooked_time_max = cvar("g_balance_hook_primary_hooked_time_max");                       
+                       hooked_time_max = autocvar_g_balance_hook_primary_hooked_time_max;                      
                        if (hooked_time_max > 0)
                        {
                                if ( time > self.hook_time_hooked + hooked_time_max )
                                        self.hook_state |= HOOK_REMOVING;
                        }
                        
-                       hooked_fuel = cvar("g_balance_hook_primary_hooked_fuel");
+                       hooked_fuel = autocvar_g_balance_hook_primary_hooked_fuel;
                        if (hooked_fuel > 0)
                        {
                                if ( time > self.hook_time_fueldecrease )
@@ -168,7 +188,7 @@ float w_hook(float req)
                                        {
                                                if ( self.ammo_fuel >= (time - self.hook_time_fueldecrease) * hooked_fuel )
                                                {
-                                                       self.ammo_fuel -= (time - self.hook_time_fueldecrease) * hooked_fuel;
+                                                       W_DecreaseAmmo(ammo_fuel, (time - self.hook_time_fueldecrease) * hooked_fuel, FALSE);
                                                        self.hook_time_fueldecrease = time;
                                                        // decrease next frame again
                                                }
@@ -185,7 +205,7 @@ float w_hook(float req)
                else
                {
                        self.hook_time_hooked = time;                           
-                       self.hook_time_fueldecrease = time + cvar("g_balance_hook_primary_hooked_time_free");
+                       self.hook_time_fueldecrease = time + autocvar_g_balance_hook_primary_hooked_time_free;
                }
 
                if (self.BUTTON_CROUCH)
@@ -226,6 +246,7 @@ float w_hook(float req)
        else if (req == WR_SETUP)
        {
                weapon_setup(WEP_HOOK);
+               self.current_ammo = ammo_fuel;
                self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
        }
        else if (req == WR_CHECKAMMO1)
@@ -233,18 +254,18 @@ float w_hook(float req)
                if(self.hook)
                        return self.ammo_fuel > 0;
                else
-                       return self.ammo_fuel >= cvar("g_balance_hook_primary_fuel");
+                       return self.ammo_fuel >= autocvar_g_balance_hook_primary_fuel;
        }
        else if (req == WR_CHECKAMMO2)
        {
-               return self.ammo_cells >= cvar("g_balance_hook_secondary_ammo");
+               return self.ammo_cells >= autocvar_g_balance_hook_secondary_ammo;
        }
        else if (req == WR_RESETPLAYER)
        {
                self.hook_refire = time;
        }
        return TRUE;
-};
+}
 #endif
 #ifdef CSQC
 float w_hook(float req)
@@ -255,16 +276,16 @@ 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)
        {
                precache_sound("weapons/hookbomb_impact.wav");
        }
        else if (req == WR_SUICIDEMESSAGE)
-               w_deathtypestring = "%s did the impossible";
+               w_deathtypestring = _("%s did the impossible");
        else if (req == WR_KILLMESSAGE)
-               w_deathtypestring = "%s has run into %s's gravity bomb";
+               w_deathtypestring = _("%s was caught in %s's hook gravity bomb");
        return TRUE;
 }
 #endif