X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Fgamemodes%2Fgamemode%2Fassault%2Fsv_assault.qc;h=e9fb0a48dea9b2988e4bf22135d457b143a65d22;hp=95dd412f49b92be2d946e0ea8e7f4e61b0bfb37c;hb=f79d3329e933bd6d5539d2065467772d85c36079;hpb=a34c7d612200ef8fe04cb9649061b2e4b6fc5703 diff --git a/qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc b/qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc index 95dd412f4..e9fb0a48d 100644 --- a/qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc +++ b/qcsrc/common/gamemodes/gamemode/assault/sv_assault.qc @@ -1,23 +1,21 @@ #include "sv_assault.qh" +#include +#include +#include +#include +#include +#include +#include + .entity sprite; #define AS_ROUND_DELAY 5 -IntrusiveList g_assault_destructibles; -IntrusiveList g_assault_objectivedecreasers; -IntrusiveList g_assault_objectives; -STATIC_INIT(g_assault) -{ - g_assault_destructibles = IL_NEW(); - g_assault_objectivedecreasers = IL_NEW(); - g_assault_objectives = IL_NEW(); -} - // random functions void assault_objective_use(entity this, entity actor, entity trigger) { // activate objective - SetResourceAmountExplicit(this, RESOURCE_HEALTH, 100); + SetResourceExplicit(this, RES_HEALTH, 100); //print("^2Activated objective ", this.targetname, "=", etos(this), "\n"); //print("Activator is ", actor.classname, "\n"); @@ -29,7 +27,7 @@ void assault_objective_use(entity this, entity actor, entity trigger) vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current) { - float hlth = GetResourceAmount(this, RESOURCE_HEALTH); + float hlth = GetResource(this, RES_HEALTH); if (hlth < 0 || hlth >= ASSAULT_VALUE_INACTIVE) return '-1 0 0'; return current; @@ -39,7 +37,7 @@ vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, // and when a new round starts void assault_objective_reset(entity this) { - SetResourceAmountExplicit(this, RESOURCE_HEALTH, ASSAULT_VALUE_INACTIVE); + SetResourceExplicit(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE); } // decrease the health of targeted objectives @@ -60,19 +58,19 @@ void assault_objective_decrease_use(entity this, entity actor, entity trigger) else return; // already activated! cannot activate again! - float hlth = GetResourceAmount(this.enemy, RESOURCE_HEALTH); + float hlth = GetResource(this.enemy, RES_HEALTH); if (hlth < ASSAULT_VALUE_INACTIVE) { if (hlth - this.dmg > 0.5) { GameRules_scoring_add_team(actor, SCORE, this.dmg); - TakeResource(this.enemy, RESOURCE_HEALTH, this.dmg); + TakeResource(this.enemy, RES_HEALTH, this.dmg); } else { GameRules_scoring_add_team(actor, SCORE, hlth); GameRules_scoring_add_team(actor, ASSAULT_OBJECTIVES, 1); - SetResourceAmountExplicit(this.enemy, RESOURCE_HEALTH, -1); + SetResourceExplicit(this.enemy, RES_HEALTH, -1); if(this.enemy.message) FOREACH_CLIENT(IS_PLAYER(it), { centerprint(it, this.enemy.message); }); @@ -99,7 +97,7 @@ void assault_setenemytoobjective(entity this) bool assault_decreaser_sprite_visible(entity this, entity player, entity view) { - if(GetResourceAmount(this.assault_decreaser.enemy, RESOURCE_HEALTH) >= ASSAULT_VALUE_INACTIVE) + if(GetResource(this.assault_decreaser.enemy, RES_HEALTH) >= ASSAULT_VALUE_INACTIVE) return false; return true; @@ -121,13 +119,12 @@ void target_objective_decrease_activate(entity this) spr = WaypointSprite_SpawnFixed(WP_AssaultDefend, 0.5 * (it.absmin + it.absmax), it, assault_sprite, RADARICON_OBJECTIVE); spr.assault_decreaser = this; spr.waypointsprite_visible_for_player = assault_decreaser_sprite_visible; - spr.classname = "sprite_waypoint"; WaypointSprite_UpdateRule(spr, assault_attacker_team, SPRITERULE_TEAMPLAY); if(it.classname == "func_assault_destructible") { WaypointSprite_UpdateSprites(spr, WP_AssaultDefend, WP_AssaultDestroy, WP_AssaultDestroy); WaypointSprite_UpdateMaxHealth(spr, it.max_health); - WaypointSprite_UpdateHealth(spr, GetResourceAmount(it, RESOURCE_HEALTH)); + WaypointSprite_UpdateHealth(spr, GetResource(it, RES_HEALTH)); it.sprite = spr; } else @@ -176,7 +173,7 @@ void assault_roundstart_use_this(entity this) void assault_wall_think(entity this) { - if(GetResourceAmount(this.enemy, RESOURCE_HEALTH) < 0) + if(GetResource(this.enemy, RES_HEALTH) < 0) { this.model = ""; this.solid = SOLID_NOT; @@ -194,8 +191,6 @@ void assault_wall_think(entity this) // reset objectives, toggle spawnpoints, reset triggers, ... void assault_new_round(entity this) { - //bprint("ASSAULT: new round\n"); - // up round counter this.winning = this.winning + 1; @@ -215,7 +210,8 @@ void assault_new_round(entity this) // reset the level with a countdown cvar_set("timelimit", ftos(ceil(time - AS_ROUND_DELAY - game_starttime) / 60)); - ReadyRestart_force(); // sets game_starttime + bprint("Starting second round...\n"); + ReadyRestart_force(true); // sets game_starttime } entity as_round; @@ -254,12 +250,12 @@ int WinningCondition_Assault() { if(ent.winning) // round end has been triggered by attacking team { - bprint("Assault: round completed.\n"); + bprint(Team_ColoredFullName(assault_attacker_team), " destroyed the objective in ", process_time(2, ceil(time - game_starttime)), "\n"); SetWinners(team, assault_attacker_team); TeamScore_AddToTeam(assault_attacker_team, ST_ASSAULT_OBJECTIVES, 666 - TeamScore_AddToTeam(assault_attacker_team, ST_ASSAULT_OBJECTIVES, 0)); - if(ent.cnt == 1 || autocvar_g_campaign) // this was the second round + if(ent.cnt == 1 || autocvar_g_campaign) // this was the second round or the only round in campaign { status = WINNING_YES; } @@ -304,7 +300,6 @@ spawnfunc(target_objective) { if (!g_assault) { delete(this); return; } - this.classname = "target_objective"; IL_PUSH(g_assault_objectives, this); this.use = assault_objective_use; this.reset = assault_objective_reset; @@ -316,14 +311,13 @@ spawnfunc(target_objective_decrease) { if (!g_assault) { delete(this); return; } - this.classname = "target_objective_decrease"; IL_PUSH(g_assault_objectivedecreasers, this); if(!this.dmg) this.dmg = 101; this.use = assault_objective_decrease_use; - SetResourceAmountExplicit(this, RESOURCE_HEALTH, ASSAULT_VALUE_INACTIVE); + SetResourceExplicit(this, RES_HEALTH, ASSAULT_VALUE_INACTIVE); this.max_health = ASSAULT_VALUE_INACTIVE; this.enemy = NULL; @@ -333,27 +327,25 @@ spawnfunc(target_objective_decrease) // destructible walls that can be used to trigger target_objective_decrease bool destructible_heal(entity targ, entity inflictor, float amount, float limit) { - float true_limit = ((limit != RESOURCE_LIMIT_NONE) ? limit : targ.max_health); - float hlth = GetResourceAmount(targ, RESOURCE_HEALTH); + float true_limit = ((limit != RES_LIMIT_NONE) ? limit : targ.max_health); + float hlth = GetResource(targ, RES_HEALTH); if (hlth <= 0 || hlth >= true_limit) return false; - GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit); + GiveResourceWithLimit(targ, RES_HEALTH, amount, true_limit); if(targ.sprite) { - WaypointSprite_UpdateHealth(targ.sprite, GetResourceAmount(targ, RESOURCE_HEALTH)); + WaypointSprite_UpdateHealth(targ.sprite, GetResource(targ, RES_HEALTH)); } func_breakable_colormod(targ); return true; } -spawnfunc(func_breakable); spawnfunc(func_assault_destructible) { if (!g_assault) { delete(this); return; } this.spawnflags = 3; - this.classname = "func_assault_destructible"; this.event_heal = destructible_heal; IL_PUSH(g_assault_destructibles, this); @@ -362,14 +354,13 @@ spawnfunc(func_assault_destructible) else this.team = NUM_TEAM_1; - spawnfunc_func_breakable(this); + func_breakable_setup(this); } spawnfunc(func_assault_wall) { if (!g_assault) { delete(this); return; } - this.classname = "func_assault_wall"; this.mdl = this.model; _setmodel(this, this.mdl); this.solid = SOLID_BSP; @@ -383,7 +374,6 @@ spawnfunc(target_assault_roundend) if (!g_assault) { delete(this); return; } this.winning = 0; // round not yet won by attackers - this.classname = "target_assault_roundend"; this.use = target_assault_roundend_use; this.cnt = 0; // first round this.reset = target_assault_roundend_reset; @@ -394,7 +384,6 @@ spawnfunc(target_assault_roundstart) if (!g_assault) { delete(this); return; } assault_attacker_team = NUM_TEAM_1; - this.classname = "target_assault_roundstart"; this.use = assault_roundstart_use; this.reset2 = assault_roundstart_use_this; InitializeEntity(this, assault_roundstart_use_this, INITPRIO_FINDTARGET); @@ -412,7 +401,7 @@ void havocbot_goalrating_ast_targets(entity this, float ratingscale) entity destr = it; IL_EACH(g_assault_objectivedecreasers, it.targetname == destr.target, { - float hlth = GetResourceAmount(it.enemy, RESOURCE_HEALTH); + float hlth = GetResource(it.enemy, RES_HEALTH); if (hlth > 0 && hlth < ASSAULT_VALUE_INACTIVE) { found = true; @@ -579,7 +568,7 @@ MUTATOR_HOOKFUNCTION(as, TurretSpawn) entity turret = M_ARGV(0, entity); if(!turret.team || turret.team == FLOAT_MAX) - turret.team = 5; // this gets reversed when match starts? + turret.team = assault_attacker_team; // this gets reversed when match starts (assault_roundstart_use) } MUTATOR_HOOKFUNCTION(as, VehicleInit) @@ -626,7 +615,7 @@ MUTATOR_HOOKFUNCTION(as, ReadLevelCvars) MUTATOR_HOOKFUNCTION(as, OnEntityPreSpawn) { - entity ent = M_ARGV(0, entity); + entity ent = M_ARGV(0, entity); switch(ent.classname) { @@ -641,5 +630,8 @@ MUTATOR_HOOKFUNCTION(as, OnEntityPreSpawn) MUTATOR_HOOKFUNCTION(as, ReadyRestart_Deny) { // readyrestart not supported (yet) + // it's supported only in campaign mode (single round mode), since campaign requires it + if (autocvar_g_campaign) + return false; return true; }