2 // attacker spawn point
3 void info_player_attacker() {
4 info_player_deathmatch();
5 self.team = COLOR_TEAM1; // red, gets swapped every round
8 // defender spawn point
9 void info_player_defender() {
10 info_player_deathmatch();
11 self.team = COLOR_TEAM2; // blue, gets swapped every round
14 // reset this objective. Used when spawning an objective
15 // and when a new round starts
16 void assault_objective_reset() {
17 self.health = ASSAULT_VALUE_INACTIVE;
20 void assault_objective_use() {
23 self.nextthink = time + 0.1;
26 void assault_objective_think() {
31 ent = find(world, targetname, self.target);
37 ent = find(ent, targetname, self.target);
41 //self.effects = EF_STARDUST;
42 self.nextthink = time + 0.1;
47 void target_objective() {
48 self.classname = "target_objective";
49 self.think = assault_objective_think;
50 self.use = assault_objective_use;
51 assault_objective_reset();
54 float assault_objective_decrease_customizeforclient() {
56 if(other.team == assault_attacker_team)
57 setmodel(self, "models/sprites/here.sp2");
59 setmodel(self, "models/sprites/helpme.sp2");
67 void assault_objective_decrease_think() {
69 local entity objective;
72 objective = find(world, targetname, self.target);
73 while(objective && found == 0) {
74 if(objective.classname == "target_objective") {
76 if(objective.health < ASSAULT_VALUE_INACTIVE) { // targeted objective is active
77 if(self.cnt == 1 && self.max_health >= ASSAULT_VALUE_INACTIVE) {
78 // decrease was fired already, but objective did recover (round reset)
81 } else { // objective isn't active
84 self.max_health = objective.health; // save current objective status for next think
89 self.nextthink = time + 0.2;
93 // decrease the health of targeted objectives
94 void assault_objective_decrease_use() {
99 if(activator.team != assault_attacker_team)
103 ent = find(world, targetname, self.target);
105 if(ent.health > 0 && ent.health < ASSAULT_VALUE_INACTIVE)
106 ent.health = ent.health - self.dmg;
107 ent = find(ent, targetname, self.target);
113 // this entity should target an objective and be targeted by triggers
114 void target_objective_decrease() {
116 self.classname = "target_objective_decrease";
121 self.cnt = 0; // not used yet
122 self.use = assault_objective_decrease_use;
123 self.mdl = "models/sprites/here.sp2";
124 self.effects = EF_NODEPTHTEST;
125 self.health = ASSAULT_VALUE_INACTIVE;
126 self.max_health = ASSAULT_VALUE_INACTIVE;
127 self.think = assault_objective_decrease_think;
128 self.customizeentityforclient = assault_objective_decrease_customizeforclient;
129 self.nextthink = time;
133 void assault_destructible_reset() {
134 self.health = self.max_health;
135 self.model = self.mdl;
136 self.solid = SOLID_BSP;
137 self.colormod = '1 1 1';
138 self.cnt = 0; // not active
143 void assault_destructible_use() {
144 self.cnt = 1; // mark active
145 self.takedamage = DAMAGE_YES;
148 void assault_destructible_destroy() {
149 local entity oldself;
152 self.takedamage = DAMAGE_NO;
153 self.solid = SOLID_NOT;
155 ent = find(world, targetname, self.target);
161 ent = find(ent, targetname, self.target);
165 void assault_destructible_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) {
167 if(self.cnt > 0 && assault_attacker_team == attacker.team) {
168 self.health = self.health - damage;
169 if(self.health / self.max_health < 0.25)
170 self.colormod = '1 0 0';
171 else if(self.health / self.max_health < 0.375)
172 self.colormod = '1 0.25 0';
173 else if(self.health / self.max_health < 0.50)
174 self.colormod = '1 0.5 0';
175 else if(self.health / self.max_health < 0.625)
176 self.colormod = '1 0.75 0';
177 else if(self.health / self.max_health < 0.75)
178 self.colormod = '1 1 0';
180 self.colormod = '1 1 1';
183 if(self.health < 0) {
184 activator = attacker;
185 assault_destructible_destroy();
189 // destructible walls that can be used to trigger target_objective_decrease
190 void func_assault_destructible() {
194 self.max_health = self.health;
196 self.cnt = 0; // not yet activated
198 self.classname = "func_assault_destructible";
199 self.mdl = self.model;
200 setmodel(self, self.mdl);
202 self.solid = SOLID_BSP;
203 self.use = assault_destructible_use;
204 self.event_damage = assault_destructible_damage;
208 void assault_wall_think() {
210 local float notvisible;
212 ent = find(world, targetname, self.target);
214 if(ent.classname == "target_objective" && ent.health < 0)
216 ent = find(ent, targetname, self.target);
221 self.solid = SOLID_NOT;
223 self.model = self.mdl;
224 self.solid = SOLID_BSP;
227 self.nextthink = time + 0.2;
230 void func_assault_wall() {
231 self.classname = "func_assault_wall";
232 self.mdl = self.model;
233 setmodel(self, self.mdl);
234 self.solid = SOLID_BSP;
235 self.think = assault_wall_think;
236 self.nextthink = time;
240 // reset objectives, toggle spawnpoints, reset triggers, ...
241 void assault_new_round() {
243 // this assumes self.classname == "func_assault_roundend"!
244 self.cnt = self.cnt + 1;
246 // swap spawn point teams
248 local entity oldself;
250 // reward attackers for winning the round
251 ent = find(world, classname, "player");
253 if(ent.team == assault_attacker_team) {
254 UpdateFrags(ent, 10);
256 ent = find(ent, classname, "player");
259 // swap attacker/defender roles
260 if(assault_attacker_team == COLOR_TEAM1) {
261 assault_attacker_team = COLOR_TEAM2;
263 assault_attacker_team = COLOR_TEAM1;
266 ent = find(world, classname, "info_player_deathmatch");
271 if(self.team == COLOR_TEAM1) {
272 self.team = COLOR_TEAM2;
274 self.team = COLOR_TEAM1;
278 ent = find(ent, classname, "info_player_deathmatch");
281 // reset all objectives
282 ent = find(world, classname, "target_objective");
287 assault_objective_reset();
290 ent = find(ent, classname, "target_objective");
293 // reset all target_object_decrease
294 ent = find(world, classname, "target_objective_decrease");
298 ent = find(ent, classname, "target_objective_decrease");
301 // reset all func_assault_destructible
302 ent = find(world, classname, "func_assault_destructible");
307 assault_destructible_reset();
309 ent = find(ent, classname, "func_assault_destructible");
312 ent = find(world, classname, "target_assault_roundstart");
319 ent = find(ent, classname, "target_assault_roundstart");
322 // actually restart round... how to do that?
323 ent = find(world, classname, "player");
329 ent = find(ent, classname, "player");
335 void target_assault_roundend() {
336 self.cnt = 0; // round counter
337 self.classname = "target_assault_roundend";
338 self.use = assault_new_round;
341 void assault_roundstart_use() {
343 local entity oldself;
344 ent = find(world, targetname, self.target);
350 ent = find(ent, targetname, self.target);
354 void target_assault_roundstart() {
355 assault_attacker_team = COLOR_TEAM1;
356 self.classname = "target_assault_roundstart";
357 self.use = assault_roundstart_use;
358 self.think = assault_roundstart_use;
359 self.nextthink = time + 0.1;