From: TimePath <andrew.hardaker1995@gmail.com>
Date: Mon, 5 Oct 2015 09:07:44 +0000 (+1100)
Subject: Hook: fix hookbomb ownership
X-Git-Tag: xonotic-v0.8.2~1874^2~8
X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=d0fd6131acd3139526c1a393a17224d5a32e7b36;p=xonotic%2Fxonotic-data.pk3dir.git

Hook: fix hookbomb ownership
---

diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc
index 9d5eb29ec8..48fdb6508e 100644
--- a/qcsrc/common/weapons/weapon/hook.qc
+++ b/qcsrc/common/weapons/weapon/hook.qc
@@ -131,16 +131,13 @@ void W_Hook_Touch2(void)
 	self.use();
 }
 
-void W_Hook_Attack2(Weapon thiswep)
-{SELFPARAM();
-	entity gren;
-
-	//W_DecreaseAmmo(thiswep, self, WEP_CVAR_SEC(hook, ammo)); // WEAPONTODO: Figure out how to handle ammo with hook secondary (gravitybomb)
-	W_SetupShot(self, false, 4, SND(HOOKBOMB_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(hook, damage));
+void W_Hook_Attack2(Weapon thiswep, entity actor)
+{
+	//W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hook, ammo)); // WEAPONTODO: Figure out how to handle ammo with hook secondary (gravitybomb)
+	W_SetupShot(actor, false, 4, SND(HOOKBOMB_FIRE), CH_WEAPON_A, WEP_CVAR_SEC(hook, damage));
 
-	gren = spawn();
-	gren.owner = gren.realowner = self;
-	gren.classname = "hookbomb";
+	entity gren = new(hookbomb);
+	gren.owner = gren.realowner = actor;
 	gren.bot_dodge = true;
 	gren.bot_dodgerating = WEP_CVAR_SEC(hook, damage);
 	gren.movetype = MOVETYPE_TOSS;
@@ -162,8 +159,8 @@ void W_Hook_Attack2(Weapon thiswep)
 	gren.missile_flags = MIF_SPLASH | MIF_ARC;
 
 	gren.velocity = '0 0 1' * WEP_CVAR_SEC(hook, speed);
-	if(autocvar_g_projectiles_newton_style)
-		gren.velocity = gren.velocity + self.velocity;
+	if (autocvar_g_projectiles_newton_style)
+		gren.velocity = gren.velocity + actor.velocity;
 
 	gren.gravity = WEP_CVAR_SEC(hook, gravity);
 	//W_SetupProjVelocity_Basic(gren); // just falling down!
@@ -173,7 +170,7 @@ void W_Hook_Attack2(Weapon thiswep)
 
 	CSQCProjectile(gren, true, PROJECTILE_HOOKBOMB, true);
 
-	MUTATOR_CALLHOOK(EditProjectile, self, gren);
+	MUTATOR_CALLHOOK(EditProjectile, actor, gren);
 }
 
 		METHOD(Hook, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
@@ -196,7 +193,7 @@ void W_Hook_Attack2(Weapon thiswep)
 			{
 				if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(hook, refire)))
 				{
-					W_Hook_Attack2(thiswep);
+					W_Hook_Attack2(thiswep, actor);
 					weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready);
 				}
 			}