X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fporto.qc;h=782cb0e3e8b34ba16be8c78304bb589af7fc5107;hp=ac9f759fc75954fd3988ae334ffeafcb03775f2c;hb=12150869d71c8ff952778108e82f665530d60778;hpb=3d4a324cc2e15c1eb99209674942506eb998e2ec diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index ac9f759fc..782cb0e3e 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -1,12 +1,13 @@ +#include "porto.qh" #ifndef IMPLEMENTATION CLASS(PortoLaunch, Weapon) -/* ammotype */ ATTRIB(PortoLaunch, ammo_field, .int, ammo_none) -/* impulse */ ATTRIB(PortoLaunch, impulse, int, 0) +/* ammotype */ ATTRIB(PortoLaunch, ammo_field, .int, ammo_none); +/* impulse */ ATTRIB(PortoLaunch, impulse, int, 0); /* flags */ ATTRIB(PortoLaunch, spawnflags, int, WEP_TYPE_OTHER | WEP_FLAG_SUPERWEAPON); /* rating */ ATTRIB(PortoLaunch, bot_pickupbasevalue, float, 0); /* color */ ATTRIB(PortoLaunch, wpcolor, vector, '0.5 0.5 0.5'); /* modelname */ ATTRIB(PortoLaunch, mdl, string, "porto"); -#ifndef MENUQC +#ifdef GAMEQC /* model */ ATTRIB(PortoLaunch, m_model, Model, MDL_PORTO_ITEM); #endif /* crosshair */ ATTRIB(PortoLaunch, w_crosshair, string, "gfx/crosshairporto"); @@ -55,22 +56,22 @@ MUTATOR_HOOKFUNCTION(porto_ticker, SV_StartFrame) { void W_Porto_Success(entity this) { - if(self.realowner == world) + 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; + delete(this); } -string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo); +string W_ThrowNewWeapon(entity own, float wpn, float doreduce, vector org, vector velo, .entity weaponentity); void W_Porto_Fail(entity this, float failhard) { - if(this.realowner == world) + if(this.realowner == NULL) { - objerror("Cannot fail successfully: no owner\n"); + objerror(this, "Cannot fail successfully: no owner\n"); return; } @@ -80,7 +81,7 @@ void W_Porto_Fail(entity this, float failhard) Portal_ClearWithID(this.realowner, this.portal_id); } - this.realowner.porto_current = world; + this.realowner.porto_current = NULL; if(this.cnt < 0 && !failhard && this.realowner.playerid == this.playerid && !IS_DEAD(this.realowner) && !(this.realowner.weapons & WEPSET(PORTO))) { @@ -89,49 +90,51 @@ void W_Porto_Fail(entity this, float failhard) if(move_out_of_solid(this)) { this.flags = FL_ITEM; + IL_PUSH(g_items, this); this.velocity = trigger_push_calculatevelocity(this.origin, this.realowner, 128); tracetoss(this, this); if(vdist(trace_endpos - this.realowner.origin, <, 128)) { - W_ThrowNewWeapon(this.realowner, WEP_PORTO.m_id, 0, this.origin, this.velocity); + .entity weaponentity = this.weaponentity_fld; + W_ThrowNewWeapon(this.realowner, WEP_PORTO.m_id, 0, this.origin, this.velocity, weaponentity); Send_Notification(NOTIF_ONE, this.realowner, MSG_CENTER, CENTER_PORTO_FAILED); } } } - remove(this); + delete(this); } void W_Porto_Remove(entity p) { if(p.porto_current.realowner == p && p.porto_current.classname == "porto") { - WITHSELF(p.porto_current, W_Porto_Fail(p.porto_current, 1)); + W_Porto_Fail(p.porto_current, 1); } } 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) + delete(this); else - W_Porto_Fail(self, 0); + W_Porto_Fail(this, 0); } -void W_Porto_Touch(entity this) +void W_Porto_Touch(entity this, entity toucher) { vector norm; // do not use PROJECTILE_TOUCH here // FIXME but DO handle warpzones! - if(other.classname == "portal") + if(toucher.classname == "portal") return; // handled by the portal 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,124 +143,125 @@ void W_Porto_Touch(entity this) 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); + delete(this); } - else if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SLICK || trace_dphitcontents & DPCONTENTS_PLAYERCLIP) + 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(self, 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(self); + 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(self, 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(self); + 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(self, 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(self, 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(self); + 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(self, 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(self, 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(entity actor, float type) -{entity this = actor; +void W_Porto_Attack(entity actor, .entity weaponentity, float type) +{ entity gren; - W_SetupShot(self, false, 4, SND_PORTO_FIRE, CH_WEAPON_A, 0); + W_SetupShot(actor, weaponentity, 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.weaponentity_fld = weaponentity; 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; + set_movetype(gren, MOVETYPE_BOUNCEMISSILE); PROJECTILE_MAKETRIGGER(gren); gren.effects = EF_RED; gren.scale = 4; @@ -268,17 +272,19 @@ void W_Porto_Attack(entity actor, float type) 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); gren.angles = vectoangles(gren.velocity); gren.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, gren); + IL_PUSH(g_bot_dodge, gren); 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 +295,16 @@ void W_Porto_Attack(entity actor, 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, entity actor)) { - entity this = actor; - 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 +315,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(actor, 0); + W_Porto_Attack(actor, weaponentity, 0); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); } @@ -319,7 +324,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(actor, 1); + W_Porto_Attack(actor, weaponentity, 1); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready); } } @@ -352,35 +357,29 @@ 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(actor, -1); + W_Porto_Attack(actor, weaponentity, -1); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); } } } -METHOD(PortoLaunch, wr_checkammo1, bool(entity thiswep, entity this)) +METHOD(PortoLaunch, wr_checkammo1, bool(entity thiswep, entity this, .entity weaponentity)) { // always allow infinite ammo return true; } -METHOD(PortoLaunch, wr_checkammo2, bool(entity thiswep, entity this)) +METHOD(PortoLaunch, wr_checkammo2, bool(entity thiswep, entity this, .entity weaponentity)) { // always allow infinite ammo return true; } -METHOD(PortoLaunch, wr_setup, void(entity thiswep, entity actor)) -{ - entity this = actor; - self.ammo_field = ammo_none; -} METHOD(PortoLaunch, wr_resetplayer, void(entity thiswep, entity actor)) { - entity this = actor; - self.porto_current = world; + actor.porto_current = NULL; } #endif #ifdef CSQC METHOD(PortoLaunch, wr_impacteffect, void(entity this, entity actor)) { - LOG_WARNING("Since when does Porto send DamageInfo?\n"); + LOG_WARN("Since when does Porto send DamageInfo?"); } #endif #endif