From e78c2f5aa0e2a7a4d1d96c2edc17bcfeb0f50089 Mon Sep 17 00:00:00 2001 From: avirox Date: Tue, 31 Jan 2006 02:16:49 +0000 Subject: [PATCH] - Added more code for "maprules" entity which controls team/class restrictions on a map - Tweaked .avelocity of ball entity git-svn-id: svn://svn.icculus.org/nexuiz/trunk@934 f962a42d-fe04-0410-a3ab-8c8b0445ebaa --- TeamNexuiz/game/gamec/g_world.c | 3 + TeamNexuiz/game/gamec/tf_ball.c | 25 +-- TeamNexuiz/game/gamec/tfdefs.c | 5 +- TeamNexuiz/game/gamec/tffunctions.c | 277 +++++++++++++++++++++++++++- TeamNexuiz/game/gamec/tfitems.c | 33 +++- 5 files changed, 313 insertions(+), 30 deletions(-) diff --git a/TeamNexuiz/game/gamec/g_world.c b/TeamNexuiz/game/gamec/g_world.c index d42b618a3..10b890f8a 100644 --- a/TeamNexuiz/game/gamec/g_world.c +++ b/TeamNexuiz/game/gamec/g_world.c @@ -223,6 +223,9 @@ void worldspawn (void) precache_model ("models/magmine/magnetmine.md3"); // mag mine precache_model ("models/sentry/turr1_barrel.md3"); + // Misc TN Stuff + precache_model ("models/team/team.sp2"); + // plays music for the level if there is any if (self.noise) diff --git a/TeamNexuiz/game/gamec/tf_ball.c b/TeamNexuiz/game/gamec/tf_ball.c index 0505b4925..c647161ba 100644 --- a/TeamNexuiz/game/gamec/tf_ball.c +++ b/TeamNexuiz/game/gamec/tf_ball.c @@ -10,21 +10,21 @@ void() BallTouch = { if (other.classname == "player" && self.last_used <= time) { - sound(self, 3, "zombie/z_fall.wav", 0.8, TRUE); + sound(self, 3, "ball/bounce_fall.wav", 0.8, TRUE); self.last_used = time + 0.3; } if (other.classname != "player") { - sound(self, TRUE, "zombie/z_hit.wav", TRUE, TRUE); + sound(self, TRUE, "ball/bounce_hit.wav", TRUE, TRUE); } if (other.classname == "player") { makevectors(other.v_angle); self.velocity = other.velocity + v_forward * 100 + v_up * 200; //self.angles = -1 * (vectoangles (self.velocity)); - v_forward_y = 0; - v_forward_z = 0; - self.avelocity = -1 * ((v_forward * 250) + crandom() * v_right); +// v_forward_y = 0; +// v_forward_z = 0; + self.avelocity = -1 * ((v_forward * 250)/* + crandom() * v_right*/); self.lastplayer = other; } }; @@ -49,7 +49,7 @@ void() ballstart = void() BallStart = { local entity te; - sound(self, 3, "sandball/whistle.wav", TRUE, FALSE); + sound(self, 3, "ball/whistle.wav", TRUE, FALSE); te = find(world, classname, "ballstart"); while (te) { @@ -93,7 +93,7 @@ void() GoalTouch = { return; } - sound(self, 3, "sandball/goal.wav", TRUE, FALSE); + sound(self, 3, "ball/goal.wav", TRUE, FALSE); self.last_used = time + 10; te = find(world, classname, "player"); while (te) @@ -129,9 +129,10 @@ void() sandball_goal = return; } precache_model("progs/null.mdl"); - precache_sound("sandball/goal.wav"); - precache_sound("sandball/whistle.wav"); - precache_sound("zombie/z_fall.wav"); + precache_sound("ball/goal.wav"); + precache_sound("ball/whistle.wav"); + precache_sound("ball/bounce_fall.wav"); + precache_sound("ball/bounce_hit.wav"); setmodel(self, "progs/null.mdl"); self.movetype = FALSE; self.skin = self.team_no; @@ -145,12 +146,12 @@ void() PuckTouch = { if (other.classname == "player" && self.last_used <= time) { - sound(self, 3, "zombie/z_fall.wav", 0.8, TRUE); + sound(self, 3, "ball/bounce_fall.wav", 0.8, TRUE); self.last_used = time + 0.3; } if (other.classname != "player") { - sound(self, TRUE, "zombie/z_hit.wav", TRUE, TRUE); + sound(self, TRUE, "ball/bounce_hit.wav", TRUE, TRUE); } if (other.classname == "player") { diff --git a/TeamNexuiz/game/gamec/tfdefs.c b/TeamNexuiz/game/gamec/tfdefs.c index 833b3e1e9..f23863b70 100644 --- a/TeamNexuiz/game/gamec/tfdefs.c +++ b/TeamNexuiz/game/gamec/tfdefs.c @@ -40,6 +40,7 @@ float civilianteams; .float team2_scout, team2_soldier, team2_medic, team2_pyro, team2_spy, team2_engineer; .float team3_scout, team3_soldier, team3_medic, team3_pyro, team3_spy, team3_engineer; .float team4_scout, team4_soldier, team4_medic, team4_pyro, team4_spy, team4_engineer; +.float team1_civilian, team2_civilian, team3_civilian, team4_civilian; // Last Spawn Place of Team entity lastspawn_team1; @@ -59,8 +60,8 @@ float TF_CLASS_HWGUY = 6; //not in NexTF float TF_CLASS_PYRO = 7; float TF_CLASS_SPY = 8; float TF_CLASS_ENGINEER = 9; -float TF_CLASS_RANDOM = 10; // Need fucntions for these 2 -float TF_CLASS_CIVILIAN = 11; //// +float TF_CLASS_RANDOM = 10; +float TF_CLASS_CIVILIAN = 11; .float respawn_as_new_class; // what class the player will respawn as in accordance to tf's .playerclass // Death Message (we should incorporate this into Team:Nexuiz some time) diff --git a/TeamNexuiz/game/gamec/tffunctions.c b/TeamNexuiz/game/gamec/tffunctions.c index 45671305d..c642d46c8 100644 --- a/TeamNexuiz/game/gamec/tffunctions.c +++ b/TeamNexuiz/game/gamec/tffunctions.c @@ -891,6 +891,7 @@ void (entity Player) TeamFortress_TeamShowMemberClasses = }; // Returns class name value +// We use another function for the TN classnames though.. string (float pc) TeamFortress_GetClassName = { if ((pc == 1)) // Scout is class 1 (normal) @@ -1558,32 +1559,290 @@ float (float tno) TeamFortress_TeamGetIllegalClasses = }; // Check if legal class -float (float pc, float tno, entity chkr) Check_Class_Scout = +float (float tno, entity chkr, float NumOnTeam) Check_Class_Scout = { - if (tno == 1 ) + if (tno == 1) { + if (chkr.team1_scout == -1) + return (0); + if (chkr.team1_scout != 0 && chkr.team1_scout == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 2) + { + if (chkr.team2_scout == -1) + return (0); + if (chkr.team2_scout != 0 && chkr.team2_scout == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 3) + { + if (chkr.team3_scout == -1) + return (0); + if (chkr.team3_scout != 0 && chkr.team3_scout == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 4) + { + if (chkr.team4_scout == -1) + return (0); + if (chkr.team4_scout != 0 && chkr.team4_scout == NumOnTeam) + return (0); + else + return (1); } +}; +float (float tno, entity chkr, float NumOnTeam) Check_Class_Soldier = +{ + if (tno == 1) + { + if (chkr.team1_soldier == -1) + return (0); + if (chkr.team1_soldier != 0 && chkr.team1_soldier == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 2) + { + if (chkr.team2_soldier == -1) + return (0); + if (chkr.team2_soldier != 0 && chkr.team2_soldier == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 3) + { + if (chkr.team3_soldier == -1) + return (0); + if (chkr.team3_soldier != 0 && chkr.team3_soldier == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 4) + { + if (chkr.team4_soldier == -1) + return (0); + if (chkr.team4_soldier != 0 && chkr.team4_soldier == NumOnTeam) + return (0); + else + return (1); + } }; -float (float pc, float tno, entity chkr) Check_Class_Soldier = +float (float tno, entity chkr, float NumOnTeam) Check_Class_Medic = { + if (tno == 1) + { + if (chkr.team1_medic == -1) + return (0); + if (chkr.team1_medic != 0 && chkr.team1_medic == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 2) + { + if (chkr.team2_medic == -1) + return (0); + if (chkr.team2_medic != 0 && chkr.team2_medic == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 3) + { + if (chkr.team3_medic == -1) + return (0); + if (chkr.team3_medic != 0 && chkr.team3_medic == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 4) + { + if (chkr.team4_medic == -1) + return (0); + if (chkr.team4_medic != 0 && chkr.team4_medic == NumOnTeam) + return (0); + else + return (1); + } +}; + +float (float tno, entity chkr, float NumOnTeam) Check_Class_Pyro = +{ + if (tno == 1) + { + if (chkr.team1_pyro == -1) + return (0); + if (chkr.team1_pyro != 0 && chkr.team1_pyro == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 2) + { + if (chkr.team2_pyro == -1) + return (0); + if (chkr.team2_pyro != 0 && chkr.team2_pyro == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 3) + { + if (chkr.team3_pyro == -1) + return (0); + if (chkr.team3_pyro != 0 && chkr.team3_pyro == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 4) + { + if (chkr.team4_pyro == -1) + return (0); + if (chkr.team4_pyro != 0 && chkr.team4_pyro == NumOnTeam) + return (0); + else + return (1); + } +}; + +float (float tno, entity chkr, float NumOnTeam) Check_Class_Engineer = +{ + if (tno == 1) + { + if (chkr.team1_engineer == -1) + return (0); + if (chkr.team1_engineer != 0 && chkr.team1_engineer == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 2) + { + if (chkr.team2_engineer == -1) + return (0); + if (chkr.team2_engineer != 0 && chkr.team2_engineer == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 3) + { + if (chkr.team3_engineer == -1) + return (0); + if (chkr.team3_engineer != 0 && chkr.team3_engineer == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 4) + { + if (chkr.team4_engineer == -1) + return (0); + if (chkr.team4_engineer != 0 && chkr.team4_engineer == NumOnTeam) + return (0); + else + return (1); + } +}; + +float (float tno, entity chkr, float NumOnTeam) Check_Class_Spy = +{ + if (tno == 1) + { + if (chkr.team1_spy == -1) + return (0); + if (chkr.team1_spy != 0 && chkr.team1_spy == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 2) + { + if (chkr.team2_spy == -1) + return (0); + if (chkr.team2_spy != 0 && chkr.team2_spy == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 3) + { + if (chkr.team3_spy == -1) + return (0); + if (chkr.team3_spy != 0 && chkr.team3_spy == NumOnTeam) + return (0); + else + return (1); + } + if (tno == 4) + { + if (chkr.team4_spy == -1) + return (0); + if (chkr.team4_spy != 0 && chkr.team4_spy == NumOnTeam) + return (0); + else + return (1); + } }; float (float pc) IsLegalClass = { local float bit; + local float NumOnTeam; + local entity te; // Team:Nexuiz class check local entity findme; local float yesorno; findme = find (world,classname,"class_restrictions"); - if (pc == TF_CLASS_SCOUT) - yesorno = Check_Class_Scout(pc, self.team_no, findme); - else if (pc == TF_CLASS_SOLDIER) - yesorno = Check_Class_Soldier(pc, self.team_no, findme); +// findme = find (world, classname, "info_tfdetect"); + if (findme) + { + // first, find the number of players of that class on a team + te = find (world, classname, "player"); + while (te) + { + if (te.playerclass == pc) + { + if (te.team_no == self.team_no) + { + NumOnTeam = NumOnTeam + 1; + } + } + te = find (te, classname, "player"); + } + + // next we check to see if the team is allowed to have that player class and the amount per team allowed for that class + if (pc == TF_CLASS_SCOUT) + yesorno = Check_Class_Scout(self.team_no, findme, NumOnTeam); + else if (pc == TF_CLASS_SOLDIER) + yesorno = Check_Class_Soldier(self.team_no, findme, NumOnTeam); + else if (pc == TF_CLASS_MEDIC) + yesorno = Check_Class_Medic(self.team_no, findme, NumOnTeam); + else if (pc == TF_CLASS_PYRO) + yesorno = Check_Class_Pyro(self.team_no, findme, NumOnTeam); + else if (pc == TF_CLASS_ENGINEER) + yesorno = Check_Class_Engineer(self.team_no, findme, NumOnTeam); + else if (pc == TF_CLASS_SPY) + yesorno = Check_Class_Spy(self.team_no, findme, NumOnTeam); + return (yesorno); + } /* if (((spy_off == 1) && (pc == 8))) { @@ -1681,7 +1940,7 @@ void () TeamFortress_DisplayLegalClasses = gotone = 1; sprint (self, "Scout"); } - if ((!(illegalclasses & 2) && !(ill & 2))) +/* if ((!(illegalclasses & 2) && !(ill & 2))) { if (gotone) { @@ -1689,7 +1948,7 @@ void () TeamFortress_DisplayLegalClasses = } gotone = 1; sprint (self, "Sniper"); - } + }*/ if ((!(illegalclasses & 4) && !(ill & 4))) { if (gotone) diff --git a/TeamNexuiz/game/gamec/tfitems.c b/TeamNexuiz/game/gamec/tfitems.c index 103c4c872..46fb5d315 100644 --- a/TeamNexuiz/game/gamec/tfitems.c +++ b/TeamNexuiz/game/gamec/tfitems.c @@ -61,15 +61,13 @@ float (entity e, float healamount, float ignore) T_Heal = .float team2_scout, team2_soldier, team2_medic, team2_pyro, team2_spy, team2_engineer; .float team3_scout, team3_soldier, team3_medic, team3_pyro, team3_spy, team3_engineer; .float team4_scout, team4_soldier, team4_medic, team4_pyro, team4_spy, team4_engineer;*/ +entity infoent; // our class restricts info entity -void () Map_Rules = +void() maprules = { - local entity infoent; // our class restricts info entity is spaned here - infoent = spawn(); - infoent.classname = "class_restrictions"; - copyentity (self, infoent); - // Amount of teams available on a map are determined by spawn points + + // Amount of players per team if (self.team1limit) self.ammo_medikit = stof(self.team1limit); if (self.team2limit) @@ -79,7 +77,28 @@ void () Map_Rules = if (self.team4limit) self.maxammo_detpack = stof(self.team4limit); - info_tfdetect(); + if (self.team1_civilian) + self.maxammo_shells = -1; + if (self.team2_civilian) + self.maxammo_nails = -1; + if (self.team3_civilian) + self.maxammo_rockets = -1; + if (self.team4_civilian) + self.maxammo_cells = -1; + + self.classname = "info_tfdetect"; + ParseTFDetect(self); + + infoent = spawn(); + copyentity (self, infoent); + infoent.classname = "class_restrictions"; +}; + +// older Team:Nexuiz maps use this, so i'm routing it to "maprules" +void () Map_Rules = +{ + seld.classname = "maprules"; + maprules(); }; // Team:Nexuiz backpack -- 2.39.2