]> icculus.org git repositories - divverent/nexuiz.git/blob - data/qcsrc/server/assault.qc
rename entities according to convention, introduce
[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 target_objective() {
45         self.classname = "target_objective";
46         self.think = assault_objective_think;
47         self.use = assault_objective_use;
48         assault_objective_reset();
49 }
50
51 // decrease the health of targeted objectives
52 void assault_objective_decrease() {
53
54         local entity ent;
55         local entity oldself;
56         ent = find(world, targetname, self.target);
57         while(ent) {
58                 ent.health = ent.health - self.dmg;
59                 ent = find(ent, targetname, self.target);
60         }
61 }
62
63 // this entity should target an objective and be targeted by triggers
64 void target_objective_decrease() {
65         if(!self.dmg) {
66                 self.dmg = 101;
67         }
68         self.use = assault_objective_decrease;
69 }
70
71 // trigger new round
72 // reset objectives, toggle spawnpoints, reset triggers, ...
73 void assault_new_round() {
74         
75         // this assumes self.classname == "func_assault_roundend"!
76         self.cnt = self.cnt + 1;
77
78         // swap spawn point teams
79         local entity ent;
80         local entity oldself;
81
82         ent = find(world, classname, "info_player_deathmatch");
83         while (ent)
84         {
85                 oldself = self;
86                 self = ent;
87                 if(self.team == COLOR_TEAM1) {
88                         self.team = COLOR_TEAM2;
89                 } else {
90                         self.team = COLOR_TEAM1;
91                 }
92                 self = oldself;
93
94                 ent = find(ent, classname, "info_player_deathmatch");
95         } 
96
97         // reset all objectives
98
99         ent = find(world, classname, "target_objective");
100         while (ent)
101         {
102                 oldself = self;
103                 self = ent;
104                 assault_objective_reset();
105                 self = oldself;
106
107                 ent = find(ent, classname, "target_objective");
108         } 
109
110         // actually restart round... how to do that?
111 }
112
113 void target_assault_roundend() {
114         self.cnt = 0; // round counter
115         self.classname = "target_assault_roundend";
116         self.use = assault_new_round;
117         
118 }