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() {
96 if(activator.team != assault_attacker_team)
100 ent = find(world, targetname, self.target);
102 if(ent.health > 0 && ent.health < ASSAULT_VALUE_INACTIVE)
103 ent.health = ent.health - self.dmg;
104 ent = find(ent, targetname, self.target);
110 // this entity should target an objective and be targeted by triggers
111 void target_objective_decrease() {
113 self.classname = "target_objective_decrease";
118 self.cnt = 0; // not used yet
119 self.use = assault_objective_decrease_use;
120 self.mdl = "models/sprites/here.sp2";
121 self.effects = EF_NODEPTHTEST;
122 self.health = ASSAULT_VALUE_INACTIVE;
123 self.max_health = ASSAULT_VALUE_INACTIVE;
124 self.think = assault_objective_decrease_think;
125 self.customizeentityforclient = assault_objective_decrease_customizeforclient;
126 self.nextthink = time;
130 void assault_destructible_reset() {
131 self.health = self.max_health;
132 self.model = self.mdl;
133 self.solid = SOLID_BSP;
134 self.cnt = 0; // not active
139 void assault_destructible_use() {
140 self.cnt = 1; // mark active
141 self.takedamage = DAMAGE_YES;
144 void assault_destructible_destroy() {
145 local entity oldself;
148 self.takedamage = DAMAGE_NO;
149 self.solid = SOLID_NOT;
151 ent = find(world, targetname, self.target);
157 ent = find(ent, targetname, self.target);
161 void assault_destructible_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) {
163 if(self.cnt > 0 && assault_attacker_team == attacker.team) {
164 self.health = self.health - damage;
167 if(self.health < 0) {
168 activator = attacker;
169 assault_destructible_destroy();
173 // destructible walls that can be used to trigger target_objective_decrease
174 void func_assault_destructible() {
178 self.max_health = self.health;
180 self.cnt = 0; // not yet activated
182 self.classname = "func_assault_destructible";
183 self.mdl = self.model;
184 setmodel(self, self.mdl);
186 self.solid = SOLID_BSP;
187 self.use = assault_destructible_use;
188 self.event_damage = assault_destructible_damage;
194 // reset objectives, toggle spawnpoints, reset triggers, ...
195 void assault_new_round() {
197 // this assumes self.classname == "func_assault_roundend"!
198 self.cnt = self.cnt + 1;
200 // swap spawn point teams
202 local entity oldself;
204 ent = find(world, classname, "info_player_deathmatch");
209 if(self.team == COLOR_TEAM1) {
210 self.team = COLOR_TEAM2;
212 self.team = COLOR_TEAM1;
216 ent = find(ent, classname, "info_player_deathmatch");
219 // reset all objectives
220 ent = find(world, classname, "target_objective");
225 assault_objective_reset();
228 ent = find(ent, classname, "target_objective");
231 // reset all target_object_decrease
232 ent = find(world, classname, "target_objective_decrease");
236 ent = find(ent, classname, "target_objective_decrease");
239 // reset all func_assault_destructible
240 ent = find(world, classname, "func_assault_destructible");
245 assault_destructible_reset();
247 ent = find(ent, classname, "func_assault_destructible");
250 ent = find(world, classname, "target_assault_roundstart");
257 ent = find(ent, classname, "target_assault_roundstart");
260 // actually restart round... how to do that?
261 ent = find(world, classname, "player");
265 if(self.team == assault_attacker_team) {
266 UpdateFrags(self, 10);
270 ent = find(ent, classname, "player");
273 // swap attacker/defender roles
274 if(assault_attacker_team == COLOR_TEAM1) {
275 assault_attacker_team = COLOR_TEAM2;
277 assault_attacker_team = COLOR_TEAM1;
281 void target_assault_roundend() {
282 self.cnt = 0; // round counter
283 self.classname = "target_assault_roundend";
284 self.use = assault_new_round;
287 void assault_roundstart_use() {
289 local entity oldself;
290 ent = find(world, targetname, self.target);
296 ent = find(ent, targetname, self.target);
300 void target_assault_roundstart() {
301 assault_attacker_team = COLOR_TEAM1;
302 self.classname = "target_assault_roundstart";
303 self.use = assault_roundstart_use;
304 self.think = assault_roundstart_use;
305 self.nextthink = time + 0.1;