X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fhook.qc;h=ba7efe6a31a33384e1c1b0cbcb0a535e6ca72b99;hb=7c8f38e643c87bf9c02c2265ca43714c57ebe331;hp=da14caac9dd01ed611ed847a919fd7f799084764;hpb=f438b415278f56c0cf86e2018b45fb3e6972259c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index da14caac9..ba7efe6a3 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -1,12 +1,13 @@ +#include "hook.qh" #ifndef IMPLEMENTATION CLASS(Hook, Weapon) -/* ammotype */ ATTRIB(Hook, ammo_field, .int, ammo_fuel) -/* impulse */ ATTRIB(Hook, impulse, int, 0) +/* ammotype */ ATTRIB(Hook, ammo_field, .int, ammo_fuel); +/* impulse */ ATTRIB(Hook, impulse, int, 0); /* flags */ ATTRIB(Hook, spawnflags, int, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); /* rating */ ATTRIB(Hook, bot_pickupbasevalue, float, 0); /* color */ ATTRIB(Hook, wpcolor, vector, '0 0.5 0'); /* modelname */ ATTRIB(Hook, mdl, string, "hookgun"); -#ifndef MENUQC +#ifdef GAMEQC /* model */ ATTRIB(Hook, m_model, Model, MDL_HOOK_ITEM); #endif /* crosshair */ ATTRIB(Hook, w_crosshair, string, "gfx/crosshairhook"); @@ -14,7 +15,7 @@ CLASS(Hook, Weapon) /* wepimg */ ATTRIB(Hook, model2, string, "weaponhook"); /* refname */ ATTRIB(Hook, netname, string, "hook"); /* wepname */ ATTRIB(Hook, m_name, string, _("Grappling Hook")); - ATTRIB(Hook, ammo_factor, float, 1) + ATTRIB(Hook, ammo_factor, float, 1); #define X(BEGIN, P, END, class, prefix) \ BEGIN(class) \ @@ -79,48 +80,48 @@ 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; - dmg_remaining_next = pow(bound(0, 1 - dt / self.dmg_duration, 1), self.dmg_power); + dt = time - this.teleport_time; + dmg_remaining_next = pow(bound(0, 1 - dt / this.dmg_duration, 1), this.dmg_power); - f = self.dmg_last - dmg_remaining_next; - self.dmg_last = dmg_remaining_next; + f = this.dmg_last - dmg_remaining_next; + this.dmg_last = dmg_remaining_next; - RadiusDamage(self, self.realowner, self.dmg * f, self.dmg_edge * f, self.dmg_radius, self.realowner, world, 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, world, self.dmg_force * f, self.projectiledeathtype, world); + RadiusDamage(this, this.realowner, this.dmg * f, this.dmg_edge * f, this.dmg_radius, this.realowner, NULL, this.dmg_force * f, this.projectiledeathtype, NULL); + this.projectiledeathtype |= HITTYPE_BOUNCE; + //RadiusDamage(this, NULL, this.dmg * f, this.dmg_edge * f, this.dmg_radius, NULL, NULL, this.dmg_force * f, this.projectiledeathtype, NULL); - if(dt < self.dmg_duration) - self.nextthink = time + 0.05; // soon + if(dt < this.dmg_duration) + this.nextthink = time + 0.05; // soon else - remove(self); + delete(this); } -void W_Hook_Explode2() -{SELFPARAM(); - self.event_damage = func_null; - self.touch = func_null; - self.effects |= EF_NODRAW; - - self.think = W_Hook_ExplodeThink; - self.nextthink = time; - self.dmg = WEP_CVAR_SEC(hook, damage); - self.dmg_edge = WEP_CVAR_SEC(hook, edgedamage); - self.dmg_radius = WEP_CVAR_SEC(hook, radius); - self.dmg_force = WEP_CVAR_SEC(hook, force); - self.dmg_power = WEP_CVAR_SEC(hook, power); - self.dmg_duration = WEP_CVAR_SEC(hook, duration); - self.teleport_time = time; - self.dmg_last = 1; - self.movetype = MOVETYPE_NONE; +void W_Hook_Explode2(entity this) +{ + this.event_damage = func_null; + settouch(this, func_null); + this.effects |= EF_NODRAW; + + setthink(this, W_Hook_ExplodeThink); + this.nextthink = time; + this.dmg = WEP_CVAR_SEC(hook, damage); + this.dmg_edge = WEP_CVAR_SEC(hook, edgedamage); + this.dmg_radius = WEP_CVAR_SEC(hook, radius); + this.dmg_force = WEP_CVAR_SEC(hook, force); + this.dmg_power = WEP_CVAR_SEC(hook, power); + this.dmg_duration = WEP_CVAR_SEC(hook, duration); + this.teleport_time = time; + this.dmg_last = 1; + set_movetype(this, MOVETYPE_NONE); } void W_Hook_Explode2_use(entity this, entity actor, entity trigger) { - WITHSELF(this, W_Hook_Explode2()); + W_Hook_Explode2(this); } void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) @@ -137,31 +138,31 @@ void W_Hook_Damage(entity this, entity inflictor, entity attacker, float damage, W_PrepareExplosionByDamage(this, this.realowner, W_Hook_Explode2); } -void W_Hook_Touch2() -{SELFPARAM(); - PROJECTILE_TOUCH; - this.use1(this, NULL, NULL); +void W_Hook_Touch2(entity this, entity toucher) +{ + PROJECTILE_TOUCH(this, toucher); + this.use(this, NULL, NULL); } -void W_Hook_Attack2(Weapon thiswep, entity actor) +void W_Hook_Attack2(Weapon thiswep, entity actor, .entity weaponentity) { //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, weaponentity, false, 4, SND_HOOKBOMB_FIRE, CH_WEAPON_A, WEP_CVAR_SEC(hook, damage)); 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; + set_movetype(gren, MOVETYPE_TOSS); PROJECTILE_MAKETRIGGER(gren); gren.projectiledeathtype = WEP_HOOK.m_id | HITTYPE_SECONDARY; setorigin(gren, w_shotorg); setsize(gren, '0 0 0', '0 0 0'); gren.nextthink = time + WEP_CVAR_SEC(hook, lifetime); - gren.think = adaptor_think2use_hittype_splash; - gren.use1 = W_Hook_Explode2_use; - 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); @@ -179,6 +180,8 @@ void W_Hook_Attack2(Weapon thiswep, entity actor) gren.angles = '0 0 0'; gren.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, gren); + IL_PUSH(g_bot_dodge, gren); CSQCProjectile(gren, true, PROJECTILE_HOOKBOMB, true); @@ -187,7 +190,6 @@ void W_Hook_Attack2(Weapon thiswep, entity actor) METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { - SELFPARAM(); if (fire & 1) { if(!actor.hook) if(!(actor.hook_state & HOOK_WAITING_FOR_RELEASE)) @@ -208,7 +210,7 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, { if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(hook, refire))) { - W_Hook_Attack2(thiswep, actor); + W_Hook_Attack2(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready); } } @@ -216,7 +218,7 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, if(actor.hook) { // if hooked, no bombs, and increase the timer - actor.hook_refire = max(actor.hook_refire, time + WEP_CVAR_PRI(hook, refire) * W_WeaponRateFactor()); + actor.hook_refire = max(actor.hook_refire, time + WEP_CVAR_PRI(hook, refire) * W_WeaponRateFactor(actor)); // hook also inhibits health regeneration, but only for 1 second if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) @@ -267,9 +269,9 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, { if (actor.hook) RemoveGrapplingHook(actor); - WITHSELF(actor, FireGrapplingHook()); + FireGrapplingHook(actor); actor.hook_state &= ~HOOK_FIRING; - actor.hook_refire = max(actor.hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor()); + actor.hook_refire = max(actor.hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor(actor)); } else if (actor.hook_state & HOOK_REMOVING) { @@ -278,31 +280,28 @@ 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)) { - SELFPARAM(); - self.hook_state &= ~HOOK_WAITING_FOR_RELEASE; + actor.hook_state &= ~HOOK_WAITING_FOR_RELEASE; } -METHOD(Hook, wr_checkammo1, bool(Hook thiswep)) +METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor)) { - SELFPARAM(); 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)) { - SELFPARAM(); - RemoveGrapplingHook(self); - self.hook_time = 0; - self.hook_refire = time; + RemoveGrapplingHook(actor); + actor.hook_time = 0; + actor.hook_refire = time; } METHOD(Hook, wr_killmessage, Notification(entity thiswep)) { @@ -312,14 +311,13 @@ 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)) { - SELFPARAM(); vector org2; org2 = w_org + w_backoff * 2; pointparticles(EFFECT_HOOK_EXPLODE, org2, '0 0 0', 1); if(!w_issilent) - sound(self, CH_SHOTS, SND_HOOKBOMB_IMPACT, VOL_BASE, ATTN_NORM); + sound(actor, CH_SHOTS, SND_HOOKBOMB_IMPACT, VOL_BASE, ATTN_NORM); } #endif @@ -372,7 +370,7 @@ void Draw_GrapplingHook(entity this) InterpolateOrigin_Do(this); - int s = W_GetGunAlignment(world); + int s = W_GetGunAlignment(NULL); switch(this.HookType) { @@ -385,13 +383,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: @@ -399,7 +400,7 @@ void Draw_GrapplingHook(entity this) b = view_origin + view_forward * this.HookRange; else b = view_origin + view_forward * vlen(this.velocity - this.origin); // honor original length of beam! - WarpZone_TraceLine(view_origin, b, MOVE_NORMAL, world); + WarpZone_TraceLine(view_origin, b, MOVE_NORMAL, NULL); b = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos); a = view_origin + view_forward * vs.x + view_right * -vs.y + view_up * vs.z; break; @@ -446,11 +447,15 @@ void Draw_GrapplingHook(entity this) break; } + MUTATOR_CALLHOOK(DrawGrapplingHook, this, tex, rgb, t); + tex = M_ARGV(1, string); + rgb = M_ARGV(2, vector); + Draw_GrapplingHook_trace_callback_tex = tex; Draw_GrapplingHook_trace_callback_rnd = offset; Draw_GrapplingHook_trace_callback_rgb = rgb; Draw_GrapplingHook_trace_callback_a = intensity; - WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, ((this.HookType == NET_ENT_CLIENT_HOOK) ? MOVE_NOTHING : MOVE_NORMAL), world, world, Draw_GrapplingHook_trace_callback); + WarpZone_TraceBox_ThroughZone(a, '0 0 0', '0 0 0', b, ((this.HookType == NET_ENT_CLIENT_HOOK) ? MOVE_NOTHING : MOVE_NORMAL), NULL, NULL, Draw_GrapplingHook_trace_callback); Draw_GrapplingHook_trace_callback_tex = string_null; atrans = WarpZone_TransformOrigin(WarpZone_trace_transform, a); @@ -496,73 +501,74 @@ void Remove_GrapplingHook(entity this) 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; + this.owner = playerslots[myowner - 1]; + this.sv_entnum = myowner; if(csqcplayer && myowner == player_localentnum) - csqcplayer.hook = self; - switch(self.HookType) + 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; + IL_PUSH(g_drawables, this); + 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