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() {
54 self.classname = "target_objective";
55 self.use = assault_objective_use;
56 assault_objective_reset();
60 // decrease the health of targeted objectives
61 void assault_objective_decrease_use() {
62 if(activator.team != assault_attacker_team) {
63 // wrong team triggered decrease
67 if(other.assault_sprite.classname == "assault_decreaser_sprite")
68 WaypointSprite_Disown(other.assault_sprite, waypointsprite_deadlifetime);
70 return; // already activated! cannot activate again!
72 if(self.enemy.health < ASSAULT_VALUE_INACTIVE)
74 if(self.enemy.health - self.dmg > 0.5)
76 PlayerTeamScore_Add(activator, SP_SCORE, ST_SCORE, self.dmg);
77 self.enemy.health = self.enemy.health - self.dmg;
81 PlayerTeamScore_Add(activator, SP_SCORE, ST_SCORE, self.enemy.health);
82 PlayerTeamScore_Add(activator, SP_ASSAULT_OBJECTIVES, ST_ASSAULT_OBJECTIVES, 1);
83 self.enemy.health = -1;
85 entity oldself, oldactivator;
89 oldactivator = activator;
92 activator = oldactivator;
98 void assault_setenemytoobjective()
100 local entity objective;
101 for(objective = world; (objective = find(objective, targetname, self.target)); ) {
102 if(objective.classname == "target_objective") {
103 if(self.enemy == world)
104 self.enemy = objective;
106 objerror("more than one objective as target - fix the map!");
111 if(self.enemy == world)
112 objerror("no objective as target - fix the map!");
115 float assault_decreaser_sprite_visible(entity e)
119 decreaser = self.assault_decreaser;
121 if(decreaser.enemy.health >= ASSAULT_VALUE_INACTIVE)
127 void target_objective_decrease_activate()
131 for(ent = world; (ent = find(ent, target, self.targetname)); )
133 if(ent.assault_sprite != world)
134 WaypointSprite_Disown(ent.assault_sprite, waypointsprite_deadlifetime);
136 spr = WaypointSprite_SpawnFixed("<placeholder>", 0.5 * (ent.absmin + ent.absmax), ent, assault_sprite);
137 spr.assault_decreaser = self;
138 spr.waypointsprite_visible_for_player = assault_decreaser_sprite_visible;
139 spr.classname = "assault_decreaser_sprite";
140 WaypointSprite_UpdateRule(spr, assault_attacker_team, SPRITERULE_TEAMPLAY);
141 if(ent.classname == "func_assault_destructible")
142 WaypointSprite_UpdateSprites(spr, "as-defend", "as-destroy", "as-destroy");
144 WaypointSprite_UpdateSprites(spr, "as-defend", "as-push", "as-push");
145 WaypointSprite_UpdateTeamRadar(spr, RADARICON_OBJECTIVE, '1 0.5 0');
149 void target_objective_decrease_findtarget()
151 assault_setenemytoobjective();
154 //=============================================================================
156 void spawnfunc_target_objective_decrease() {
158 self.classname = "target_objective_decrease";
163 self.use = assault_objective_decrease_use;
164 self.health = ASSAULT_VALUE_INACTIVE;
165 self.max_health = ASSAULT_VALUE_INACTIVE;
168 InitializeEntity(self, target_objective_decrease_findtarget, INITPRIO_FINDTARGET);
171 // destructible walls that can be used to trigger target_objective_decrease
172 void spawnfunc_func_assault_destructible() {
174 spawnfunc_func_breakable();
177 void assault_wall_think() {
178 if(self.enemy.health < 0) {
180 self.solid = SOLID_NOT;
182 self.model = self.mdl;
183 self.solid = SOLID_BSP;
186 self.nextthink = time + 0.2;
189 void spawnfunc_func_assault_wall() {
190 self.classname = "func_assault_wall";
191 self.mdl = self.model;
192 setmodel(self, self.mdl);
193 self.solid = SOLID_BSP;
194 self.think = assault_wall_think;
195 self.nextthink = time;
196 InitializeEntity(self, assault_setenemytoobjective, INITPRIO_FINDTARGET);
200 void target_assault_roundend_reset() {
201 //print("round end reset\n");
202 self.cnt = self.cnt + 1; // up round counter
203 self.winning = 0; // up round
206 void target_assault_roundend_use() {
207 self.winning = 1; // round has been won by attackers
210 void spawnfunc_target_assault_roundend() {
211 self.winning = 0; // round not yet won by attackers
212 self.classname = "target_assault_roundend";
213 self.use = target_assault_roundend_use;
214 self.cnt = 0; // first round
217 void assault_roundstart_use() {
223 #ifdef TTURRETS_ENABLED
226 //(Re)spawn all turrets
228 ent = find(world, classname, "turret_main");
231 if(ent.team == COLOR_TEAM1)
232 ent.team = COLOR_TEAM2;
234 ent.team = COLOR_TEAM1;
238 // Dubbles as teamchange
239 turret_stdproc_respawn();
240 //ent.turret_spawnfunc();
242 ent = find(ent, classname, "turret_main");
250 void spawnfunc_target_assault_roundstart() {
251 assault_attacker_team = COLOR_TEAM1;
252 self.classname = "target_assault_roundstart";
253 self.use = assault_roundstart_use;
254 InitializeEntity(self, assault_roundstart_use, INITPRIO_FINDTARGET);
258 // reset objectives, toggle spawnpoints, reset triggers, ...
259 void assault_new_round() {
260 //bprint("ASSAULT: new round\n");
263 self.winning = self.winning + 1;
265 // swap attacker/defender roles
266 if(assault_attacker_team == COLOR_TEAM1) {
267 assault_attacker_team = COLOR_TEAM2;
269 assault_attacker_team = COLOR_TEAM1;
272 // swap spawn point teams
274 ent = find(world, classname, "info_player_deathmatch");
277 if(ent.team == COLOR_TEAM1) {
278 ent.team = COLOR_TEAM2;
280 ent.team = COLOR_TEAM1;
282 ent = find(ent, classname, "info_player_deathmatch");
285 // swap all destructibles
286 ent = find(world, classname, "func_assault_destructible");
289 if(ent.team == COLOR_TEAM1)
290 ent.team = COLOR_TEAM2;
292 ent.team = COLOR_TEAM1;
293 ent = find(ent, classname, "func_assault_destructible");
296 // reset the level with a countdown
297 cvar_set("timelimit", ftos(ceil(time - game_starttime) / 60));
298 ReadyRestartForce(); // sets game_starttime