X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fgamemodes%2Fgamemode%2Fnexball%2Fnexball.qc;h=afa6db93f0a31c84cd9a69bef59c3601e6004427;hb=fd20a1f1eae2b2ba955ce9ddedc20cd151a6f362;hp=2acc4faf6d061c60d322ac13a1acc5cd3af30817;hpb=537313c9e52ce93b28ad6580b76e92d99f0a9d93;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 2acc4faf6..afa6db93f 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -40,9 +40,9 @@ float autocvar_g_balance_nexball_secondary_lifetime; float autocvar_g_balance_nexball_secondary_refire; float autocvar_g_balance_nexball_secondary_speed; -void basketball_touch(); -void football_touch(); -void ResetBall(); +void basketball_touch(entity this); +void football_touch(entity this); +void ResetBall(entity this); const int NBM_NONE = 0; const int NBM_FOOTBALL = 2; const int NBM_BASKETBALL = 4; @@ -84,24 +84,23 @@ void ball_restart(entity this) { if(this.owner) DropBall(this, this.owner.origin, '0 0 0'); - ResetBall(); + ResetBall(this); } void nexball_setstatus() {SELFPARAM(); - self.items &= ~IT_KEY1; - if(self.ballcarried) + this.items &= ~IT_KEY1; + if(this.ballcarried) { - if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time)) + if(this.ballcarried.teamtime && (this.ballcarried.teamtime < time)) { - bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n"); - setself(self.ballcarried); - DropBall(self, self.owner.origin, '0 0 0'); - ResetBall(); - setself(this); + bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n"); + DropBall(this.ballcarried, this.ballcarried.owner.origin, '0 0 0'); + entity e = this.ballcarried; + WITHSELF(e, ResetBall(e)); } else - self.items |= IT_KEY1; + this.items |= IT_KEY1; } } @@ -122,8 +121,8 @@ void relocate_nexball(entity this) } } -void DropOwner() -{SELFPARAM(); +void DropOwner(entity this) +{ entity ownr; ownr = this.owner; DropBall(this, ownr.origin, ownr.velocity); @@ -133,7 +132,7 @@ void DropOwner() } void GiveBall(entity plyr, entity ball) -{SELFPARAM(); +{ .entity weaponentity = weaponentities[0]; // TODO: find ballstealer entity ownr = ball.owner; if(ownr) @@ -168,7 +167,7 @@ void GiveBall(entity plyr, entity ball) ball.velocity = '0 0 0'; ball.movetype = MOVETYPE_NONE; - ball.touch = func_null; + settouch(ball, func_null); ball.effects |= EF_NOSHADOW; ball.scale = 1; // scale down. @@ -177,19 +176,17 @@ void GiveBall(entity plyr, entity ball) if(autocvar_g_nexball_basketball_delay_hold) { - ball.think = DropOwner; + setthink(ball, DropOwner); ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold; } plyr.(weaponentity).weapons = plyr.weapons; plyr.(weaponentity).m_switchweapon = PS(plyr).m_weapon; plyr.weapons = WEPSET(NEXBALL); - setself(plyr); Weapon w = WEP_NEXBALL; - w.wr_resetplayer(w); + WITHSELF(plyr, w.wr_resetplayer(w, plyr)); PS(plyr).m_switchweapon = WEP_NEXBALL; - W_SwitchWeapon(plyr, WEP_NEXBALL); - setself(this); + WITHSELF(plyr, W_SwitchWeapon(plyr, WEP_NEXBALL)); } void DropBall(entity ball, vector org, vector vel) @@ -205,8 +202,8 @@ void DropBall(entity ball, vector org, vector vel) ball.scale = ball_scale; ball.velocity = vel; ball.nb_droptime = time; - ball.touch = basketball_touch; - ball.think = ResetBall; + settouch(ball, basketball_touch); + setthink(ball, ResetBall); ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime); if(ball.owner.metertime) @@ -224,17 +221,17 @@ void DropBall(entity ball, vector org, vector vel) ball.owner = world; } -void InitBall() -{SELFPARAM(); +void InitBall(entity this) +{ if(gameover) return; UNSET_ONGROUND(this); this.movetype = MOVETYPE_BOUNCE; if(this.classname == "nexball_basketball") - this.touch = basketball_touch; + settouch(this, basketball_touch); else if(this.classname == "nexball_football") - this.touch = football_touch; + settouch(this, football_touch); this.cnt = 0; - this.think = ResetBall; + setthink(this, ResetBall); this.nextthink = time + autocvar_g_nexball_delay_idle + 3; this.teamtime = 0; this.pusher = world; @@ -244,14 +241,14 @@ void InitBall() LogNB("init", world); } -void ResetBall() -{SELFPARAM(); +void ResetBall(entity this) +{ if(this.cnt < 2) // step 1 { if(time == this.teamtime) bprint("The ", Team_ColoredFullName(this.team), " held the ball for too long.\n"); - this.touch = func_null; + settouch(this, func_null); this.movetype = MOVETYPE_NOCLIP; this.velocity = '0 0 0'; // just in case? if(!this.cnt) @@ -275,13 +272,13 @@ void ResetBall() this.velocity = '0 0 0'; setorigin(this, this.spawnorigin); // make sure it's positioned correctly anyway this.movetype = MOVETYPE_NONE; - this.think = InitBall; + setthink(this, InitBall); this.nextthink = max(time, game_starttime) + autocvar_g_nexball_delay_start; } } -void football_touch() -{SELFPARAM(); +void football_touch(entity this) +{ if(other.solid == SOLID_BSP) { if(time > self.lastground + 0.1) @@ -326,11 +323,11 @@ void football_touch() self.avelocity = -250 * v_forward; // maybe there is a way to make it look better? } -void basketball_touch() -{SELFPARAM(); +void basketball_touch(entity this) +{ if(other.ballcarried) { - football_touch(); + football_touch(this); return; } if(!self.cnt && IS_PLAYER(other) && !STAT(FROZEN, other) && !IS_DEAD(other) && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect)) @@ -348,8 +345,8 @@ void basketball_touch() } } -void GoalTouch() -{SELFPARAM(); +void GoalTouch(entity this) +{ entity ball; float isclient, pscore, otherteam; string pname; @@ -431,9 +428,9 @@ void GoalTouch() WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier); ball.cnt = 1; - ball.think = ResetBall; + setthink(ball, ResetBall); if(ball.classname == "nexball_basketball") - ball.touch = football_touch; // better than func_null: football control until the ball gets reset + settouch(ball, football_touch); // better than func_null: football control until the ball gets reset ball.nextthink = time + autocvar_g_nexball_delay_goal * (self.team != GOAL_OUT); } @@ -560,7 +557,7 @@ void SpawnBall(entity this) WaypointSprite_AttachCarrier(WP_NbBall, this, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed this.reset = ball_restart; - this.think = InitBall; + setthink(this, InitBall); this.nextthink = game_starttime + autocvar_g_nexball_delay_start; } @@ -627,7 +624,7 @@ void SpawnGoal(entity this) if(this.noise == "") this.noise = "ctf/respawn.wav"; precache_sound(this.noise); - this.touch = GoalTouch; + settouch(this, GoalTouch); } spawnfunc(nexball_redgoal) @@ -706,8 +703,8 @@ spawnfunc(ball_bound) //=======================// -void W_Nexball_Think() -{SELFPARAM(); +void W_Nexball_Think(entity this) +{ //dprint("W_Nexball_Think\n"); //vector new_dir = steerlib_arrive(this.enemy.origin, 2500); vector new_dir = normalize(this.enemy.origin + '0 0 50' - this.origin); @@ -721,8 +718,8 @@ void W_Nexball_Think() this.nextthink = time; } -void W_Nexball_Touch() -{SELFPARAM(); +void W_Nexball_Touch(entity this) +{ entity ball, attacker; attacker = self.owner; //self.think = func_null; @@ -797,7 +794,7 @@ void W_Nexball_Attack2() entity _ball = self.ballcarried; W_SetupShot(self, false, 4, SND_NB_SHOOT1, CH_WEAPON_A, 0); DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32)); - _ball.think = W_Nexball_Think; + setthink(_ball, W_Nexball_Think); _ball.nextthink = time; return; } @@ -819,8 +816,8 @@ void W_Nexball_Attack2() W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0); missile.angles = vectoangles(missile.velocity); - missile.touch = W_Nexball_Touch; - missile.think = SUB_Remove_self; + settouch(missile, W_Nexball_Touch); + setthink(missile, SUB_Remove); missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead? missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION; @@ -889,7 +886,7 @@ METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity we } } -METHOD(BallStealer, wr_setup, void(BallStealer this)) +METHOD(BallStealer, wr_setup, void(BallStealer this, entity actor)) { TC(BallStealer, this); //weapon_setup(WEP_PORTO.m_id); @@ -983,7 +980,7 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink) { self.weapons = self.(weaponentity).weapons; Weapon w = WEP_NEXBALL; - w.wr_resetplayer(w); + w.wr_resetplayer(w, self); PS(self).m_switchweapon = self.(weaponentity).m_switchweapon; W_SwitchWeapon(self, PS(self).m_switchweapon);