X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fweapons%2Fweapon%2Fminelayer.qc;h=ecb5059b53a4556c56dc2c7f12472597179c7af8;hb=fd20a1f1eae2b2ba955ce9ddedc20cd151a6f362;hp=c6e0fb86bce692d211e72ec39a24f89f29886060;hpb=0f8553d27e17cc90ccbdd7d56d86bb5136330db7;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index c6e0fb86b..ecb5059b5 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -53,7 +53,7 @@ ENDCLASS(MineLayer) REGISTER_WEAPON(MINE_LAYER, minelayer, NEW(MineLayer)); #ifdef SVQC -void W_MineLayer_Think(); +void W_MineLayer_Think(entity this); .float minelayer_detonate, mine_explodeanyway; .float mine_time; .vector mine_orientation; @@ -63,8 +63,8 @@ void W_MineLayer_Think(); #ifdef SVQC spawnfunc(weapon_minelayer) { weapon_defaultspawnfunc(this, WEP_MINE_LAYER); } -void W_MineLayer_Stick(entity to) -{SELFPARAM(); +void W_MineLayer_Stick(entity this, entity to) +{ spamsound(self, CH_SHOTS, SND(MINE_STICK), VOL_BASE, ATTN_NORM); // in order for mines to face properly when sticking to the ground, they must be a server side entity rather than a csqc projectile @@ -96,21 +96,20 @@ void W_MineLayer_Stick(entity to) newmine.mine_time = self.mine_time; - newmine.touch = func_null; - newmine.think = W_MineLayer_Think; + settouch(newmine, func_null); + setthink(newmine, W_MineLayer_Think); newmine.nextthink = time; newmine.cnt = self.cnt; newmine.flags = self.flags; remove(self); - setself(newmine); if(to) - SetMovetypeFollow(self, to); + SetMovetypeFollow(newmine, to); } -void W_MineLayer_Explode() -{SELFPARAM(); +void W_MineLayer_Explode(entity this) +{ if(other.takedamage == DAMAGE_AIM) if(IS_PLAYER(other)) if(DIFF_TEAM(self.realowner, other)) @@ -125,23 +124,22 @@ void W_MineLayer_Explode() if(PS(self.realowner).m_weapon == WEP_MINE_LAYER) { - setself(self.realowner); + entity own = this.realowner; Weapon w = WEP_MINE_LAYER; - if(!w.wr_checkammo1(w)) + if(!w.wr_checkammo1(w, own)) { - self.cnt = WEP_MINE_LAYER.m_id; + own.cnt = WEP_MINE_LAYER.m_id; int slot = 0; // TODO: unhardcode - ATTACK_FINISHED(self, slot) = time; - PS(self).m_switchweapon = w_getbestweapon(self); + ATTACK_FINISHED(own, slot) = time; + PS(own).m_switchweapon = w_getbestweapon(own); } - setself(this); } self.realowner.minelayer_mines -= 1; remove(self); } -void W_MineLayer_DoRemoteExplode() -{SELFPARAM(); +void W_MineLayer_DoRemoteExplode(entity this) +{ self.event_damage = func_null; self.takedamage = DAMAGE_NO; @@ -152,35 +150,34 @@ void W_MineLayer_DoRemoteExplode() if(PS(self.realowner).m_weapon == WEP_MINE_LAYER) { - setself(self.realowner); + entity own = this.realowner; Weapon w = WEP_MINE_LAYER; - if(!w.wr_checkammo1(w)) + if(!w.wr_checkammo1(w, own)) { - self.cnt = WEP_MINE_LAYER.m_id; + own.cnt = WEP_MINE_LAYER.m_id; int slot = 0; // TODO: unhardcode - ATTACK_FINISHED(self, slot) = time; - PS(self).m_switchweapon = w_getbestweapon(self); + ATTACK_FINISHED(own, slot) = time; + PS(own).m_switchweapon = w_getbestweapon(own); } - setself(this); } - self.realowner.minelayer_mines -= 1; + this.realowner.minelayer_mines -= 1; remove(self); } -void W_MineLayer_RemoteExplode() -{SELFPARAM(); +void W_MineLayer_RemoteExplode(entity this) +{ if(!IS_DEAD(self.realowner)) if((self.spawnshieldtime >= 0) ? (time >= self.spawnshieldtime) // timer : (vdist(NearestPointOnBox(self.realowner, self.origin) - self.origin, >, WEP_CVAR(minelayer, remote_radius))) // safety device ) { - W_MineLayer_DoRemoteExplode(); + W_MineLayer_DoRemoteExplode(self); } } -void W_MineLayer_ProximityExplode() -{SELFPARAM(); +void W_MineLayer_ProximityExplode(entity this) +{ // make sure no friend is in the mine's radius. If there is any, explosion is delayed until he's at a safe distance if(WEP_CVAR(minelayer, protection) && self.mine_explodeanyway == 0) { @@ -195,7 +192,7 @@ void W_MineLayer_ProximityExplode() } self.mine_time = 0; - W_MineLayer_Explode(); + W_MineLayer_Explode(self); } int W_MineLayer_Count(entity e) @@ -208,8 +205,8 @@ int W_MineLayer_Count(entity e) return minecount; } -void W_MineLayer_Think() -{SELFPARAM(); +void W_MineLayer_Think(entity this) +{ entity head; self.nextthink = time; @@ -239,7 +236,7 @@ void W_MineLayer_Think() { other = world; self.projectiledeathtype |= HITTYPE_BOUNCE; - W_MineLayer_Explode(); + W_MineLayer_Explode(self); return; } @@ -260,7 +257,7 @@ void W_MineLayer_Think() // explode if it's time to if(self.mine_time && time >= self.mine_time) { - W_MineLayer_ProximityExplode(); + W_MineLayer_ProximityExplode(self); return; } @@ -268,11 +265,11 @@ void W_MineLayer_Think() if(PS(self.realowner).m_weapon == WEP_MINE_LAYER) if(!IS_DEAD(self.realowner)) if(self.minelayer_detonate) - W_MineLayer_RemoteExplode(); + W_MineLayer_RemoteExplode(self); } -void W_MineLayer_Touch() -{SELFPARAM(); +void W_MineLayer_Touch(entity this) +{ if(self.movetype == MOVETYPE_NONE || self.movetype == MOVETYPE_FOLLOW) return; // we're already a stuck mine, why do we get called? TODO does this even happen? @@ -290,7 +287,7 @@ void W_MineLayer_Touch() } else { - W_MineLayer_Stick(other); + W_MineLayer_Stick(self, other); } } @@ -308,11 +305,11 @@ void W_MineLayer_Damage(entity this, entity inflictor, entity attacker, float da this.angles = vectoangles(this.velocity); if(this.health <= 0) - WITHSELF(this, W_PrepareExplosionByDamage(attacker, W_MineLayer_Explode)); + W_PrepareExplosionByDamage(this, attacker, W_MineLayer_Explode); } -void W_MineLayer_Attack(Weapon thiswep) -{SELFPARAM(); +void W_MineLayer_Attack(Weapon thiswep, entity actor) +{entity this = actor; entity mine; entity flash; @@ -358,8 +355,8 @@ void W_MineLayer_Attack(Weapon thiswep) W_SetupProjVelocity_Basic(mine, WEP_CVAR(minelayer, speed), 0); mine.angles = vectoangles(mine.velocity); - mine.touch = W_MineLayer_Touch; - mine.think = W_MineLayer_Think; + settouch(mine, W_MineLayer_Touch); + setthink(mine, W_MineLayer_Think); mine.nextthink = time; mine.cnt = (WEP_CVAR(minelayer, lifetime) - WEP_CVAR(minelayer, lifetime_countdown)); mine.flags = FL_PROJECTILE; @@ -383,12 +380,12 @@ void W_MineLayer_Attack(Weapon thiswep) self.minelayer_mines = W_MineLayer_Count(self); } -float W_MineLayer_PlacedMines(float detonate) -{SELFPARAM(); +float W_MineLayer_PlacedMines(entity this, float detonate) +{ entity mine; float minfound = 0; - for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == self) + for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == this) { if(detonate) { @@ -404,9 +401,9 @@ float W_MineLayer_PlacedMines(float detonate) return minfound; } -METHOD(MineLayer, wr_aim, void(entity thiswep)) +METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor)) { - SELFPARAM(); + entity this = actor; // aim and decide to fire if appropriate if(self.minelayer_mines >= WEP_CVAR(minelayer, limit)) PHYS_INPUT_BUTTON_ATCK(self) = false; @@ -508,7 +505,7 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent if(autocvar_g_balance_minelayer_reload_ammo && actor.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(false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) { + if(!(W_MineLayer_PlacedMines(actor, false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) { thiswep.wr_reload(thiswep, actor, weaponentity); } } @@ -516,46 +513,43 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent { if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(minelayer, refire))) { - W_MineLayer_Attack(thiswep); + W_MineLayer_Attack(thiswep, actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready); } } if(fire & 2) { - if(W_MineLayer_PlacedMines(true)) + if(W_MineLayer_PlacedMines(actor, true)) sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM); } } -METHOD(MineLayer, wr_checkammo1, bool(entity thiswep)) +METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor)) { - SELFPARAM(); - int slot = 0; // TODO: unhardcode - // don't switch while placing a mine - if(ATTACK_FINISHED(self, slot) <= time || PS(self).m_weapon != WEP_MINE_LAYER) - { - float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo); - ammo_amount += self.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo); + //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) + //{ + float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo); + ammo_amount += actor.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo); return ammo_amount; - } - return true; + //} + //return true; } -METHOD(MineLayer, wr_checkammo2, bool(entity thiswep)) +METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor)) { - if(W_MineLayer_PlacedMines(false)) + if(W_MineLayer_PlacedMines(actor, false)) return true; else return false; } -METHOD(MineLayer, wr_resetplayers, void(entity thiswep)) +METHOD(MineLayer, wr_resetplayer, void(entity thiswep, entity actor)) { - SELFPARAM(); - self.minelayer_mines = 0; + actor.minelayer_mines = 0; } METHOD(MineLayer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity)) { - SELFPARAM(); - W_Reload(self, WEP_CVAR(minelayer, ammo), SND_RELOAD); + W_Reload(actor, WEP_CVAR(minelayer, ammo), SND_RELOAD); } METHOD(MineLayer, wr_suicidemessage, Notification(entity thiswep)) { @@ -569,9 +563,9 @@ METHOD(MineLayer, wr_killmessage, Notification(entity thiswep)) #endif #ifdef CSQC -METHOD(MineLayer, wr_impacteffect, void(entity thiswep)) +METHOD(MineLayer, wr_impacteffect, void(entity thiswep, entity actor)) { - SELFPARAM(); + entity this = actor; vector org2; org2 = w_org + w_backoff * 12; pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);