X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fdevastator.qc;h=e02a474c2d43e817600595e22ae3725060020db6;hb=cf7d70cea2066703aad74fce5931e635471904f3;hp=9d955f058dd3a59ecd9fdc0dd7a54548ea4b38ba;hpb=ee7a78f942624de2ab30112a798e3f663cf9cc2f;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 9d955f058..e02a474c2 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -1,7 +1,7 @@ #ifndef IMPLEMENTATION CLASS(Devastator, Weapon) -/* ammotype */ ATTRIB(Devastator, ammo_field, .int, ammo_rockets) -/* impulse */ ATTRIB(Devastator, impulse, int, 9) +/* ammotype */ ATTRIB(Devastator, ammo_field, .int, ammo_rockets); +/* impulse */ ATTRIB(Devastator, impulse, int, 9); /* flags */ ATTRIB(Devastator, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH); /* rating */ ATTRIB(Devastator, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH); /* color */ ATTRIB(Devastator, wpcolor, vector, '1 1 0'); @@ -61,7 +61,7 @@ ENDCLASS(Devastator) REGISTER_WEAPON(DEVASTATOR, devastator, NEW(Devastator)); #ifdef SVQC -.float rl_release; +.float rl_release[MAX_WEAPONSLOTS]; .float rl_detonate_later; #endif #endif @@ -76,7 +76,12 @@ void W_Devastator_Unregister(entity this) { if(this.realowner && this.realowner.lastrocket == this) { - this.realowner.lastrocket = NULL; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + if(this.realowner.(weaponentity).lastrocket == this) + this.realowner.(weaponentity).lastrocket = NULL; + } // this.realowner.rl_release = 1; } } @@ -120,7 +125,7 @@ void W_Devastator_Explode(entity this, entity directhitentity) PS(this.realowner).m_switchweapon = w_getbestweapon(this.realowner); } } - remove(this); + delete(this); } void W_Devastator_Explode_think(entity this) @@ -206,13 +211,13 @@ void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity) PS(this.realowner).m_switchweapon = w_getbestweapon(this.realowner); } } - remove(this); + delete(this); } void W_Devastator_RemoteExplode(entity this, .entity weaponentity) { if(!IS_DEAD(this.realowner)) - if(this.realowner.lastrocket) + if(this.realowner.(weaponentity).lastrocket) { if((this.spawnshieldtime >= 0) ? (time >= this.spawnshieldtime) // timer @@ -278,8 +283,11 @@ void W_Devastator_Think(entity this) // laser guided, or remote detonation if(PS(this.realowner).m_weapon == WEP_DEVASTATOR) { - if(this == this.realowner.lastrocket) - if(!this.realowner.rl_release) + .entity weaponentity = this.weaponentity_fld; + int slot = weaponslot(weaponentity); + + if(this == this.realowner.(weaponentity).lastrocket) + if(!this.realowner.rl_release[slot]) if(!PHYS_INPUT_BUTTON_ATCK2(this)) if(WEP_CVAR(devastator, guiderate)) if(time > this.pushltime) @@ -315,7 +323,6 @@ void W_Devastator_Think(entity this) } } - .entity weaponentity = weaponentities[0]; // TODO: unhardcode if(this.rl_detonate_later) W_Devastator_RemoteExplode(this, weaponentity); } @@ -351,16 +358,17 @@ void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float d W_PrepareExplosionByDamage(this, attacker, W_Devastator_Explode_think); } -void W_Devastator_Attack(Weapon thiswep, entity actor) +void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity) { W_DecreaseAmmo(thiswep, actor, WEP_CVAR(devastator, ammo)); - W_SetupShot_ProjectileSize(actor, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage)); + W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage)); Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); entity missile = WarpZone_RefSys_SpawnSameRefSys(actor); + missile.weaponentity_fld = weaponentity; missile.owner = missile.realowner = actor; - actor.lastrocket = missile; + actor.(weaponentity).lastrocket = missile; if(WEP_CVAR(devastator, detonatedelay) >= 0) missile.spawnshieldtime = time + WEP_CVAR(devastator, detonatedelay); else @@ -376,7 +384,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor) missile.event_damage = W_Devastator_Damage; missile.damagedbycontents = true; - missile.movetype = MOVETYPE_FLY; + set_movetype(missile, MOVETYPE_FLY); PROJECTILE_MAKETRIGGER(missile); missile.projectiledeathtype = WEP_DEVASTATOR.m_id; setsize(missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot @@ -390,6 +398,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor) missile.nextthink = time; missile.cnt = time + WEP_CVAR(devastator, lifetime); missile.flags = FL_PROJECTILE; + IL_PUSH(g_projectiles, missile); missile.missile_flags = MIF_SPLASH; CSQCProjectile(missile, WEP_CVAR(devastator, guiderate) == 0 && WEP_CVAR(devastator, speedaccel) == 0, PROJECTILE_ROCKET, false); // because of fly sound @@ -399,7 +408,7 @@ void W_Devastator_Attack(Weapon thiswep, entity actor) setmodel(flash, MDL_DEVASTATOR_MUZZLEFLASH); // precision set below SUB_SetFade(flash, time, 0.1); flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(actor, flash, '5 0 0'); + W_AttachToShotorg(actor, weaponentity, flash, '5 0 0'); // common properties MUTATOR_CALLHOOK(EditProjectile, actor, missile); @@ -441,8 +450,7 @@ METHOD(Devastator, wr_aim, void(entity thiswep, entity actor)) if(skill >= 2) // skill 0 and 1 bots won't detonate rockets! { // decide whether to detonate rockets - entity targetlist, targ; - float edgedamage, coredamage, edgeradius, recipricoledgeradius, d; + float edgedamage, coredamage, edgeradius, recipricoledgeradius; float selfdamage, teamdamage, enemydamage; edgedamage = WEP_CVAR(devastator, edgedamage); coredamage = WEP_CVAR(devastator, damage); @@ -451,25 +459,23 @@ METHOD(Devastator, wr_aim, void(entity thiswep, entity actor)) selfdamage = 0; teamdamage = 0; enemydamage = 0; - targetlist = findchainfloat(bot_attack, true); FOREACH_ENTITY_ENT(realowner, actor, { if(it.classname != "rocket") continue; - targ = targetlist; - while(targ) + entity rocket = it; + FOREACH_ENTITY_FLOAT(bot_attack, true, { - d = vlen(targ.origin + (targ.mins + targ.maxs) * 0.5 - it.origin); - d = bound(0, edgedamage + (coredamage - edgedamage) * sqrt(1 - d * recipricoledgeradius), 10000); - // count potential damage according to type of target - if(targ == actor) - selfdamage = selfdamage + d; - else if(targ.team == actor.team && teamplay) - teamdamage = teamdamage + d; - else if(bot_shouldattack(actor, targ)) - enemydamage = enemydamage + d; - targ = targ.chain; - } + float d = vlen(it.origin + (it.mins + it.maxs) * 0.5 - rocket.origin); + d = bound(0, edgedamage + (coredamage - edgedamage) * sqrt(1 - d * recipricoledgeradius), 10000); + // count potential damage according to type of target + if(it == actor) + selfdamage = selfdamage + d; + else if(SAME_TEAM(it, actor)) + teamdamage = teamdamage + d; + else if(bot_shouldattack(actor, it)) + enemydamage = enemydamage + d; + }); }); float desirabledamage; desirabledamage = enemydamage; @@ -478,36 +484,35 @@ METHOD(Devastator, wr_aim, void(entity thiswep, entity actor)) if(teamplay && actor.team) desirabledamage = desirabledamage - teamdamage; + makevectors(actor.v_angle); FOREACH_ENTITY_ENT(realowner, actor, { if(it.classname != "rocket") continue; - makevectors(it.v_angle); - targ = targetlist; if(skill > 9) // normal players only do this for the target they are tracking { - targ = targetlist; - while(targ) - { - if( - (v_forward * normalize(it.origin - targ.origin)< 0.1) - && desirabledamage > 0.1*coredamage - ) PHYS_INPUT_BUTTON_ATCK2(actor) = true; - targ = targ.chain; - } - } - else - { - float distance; distance= bound(300,vlen(actor.origin-actor.enemy.origin),30000); + entity rocket = it; + FOREACH_ENTITY_FLOAT(bot_attack, true, + { + if((v_forward * normalize(rocket.origin - it.origin) < 0.1) + && desirabledamage > 0.1 * coredamage + ) PHYS_INPUT_BUTTON_ATCK2(actor) = true; + }); + } + else + { //As the distance gets larger, a correct detonation gets near imposible //Bots are assumed to use the rocket spawnfunc_light to see if the rocket gets near a player - if(v_forward * normalize(it.origin - actor.enemy.origin)< 0.1) - if(IS_PLAYER(actor.enemy)) - if(desirabledamage >= 0.1*coredamage) - if(random()/distance*300 > frametime*bound(0,(10-skill)*0.2,1)) - PHYS_INPUT_BUTTON_ATCK2(actor) = true; - // dprint(ftos(random()/distance*300),">");dprint(ftos(frametime*bound(0,(10-skill)*0.2,1)),"\n"); - } + if((v_forward * normalize(it.origin - actor.enemy.origin) < 0.1) + && IS_PLAYER(actor.enemy) + && (desirabledamage >= 0.1 * coredamage) + ) + { + float distance = bound(300, vlen(actor.origin - actor.enemy.origin), 30000); + if(random() / distance * 300 > frametime * bound(0, (10 - skill) * 0.2, 1)) + PHYS_INPUT_BUTTON_ATCK2(actor) = true; + } + } }); // if we would be doing at X percent of the core damage, detonate it // but don't fire a new shot at the same time! @@ -526,18 +531,19 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen if(WEP_CVAR(devastator, reload_ammo) && actor.clip_load < WEP_CVAR(devastator, ammo)) { // forced reload thiswep.wr_reload(thiswep, actor, weaponentity); } else { + int slot = weaponslot(weaponentity); if(fire & 1) { - if(actor.rl_release || WEP_CVAR(devastator, guidestop)) + if(actor.rl_release[slot] || WEP_CVAR(devastator, guidestop)) if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(devastator, refire))) { - W_Devastator_Attack(thiswep, actor); + W_Devastator_Attack(thiswep, actor, weaponentity); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready); - actor.rl_release = 0; + actor.rl_release[slot] = 0; } } else - actor.rl_release = 1; + actor.rl_release[slot] = 1; if(fire & 2) if(PS(actor).m_switchweapon == WEP_DEVASTATOR) @@ -559,7 +565,8 @@ METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponen } METHOD(Devastator, wr_setup, void(entity thiswep, entity actor)) { - actor.rl_release = 1; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + actor.rl_release[slot] = 1; } METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor)) { @@ -603,12 +610,16 @@ METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor)) } METHOD(Devastator, wr_resetplayer, void(entity thiswep, entity actor)) { - actor.lastrocket = NULL; // stop rocket guiding, no revenge from the grave! - actor.rl_release = 0; + for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) + { + .entity weaponentity = weaponentities[slot]; + actor.(weaponentity).lastrocket = NULL; // stop rocket guiding, no revenge from the grave! + actor.rl_release[slot] = 0; + } } METHOD(Devastator, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - W_Reload(actor, WEP_CVAR(devastator, ammo), SND_RELOAD); + W_Reload(actor, weaponentity, WEP_CVAR(devastator, ammo), SND_RELOAD); } METHOD(Devastator, wr_suicidemessage, Notification(entity thiswep)) {