2 // attacker spawn point
3 void info_player_attacker() {
4 self.team = COLOR_TEAM1; // red, gets swapped every round
5 info_player_deathmatch();
8 // defender spawn point
9 void info_player_defender() {
10 self.team = COLOR_TEAM2; // blue, gets swapped every round
11 info_player_deathmatch();
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();
55 void assault_objective_decrease_think() {
57 local entity objective;
60 objective = find(world, targetname, self.target);
61 while(objective && found == 0) {
62 if(objective.classname == "target_objective") {
64 if(objective.health < ASSAULT_VALUE_INACTIVE) { // targeted objective is active
65 if(self.cnt == 1 && self.max_health >= ASSAULT_VALUE_INACTIVE) {
66 // decrease was fired already, but objective did recover (round reset)
69 } else { // objective isn't active
72 self.max_health = objective.health; // save current objective status for next think
77 if(self.model != self.mdl)
78 setmodel(self, self.mdl);
83 self.nextthink = time + 0.2;
87 // decrease the health of targeted objectives
88 void assault_objective_decrease() {
91 ent = find(world, targetname, self.target);
93 if(ent.health > 0 && ent.health < ASSAULT_VALUE_INACTIVE)
94 ent.health = ent.health - self.dmg;
95 ent = find(ent, targetname, self.target);
101 // this entity should target an objective and be targeted by triggers
102 void target_objective_decrease() {
104 self.classname = "target_objective_decrease";
109 self.cnt = 0; // not used yet
110 self.use = assault_objective_decrease;
111 self.mdl = "models/sprites/here.sp2";
112 self.effects = EF_NODEPTHTEST;
113 self.health = ASSAULT_VALUE_INACTIVE;
114 self.max_health = ASSAULT_VALUE_INACTIVE;
115 self.think = assault_objective_decrease_think;
116 self.nextthink = time;
120 void assault_destructible_reset() {
121 self.health = self.max_health;
122 self.model = self.mdl;
123 self.solid = SOLID_BSP;
124 self.cnt = 0; // not active
129 void assault_destructible_use() {
130 self.cnt = 1; // mark active
131 self.takedamage = DAMAGE_YES;
132 self.nextthink = time + 0.1;
135 void assault_destructible_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force) {
136 // TODO: check for teams
139 self.health = self.health - damage;
144 void assault_destructible_think() {
145 local entity oldself;
147 if(self.cnt > 0 && self.health < 0) {
149 self.takedamage = DAMAGE_NO;
150 self.solid = SOLID_NOT;
152 ent = find(world, targetname, self.target);
158 ent = find(ent, targetname, self.target);
161 self.nextthink = time + 0.1;
165 // destructible walls that can be used to trigger target_objective_decrease
166 void func_assault_destructible() {
170 self.max_health = self.health;
172 self.cnt = 0; // not yet activated
174 self.classname = "func_assault_destructible";
175 self.mdl = self.model;
176 setmodel(self, self.mdl);
178 self.solid = SOLID_BSP;
179 self.think = assault_destructible_think;
180 self.use = assault_destructible_use;
181 self.event_damage = assault_destructible_damage;
187 // reset objectives, toggle spawnpoints, reset triggers, ...
188 void assault_new_round() {
190 // this assumes self.classname == "func_assault_roundend"!
191 self.cnt = self.cnt + 1;
193 // swap spawn point teams
195 local entity oldself;
197 ent = find(world, classname, "info_player_deathmatch");
202 if(self.team == COLOR_TEAM1) {
203 self.team = COLOR_TEAM2;
205 self.team = COLOR_TEAM1;
209 ent = find(ent, classname, "info_player_deathmatch");
212 // reset all objectives
213 ent = find(world, classname, "target_objective");
218 assault_objective_reset();
221 ent = find(ent, classname, "target_objective");
224 // reset all target_object_decrease
225 ent = find(world, classname, "target_objective_decrease");
229 ent = find(ent, classname, "target_objective_decrease");
232 // reset all func_assault_destructible
233 ent = find(world, classname, "func_assault_destructible");
238 assault_destructible_reset();
240 ent = find(ent, classname, "func_assault_destructible");
243 ent = find(world, classname, "target_assault_roundstart");
250 ent = find(ent, classname, "target_assault_roundstart");
253 // actually restart round... how to do that?
256 void target_assault_roundend() {
257 self.cnt = 0; // round counter
258 self.classname = "target_assault_roundend";
259 self.use = assault_new_round;
262 void assault_roundstart_use() {
264 local entity oldself;
265 ent = find(world, targetname, self.target);
271 ent = find(ent, targetname, self.target);
275 void target_assault_roundstart() {
276 self.classname = "target_assault_roundstart";
277 self.use = assault_roundstart_use;
278 self.think = assault_roundstart_use;
279 self.nextthink = time + 0.1;