X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fminelayer.qc;h=f9ff84653a63ffa3f499cff7fa20e905203f1e6a;hb=bdb5a7169145f7982de9109bd4c833112a6b747b;hp=a4fae6f5ffda58f1759ceb6b8511b2e651803911;hpb=d97366b07415fca128337f8ef84396c8c2236b69;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index a4fae6f5f..f9ff84653 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -18,16 +18,16 @@ void W_MineLayer_Stick(entity this, entity to) newmine.owner = this.owner; newmine.realowner = this.realowner; - setsize(newmine, '-4 -4 -4', '4 4 4'); setorigin(newmine, this.origin); setmodel(newmine, MDL_MINELAYER_MINE); + setsize(newmine, '-4 -4 -4', '4 4 4'); newmine.angles = vectoangles(-trace_plane_normal); // face against the surface newmine.mine_orientation = -trace_plane_normal; newmine.takedamage = this.takedamage; newmine.damageforcescale = this.damageforcescale; - SetResourceAmountExplicit(newmine, RESOURCE_HEALTH, GetResourceAmount(this, RESOURCE_HEALTH)); + SetResourceExplicit(newmine, RES_HEALTH, GetResource(this, RES_HEALTH)); newmine.event_damage = this.event_damage; newmine.spawnshieldtime = this.spawnshieldtime; newmine.damagedbycontents = true; @@ -74,8 +74,7 @@ void W_MineLayer_Explode(entity this, entity directhitentity) if(!thiswep.wr_checkammo1(thiswep, own, weaponentity)) { own.cnt = thiswep.m_id; - int slot = weaponslot(weaponentity); - ATTACK_FINISHED(own, slot) = time; + ATTACK_FINISHED(own, weaponentity) = time; own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity); } } @@ -106,8 +105,7 @@ void W_MineLayer_DoRemoteExplode(entity this) if(!thiswep.wr_checkammo1(thiswep, own, weaponentity)) { own.cnt = thiswep.m_id; - int slot = weaponslot(weaponentity); - ATTACK_FINISHED(own, slot) = time; + ATTACK_FINISHED(own, weaponentity) = time; own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity); } } @@ -239,7 +237,7 @@ void W_MineLayer_Touch(entity this, entity toucher) void W_MineLayer_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force) { - if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0) + if(GetResource(this, RES_HEALTH) <= 0) return; float is_from_enemy = (inflictor.realowner != this.realowner); @@ -247,22 +245,19 @@ void W_MineLayer_Damage(entity this, entity inflictor, entity attacker, float da if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, (is_from_enemy ? 1 : -1))) return; // g_projectiles_damage says to halt - TakeResource(this, RESOURCE_HEALTH, damage); + TakeResource(this, RES_HEALTH, damage); this.angles = vectoangles(this.velocity); - if(GetResourceAmount(this, RESOURCE_HEALTH) <= 0) + if(GetResource(this, RES_HEALTH) <= 0) W_PrepareExplosionByDamage(this, attacker, W_MineLayer_Explode_think); } void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity) { - entity mine; - entity flash; - // scan how many mines we placed, and return if we reached our limit if(WEP_CVAR(minelayer, limit)) { - int minecount = W_MineLayer_Count(actor); + int minecount = W_MineLayer_Count(actor, weaponentity); if(minecount >= WEP_CVAR(minelayer, limit)) { // the refire delay keeps this message from being spammed @@ -275,9 +270,9 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity) W_DecreaseAmmo(thiswep, actor, WEP_CVAR(minelayer, ammo), weaponentity); W_SetupShot_ProjectileSize(actor, weaponentity, '-4 -4 -4', '4 4 4', false, 5, SND_MINE_FIRE, CH_WEAPON_A, WEP_CVAR(minelayer, damage), thiswep.m_id); - Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); + W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir); - mine = WarpZone_RefSys_SpawnSameRefSys(actor); + entity mine = WarpZone_RefSys_SpawnSameRefSys(actor); mine.weaponentity_fld = weaponentity; IL_PUSH(g_mines, mine); mine.owner = mine.realowner = actor; @@ -291,7 +286,7 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity) mine.takedamage = DAMAGE_YES; mine.damageforcescale = WEP_CVAR(minelayer, damageforcescale); - SetResourceAmountExplicit(mine, RESOURCE_HEALTH, WEP_CVAR(minelayer, health)); + SetResourceExplicit(mine, RES_HEALTH, WEP_CVAR(minelayer, health)); mine.event_damage = W_MineLayer_Damage; mine.damagedbycontents = true; IL_PUSH(g_damagedbycontents, mine); @@ -319,13 +314,6 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity) CSQCProjectile(mine, true, PROJECTILE_MINE, true); - // muzzle flash for 1st person view - flash = spawn(); - setmodel(flash, MDL_MINELAYER_MUZZLEFLASH); // precision set below - SUB_SetFade(flash, time, 0.1); - flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION; - W_AttachToShotorg(actor, weaponentity, flash, '5 0 0'); - // common properties MUTATOR_CALLHOOK(EditProjectile, actor, mine); @@ -391,7 +379,7 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor, .entity weaponentit float desirabledamage; desirabledamage = enemydamage; - if(time > actor.invincible_finished && time > actor.spawnshieldtime) + if(time > STAT(INVINCIBLE_FINISHED, actor) && time > actor.spawnshieldtime) desirabledamage = desirabledamage - selfdamage * autocvar_g_balance_selfdamagepercent; if(teamplay && actor.team) desirabledamage = desirabledamage - teamdamage; @@ -429,7 +417,7 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor, .entity weaponentit // but don't fire a new shot at the same time! if(desirabledamage >= 0.75 * coredamage) //this should do group damage in rare fortunate events PHYS_INPUT_BUTTON_ATCK2(actor) = true; - if((skill > 6.5) && (selfdamage > GetResourceAmount(actor, RESOURCE_HEALTH))) + if((skill > 6.5) && (selfdamage > GetResource(actor, RES_HEALTH))) PHYS_INPUT_BUTTON_ATCK2(actor) = false; //if(PHYS_INPUT_BUTTON_ATCK2(actor) == true) // dprint(ftos(desirabledamage),"\n"); @@ -443,7 +431,7 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent if(autocvar_g_balance_minelayer_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR(minelayer, ammo)) // forced reload { // not if we're holding the minelayer without enough ammo, but can detonate existing mines - if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && GetResourceAmount(actor, thiswep.ammo_type) < WEP_CVAR(minelayer, ammo))) { + if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && GetResource(actor, thiswep.ammo_type) < WEP_CVAR(minelayer, ammo))) { thiswep.wr_reload(thiswep, actor, weaponentity); } } @@ -464,11 +452,10 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent } METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity)) { - //int slot = 0; // TODO: unhardcode // actually do // don't switch while placing a mine - //if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_MINE_LAYER) + //if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_MINE_LAYER) //{ - float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo); + float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo); ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(minelayer, ammo); return ammo_amount; //}