1 void spawnfunc_func_breakable();
2 void target_objective_decrease_activate();
3 .entity assault_decreaser;
4 .entity assault_sprite;
6 void spawnfunc_info_player_attacker() {
12 self.team = COLOR_TEAM1; // red, gets swapped every round
13 spawnfunc_info_player_deathmatch();
16 void spawnfunc_info_player_defender() {
22 self.team = COLOR_TEAM2; // blue, gets swapped every round
23 spawnfunc_info_player_deathmatch();
26 // reset this objective. Used when spawning an objective
27 // and when a new round starts
28 void assault_objective_reset() {
29 self.health = ASSAULT_VALUE_INACTIVE;
32 void assault_objective_use() {
35 //print("^2Activated objective ", self.targetname, "=", etos(self), "\n");
36 //print("Activator is ", activator.classname, "\n");
41 for(self = world; (self = find(self, target, oldself.targetname)); )
43 if(self.classname == "target_objective_decrease")
44 target_objective_decrease_activate();
50 void spawnfunc_target_objective() {
56 self.classname = "target_objective";
57 self.use = assault_objective_use;
58 assault_objective_reset();
59 self.reset = assault_objective_reset;
63 // decrease the health of targeted objectives
64 void assault_objective_decrease_use() {
65 if(activator.team != assault_attacker_team) {
66 // wrong team triggered decrease
70 if(other.assault_sprite)
72 WaypointSprite_Disown(other.assault_sprite, waypointsprite_deadlifetime);
73 if(other.classname == "func_assault_destructible")
77 return; // already activated! cannot activate again!
79 if(self.enemy.health < ASSAULT_VALUE_INACTIVE)
81 if(self.enemy.health - self.dmg > 0.5)
83 PlayerTeamScore_Add(activator, SP_SCORE, ST_SCORE, self.dmg);
84 self.enemy.health = self.enemy.health - self.dmg;
88 PlayerTeamScore_Add(activator, SP_SCORE, ST_SCORE, self.enemy.health);
89 PlayerTeamScore_Add(activator, SP_ASSAULT_OBJECTIVES, ST_ASSAULT_OBJECTIVES, 1);
90 self.enemy.health = -1;
92 entity oldself, oldactivator;
100 FOR_EACH_PLAYER(player)
102 s = strcat(self.message, "\n");
103 centerprint(player, s);
107 oldactivator = activator;
110 activator = oldactivator;
116 void assault_setenemytoobjective()
118 local entity objective;
119 for(objective = world; (objective = find(objective, targetname, self.target)); ) {
120 if(objective.classname == "target_objective") {
121 if(self.enemy == world)
122 self.enemy = objective;
124 objerror("more than one objective as target - fix the map!");
129 if(self.enemy == world)
130 objerror("no objective as target - fix the map!");
133 float assault_decreaser_sprite_visible(entity e)
137 decreaser = self.assault_decreaser;
139 if(decreaser.enemy.health >= ASSAULT_VALUE_INACTIVE)
145 void target_objective_decrease_activate()
149 for(ent = world; (ent = find(ent, target, self.targetname)); )
151 if(ent.assault_sprite != world)
153 WaypointSprite_Disown(ent.assault_sprite, waypointsprite_deadlifetime);
154 if(ent.classname == "func_assault_destructible")
158 spr = WaypointSprite_SpawnFixed("<placeholder>", 0.5 * (ent.absmin + ent.absmax), ent, assault_sprite, RADARICON_OBJECTIVE, '1 0.5 0');
159 spr.assault_decreaser = self;
160 spr.waypointsprite_visible_for_player = assault_decreaser_sprite_visible;
161 spr.classname = "sprite_waypoint";
162 WaypointSprite_UpdateRule(spr, assault_attacker_team, SPRITERULE_TEAMPLAY);
163 if(ent.classname == "func_assault_destructible")
165 WaypointSprite_UpdateSprites(spr, "as-defend", "as-destroy", "as-destroy");
166 WaypointSprite_UpdateMaxHealth(spr, ent.max_health);
167 WaypointSprite_UpdateHealth(spr, ent.health);
171 WaypointSprite_UpdateSprites(spr, "as-defend", "as-push", "as-push");
175 void target_objective_decrease_findtarget()
177 assault_setenemytoobjective();
180 //=============================================================================
182 void spawnfunc_target_objective_decrease() {
189 self.classname = "target_objective_decrease";
194 self.use = assault_objective_decrease_use;
195 self.health = ASSAULT_VALUE_INACTIVE;
196 self.max_health = ASSAULT_VALUE_INACTIVE;
199 InitializeEntity(self, target_objective_decrease_findtarget, INITPRIO_FINDTARGET);
202 // destructible walls that can be used to trigger target_objective_decrease
203 void spawnfunc_func_assault_destructible() {
210 if(assault_attacker_team == COLOR_TEAM1) {
211 self.team = COLOR_TEAM2;
213 self.team = COLOR_TEAM1;
215 spawnfunc_func_breakable();
218 void assault_wall_think() {
219 if(self.enemy.health < 0) {
221 self.solid = SOLID_NOT;
223 self.model = self.mdl;
224 self.solid = SOLID_BSP;
227 self.nextthink = time + 0.2;
230 void spawnfunc_func_assault_wall() {
236 self.classname = "func_assault_wall";
237 self.mdl = self.model;
238 setmodel(self, self.mdl);
239 self.solid = SOLID_BSP;
240 self.think = assault_wall_think;
241 self.nextthink = time;
242 InitializeEntity(self, assault_setenemytoobjective, INITPRIO_FINDTARGET);
246 void target_assault_roundend_reset() {
247 //print("round end reset\n");
248 self.cnt = self.cnt + 1; // up round counter
249 self.winning = 0; // up round
252 void target_assault_roundend_use() {
253 self.winning = 1; // round has been won by attackers
256 void spawnfunc_target_assault_roundend() {
262 self.winning = 0; // round not yet won by attackers
263 self.classname = "target_assault_roundend";
264 self.use = target_assault_roundend_use;
265 self.cnt = 0; // first round
266 self.reset = target_assault_roundend_reset;
269 void assault_roundstart_use() {
275 #ifdef TTURRETS_ENABLED
278 //(Re)spawn all turrets
280 ent = find(world, classname, "turret_main");
283 if(ent.team == COLOR_TEAM1)
284 ent.team = COLOR_TEAM2;
286 ent.team = COLOR_TEAM1;
290 // Dubbles as teamchange
291 turret_stdproc_respawn();
293 ent = find(ent, classname, "turret_main");
301 void spawnfunc_target_assault_roundstart() {
307 assault_attacker_team = COLOR_TEAM1;
308 self.classname = "target_assault_roundstart";
309 self.use = assault_roundstart_use;
310 self.reset2 = assault_roundstart_use;
311 InitializeEntity(self, assault_roundstart_use, INITPRIO_FINDTARGET);
315 // reset objectives, toggle spawnpoints, reset triggers, ...
316 void assault_new_round() {
317 //bprint("ASSAULT: new round\n");
320 self.winning = self.winning + 1;
322 // swap attacker/defender roles
323 if(assault_attacker_team == COLOR_TEAM1) {
324 assault_attacker_team = COLOR_TEAM2;
326 assault_attacker_team = COLOR_TEAM1;
331 for(ent = world; (ent = nextent(ent)); )
333 if(clienttype(ent) == CLIENTTYPE_NOTACLIENT)
335 if(ent.team_saved == COLOR_TEAM1)
336 ent.team_saved = COLOR_TEAM2;
337 else if(ent.team_saved == COLOR_TEAM2)
338 ent.team_saved = COLOR_TEAM1;
342 // reset the level with a countdown
343 cvar_set("timelimit", ftos(ceil(time - game_starttime) / 60));
344 ReadyRestartForce(); // sets game_starttime