r2899 - trunk/data/qcsrc/server
savagex at icculus.org
savagex at icculus.org
Sun Nov 4 08:24:07 EST 2007
Author: savagex
Date: 2007-11-04 08:24:04 -0500 (Sun, 04 Nov 2007)
New Revision: 2899
Modified:
trunk/data/qcsrc/server/assault.qc
trunk/data/qcsrc/server/g_world.qc
Log:
first version of assault mode with winning condition. Untested as for
some reason one cannot join assault games (pressing jump doesn't work).
This used to work.
Modified: trunk/data/qcsrc/server/assault.qc
===================================================================
--- trunk/data/qcsrc/server/assault.qc 2007-11-04 09:09:40 UTC (rev 2898)
+++ trunk/data/qcsrc/server/assault.qc 2007-11-04 13:24:04 UTC (rev 2899)
@@ -292,6 +292,48 @@
self.nextthink = time;
}
+
+void target_assault_roundend_reset() {
+ self.cnt = self.cnt + 1; // up round counter
+ self.winning = 0; // up round
+}
+
+void target_assault_roundend_use() {
+ self.winning = 1; // round has been won by attackers
+}
+
+void target_assault_roundend() {
+ if(!self.health)
+ self.health = 300; // 5 minutes
+
+ cvar_set("timelimit", ftos(self.health/60));
+ self.winning = 0; // round not yet won by attackers
+ self.classname = "target_assault_roundend";
+ self.use = target_assault_roundend_use;
+ self.cnt = 0; // first round
+}
+
+void assault_roundstart_use() {
+ local entity ent;
+ local entity oldself;
+ ent = find(world, targetname, self.target);
+ while(ent) {
+ oldself = self;
+ self = ent;
+ self.use();
+ self = oldself;
+ ent = find(ent, targetname, self.target);
+ }
+}
+
+void target_assault_roundstart() {
+ assault_attacker_team = COLOR_TEAM1;
+ self.classname = "target_assault_roundstart";
+ self.use = assault_roundstart_use;
+ self.think = assault_roundstart_use;
+ self.nextthink = time + 0.1;
+}
+
// trigger new round
// reset objectives, toggle spawnpoints, reset triggers, ...
void assault_new_round() {
@@ -348,6 +390,18 @@
ent = find(ent, classname, "target_objective");
}
+ // reset round end triggers
+ ent = find(world, classname, "target_assault_roundend");
+ while (ent)
+ {
+ oldself = self;
+ self = ent;
+ target_assault_roundend_reset();
+ self = oldself;
+
+ ent = find(ent, classname, "target_assault_roundend");
+ }
+
// reset all target_object_decrease
ent = find(world, classname, "target_objective_decrease");
while (ent)
@@ -390,92 +444,4 @@
}
-void assault_print_time_warning(string s) {
- local entity ent;
- ent = find(world, classname, "player");
- while(ent) {
- centerprint(ent, s);
- ent = find(ent, classname, "player");
- }
-}
-void assault_roundend_think() {
- if(time > self.cnt)
- assault_new_round();
-
- local float timeleft;
- timeleft = self.cnt - time;
- timeleft = ceil(timeleft);
-
- // reset time notification if the values don't make sense
- if(timeleft > self.nextstep)
- self.nextstep = 9999999;
-
- if(timeleft <= 300 && self.nextstep > 300) {
- assault_print_time_warning("5 minutes left");
- self.nextstep = 300;
- }
-
- if(timeleft <= 240 && self.nextstep > 240) {
- assault_print_time_warning("4 minutes left");
- self.nextstep = 240;
- }
-
- if(timeleft <= 180 && self.nextstep > 180) {
- assault_print_time_warning("3 minutes left");
- self.nextstep = 180;
- }
-
- if(timeleft <= 120 && self.nextstep > 120) {
- assault_print_time_warning("2 minutes left");
- self.nextstep = 120;
- }
-
- if(timeleft <= 60 && self.nextstep > 60) {
- assault_print_time_warning("one minute left");
- self.nextstep = 60;
- }
-
- if(timeleft <= 10) {
- assault_print_time_warning(ftos(timeleft));
- }
-
- self.nextthink = time + 0.25;
-}
-
-
-
-void target_assault_roundend() {
- if(!self.health)
- self.health = 300; // 5 minutes
- self.winning = 0; // round counter
- self.cnt = time + self.max_health; // time when this round ends
- self.classname = "target_assault_roundend";
- self.nextstep = 9999999; // used to store what time warning was last issued;
- self.use = assault_new_round;
- self.think = assault_roundend_think;
- self.nextthink = time;
-}
-
-void assault_roundstart_use() {
- local entity ent;
- local entity oldself;
- ent = find(world, targetname, self.target);
- while(ent) {
- oldself = self;
- self = ent;
- self.use();
- self = oldself;
- ent = find(ent, targetname, self.target);
- }
-}
-
-void target_assault_roundstart() {
- assault_attacker_team = COLOR_TEAM1;
- self.classname = "target_assault_roundstart";
- self.use = assault_roundstart_use;
- self.think = assault_roundstart_use;
- self.nextthink = time + 0.1;
-}
-
-
Modified: trunk/data/qcsrc/server/g_world.qc
===================================================================
--- trunk/data/qcsrc/server/g_world.qc 2007-11-04 09:09:40 UTC (rev 2898)
+++ trunk/data/qcsrc/server/g_world.qc 2007-11-04 13:24:04 UTC (rev 2899)
@@ -1170,6 +1170,57 @@
return bound(1, lms_lowest_lives, fl);
}
+// Assault winning condition: If the attackers triggered a round end (by fulfilling all objectives)
+// they win. Otherwise the defending team wins once the timelimit passes.
+void assault_new_round();
+float() WinningCondition_Assault =
+{
+ local float status;
+ status = WINNING_NO;
+
+ // as the timelimit has not yet passed just assume the defending team will win
+ if(assault_attacker_team == COLOR_TEAM1)
+ {
+ SetWinners(team, COLOR_TEAM2);
+ }
+ else
+ {
+ SetWinners(team, COLOR_TEAM1);
+ }
+
+ local entity ent;
+ ent = find(world, classname, "target_assault_roundend");
+ if(ent)
+ {
+ if(ent.winning) // round end has been triggered by attacking team
+ {
+ SetWinners(team, assault_attacker_team);
+ if(assault_attacker_team == COLOR_TEAM1)
+ {
+ team1_score = team1_score + 50;
+ }
+ else
+ {
+ team2_score = team2_score + 50;
+ }
+
+ if(ent.cnt == 1) // this was the second round
+ {
+ status = WINNING_YES;
+ }
+ else
+ {
+ cvar_set("timelimit", ftos((2*time)/60));
+ assault_new_round();
+ }
+ }
+ }
+
+ return status;
+
+}
+
+
// LMS winning condition: game terminates if and only if there's at most one
// one player who's living lives. Top two scores being equal cancels the time
// limit.
@@ -1574,8 +1625,12 @@
}
status = WINNING_NO;
- if(cvar("g_lms"))
+ if(cvar("g_assault"))
{
+ status = WinningCondition_Assault();
+ }
+ else if(cvar("g_lms"))
+ {
status = WinningCondition_LMS();
}
else if (cvar("g_onslaught"))
More information about the nexuiz-commits
mailing list