X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fgamemode_nexball.qc;h=ba70a6cda8a5e301242f978430cf2c82d31a5e95;hb=30e9db455abe691a3560555a989beb382b3b2531;hp=aa56d7647772ac4c5c5593bb6d324ce39b69dcf2;hpb=8ec332c7d3cffdc6b39c3ada385fa41995630589;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/gamemode_nexball.qc b/qcsrc/server/mutators/gamemode_nexball.qc index aa56d7647..ba70a6cda 100644 --- a/qcsrc/server/mutators/gamemode_nexball.qc +++ b/qcsrc/server/mutators/gamemode_nexball.qc @@ -49,7 +49,7 @@ void nexball_setstatus(void) { if(self.ballcarried.teamtime && (self.ballcarried.teamtime < time)) { - bprint("The ", ColoredTeamName(self.team), " held the ball for too long.\n"); + bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n"); oldself = self; self = self.ballcarried; DropBall(self, self.owner.origin, '0 0 0'); @@ -117,14 +117,14 @@ void GiveBall(entity plyr, entity ball) ball.owner = ball.pusher = plyr; //"owner" is set to the player carrying, "pusher" to the last player who touched it ball.team = plyr.team; plyr.ballcarried = ball; - ball.dropperid = plyr.playerid; + ball.nb_dropper = plyr; plyr.effects |= autocvar_g_nexball_basketball_effects_default; ball.effects &~= autocvar_g_nexball_basketball_effects_default; ball.velocity = '0 0 0'; ball.movetype = MOVETYPE_NONE; - ball.touch = SUB_Null; + ball.touch = func_null; ball.effects |= EF_NOSHADOW; ball.scale = 1; // scale down. @@ -137,15 +137,15 @@ void GiveBall(entity plyr, entity ball) ball.nextthink = time + autocvar_g_nexball_basketball_delay_hold; } - ownr = self; - self = plyr; - WEPSET_COPY_EE(self.weaponentity, self); - self.weaponentity.switchweapon = self.weapon; - WEPSET_COPY_EW(self, WEP_PORTO); - weapon_action(WEP_PORTO, WR_RESETPLAYER); - self.switchweapon = WEP_PORTO; - W_SwitchWeapon(WEP_PORTO); - self = ownr; + ownr = self; + self = plyr; + WEPSET_COPY_EE(self.weaponentity, self); + self.weaponentity.switchweapon = self.weapon; + WEPSET_COPY_EW(self, WEP_PORTO); + weapon_action(WEP_PORTO, WR_RESETPLAYER); + self.switchweapon = WEP_PORTO; + W_SwitchWeapon(WEP_PORTO); + self = ownr; } void DropBall(entity ball, vector org, vector vel) @@ -160,7 +160,7 @@ void DropBall(entity ball, vector org, vector vel) ball.flags &~= FL_ONGROUND; ball.scale = ball_scale; ball.velocity = vel; - ball.ctf_droptime = time; + ball.nb_droptime = time; ball.touch = basketball_touch; ball.think = ResetBall; ball.nextthink = min(time + autocvar_g_nexball_delay_idle, ball.teamtime); @@ -201,11 +201,12 @@ void InitBall(void) void ResetBall(void) { - if(self.cnt < 2) // step 1 + if(self.cnt < 2) // step 1 { if(time == self.teamtime) - bprint("The ", ColoredTeamName(self.team), " held the ball for too long.\n"); - self.touch = SUB_Null; + bprint("The ", Team_ColoredFullName(self.team), " held the ball for too long.\n"); + + self.touch = func_null; self.movetype = MOVETYPE_NOCLIP; self.velocity = '0 0 0'; // just in case? if(!self.cnt) @@ -213,14 +214,14 @@ void ResetBall(void) self.cnt = 2; self.nextthink = time; } - else if(self.cnt < 4) // step 2 and 3 + else if(self.cnt < 4) // step 2 and 3 { // dprint("Step ", ftos(self.cnt), ": Calculated velocity: ", vtos(self.spawnorigin - self.origin), ", time: ", ftos(time), "\n"); self.velocity = (self.spawnorigin - self.origin) * (self.cnt - 1); // 1 or 0.5 second movement self.nextthink = time + 0.5; self.cnt += 1; } - else // step 4 + else // step 4 { // dprint("Step 4: time: ", ftos(time), "\n"); if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore @@ -247,7 +248,7 @@ void football_touch(void) self.nextthink = time + autocvar_g_nexball_delay_idle; return; } - if(other.classname != "player") + if not(IS_PLAYER(other)) return; if(other.health < 1) return; @@ -257,22 +258,22 @@ void football_touch(void) self.pusher = other; self.team = other.team; - if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original + if(autocvar_g_nexball_football_physics == -1) // MrBougo try 1, before decompiling Rev's original { if(vlen(other.velocity)) self.velocity = other.velocity * 1.5 + '0 0 1' * autocvar_g_nexball_football_boost_up; } - else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point + else if(autocvar_g_nexball_football_physics == 1) // MrBougo's modded Rev style: partially independant of the height of the aiming point { makevectors(other.v_angle); self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + '0 0 1' * autocvar_g_nexball_football_boost_up; } - else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable! + else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable! { makevectors(other.v_angle_y * '0 1 0'); self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up; } - else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant) + else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant) { makevectors(other.v_angle); self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up; @@ -287,7 +288,7 @@ void basketball_touch(void) football_touch(); return; } - if(!self.cnt && other.classname == "player" && (other.playerid != self.dropperid || time > self.ctf_droptime + autocvar_g_nexball_delay_collect)) + if(!self.cnt && IS_PLAYER(other) && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect)) { if(other.health <= 0) return; @@ -326,12 +327,12 @@ void GoalTouch(void) else otherteam = 0; - if((isclient = ball.pusher.flags & FL_CLIENT)) + if((isclient = IS_CLIENT(ball.pusher))) pname = ball.pusher.netname; else pname = "Someone (?)"; - if(ball.team == self.team) //owngoal (regular goals) + if(ball.team == self.team) //owngoal (regular goals) { LogNB("owngoal", ball.pusher); bprint("Boo! ", pname, "^7 scored a goal against their own team!\n"); @@ -341,9 +342,9 @@ void GoalTouch(void) { LogNB("fault", ball.pusher); if(nb_teams == 2) - bprint(ColoredTeamName(otherteam), " gets a point due to ", pname, "^7's silliness.\n"); + bprint(Team_ColoredFullName(otherteam), " gets a point due to ", pname, "^7's silliness.\n"); else - bprint(ColoredTeamName(ball.team), " loses a point due to ", pname, "^7's silliness.\n"); + bprint(Team_ColoredFullName(ball.team), " loses a point due to ", pname, "^7's silliness.\n"); pscore = -1; } else if(self.team == GOAL_OUT) @@ -355,10 +356,10 @@ void GoalTouch(void) bprint("The ball was returned.\n"); pscore = 0; } - else //score + else //score { LogNB(strcat("goal:", ftos(self.team)), ball.pusher); - bprint("Goaaaaal! ", pname, "^7 scored a point for the ", ColoredTeamName(ball.team), ".\n"); + bprint("Goaaaaal! ", pname, "^7 scored a point for the ", Team_ColoredFullName(ball.team), ".\n"); pscore = 1; } @@ -387,12 +388,12 @@ void GoalTouch(void) ball.cnt = 1; ball.think = ResetBall; if(ball.classname == "nexball_basketball") - ball.touch = football_touch; // better than SUB_Null: football control until the ball gets reset + ball.touch = 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); } //=======================// -// team ents // +// team ents // //=======================// void spawnfunc_nexball_team(void) { @@ -424,28 +425,28 @@ void nb_spawnteams(void) { switch(e.team) { - case COLOR_TEAM1: + case NUM_TEAM_1: if(!t_r) { nb_spawnteam("Red", e.team-1) ; t_r = 1; } break; - case COLOR_TEAM2: + case NUM_TEAM_2: if(!t_b) { nb_spawnteam("Blue", e.team-1) ; t_b = 1; } break; - case COLOR_TEAM3: + case NUM_TEAM_3: if(!t_y) { nb_spawnteam("Yellow", e.team-1); t_y = 1; } break; - case COLOR_TEAM4: + case NUM_TEAM_4: if(!t_p) { nb_spawnteam("Pink", e.team-1) ; @@ -465,7 +466,7 @@ void nb_delayedinit(void) //=======================// -// spawnfuncs // +// spawnfuncs // //=======================// void SpawnBall(void) @@ -526,7 +527,7 @@ void SpawnBall(void) void spawnfunc_nexball_basketball(void) { - nexball_mode |= NBM_BASKETBALL; + nexball_mode |= NBM_BASKETBALL; self.classname = "nexball_basketball"; if not(balls & BALL_BASKET) { @@ -549,7 +550,7 @@ void spawnfunc_nexball_basketball(void) void spawnfunc_nexball_football(void) { - nexball_mode |= NBM_FOOTBALL; + nexball_mode |= NBM_FOOTBALL; self.classname = "nexball_football"; self.solid = SOLID_TRIGGER; balls |= BALL_FOOT; @@ -575,22 +576,22 @@ void SpawnGoal(void) void spawnfunc_nexball_redgoal(void) { - self.team = COLOR_TEAM1; + self.team = NUM_TEAM_1; SpawnGoal(); } void spawnfunc_nexball_bluegoal(void) { - self.team = COLOR_TEAM2; + self.team = NUM_TEAM_2; SpawnGoal(); } void spawnfunc_nexball_yellowgoal(void) { - self.team = COLOR_TEAM3; + self.team = NUM_TEAM_3; SpawnGoal(); } void spawnfunc_nexball_pinkgoal(void) { - self.team = COLOR_TEAM4; + self.team = NUM_TEAM_4; SpawnGoal(); } @@ -629,11 +630,11 @@ void spawnfunc_ball_basketball(void) // The "red goal" is defended by blue team. A ball in there counts as a point for red. void spawnfunc_ball_redgoal(void) { - spawnfunc_nexball_bluegoal(); // I blame Revenant + spawnfunc_nexball_bluegoal(); // I blame Revenant } void spawnfunc_ball_bluegoal(void) { - spawnfunc_nexball_redgoal(); // but he didn't mean to cause trouble :p + spawnfunc_nexball_redgoal(); // but he didn't mean to cause trouble :p } void spawnfunc_ball_fault(void) { @@ -645,35 +646,35 @@ void spawnfunc_ball_bound(void) } //=======================// -// Weapon code // +// Weapon code // //=======================// void W_Nexball_Think() { - //dprint("W_Nexball_Think\n"); - //vector new_dir = steerlib_arrive(self.enemy.origin, 2500); - vector new_dir = normalize(self.enemy.origin - self.origin); - vector old_dir = normalize(self.velocity); - float _speed = vlen(self.velocity); - vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed; - //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate - - self.velocity = new_vel; - - self.nextthink = time; + //dprint("W_Nexball_Think\n"); + //vector new_dir = steerlib_arrive(self.enemy.origin, 2500); + vector new_dir = normalize(self.enemy.origin + '0 0 50' - self.origin); + vector old_dir = normalize(self.velocity); + float _speed = vlen(self.velocity); + vector new_vel = normalize(old_dir + (new_dir * autocvar_g_nexball_safepass_turnrate)) * _speed; + //vector new_vel = (new_dir * autocvar_g_nexball_safepass_turnrate + + self.velocity = new_vel; + + self.nextthink = time; } void W_Nexball_Touch(void) { entity ball, attacker; attacker = self.owner; - //self.think = SUB_Null; - //self.enemy = world; - + //self.think = func_null; + //self.enemy = world; + PROJECTILE_TOUCH; if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal) - if((ball = other.ballcarried) && (attacker.classname == "player")) + if((ball = other.ballcarried) && (IS_PLAYER(attacker))) { other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force; other.flags &~= FL_ONGROUND; @@ -725,7 +726,7 @@ void W_Nexball_Attack(float t) mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power } - DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, FALSE)); + DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, FALSE)); //TODO: use the speed_up cvar too ?? @@ -735,16 +736,16 @@ void W_Nexball_Attack2(void) { if(self.ballcarried.enemy) { - entity _ball = self.ballcarried; - W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0); - DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32)); - _ball.think = W_Nexball_Think; - _ball.nextthink = time; - return; + entity _ball = self.ballcarried; + W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0); + DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32)); + _ball.think = W_Nexball_Think; + _ball.nextthink = time; + return; } - - if(!autocvar_g_nexball_tackling) - return; + + if(!autocvar_g_nexball_tackling) + return; entity missile; if(!(balls & BALL_BASKET)) @@ -773,32 +774,31 @@ void W_Nexball_Attack2(void) missile.flags = FL_PROJECTILE; } -var const float() nullfunc; float ball_customize() { - if(!self.owner) - { - self.effects &~= EF_FLAME; - self.scale = 1; - self.customizeentityforclient = nullfunc; - return TRUE; - } - - if(other == self.owner) - { - self.scale = autocvar_g_nexball_viewmodel_scale; - if(self.enemy) - self.effects |= EF_FLAME; - else - self.effects &~= EF_FLAME; - } - else - { - self.effects &~= EF_FLAME; - self.scale = 1; - } - - return TRUE; + if(!self.owner) + { + self.effects &~= EF_FLAME; + self.scale = 1; + self.customizeentityforclient = func_null; + return TRUE; + } + + if(other == self.owner) + { + self.scale = autocvar_g_nexball_viewmodel_scale; + if(self.enemy) + self.effects |= EF_FLAME; + else + self.effects &~= EF_FLAME; + } + else + { + self.effects &~= EF_FLAME; + self.scale = 1; + } + + return TRUE; } float w_nexball_weapon(float req) @@ -844,14 +844,8 @@ float w_nexball_weapon(float req) precache_sound("misc/typehit.wav"); } else if(req == WR_SETUP) - weapon_setup(WEP_PORTO); - else if(req == WR_SUICIDEMESSAGE) - { - w_deathtypestring = "is a weirdo"; - } - else if(req == WR_KILLMESSAGE) { - w_deathtypestring = "got killed by #'s black magic"; + weapon_setup(WEP_PORTO); } // No need to check WR_CHECKAMMO* or WR_AIM, it should always return TRUE return TRUE; @@ -879,75 +873,75 @@ MUTATOR_HOOKFUNCTION(nexball_BuildMutatorsPrettyString) MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink) { - makevectors(self.v_angle); - if(nexball_mode & NBM_BASKETBALL) - { - if(self.ballcarried) - { - // 'view ball' - self.ballcarried.velocity = self.velocity; - self.ballcarried.customizeentityforclient = ball_customize; - - setorigin(self.ballcarried, 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); - - // 'safe passing' - if(autocvar_g_nexball_safepass_maxdist) - { - if(self.ballcarried.wait < time && self.ballcarried.enemy) - { - //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname)); - self.ballcarried.enemy = world; - } - - - //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist); - crosshair_trace(self); - if( trace_ent && - trace_ent.flags & FL_CLIENT && - trace_ent.deadflag == DEAD_NO && - trace_ent.team == self.team && - vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist ) - { - - //if(self.ballcarried.enemy != trace_ent) - // centerprint(self, sprintf("Locked to %s", trace_ent.netname)); - self.ballcarried.enemy = trace_ent; - self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime; - - - } - } - } - else - { - if(!WEPSET_EMPTY_E(self.weaponentity)) - { - WEPSET_COPY_EE(self, self.weaponentity); - weapon_action(WEP_PORTO, WR_RESETPLAYER); - self.switchweapon = self.weaponentity.switchweapon; - W_SwitchWeapon(self.switchweapon); - + makevectors(self.v_angle); + if(nexball_mode & NBM_BASKETBALL) + { + if(self.ballcarried) + { + // 'view ball' + self.ballcarried.velocity = self.velocity; + self.ballcarried.customizeentityforclient = ball_customize; + + setorigin(self.ballcarried, 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); + + // 'safe passing' + if(autocvar_g_nexball_safepass_maxdist) + { + if(self.ballcarried.wait < time && self.ballcarried.enemy) + { + //centerprint(self, sprintf("Lost lock on %s", self.ballcarried.enemy.netname)); + self.ballcarried.enemy = world; + } + + + //tracebox(self.origin + self.view_ofs, '-2 -2 -2', '2 2 2', self.origin + self.view_ofs + v_forward * autocvar_g_nexball_safepass_maxdist); + crosshair_trace(self); + if( trace_ent && + IS_CLIENT(trace_ent) && + trace_ent.deadflag == DEAD_NO && + trace_ent.team == self.team && + vlen(trace_ent.origin - self.origin) <= autocvar_g_nexball_safepass_maxdist ) + { + + //if(self.ballcarried.enemy != trace_ent) + // centerprint(self, sprintf("Locked to %s", trace_ent.netname)); + self.ballcarried.enemy = trace_ent; + self.ballcarried.wait = time + autocvar_g_nexball_safepass_holdtime; + + + } + } + } + else + { + if(!WEPSET_EMPTY_E(self.weaponentity)) + { + WEPSET_COPY_EE(self, self.weaponentity); + weapon_action(WEP_PORTO, WR_RESETPLAYER); + self.switchweapon = self.weaponentity.switchweapon; + W_SwitchWeapon(self.switchweapon); + WEPSET_CLEAR_E(self.weaponentity); - } - } - - } - return FALSE; + } + } + + } + return FALSE; } MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn) -{ - WEPSET_CLEAR_E(self.weaponentity); - - if(nexball_mode & NBM_BASKETBALL) - WEPSET_OR_EW(self, WEP_PORTO); - else - WEPSET_CLEAR_E(self); +{ + WEPSET_CLEAR_E(self.weaponentity); + + if(nexball_mode & NBM_BASKETBALL) + WEPSET_OR_EW(self, WEP_PORTO); + else + WEPSET_CLEAR_E(self); - return FALSE; + return FALSE; } MUTATOR_DEFINITION(gamemode_nexball) @@ -962,7 +956,6 @@ MUTATOR_DEFINITION(gamemode_nexball) MUTATOR_ONADD { - g_nexball = 1; g_nexball_meter_period = autocvar_g_nexball_meter_period; if(g_nexball_meter_period <= 0) g_nexball_meter_period = 2; // avoid division by zero etc. due to silly users @@ -972,14 +965,27 @@ MUTATOR_DEFINITION(gamemode_nexball) // General settings /* CVTOV(g_nexball_football_boost_forward); //100 - CVTOV(g_nexball_football_boost_up); //200 - CVTOV(g_nexball_delay_idle); //10 - CVTOV(g_nexball_football_physics); //0 + CVTOV(g_nexball_football_boost_up); //200 + CVTOV(g_nexball_delay_idle); //10 + CVTOV(g_nexball_football_physics); //0 */ radar_showennemies = autocvar_g_nexball_radar_showallplayers; InitializeEntity(world, nb_delayedinit, INITPRIO_GAMETYPE); } + MUTATOR_ONROLLBACK_OR_REMOVE + { + // we actually cannot roll back nb_delayedinit here + // BUT: we don't need to! If this gets called, adding always + // succeeds. + } + + MUTATOR_ONREMOVE + { + print("This is a game type and it cannot be removed at runtime."); + return -1; + } + return 0; }