X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fhook.qc;h=7c4aabfe71e2b280e106bb4759cd893b81bf270d;hb=1a9e7607796f021c85d200ce66bdfb7f3932d882;hp=5af5a9ad1f95a84b0dd7414fc4250a8e5becd2f4;hpb=e0e847a336cdb7ab1fcb93d3cf3e1402b761a726;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 5af5a9ad1..7c4aabfe7 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -79,8 +79,8 @@ OffhandHook OFFHAND_HOOK; STATIC_INIT(OFFHAND_HOOK) { OFFHAND_HOOK = NEW(Offhand spawnfunc(weapon_hook) { weapon_defaultspawnfunc(this, WEP_HOOK); } -void W_Hook_ExplodeThink() -{SELFPARAM(); +void W_Hook_ExplodeThink(entity this) +{ float dt, dmg_remaining_next, f; dt = time - self.teleport_time; @@ -99,13 +99,13 @@ void W_Hook_ExplodeThink() remove(self); } -void W_Hook_Explode2() -{SELFPARAM(); +void W_Hook_Explode2(entity this) +{ self.event_damage = func_null; - self.touch = func_null; + settouch(self, func_null); self.effects |= EF_NODRAW; - self.think = W_Hook_ExplodeThink; + setthink(self, W_Hook_ExplodeThink); self.nextthink = time; self.dmg = WEP_CVAR_SEC(hook, damage); self.dmg_edge = WEP_CVAR_SEC(hook, edgedamage); @@ -118,6 +118,11 @@ void W_Hook_Explode2() self.movetype = MOVETYPE_NONE; } +void W_Hook_Explode2_use(entity this, entity actor, entity trigger) +{ + WITHSELF(this, W_Hook_Explode2(this)); +} + void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) { if(this.health <= 0) @@ -129,19 +134,19 @@ void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, this.health = this.health - damage; if(this.health <= 0) - WITH(entity, self, this, W_PrepareExplosionByDamage(this.realowner, W_Hook_Explode2)); + W_PrepareExplosionByDamage(this, this.realowner, W_Hook_Explode2); } -void W_Hook_Touch2() -{SELFPARAM(); - PROJECTILE_TOUCH; - self.use(); +void W_Hook_Touch2(entity this) +{ + PROJECTILE_TOUCH(this); + this.use(this, NULL, NULL); } 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)); + W_SetupShot(actor, false, 4, SND_HOOKBOMB_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hook, damage)); entity gren = new(hookbomb); gren.owner = gren.realowner = actor; @@ -154,9 +159,9 @@ void W_Hook_Attack2(Weapon thiswep, entity actor) setsize(gren, '0 0 0', '0 0 0'); gren.nextthink = time + WEP_CVAR_SEC(hook, lifetime); - gren.think = adaptor_think2use_hittype_splash; - gren.use = W_Hook_Explode2; - gren.touch = W_Hook_Touch2; + setthink(gren, adaptor_think2use_hittype_splash); + gren.use = W_Hook_Explode2_use; + settouch(gren, W_Hook_Touch2); gren.takedamage = DAMAGE_YES; gren.health = WEP_CVAR_SEC(hook, health); @@ -261,7 +266,7 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, { if (actor.hook) RemoveGrapplingHook(actor); - WITH(entity, self, actor, FireGrapplingHook()); + WITHSELF(actor, FireGrapplingHook()); actor.hook_state &= ~HOOK_FIRING; actor.hook_refire = max(actor.hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor()); } @@ -272,25 +277,27 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, actor.hook_state &= ~HOOK_REMOVING; } } -METHOD(Hook, wr_setup, void(entity thiswep)) +METHOD(Hook, wr_setup, void(entity thiswep, entity actor)) { + entity this = actor; self.hook_state &= ~HOOK_WAITING_FOR_RELEASE; } -METHOD(Hook, wr_checkammo1, bool(Hook thiswep)) +METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor)) { if (!thiswep.ammo_factor) return true; - if(self.hook) - return self.ammo_fuel > 0; + if(actor.hook) + return actor.ammo_fuel > 0; else - return self.ammo_fuel >= WEP_CVAR_PRI(hook, ammo); + return actor.ammo_fuel >= WEP_CVAR_PRI(hook, ammo); } -METHOD(Hook, wr_checkammo2, bool(Hook thiswep)) +METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor)) { // infinite ammo for now - return true; // self.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above + return true; // actor.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above } -METHOD(Hook, wr_resetplayer, void(entity thiswep)) +METHOD(Hook, wr_resetplayer, void(entity thiswep, entity actor)) { + entity this = actor; RemoveGrapplingHook(self); self.hook_time = 0; self.hook_refire = time; @@ -303,8 +310,9 @@ METHOD(Hook, wr_killmessage, Notification(entity thiswep)) #endif #ifdef CSQC -METHOD(Hook, wr_impacteffect, void(entity thiswep)) +METHOD(Hook, wr_impacteffect, void(entity thiswep, entity actor)) { + entity this = actor; vector org2; org2 = w_org + w_backoff * 2; pointparticles(EFFECT_HOOK_EXPLODE, org2, '0 0 0', 1); @@ -479,75 +487,80 @@ void Draw_GrapplingHook(entity this) void Remove_GrapplingHook(entity this) { sound (this, CH_SHOTS_SINGLE, SND_Null, VOL_BASE, ATTEN_NORM); + + if(csqcplayer && csqcplayer.hook == this) + csqcplayer.hook = NULL; } NET_HANDLE(ENT_CLIENT_HOOK, bool bIsNew) { - self.HookType = NET_ENT_CLIENT_HOOK; + this.HookType = NET_ENT_CLIENT_HOOK; int sf = ReadByte(); - self.HookSilent = (sf & 0x80); - self.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN; + this.HookSilent = (sf & 0x80); + this.iflags = IFLAG_VELOCITY | IFLAG_ORIGIN; - InterpolateOrigin_Undo(self); + InterpolateOrigin_Undo(this); if(sf & 1) { int myowner = ReadByte(); - self.owner = playerslots[myowner - 1]; - self.sv_entnum = myowner; - switch(self.HookType) + this.owner = playerslots[myowner - 1]; + this.sv_entnum = myowner; + if(csqcplayer && myowner == player_localentnum) + csqcplayer.hook = this; + switch(this.HookType) { default: case NET_ENT_CLIENT_HOOK: - self.HookRange = 0; + this.HookRange = 0; break; case NET_ENT_CLIENT_ARC_BEAM: - self.HookRange = ReadCoord(); + this.HookRange = ReadCoord(); break; } } if(sf & 2) { - self.origin_x = ReadCoord(); - self.origin_y = ReadCoord(); - self.origin_z = ReadCoord(); - setorigin(self, self.origin); + this.origin_x = ReadCoord(); + this.origin_y = ReadCoord(); + this.origin_z = ReadCoord(); + setorigin(this, this.origin); } if(sf & 4) { - self.velocity_x = ReadCoord(); - self.velocity_y = ReadCoord(); - self.velocity_z = ReadCoord(); + this.velocity_x = ReadCoord(); + this.velocity_y = ReadCoord(); + this.velocity_z = ReadCoord(); } InterpolateOrigin_Note(this); - if(bIsNew || !self.teleport_time) + if(bIsNew || !this.teleport_time) { - self.draw = Draw_GrapplingHook; - self.entremove = Remove_GrapplingHook; + this.draw = Draw_GrapplingHook; + this.entremove = Remove_GrapplingHook; - switch(self.HookType) + switch(this.HookType) { default: case NET_ENT_CLIENT_HOOK: // for the model - setmodel(self, MDL_HOOK); - self.drawmask = MASK_NORMAL; + setmodel(this, MDL_HOOK); + this.drawmask = MASK_NORMAL; break; case NET_ENT_CLIENT_ARC_BEAM: - sound (self, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM); + sound (this, CH_SHOTS_SINGLE, SND_LGBEAM_FLY, VOL_BASE, ATTEN_NORM); break; } } - self.teleport_time = time + 10; + this.teleport_time = time + 10; return true; } -// TODO: hook: temporarily transform self.origin for drawing the model along warpzones! +// TODO: hook: temporarily transform this.origin for drawing the model along warpzones! #endif #endif