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()
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 self.classname = "func_assault_destructible";
211 if(assault_attacker_team == COLOR_TEAM1) {
212 self.team = COLOR_TEAM2;
214 self.team = COLOR_TEAM1;
216 spawnfunc_func_breakable();
219 void assault_wall_think() {
220 if(self.enemy.health < 0) {
222 self.solid = SOLID_NOT;
224 self.model = self.mdl;
225 self.solid = SOLID_BSP;
228 self.nextthink = time + 0.2;
231 void spawnfunc_func_assault_wall() {
237 self.classname = "func_assault_wall";
238 self.mdl = self.model;
239 setmodel(self, self.mdl);
240 self.solid = SOLID_BSP;
241 self.think = assault_wall_think;
242 self.nextthink = time;
243 InitializeEntity(self, assault_setenemytoobjective, INITPRIO_FINDTARGET);
247 void target_assault_roundend_reset() {
248 //print("round end reset\n");
249 self.cnt = self.cnt + 1; // up round counter
250 self.winning = 0; // up round
253 void target_assault_roundend_use() {
254 self.winning = 1; // round has been won by attackers
257 void spawnfunc_target_assault_roundend() {
263 self.winning = 0; // round not yet won by attackers
264 self.classname = "target_assault_roundend";
265 self.use = target_assault_roundend_use;
266 self.cnt = 0; // first round
267 self.reset = target_assault_roundend_reset;
270 void assault_roundstart_use() {
276 #ifdef TTURRETS_ENABLED
279 //(Re)spawn all turrets
281 ent = find(world, classname, "turret_main");
284 if(ent.team == COLOR_TEAM1)
285 ent.team = COLOR_TEAM2;
287 ent.team = COLOR_TEAM1;
291 // Dubbles as teamchange
292 turret_stdproc_respawn();
294 ent = find(ent, classname, "turret_main");
302 void spawnfunc_target_assault_roundstart() {
308 assault_attacker_team = COLOR_TEAM1;
309 self.classname = "target_assault_roundstart";
310 self.use = assault_roundstart_use;
311 self.reset2 = assault_roundstart_use;
312 InitializeEntity(self, assault_roundstart_use, INITPRIO_FINDTARGET);
316 // reset objectives, toggle spawnpoints, reset triggers, ...
317 void vehicles_clearrturn();
318 void vehicles_spawn();
319 void assault_new_round()
322 //bprint("ASSAULT: new round\n");
325 // Eject players from vehicles
326 FOR_EACH_PLAYER(self)
329 vehicles_exit(VHEF_RELESE);
332 self = findchainflags(vehicle_flags, VHF_ISVEHICLE);
335 vehicles_clearrturn();
343 self.winning = self.winning + 1;
345 // swap attacker/defender roles
346 if(assault_attacker_team == COLOR_TEAM1) {
347 assault_attacker_team = COLOR_TEAM2;
349 assault_attacker_team = COLOR_TEAM1;
354 for(ent = world; (ent = nextent(ent)); )
356 if(clienttype(ent) == CLIENTTYPE_NOTACLIENT)
358 if(ent.team_saved == COLOR_TEAM1)
359 ent.team_saved = COLOR_TEAM2;
360 else if(ent.team_saved == COLOR_TEAM2)
361 ent.team_saved = COLOR_TEAM1;
365 // reset the level with a countdown
366 cvar_set("timelimit", ftos(ceil(time - game_starttime) / 60));
367 ReadyRestartForce(); // sets game_starttime