]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/assault.qc
moved magic "this objective is inactive" value to constants.qh (it's
[divverent/nexuiz.git] / data / qcsrc / server / assault.qc
1
2 // attacker spawn point
3 void info_player_attacker() {
4         self.team = COLOR_TEAM1; // red, gets swapped every round
5         info_player_deathmatch();
6 }
7
8 // defender spawn point
9 void info_player_defender() {
10         self.team = COLOR_TEAM2; // blue, gets swapped every round
11         info_player_deathmatch();
12 }
13
14 // reset this objective. Used when spawning an objective
15 // and when a new round starts
16 void assault_objective_reset() {
17         if(self.spawnflags) { // first objective
18                 self.health = 100;
19                 self.nextthink = time + 0.1;
20         } else {
21                 self.health = ASSAULT_VALUE_INACTIVE;
22         }
23 }
24
25 void assault_objective_use() {
26         // activate objective
27         self.health = 100; 
28         self.nextthink = time + 0.1;
29 }
30
31 void assault_objective_think() {
32         
33         if(self.health < 0) {
34                 local entity ent;
35                 ent = find(world, targetname, self.target);
36                 self = ent;
37                 self.use();
38         } else {
39                 self.nextthink = time + 0.1;
40         }
41         
42 }
43
44 void func_objective() {
45         self.classname = "func_objective";
46         self.think = assault_objective_think;
47         self.use = assault_objective_use;
48         assault_objective_reset();
49 }
50
51 // trigger new round
52 // reset objectives, toggle spawnpoints, reset triggers, ...
53 void assault_new_round() {
54         
55         // this assumes self.classname == "func_assault_roundend"!
56         self.cnt = self.cnt + 1;
57
58         // swap spawn point teams
59         local entity ent;
60         local entity oldself;
61
62         ent = find(world, classname, "info_player_deathmatch");
63         while (ent)
64         {
65                 oldself = self;
66                 self = ent;
67                 if(self.team == COLOR_TEAM1) {
68                         self.team = COLOR_TEAM2;
69                 } else {
70                         self.team = COLOR_TEAM1;
71                 }
72                 self = oldself;
73
74                 ent = find(ent, classname, "info_player_deathmatch");
75         } 
76
77         // reset all objectives
78
79         ent = find(world, classname, "func_objective");
80         while (ent)
81         {
82                 oldself = self;
83                 self = ent;
84                 assault_objective_reset();
85                 self = oldself;
86
87                 ent = find(ent, classname, "func_objective");
88         } 
89
90         // actually restart round... how to do that?
91 }
92
93 void func_assault_roundend() {
94         self.cnt = 0; // round counter
95         self.classname = "func_assault_roundend";
96         self.use = assault_new_round;
97         
98 }