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() {
33 if(other.classname == "info_player_deathmatch") // a spawn, a spawn
38 //print("^2Activated objective ", self.targetname, "=", etos(self), "\n");
39 //print("Activator is ", activator.classname, "\n");
44 for(self = world; (self = find(self, target, oldself.targetname)); )
46 if(self.classname == "target_objective_decrease")
47 target_objective_decrease_activate();
53 void spawnfunc_target_objective() {
59 self.classname = "target_objective";
60 self.use = assault_objective_use;
61 assault_objective_reset();
62 self.reset = assault_objective_reset;
66 // decrease the health of targeted objectives
67 void assault_objective_decrease_use() {
68 if(activator.team != assault_attacker_team) {
69 // wrong team triggered decrease
73 if(other.assault_sprite.classname == "assault_decreaser_sprite")
74 WaypointSprite_Disown(other.assault_sprite, waypointsprite_deadlifetime);
76 return; // already activated! cannot activate again!
78 if(self.enemy.health < ASSAULT_VALUE_INACTIVE)
80 if(self.enemy.health - self.dmg > 0.5)
82 PlayerTeamScore_Add(activator, SP_SCORE, ST_SCORE, self.dmg);
83 self.enemy.health = self.enemy.health - self.dmg;
87 PlayerTeamScore_Add(activator, SP_SCORE, ST_SCORE, self.enemy.health);
88 PlayerTeamScore_Add(activator, SP_ASSAULT_OBJECTIVES, ST_ASSAULT_OBJECTIVES, 1);
89 self.enemy.health = -1;
91 entity oldself, oldactivator;
95 oldactivator = activator;
98 activator = oldactivator;
104 void assault_setenemytoobjective()
106 local entity objective;
107 for(objective = world; (objective = find(objective, targetname, self.target)); ) {
108 if(objective.classname == "target_objective") {
109 if(self.enemy == world)
110 self.enemy = objective;
112 objerror("more than one objective as target - fix the map!");
117 if(self.enemy == world)
118 objerror("no objective as target - fix the map!");
121 float assault_decreaser_sprite_visible(entity e)
125 decreaser = self.assault_decreaser;
127 if(decreaser.enemy.health >= ASSAULT_VALUE_INACTIVE)
133 void target_objective_decrease_activate()
137 for(ent = world; (ent = find(ent, target, self.targetname)); )
139 if(ent.assault_sprite != world)
140 WaypointSprite_Disown(ent.assault_sprite, waypointsprite_deadlifetime);
142 spr = WaypointSprite_SpawnFixed("<placeholder>", 0.5 * (ent.absmin + ent.absmax), ent, assault_sprite);
143 spr.assault_decreaser = self;
144 spr.waypointsprite_visible_for_player = assault_decreaser_sprite_visible;
145 spr.classname = "assault_decreaser_sprite";
146 WaypointSprite_UpdateRule(spr, assault_attacker_team, SPRITERULE_TEAMPLAY);
147 if(ent.classname == "func_assault_destructible")
148 WaypointSprite_UpdateSprites(spr, "as-defend", "as-destroy", "as-destroy");
150 WaypointSprite_UpdateSprites(spr, "as-defend", "as-push", "as-push");
151 WaypointSprite_UpdateTeamRadar(spr, RADARICON_OBJECTIVE, '1 0.5 0');
155 void target_objective_decrease_findtarget()
157 assault_setenemytoobjective();
160 //=============================================================================
162 void spawnfunc_target_objective_decrease() {
169 self.classname = "target_objective_decrease";
174 self.use = assault_objective_decrease_use;
175 self.health = ASSAULT_VALUE_INACTIVE;
176 self.max_health = ASSAULT_VALUE_INACTIVE;
179 InitializeEntity(self, target_objective_decrease_findtarget, INITPRIO_FINDTARGET);
182 // destructible walls that can be used to trigger target_objective_decrease
183 void spawnfunc_func_assault_destructible() {
190 spawnfunc_func_breakable();
193 void assault_wall_think() {
194 if(self.enemy.health < 0) {
196 self.solid = SOLID_NOT;
198 self.model = self.mdl;
199 self.solid = SOLID_BSP;
202 self.nextthink = time + 0.2;
205 void spawnfunc_func_assault_wall() {
211 self.classname = "func_assault_wall";
212 self.mdl = self.model;
213 setmodel(self, self.mdl);
214 self.solid = SOLID_BSP;
215 self.think = assault_wall_think;
216 self.nextthink = time;
217 InitializeEntity(self, assault_setenemytoobjective, INITPRIO_FINDTARGET);
221 void target_assault_roundend_reset() {
222 //print("round end reset\n");
223 self.cnt = self.cnt + 1; // up round counter
224 self.winning = 0; // up round
227 void target_assault_roundend_use() {
228 self.winning = 1; // round has been won by attackers
231 void spawnfunc_target_assault_roundend() {
237 self.winning = 0; // round not yet won by attackers
238 self.classname = "target_assault_roundend";
239 self.use = target_assault_roundend_use;
240 self.cnt = 0; // first round
241 self.reset = target_assault_roundend_reset;
244 void assault_roundstart_use() {
250 #ifdef TTURRETS_ENABLED
253 //(Re)spawn all turrets
255 ent = find(world, classname, "turret_main");
258 if(ent.team == COLOR_TEAM1)
259 ent.team = COLOR_TEAM2;
261 ent.team = COLOR_TEAM1;
265 // Dubbles as teamchange
266 turret_stdproc_respawn();
267 //ent.turret_spawnfunc();
269 ent = find(ent, classname, "turret_main");
277 void spawnfunc_target_assault_roundstart() {
283 assault_attacker_team = COLOR_TEAM1;
284 self.classname = "target_assault_roundstart";
285 self.use = assault_roundstart_use;
286 self.reset2 = assault_roundstart_use;
287 InitializeEntity(self, assault_roundstart_use, INITPRIO_FINDTARGET);
291 // reset objectives, toggle spawnpoints, reset triggers, ...
292 void assault_new_round() {
293 //bprint("ASSAULT: new round\n");
296 self.winning = self.winning + 1;
298 // swap attacker/defender roles
299 if(assault_attacker_team == COLOR_TEAM1) {
300 assault_attacker_team = COLOR_TEAM2;
302 assault_attacker_team = COLOR_TEAM1;
307 for(ent = world; (ent = nextent(ent)); )
309 if(clienttype(ent) == CLIENTTYPE_NOTACLIENT)
311 if(ent.team_saved == COLOR_TEAM1)
312 ent.team_saved = COLOR_TEAM2;
313 else if(ent.team_saved == COLOR_TEAM2)
314 ent.team_saved = COLOR_TEAM1;
318 // reset the level with a countdown
319 cvar_set("timelimit", ftos(ceil(time - game_starttime) / 60));
320 ReadyRestartForce(); // sets game_starttime