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