X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fseeker.qc;h=0f0c426eccac166645dced19d330f71452d14ebb;hp=0e73adf2d3bd23da383640b9b6f875851ddeb150;hb=9e8ea75b9aacffc5cfa18c8852c4dd9ffdbd3192;hpb=530e29e1a8395e12b8b8b44ac1030a84546eb903 diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 0e73adf2d3..0f0c426ecc 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -1,96 +1,6 @@ #include "seeker.qh" -#ifndef IMPLEMENTATION -CLASS(Seeker, Weapon) -/* ammotype */ ATTRIB(Seeker, ammo_field, .int, ammo_rockets); -/* impulse */ ATTRIB(Seeker, impulse, int, 8); -/* flags */ ATTRIB(Seeker, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH); -/* rating */ ATTRIB(Seeker, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH); -/* color */ ATTRIB(Seeker, wpcolor, vector, '0.5 1 0'); -/* modelname */ ATTRIB(Seeker, mdl, string, "seeker"); -#ifdef GAMEQC -/* model */ ATTRIB(Seeker, m_model, Model, MDL_SEEKER_ITEM); -#endif -/* crosshair */ ATTRIB(Seeker, w_crosshair, string, "gfx/crosshairseeker"); -/* crosshair */ ATTRIB(Seeker, w_crosshair_size, float, 0.8); -/* wepimg */ ATTRIB(Seeker, model2, string, "weaponseeker"); -/* refname */ ATTRIB(Seeker, netname, string, "seeker"); -/* wepname */ ATTRIB(Seeker, m_name, string, _("T.A.G. Seeker")); - -#define X(BEGIN, P, END, class, prefix) \ - BEGIN(class) \ - P(class, prefix, flac_ammo, float, NONE) \ - P(class, prefix, flac_animtime, float, NONE) \ - P(class, prefix, flac_damage, float, NONE) \ - P(class, prefix, flac_edgedamage, float, NONE) \ - P(class, prefix, flac_force, float, NONE) \ - P(class, prefix, flac_lifetime, float, NONE) \ - P(class, prefix, flac_lifetime_rand, float, NONE) \ - P(class, prefix, flac_radius, float, NONE) \ - P(class, prefix, flac_refire, float, NONE) \ - P(class, prefix, flac_speed, float, NONE) \ - P(class, prefix, flac_speed_up, float, NONE) \ - P(class, prefix, flac_speed_z, float, NONE) \ - P(class, prefix, flac_spread, float, NONE) \ - P(class, prefix, missile_accel, float, NONE) \ - P(class, prefix, missile_ammo, float, NONE) \ - P(class, prefix, missile_animtime, float, NONE) \ - P(class, prefix, missile_count, float, NONE) \ - P(class, prefix, missile_damageforcescale, float, NONE) \ - P(class, prefix, missile_damage, float, NONE) \ - P(class, prefix, missile_decel, float, NONE) \ - P(class, prefix, missile_delay, float, NONE) \ - P(class, prefix, missile_edgedamage, float, NONE) \ - P(class, prefix, missile_force, float, NONE) \ - P(class, prefix, missile_health, float, NONE) \ - P(class, prefix, missile_lifetime, float, NONE) \ - P(class, prefix, missile_proxy, float, NONE) \ - P(class, prefix, missile_proxy_delay, float, NONE) \ - P(class, prefix, missile_proxy_maxrange, float, NONE) \ - P(class, prefix, missile_radius, float, NONE) \ - P(class, prefix, missile_refire, float, NONE) \ - P(class, prefix, missile_smart, float, NONE) \ - P(class, prefix, missile_smart_mindist, float, NONE) \ - P(class, prefix, missile_smart_trace_max, float, NONE) \ - P(class, prefix, missile_smart_trace_min, float, NONE) \ - P(class, prefix, missile_speed, float, NONE) \ - P(class, prefix, missile_speed_max, float, NONE) \ - P(class, prefix, missile_speed_up, float, NONE) \ - P(class, prefix, missile_speed_z, float, NONE) \ - P(class, prefix, missile_spread, float, NONE) \ - P(class, prefix, missile_turnrate, float, NONE) \ - P(class, prefix, reload_ammo, float, NONE) \ - P(class, prefix, reload_time, float, NONE) \ - P(class, prefix, switchdelay_drop, float, NONE) \ - P(class, prefix, switchdelay_raise, float, NONE) \ - P(class, prefix, tag_ammo, float, NONE) \ - P(class, prefix, tag_animtime, float, NONE) \ - P(class, prefix, tag_damageforcescale, float, NONE) \ - P(class, prefix, tag_health, float, NONE) \ - P(class, prefix, tag_lifetime, float, NONE) \ - P(class, prefix, tag_refire, float, NONE) \ - P(class, prefix, tag_speed, float, NONE) \ - P(class, prefix, tag_spread, float, NONE) \ - P(class, prefix, tag_tracker_lifetime, float, NONE) \ - P(class, prefix, type, float, NONE) \ - P(class, prefix, weaponreplace, string, NONE) \ - P(class, prefix, weaponstartoverride, float, NONE) \ - P(class, prefix, weaponstart, float, NONE) \ - P(class, prefix, weaponthrowable, float, NONE) \ - END() - W_PROPS(X, Seeker, seeker) -#undef X -ENDCLASS(Seeker) -REGISTER_WEAPON(SEEKER, seeker, NEW(Seeker)); - #ifdef SVQC -.entity tag_target, wps_tag_tracker; -.float tag_time; -#endif -#endif -#ifdef IMPLEMENTATION -#ifdef SVQC -spawnfunc(weapon_seeker) { weapon_defaultspawnfunc(this, WEP_SEEKER); } // ============================ // Begin: Missile functions, these are general functions to be manipulated by other code @@ -98,7 +8,7 @@ spawnfunc(weapon_seeker) { weapon_defaultspawnfunc(this, WEP_SEEKER); } void W_Seeker_Missile_Explode(entity this, entity directhitentity) { this.event_damage = func_null; - RadiusDamage(this, this.realowner, WEP_CVAR(seeker, missile_damage), WEP_CVAR(seeker, missile_edgedamage), WEP_CVAR(seeker, missile_radius), NULL, NULL, WEP_CVAR(seeker, missile_force), this.projectiledeathtype, directhitentity); + RadiusDamage(this, this.realowner, WEP_CVAR(seeker, missile_damage), WEP_CVAR(seeker, missile_edgedamage), WEP_CVAR(seeker, missile_radius), NULL, NULL, WEP_CVAR(seeker, missile_force), this.projectiledeathtype, this.weaponentity_fld, directhitentity); delete(this); } @@ -212,7 +122,7 @@ void W_Seeker_Missile_Think(entity this) -void W_Seeker_Missile_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +void W_Seeker_Missile_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { if(this.health <= 0) return; @@ -256,10 +166,10 @@ void W_Seeker_Missile_Animate(entity this) void W_Seeker_Fire_Missile(Weapon thiswep, entity actor, .entity weaponentity, vector f_diff, entity m_target) { - W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, missile_ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, missile_ammo), weaponentity); makevectors(actor.v_angle); - W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_SEEKER_FIRE, CH_WEAPON_A, 0); + W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_SEEKER_FIRE, CH_WEAPON_A, 0, ((m_target != NULL) ? WEP_SEEKER.m_id | HITTYPE_SECONDARY : WEP_SEEKER.m_id)); w_shotorg += f_diff; Send_Effect(EFFECT_SEEKER_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -279,6 +189,7 @@ void W_Seeker_Fire_Missile(Weapon thiswep, entity actor, .entity weaponentity, v missile.solid = SOLID_BBOX; missile.scale = 2; missile.takedamage = DAMAGE_YES; + missile.weaponentity_fld = weaponentity; missile.health = WEP_CVAR(seeker, missile_health); missile.damageforcescale = WEP_CVAR(seeker, missile_damageforcescale); missile.damagedbycontents = true; @@ -315,7 +226,7 @@ void W_Seeker_Flac_Explode(entity this, entity directhitentity) { this.event_damage = func_null; - RadiusDamage(this, this.realowner, WEP_CVAR(seeker, flac_damage), WEP_CVAR(seeker, flac_edgedamage), WEP_CVAR(seeker, flac_radius), NULL, NULL, WEP_CVAR(seeker, flac_force), this.projectiledeathtype, directhitentity); + RadiusDamage(this, this.realowner, WEP_CVAR(seeker, flac_damage), WEP_CVAR(seeker, flac_edgedamage), WEP_CVAR(seeker, flac_radius), NULL, NULL, WEP_CVAR(seeker, flac_force), this.projectiledeathtype, this.weaponentity_fld, directhitentity); delete(this); } @@ -336,9 +247,9 @@ void W_Seeker_Fire_Flac(Weapon thiswep, entity actor, .entity weaponentity) vector f_diff; float c; - W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, flac_ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, flac_ammo), weaponentity); - c = actor.bulletcounter % 4; + c = actor.(weaponentity).bulletcounter % 4; switch(c) { case 0: @@ -355,7 +266,7 @@ void W_Seeker_Fire_Flac(Weapon thiswep, entity actor, .entity weaponentity) f_diff = '+1.25 +3.75 0'; break; } - W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_FLAC_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, flac_damage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_FLAC_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, flac_damage), WEP_SEEKER.m_id | HITTYPE_SECONDARY); w_shotorg += f_diff; Send_Effect(EFFECT_HAGAR_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); @@ -370,8 +281,8 @@ void W_Seeker_Fire_Flac(Weapon thiswep, entity actor, .entity weaponentity) missile.nextthink = time + WEP_CVAR(seeker, flac_lifetime) + WEP_CVAR(seeker, flac_lifetime_rand); missile.solid = SOLID_BBOX; set_movetype(missile, MOVETYPE_FLY); - missile.projectiledeathtype = WEP_SEEKER.m_id; missile.projectiledeathtype = WEP_SEEKER.m_id | HITTYPE_SECONDARY; + missile.weaponentity_fld = weaponentity; missile.flags = FL_PROJECTILE; IL_PUSH(g_projectiles, missile); IL_PUSH(g_bot_dodge, missile); @@ -393,35 +304,38 @@ void W_Seeker_Fire_Flac(Weapon thiswep, entity actor, .entity weaponentity) // ============================ // Begin: Tag and rocket controllers // ============================ -entity W_Seeker_Tagged_Info(entity isowner, entity istarget) +entity W_Seeker_Tagged_Info(entity isowner, .entity weaponentity, entity istarget) { - entity tag; - for(tag = NULL; (tag = find(tag, classname, "tag_tracker")); ) - if((tag.realowner == isowner) && (tag.tag_target == istarget)) - return tag; + IL_EACH(g_seeker_trackers, it.classname == "tag_tracker" && it.realowner == isowner, + { + if(it.tag_target == istarget && it.weaponentity_fld == weaponentity) + return it; + }); return NULL; } void W_Seeker_Attack(entity actor, .entity weaponentity) { - entity tracker, closest_target; + entity closest_target = NULL; - closest_target = NULL; - for(tracker = NULL; (tracker = find(tracker, classname, "tag_tracker")); ) if (tracker.realowner == actor) + IL_EACH(g_seeker_trackers, it.classname == "tag_tracker" && it.realowner == actor, { if(closest_target) { - if(vlen2(actor.origin - tracker.tag_target.origin) < vlen2(actor.origin - closest_target.origin)) - closest_target = tracker.tag_target; + if(vlen2(actor.origin - it.tag_target.origin) < vlen2(actor.origin - closest_target.origin)) + closest_target = it.tag_target; } else - closest_target = tracker.tag_target; - } + closest_target = it.tag_target; + }); - traceline(actor.origin + actor.view_ofs, closest_target.origin, MOVE_NOMONSTERS, actor); - if((!closest_target) || ((trace_fraction < 1) && (trace_ent != closest_target))) - closest_target = NULL; + if(closest_target) + { + traceline(actor.origin + actor.view_ofs, closest_target.origin, MOVE_NOMONSTERS, actor); + if(!closest_target || (trace_fraction < 1 && trace_ent != closest_target)) + closest_target = NULL; + } W_Seeker_Fire_Missile(WEP_SEEKER, actor, weaponentity, '0 0 0', closest_target); } @@ -433,7 +347,8 @@ void W_Seeker_Vollycontroller_Think(entity this) // TODO: Merge this with W_Seek this.cnt = this.cnt - 1; Weapon thiswep = WEP_SEEKER; - if((!(this.realowner.items & IT_UNLIMITED_AMMO) && this.realowner.(thiswep.ammo_field) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (PS(this.realowner).m_switchweapon != WEP_SEEKER)) + .entity weaponentity = this.weaponentity_fld; + if((!(this.realowner.items & IT_UNLIMITED_AMMO) && GetResourceAmount(this.realowner, thiswep.ammo_type) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (this.realowner.(weaponentity).m_switchweapon != WEP_SEEKER)) { delete(this); return; @@ -445,7 +360,6 @@ void W_Seeker_Vollycontroller_Think(entity this) // TODO: Merge this with W_Seek oldenemy = own.enemy; own.enemy = this.enemy; - .entity weaponentity = this.weaponentity_fld; c = own.cnt % 4; switch(c) @@ -470,8 +384,9 @@ void W_Seeker_Vollycontroller_Think(entity this) // TODO: Merge this with W_Seek void W_Seeker_Tracker_Think(entity this) { + .entity weaponentity = this.weaponentity_fld; // commit suicide if: You die OR target dies OR you switch away from the seeker OR commit suicide if lifetime is up - if((IS_DEAD(this.realowner)) || (IS_DEAD(this.tag_target)) || (PS(this.realowner).m_switchweapon != WEP_SEEKER) + if((IS_DEAD(this.realowner)) || (IS_DEAD(this.tag_target)) || (this.realowner.(weaponentity).m_switchweapon != WEP_SEEKER) || (time > this.tag_time + WEP_CVAR(seeker, tag_tracker_lifetime))) { if(this) @@ -498,7 +413,7 @@ void W_Seeker_Tag_Explode(entity this) delete(this); } -void W_Seeker_Tag_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) +void W_Seeker_Tag_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { if(this.health <= 0) return; @@ -526,7 +441,8 @@ void W_Seeker_Tag_Touch(entity this, entity toucher) if(toucher.takedamage == DAMAGE_AIM && !IS_DEAD(toucher)) { // check to see if this person is already tagged by me - entity tag = W_Seeker_Tagged_Info(this.realowner, toucher); + .entity weaponentity = this.weaponentity_fld; + entity tag = W_Seeker_Tagged_Info(this.realowner, weaponentity, toucher); if(tag != NULL) { @@ -543,6 +459,7 @@ void W_Seeker_Tag_Touch(entity this, entity toucher) e.cnt = WEP_CVAR(seeker, missile_count); e.owner = this.owner; e.realowner = this.realowner; + IL_PUSH(g_seeker_trackers, e); if(WEP_CVAR(seeker, type) == 1) { @@ -572,9 +489,9 @@ void W_Seeker_Tag_Touch(entity this, entity toucher) void W_Seeker_Fire_Tag(Weapon thiswep, entity actor, .entity weaponentity) { - W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, tag_ammo)); + W_DecreaseAmmo(thiswep, actor, WEP_CVAR(seeker, tag_ammo), weaponentity); - W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_TAG_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, missile_damage) * WEP_CVAR(seeker, missile_count)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-2 -2 -2', '2 2 2', false, 2, SND_TAG_FIRE, CH_WEAPON_A, WEP_CVAR(seeker, missile_damage) * WEP_CVAR(seeker, missile_count), WEP_SEEKER.m_id | HITTYPE_BOUNCE | HITTYPE_SECONDARY); entity missile = new(seeker_tag); missile.weaponentity_fld = weaponentity; @@ -613,19 +530,19 @@ void W_Seeker_Fire_Tag(Weapon thiswep, entity actor, .entity weaponentity) // Begin: Genereal weapon functions // ============================ -METHOD(Seeker, wr_aim, void(entity thiswep, entity actor)) +METHOD(Seeker, wr_aim, void(entity thiswep, entity actor, .entity weaponentity)) { if(WEP_CVAR(seeker, type) == 1) - if(W_Seeker_Tagged_Info(actor, actor.enemy) != NULL) - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(seeker, missile_speed_max), 0, WEP_CVAR(seeker, missile_lifetime), false); + if(W_Seeker_Tagged_Info(actor, weaponentity, actor.enemy) != NULL) + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, missile_speed_max), 0, WEP_CVAR(seeker, missile_lifetime), false); else - PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false); + PHYS_INPUT_BUTTON_ATCK2(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false); else - PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false); + PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false); } METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { - if(autocvar_g_balance_seeker_reload_ammo && actor.clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload + if(autocvar_g_balance_seeker_reload_ammo && actor.(weaponentity).clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload thiswep.wr_reload(thiswep, actor, weaponentity); } else if(fire & 1) { @@ -667,33 +584,33 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity } } } -METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor)) +METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount; if(WEP_CVAR(seeker, type) == 1) { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, missile_ammo); - ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, missile_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo); } else { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo); - ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo); } return ammo_amount; } -METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor)) +METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity)) { float ammo_amount; if(WEP_CVAR(seeker, type) == 1) { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo); - ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, tag_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo); } else { - ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, flac_ammo); - ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo); + ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(seeker, flac_ammo); + ammo_amount += actor.(weaponentity).(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo); } return ammo_amount; } @@ -757,4 +674,3 @@ METHOD(Seeker, wr_impacteffect, void(entity thiswep, entity actor)) } #endif -#endif