X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fporto.qc;h=3b047dc8c9d017ee2de7790a85ef1b3e6feb3be4;hb=b9671f63469586007314131f3f53728795c035cd;hp=b9488889ddf69c81d639e522905c6906d8685c3f;hpb=834fed09016056ff2cd32d1980f0719d09c403a2;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index b9488889d..3b047dc8c 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -53,73 +53,73 @@ MUTATOR_HOOKFUNCTION(porto_ticker, SV_StartFrame) { FOREACH_CLIENT(IS_PLAYER(it), it.porto_forbidden = max(0, it.porto_forbidden - 1)); } -void W_Porto_Success() -{SELFPARAM(); - if(self.realowner == world) +void W_Porto_Success(entity this) +{ + if(this.realowner == NULL) { - objerror("Cannot succeed successfully: no owner\n"); + objerror(this, "Cannot succeed successfully: no owner\n"); return; } - self.realowner.porto_current = world; - remove(self); + this.realowner.porto_current = NULL; + remove(this); } string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo); -void W_Porto_Fail(float failhard) -{SELFPARAM(); - if(self.realowner == world) +void W_Porto_Fail(entity this, float failhard) +{ + if(this.realowner == NULL) { - objerror("Cannot fail successfully: no owner\n"); + objerror(this, "Cannot fail successfully: no owner\n"); return; } // no portals here! - if(self.cnt < 0) + if(this.cnt < 0) { - Portal_ClearWithID(self.realowner, self.portal_id); + Portal_ClearWithID(this.realowner, this.portal_id); } - self.realowner.porto_current = world; + this.realowner.porto_current = NULL; - if(self.cnt < 0 && !failhard && self.realowner.playerid == self.playerid && !IS_DEAD(self.realowner) && !(self.realowner.weapons & WEPSET(PORTO))) + if(this.cnt < 0 && !failhard && this.realowner.playerid == this.playerid && !IS_DEAD(this.realowner) && !(this.realowner.weapons & WEPSET(PORTO))) { - setsize(self, '-16 -16 0', '16 16 32'); - setorigin(self, self.origin + trace_plane_normal); - if(move_out_of_solid(self)) + setsize(this, '-16 -16 0', '16 16 32'); + setorigin(this, this.origin + trace_plane_normal); + if(move_out_of_solid(this)) { - self.flags = FL_ITEM; - self.velocity = trigger_push_calculatevelocity(self.origin, self.realowner, 128); - tracetoss(self, self); - if(vdist(trace_endpos - self.realowner.origin, <, 128)) + this.flags = FL_ITEM; + this.velocity = trigger_push_calculatevelocity(this.origin, this.realowner, 128); + tracetoss(this, this); + if(vdist(trace_endpos - this.realowner.origin, <, 128)) { - W_ThrowNewWeapon(self.realowner, WEP_PORTO.m_id, 0, self.origin, self.velocity); - Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_FAILED); + W_ThrowNewWeapon(this.realowner, WEP_PORTO.m_id, 0, this.origin, this.velocity); + Send_Notification(NOTIF_ONE, this.realowner, MSG_CENTER, CENTER_PORTO_FAILED); } } } - remove(self); + remove(this); } void W_Porto_Remove(entity p) -{SELFPARAM(); +{ if(p.porto_current.realowner == p && p.porto_current.classname == "porto") { - WITHSELF(p.porto_current, W_Porto_Fail(1)); + W_Porto_Fail(p.porto_current, 1); } } -void W_Porto_Think() -{SELFPARAM(); +void W_Porto_Think(entity this) +{ trace_plane_normal = '0 0 0'; - if(self.realowner.playerid != self.playerid) - remove(self); + if(this.realowner.playerid != this.playerid) + remove(this); else - W_Porto_Fail(0); + W_Porto_Fail(this, 0); } -void W_Porto_Touch() -{SELFPARAM(); +void W_Porto_Touch(entity this) +{ vector norm; // do not use PROJECTILE_TOUCH here @@ -131,7 +131,7 @@ void W_Porto_Touch() norm = trace_plane_normal; if(trace_ent.iscreature) { - traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * STAT(PL_MIN, NULL).z, MOVE_WORLDONLY, self); + traceline(trace_ent.origin, trace_ent.origin + '0 0 2' * STAT(PL_MIN, NULL).z, MOVE_WORLDONLY, this); if(trace_fraction >= 1) return; if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP) @@ -140,121 +140,121 @@ void W_Porto_Touch() return; } - if(self.realowner.playerid != self.playerid) + if(this.realowner.playerid != this.playerid) { - sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); - remove(self); + sound(this, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); + remove(this); } else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP) { - spamsound(self, CH_SHOTS, SND(PORTO_BOUNCE), VOL_BASE, ATTEN_NORM); + spamsound(this, CH_SHOTS, SND(PORTO_BOUNCE), VOL_BASE, ATTEN_NORM); // just reflect - self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * trace_plane_normal); - self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * trace_plane_normal)); + this.right_vector = this.right_vector - 2 * trace_plane_normal * (this.right_vector * trace_plane_normal); + this.angles = vectoangles(this.velocity - 2 * trace_plane_normal * (this.velocity * trace_plane_normal)); } else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT) { - sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); - W_Porto_Fail(0); - if(self.cnt < 0) - Portal_ClearAll_PortalsOnly(self.realowner); + sound(this, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); + W_Porto_Fail(this, 0); + if(this.cnt < 0) + Portal_ClearAll_PortalsOnly(this.realowner); } - else if(self.cnt == 0) + else if(this.cnt == 0) { // in-portal only - if(Portal_SpawnInPortalAtTrace(self.realowner, self.right_vector, self.portal_id)) + if(Portal_SpawnInPortalAtTrace(this.realowner, this.right_vector, this.portal_id)) { - sound(self, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM); + sound(this, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM); trace_plane_normal = norm; - Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_IN); - W_Porto_Success(); + Send_Notification(NOTIF_ONE, this.realowner, MSG_CENTER, CENTER_PORTO_CREATED_IN); + W_Porto_Success(this); } else { - sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); + sound(this, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); trace_plane_normal = norm; - W_Porto_Fail(0); + W_Porto_Fail(this, 0); } } - else if(self.cnt == 1) + else if(this.cnt == 1) { // out-portal only - if(Portal_SpawnOutPortalAtTrace(self.realowner, self.right_vector, self.portal_id)) + if(Portal_SpawnOutPortalAtTrace(this.realowner, this.right_vector, this.portal_id)) { - sound(self, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM); + sound(this, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM); trace_plane_normal = norm; - Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT); - W_Porto_Success(); + Send_Notification(NOTIF_ONE, this.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT); + W_Porto_Success(this); } else { - sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); + sound(this, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); trace_plane_normal = norm; - W_Porto_Fail(0); + W_Porto_Fail(this, 0); } } - else if(self.effects & EF_RED) + else if(this.effects & EF_RED) { - self.effects += EF_BLUE - EF_RED; - if(Portal_SpawnInPortalAtTrace(self.realowner, self.right_vector, self.portal_id)) + this.effects += EF_BLUE - EF_RED; + if(Portal_SpawnInPortalAtTrace(this.realowner, this.right_vector, this.portal_id)) { - sound(self, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM); + sound(this, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM); trace_plane_normal = norm; - Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_IN); - self.right_vector = self.right_vector - 2 * trace_plane_normal * (self.right_vector * norm); - self.angles = vectoangles(self.velocity - 2 * trace_plane_normal * (self.velocity * norm)); - CSQCProjectile(self, true, PROJECTILE_PORTO_BLUE, true); // change type + Send_Notification(NOTIF_ONE, this.realowner, MSG_CENTER, CENTER_PORTO_CREATED_IN); + this.right_vector = this.right_vector - 2 * trace_plane_normal * (this.right_vector * norm); + this.angles = vectoangles(this.velocity - 2 * trace_plane_normal * (this.velocity * norm)); + CSQCProjectile(this, true, PROJECTILE_PORTO_BLUE, true); // change type } else { - sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); + sound(this, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); trace_plane_normal = norm; - Portal_ClearAll_PortalsOnly(self.realowner); - W_Porto_Fail(0); + Portal_ClearAll_PortalsOnly(this.realowner); + W_Porto_Fail(this, 0); } } else { - if(self.realowner.portal_in.portal_id == self.portal_id) + if(this.realowner.portal_in.portal_id == this.portal_id) { - if(Portal_SpawnOutPortalAtTrace(self.realowner, self.right_vector, self.portal_id)) + if(Portal_SpawnOutPortalAtTrace(this.realowner, this.right_vector, this.portal_id)) { - sound(self, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM); + sound(this, CH_SHOTS, SND_PORTO_CREATE, VOL_BASE, ATTEN_NORM); trace_plane_normal = norm; - Send_Notification(NOTIF_ONE, self.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT); - W_Porto_Success(); + Send_Notification(NOTIF_ONE, this.realowner, MSG_CENTER, CENTER_PORTO_CREATED_OUT); + W_Porto_Success(this); } else { - sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); - Portal_ClearAll_PortalsOnly(self.realowner); - W_Porto_Fail(0); + sound(this, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); + Portal_ClearAll_PortalsOnly(this.realowner); + W_Porto_Fail(this, 0); } } else { - sound(self, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); - Portal_ClearAll_PortalsOnly(self.realowner); - W_Porto_Fail(0); + sound(this, CH_SHOTS, SND_PORTO_UNSUPPORTED, VOL_BASE, ATTEN_NORM); + Portal_ClearAll_PortalsOnly(this.realowner); + W_Porto_Fail(this, 0); } } } -void W_Porto_Attack(float type) -{SELFPARAM(); +void W_Porto_Attack(entity actor, float type) +{ entity gren; - W_SetupShot(self, false, 4, SND_PORTO_FIRE, CH_WEAPON_A, 0); + W_SetupShot(actor, false, 4, SND_PORTO_FIRE, CH_WEAPON_A, 0); // always shoot from the eye w_shotdir = v_forward; - w_shotorg = self.origin + self.view_ofs + ((w_shotorg - self.origin - self.view_ofs) * v_forward) * v_forward; + w_shotorg = actor.origin + actor.view_ofs + ((w_shotorg - actor.origin - actor.view_ofs) * v_forward) * v_forward; //Send_Effect(EFFECT_GRENADE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); gren = new(porto); gren.cnt = type; - gren.owner = gren.realowner = self; - gren.playerid = self.playerid; + gren.owner = gren.realowner = actor; + gren.playerid = actor.playerid; gren.bot_dodge = true; gren.bot_dodgerating = 200; gren.movetype = MOVETYPE_BOUNCEMISSILE; @@ -265,10 +265,10 @@ void W_Porto_Attack(float type) setsize(gren, '0 0 0', '0 0 0'); gren.nextthink = time + WEP_CVAR_BOTH(porto, (type <= 0), lifetime); - gren.think = W_Porto_Think; - gren.touch = W_Porto_Touch; + setthink(gren, W_Porto_Think); + settouch(gren, W_Porto_Touch); - if(self.items & ITEM_Strength.m_itemid) + if(actor.items & ITEM_Strength.m_itemid) W_SetupProjVelocity_Basic(gren, WEP_CVAR_BOTH(porto, (type <= 0), speed) * autocvar_g_balance_powerup_strength_force, 0); else W_SetupProjVelocity_Basic(gren, WEP_CVAR_BOTH(porto, (type <= 0), speed), 0); @@ -277,8 +277,8 @@ void W_Porto_Attack(float type) gren.flags = FL_PROJECTILE; gren.portal_id = time; - self.porto_current = gren; - gren.playerid = self.playerid; + actor.porto_current = gren; + gren.playerid = actor.playerid; fixedmakevectors(fixedvectoangles(gren.velocity)); gren.right_vector = v_right; @@ -289,17 +289,16 @@ void W_Porto_Attack(float type) else CSQCProjectile(gren, true, PROJECTILE_PORTO_RED, true); - MUTATOR_CALLHOOK(EditProjectile, self, gren); + MUTATOR_CALLHOOK(EditProjectile, actor, gren); } -METHOD(PortoLaunch, wr_aim, void(entity thiswep)) +METHOD(PortoLaunch, wr_aim, void(entity thiswep, entity actor)) { - SELFPARAM(); - PHYS_INPUT_BUTTON_ATCK(self) = false; - PHYS_INPUT_BUTTON_ATCK2(self) = false; + PHYS_INPUT_BUTTON_ATCK(actor) = false; + PHYS_INPUT_BUTTON_ATCK2(actor) = false; if(!WEP_CVAR(porto, secondary)) - if(bot_aim(self, WEP_CVAR_PRI(porto, speed), 0, WEP_CVAR_PRI(porto, lifetime), false)) - PHYS_INPUT_BUTTON_ATCK(self) = true; + if(bot_aim(actor, WEP_CVAR_PRI(porto, speed), 0, WEP_CVAR_PRI(porto, lifetime), false)) + PHYS_INPUT_BUTTON_ATCK(actor) = true; } METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { @@ -310,7 +309,7 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone if(!actor.porto_forbidden) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire))) { - W_Porto_Attack(0); + W_Porto_Attack(actor, 0); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); } @@ -319,7 +318,7 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone if(!actor.porto_forbidden) if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(porto, refire))) { - W_Porto_Attack(1); + W_Porto_Attack(actor, 1); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready); } } @@ -352,34 +351,32 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone if(!actor.porto_forbidden) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(porto, refire))) { - W_Porto_Attack(-1); + W_Porto_Attack(actor, -1); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); } } } -METHOD(PortoLaunch, wr_checkammo1, bool(entity this)) +METHOD(PortoLaunch, wr_checkammo1, bool(entity thiswep, entity this)) { // always allow infinite ammo return true; } -METHOD(PortoLaunch, wr_checkammo2, bool(entity this)) +METHOD(PortoLaunch, wr_checkammo2, bool(entity thiswep, entity this)) { // always allow infinite ammo return true; } -METHOD(PortoLaunch, wr_setup, void(entity thiswep)) +METHOD(PortoLaunch, wr_setup, void(entity thiswep, entity actor)) { - SELFPARAM(); - self.ammo_field = ammo_none; + actor.ammo_field = ammo_none; } -METHOD(PortoLaunch, wr_resetplayer, void(entity thiswep)) +METHOD(PortoLaunch, wr_resetplayer, void(entity thiswep, entity actor)) { - SELFPARAM(); - self.porto_current = world; + actor.porto_current = NULL; } #endif #ifdef CSQC -METHOD(PortoLaunch, wr_impacteffect, void(entity this)) { +METHOD(PortoLaunch, wr_impacteffect, void(entity this, entity actor)) { LOG_WARNING("Since when does Porto send DamageInfo?\n"); } #endif