X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fgamemodes%2Fgamemode%2Fnexball%2Fnexball.qc;h=4a8005d6c2ad40e7991a967e29560429e206cdbc;hb=9f1091e432a2db424bfad2482694ee8b34edbe9c;hp=3dc5c107fe9a26e29513600eb7b203713c1aebf4;hpb=b683bf23a495d3b1b3f6df3bda75bfe0f069ab05;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 3dc5c107f..4a8005d6c 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -2,7 +2,7 @@ #ifdef IMPLEMENTATION #ifdef SVQC -.float metertime; +.float metertime = _STAT(NB_METERSTART); int autocvar_g_nexball_goalleadlimit; #define autocvar_g_nexball_goallimit cvar("g_nexball_goallimit") @@ -78,14 +78,14 @@ void LogNB(string mode, entity actor) GameLogEcho(s); } -void ball_restart(void) -{SELFPARAM(); - if(self.owner) - DropBall(self, self.owner.origin, '0 0 0'); +void ball_restart(entity this) +{ + if(this.owner) + DropBall(this, this.owner.origin, '0 0 0'); ResetBall(); } -void nexball_setstatus(void) +void nexball_setstatus() {SELFPARAM(); self.items &= ~IT_KEY1; if(self.ballcarried) @@ -103,7 +103,7 @@ void nexball_setstatus(void) } } -void relocate_nexball(void) +void relocate_nexball() {SELFPARAM(); tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self); if(trace_startsolid) @@ -120,19 +120,19 @@ void relocate_nexball(void) } } -void DropOwner(void) +void DropOwner() {SELFPARAM(); entity ownr; ownr = self.owner; DropBall(self, ownr.origin, ownr.velocity); makevectors(ownr.v_angle.y * '0 1 0'); ownr.velocity += ('0 0 0.75' - v_forward) * 1000; - ownr.flags &= ~FL_ONGROUND; + UNSET_ONGROUND(ownr); } void GiveBall(entity plyr, entity ball) {SELFPARAM(); - int slot = 0; // TODO: find ballstealer + .entity weaponentity = weaponentities[0]; // TODO: find ballstealer entity ownr = ball.owner; if(ownr) { @@ -141,7 +141,7 @@ void GiveBall(entity plyr, entity ball) if(ownr.metertime) { ownr.metertime = 0; - ownr.weaponentity[slot].state = WS_READY; + ownr.(weaponentity).state = WS_READY; } WaypointSprite_Kill(ownr.waypointsprite_attachedforcarrier); } @@ -179,14 +179,14 @@ void GiveBall(entity plyr, entity ball) ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold; } - plyr.weaponentity[slot].weapons = plyr.weapons; - plyr.weaponentity[slot].switchweapon = plyr.weapon; + 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); - plyr.switchweapon = WEP_NEXBALL.m_id; - W_SwitchWeapon(WEP_NEXBALL.m_id); + PS(plyr).m_switchweapon = WEP_NEXBALL; + W_SwitchWeapon(WEP_NEXBALL); setself(this); } @@ -199,7 +199,7 @@ void DropBall(entity ball, vector org, vector vel) setattachment(ball, world, ""); setorigin(ball, org); ball.movetype = MOVETYPE_BOUNCE; - ball.flags &= ~FL_ONGROUND; + UNSET_ONGROUND(ball); ball.scale = ball_scale; ball.velocity = vel; ball.nb_droptime = time; @@ -210,8 +210,8 @@ void DropBall(entity ball, vector org, vector vel) if(ball.owner.metertime) { ball.owner.metertime = 0; - int slot = 0; // TODO: find ballstealer - ball.owner.weaponentity[slot].state = WS_READY; + .entity weaponentity = weaponentities[0]; // TODO: find ballstealer + ball.owner.(weaponentity).state = WS_READY; } WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier); @@ -222,10 +222,10 @@ void DropBall(entity ball, vector org, vector vel) ball.owner = world; } -void InitBall(void) +void InitBall() {SELFPARAM(); if(gameover) return; - self.flags &= ~FL_ONGROUND; + UNSET_ONGROUND(self); self.movetype = MOVETYPE_BOUNCE; if(self.classname == "nexball_basketball") self.touch = basketball_touch; @@ -242,7 +242,7 @@ void InitBall(void) LogNB("init", world); } -void ResetBall(void) +void ResetBall() {SELFPARAM(); if(self.cnt < 2) // step 1 { @@ -278,7 +278,7 @@ void ResetBall(void) } } -void football_touch(void) +void football_touch() {SELFPARAM(); if(other.solid == SOLID_BSP) { @@ -324,7 +324,7 @@ void football_touch(void) self.avelocity = -250 * v_forward; // maybe there is a way to make it look better? } -void basketball_touch(void) +void basketball_touch() {SELFPARAM(); if(other.ballcarried) { @@ -346,7 +346,7 @@ void basketball_touch(void) } } -void GoalTouch(void) +void GoalTouch() {SELFPARAM(); entity ball; float isclient, pscore, otherteam; @@ -458,7 +458,7 @@ void nb_spawnteam(string teamname, float teamcolor) nb_teams += 1; } -void nb_spawnteams(void) +void nb_spawnteams() { bool t_red = false, t_blue = false, t_yellow = false, t_pink = false; entity e; @@ -498,7 +498,7 @@ void nb_spawnteams(void) } } -void nb_delayedinit(void) +void nb_delayedinit() { if(find(world, classname, "nexball_team") == world) nb_spawnteams(); @@ -510,7 +510,7 @@ void nb_delayedinit(void) // spawnfuncs // //=======================// -void SpawnBall(void) +void SpawnBall() {SELFPARAM(); if(!g_nexball) { remove(self); return; } @@ -543,13 +543,13 @@ void SpawnBall(void) if(!autocvar_g_nexball_sound_bounce) self.noise = ""; else if(self.noise == "") - self.noise = SND(NB_BOUNCE); + self.noise = strzone(SND(NB_BOUNCE)); //bounce sound placeholder (FIXME) if(self.noise1 == "") - self.noise1 = SND(NB_DROP); + self.noise1 = strzone(SND(NB_DROP)); //ball drop sound placeholder (FIXME) if(self.noise2 == "") - self.noise2 = SND(NB_STEAL); + self.noise2 = strzone(SND(NB_STEAL)); //stealing sound placeholder (FIXME) if(self.noise) precache_sound(self.noise); precache_sound(self.noise1); @@ -606,7 +606,7 @@ float nb_Goal_Customize() return true; } -void SpawnGoal(void) +void SpawnGoal() {SELFPARAM(); if(!g_nexball) { remove(self); return; } @@ -651,7 +651,7 @@ spawnfunc(nexball_fault) { self.team = GOAL_FAULT; if(self.noise == "") - self.noise = SND(TYPEHIT); + self.noise = strzone(SND(TYPEHIT)); SpawnGoal(); } @@ -659,7 +659,7 @@ spawnfunc(nexball_out) { self.team = GOAL_OUT; if(self.noise == "") - self.noise = SND(TYPEHIT); + self.noise = strzone(SND(TYPEHIT)); SpawnGoal(); } @@ -717,7 +717,7 @@ void W_Nexball_Think() self.nextthink = time; } -void W_Nexball_Touch(void) +void W_Nexball_Touch() {SELFPARAM(); entity ball, attacker; attacker = self.owner; @@ -729,7 +729,7 @@ void W_Nexball_Touch(void) if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker))) { other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force; - other.flags &= ~FL_ONGROUND; + UNSET_ONGROUND(other); if(!attacker.ballcarried) { LogNB("stole", attacker); @@ -786,7 +786,7 @@ void W_Nexball_Attack(float t) vector trigger_push_calculatevelocity(vector org, entity tgt, float ht); -void W_Nexball_Attack2(void) +void W_Nexball_Attack2() {SELFPARAM(); if(self.ballcarried.enemy) { @@ -816,7 +816,7 @@ void W_Nexball_Attack2(void) 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; + missile.think = SUB_Remove_self; missile.nextthink = time + autocvar_g_balance_nexball_secondary_lifetime; //FIXME: use a distance instead? missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION; @@ -852,34 +852,34 @@ float ball_customize() return true; } - METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, int slot, int fire)) + METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, .entity weaponentity, int fire)) { if(fire & 1) - if(weapon_prepareattack(thiswep, actor, slot, false, autocvar_g_balance_nexball_primary_refire)) + if(weapon_prepareattack(thiswep, actor, weaponentity, false, autocvar_g_balance_nexball_primary_refire)) if(autocvar_g_nexball_basketball_meter) { if(self.ballcarried && !self.metertime) self.metertime = time; else - weapon_thinkf(actor, slot, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); } else { W_Nexball_Attack(-1); - weapon_thinkf(actor, slot, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); } if(fire & 2) - if(weapon_prepareattack(thiswep, actor, slot, true, autocvar_g_balance_nexball_secondary_refire)) + if(weapon_prepareattack(thiswep, actor, weaponentity, true, autocvar_g_balance_nexball_secondary_refire)) { W_Nexball_Attack2(); - weapon_thinkf(actor, slot, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready); } if(!(fire & 1) && self.metertime && self.ballcarried) { W_Nexball_Attack(time - self.metertime); // DropBall or stealing will set metertime back to 0 - weapon_thinkf(actor, slot, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); + weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); } } METHOD(BallStealer, wr_setup, void(BallStealer thiswep)) @@ -930,10 +930,11 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink) self.ballcarried.velocity = self.velocity; self.ballcarried.customizeentityforclient = ball_customize; - setorigin(self.ballcarried, self.origin + self.view_ofs + + vector org = self.origin + self.view_ofs + v_forward * autocvar_g_nexball_viewmodel_offset.x + v_right * autocvar_g_nexball_viewmodel_offset.y + - v_up * autocvar_g_nexball_viewmodel_offset.z); + v_up * autocvar_g_nexball_viewmodel_offset.z; + setorigin(self.ballcarried, org); // 'safe passing' if(autocvar_g_nexball_safepass_maxdist) @@ -965,16 +966,16 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink) } else { - int slot = 0; // TODO - if(self.weaponentity[slot].weapons) + .entity weaponentity = weaponentities[0]; // TODO + if(self.(weaponentity).weapons) { - self.weapons = self.weaponentity[slot].weapons; + self.weapons = self.(weaponentity).weapons; Weapon w = WEP_NEXBALL; w.wr_resetplayer(w); - self.switchweapon = self.weaponentity[slot].switchweapon; - W_SwitchWeapon(self.switchweapon); + PS(self).m_switchweapon = self.(weaponentity).m_switchweapon; + W_SwitchWeapon(PS(self).m_switchweapon); - self.weaponentity[slot].weapons = '0 0 0'; + self.(weaponentity).weapons = '0 0 0'; } } @@ -995,8 +996,8 @@ MUTATOR_HOOKFUNCTION(nb, PlayerSpawn) { SELFPARAM(); this.metertime = 0; - int slot = 0; - this.weaponentity[slot].weapons = '0 0 0'; + .entity weaponentity = weaponentities[0]; + this.(weaponentity).weapons = '0 0 0'; if (nexball_mode & NBM_BASKETBALL) this.weapons |= WEPSET(NEXBALL); @@ -1021,12 +1022,12 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPhysics) MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon) {SELFPARAM(); - return self.weapon == WEP_NEXBALL.m_id; + return PS(self).m_weapon == WEP_NEXBALL; } MUTATOR_HOOKFUNCTION(nb, ForbidDropCurrentWeapon) {SELFPARAM(); - return self.weapon == WEP_MORTAR.m_id; // TODO: what is this for? + return PS(self).m_weapon == WEP_MORTAR; // TODO: what is this for? } MUTATOR_HOOKFUNCTION(nb, FilterItem) @@ -1072,7 +1073,6 @@ REGISTER_MUTATOR(nb, g_nexball) if(g_nexball_meter_period <= 0) g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users g_nexball_meter_period = rint(g_nexball_meter_period * 32) / 32; //Round to 1/32ths to send as a byte multiplied by 32 - addstat(STAT_NB_METERSTART, AS_FLOAT, metertime); // General settings /*