1 void spawnfunc_func_breakable();
2 void target_objective_decrease_activate();
3 .entity assault_decreaser;
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.sprite.classname == "assault_decreaser_sprite")
68 WaypointSprite_Disown(other.sprite, waypointsprite_deadlifetime);
70 if(self.enemy.health < ASSAULT_VALUE_INACTIVE)
72 if(self.enemy.health - self.dmg > 0.5)
74 PlayerTeamScore_Add(activator, SP_SCORE, ST_SCORE, self.dmg);
75 self.enemy.health = self.enemy.health - self.dmg;
79 PlayerTeamScore_Add(activator, SP_SCORE, ST_SCORE, self.enemy.health);
80 PlayerTeamScore_Add(activator, SP_ASSAULT_OBJECTIVES, ST_ASSAULT_OBJECTIVES, 1);
81 self.enemy.health = -1;
83 entity oldself, oldactivator;
87 oldactivator = activator;
90 activator = oldactivator;
96 void assault_setenemytoobjective()
98 local entity objective;
99 for(objective = world; (objective = find(objective, targetname, self.target)); ) {
100 if(objective.classname == "target_objective") {
101 if(self.enemy == world)
102 self.enemy = objective;
104 objerror("more than one objective as target - fix the map!");
109 if(self.enemy == world)
110 objerror("no objective as target - fix the map!");
113 float assault_decreaser_sprite_visible(entity e)
118 decreaser = self.assault_decreaser;
120 if(decreaser.enemy.health >= ASSAULT_VALUE_INACTIVE)
126 void target_objective_decrease_activate()
130 for(ent = world; (ent = find(ent, target, self.targetname)); )
132 if(ent.sprite != world)
133 WaypointSprite_Disown(ent.sprite, waypointsprite_deadlifetime);
135 spr = WaypointSprite_SpawnFixed("<placeholder>", 0.5 * (ent.absmin + ent.absmax), ent, sprite);
136 spr.assault_decreaser = self;
137 spr.waypointsprite_visible_for_player = assault_decreaser_sprite_visible;
138 spr.classname = "assault_decreaser_sprite";
139 WaypointSprite_UpdateRule(spr, assault_attacker_team, SPRITERULE_TEAMPLAY);
140 if(ent.classname == "func_assault_destructible")
141 WaypointSprite_UpdateSprites(spr, "as-defend", "as-destroy", "as-destroy");
143 WaypointSprite_UpdateSprites(spr, "as-defend", "as-push", "as-push");
144 WaypointSprite_UpdateTeamRadar(spr, RADARICON_OBJECTIVE, '1 0.5 0');
148 void target_objective_decrease_findtarget()
150 assault_setenemytoobjective();
153 //=============================================================================
155 void spawnfunc_target_objective_decrease() {
157 self.classname = "target_objective_decrease";
159 precache_model("models/sprites/defend.sp2");
160 precache_model("models/sprites/destroy.sp2");
161 precache_model("models/sprites/push.sp2");
166 self.use = assault_objective_decrease_use;
167 self.health = ASSAULT_VALUE_INACTIVE;
168 self.max_health = ASSAULT_VALUE_INACTIVE;
171 InitializeEntity(self, target_objective_decrease_findtarget, INITPRIO_FINDTARGET);
174 // destructible walls that can be used to trigger target_objective_decrease
175 void spawnfunc_func_assault_destructible() {
177 spawnfunc_func_breakable();
180 void assault_wall_think() {
181 if(self.enemy.health < 0) {
183 self.solid = SOLID_NOT;
185 self.model = self.mdl;
186 self.solid = SOLID_BSP;
189 self.nextthink = time + 0.2;
192 void spawnfunc_func_assault_wall() {
193 self.classname = "func_assault_wall";
194 self.mdl = self.model;
195 setmodel(self, self.mdl);
196 self.solid = SOLID_BSP;
197 self.think = assault_wall_think;
198 self.nextthink = time;
199 InitializeEntity(self, assault_setenemytoobjective, INITPRIO_FINDTARGET);
203 void target_assault_roundend_reset() {
204 print("round end reset\n");
205 self.cnt = self.cnt + 1; // up round counter
206 self.winning = 0; // up round
209 void target_assault_roundend_use() {
210 self.winning = 1; // round has been won by attackers
213 void spawnfunc_target_assault_roundend() {
214 self.winning = 0; // round not yet won by attackers
215 self.classname = "target_assault_roundend";
216 self.use = target_assault_roundend_use;
217 self.cnt = 0; // first round
220 void assault_roundstart_use() {
226 #ifdef TTURRETS_ENABLED
229 //(Re)spawn all turrets
231 ent = find(world, classname, "turret_main");
234 if(ent.team == COLOR_TEAM1)
235 ent.team = COLOR_TEAM2;
237 ent.team = COLOR_TEAM1;
241 // Dubbles as teamchange
242 turret_stdproc_respawn();
243 //ent.turret_spawnfunc();
245 ent = find(ent, classname, "turret_main");
253 void spawnfunc_target_assault_roundstart() {
254 assault_attacker_team = COLOR_TEAM1;
255 self.classname = "target_assault_roundstart";
256 self.use = assault_roundstart_use;
257 InitializeEntity(self, assault_roundstart_use, INITPRIO_FINDTARGET);
261 // reset objectives, toggle spawnpoints, reset triggers, ...
262 void assault_new_round() {
263 bprint("ASSAULT: new round\n");
266 self.winning = self.winning + 1;
268 // swap attacker/defender roles
269 if(assault_attacker_team == COLOR_TEAM1) {
270 assault_attacker_team = COLOR_TEAM2;
272 assault_attacker_team = COLOR_TEAM1;
275 // swap spawn point teams
277 local entity oldself;
278 ent = find(world, classname, "info_player_deathmatch");
281 if(ent.team == COLOR_TEAM1) {
282 ent.team = COLOR_TEAM2;
284 ent.team = COLOR_TEAM1;
286 ent = find(ent, classname, "info_player_deathmatch");
289 // swap all destructibles
290 ent = find(world, classname, "func_assault_destructible");
293 if(ent.team == COLOR_TEAM1)
294 ent.team = COLOR_TEAM2;
296 ent.team = COLOR_TEAM1;
297 ent = find(ent, classname, "func_assault_destructible");
300 // reset the level with a countdown
301 cvar_set("timelimit", ftos(ceil(time - game_starttime) / 60));
302 ReadyRestartForce(); // sets game_starttime