vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current)
{
- if(GetResourceAmount(this, RESOURCE_HEALTH) < 0 || GetResourceAmount(this, RESOURCE_HEALTH) >= ASSAULT_VALUE_INACTIVE)
+ float hlth = GetResourceAmount(this, RESOURCE_HEALTH);
+ if (hlth < 0 || hlth >= ASSAULT_VALUE_INACTIVE)
return '-1 0 0';
return current;
}
else
return; // already activated! cannot activate again!
- if(GetResourceAmount(this.enemy, RESOURCE_HEALTH) < ASSAULT_VALUE_INACTIVE)
+ float hlth = GetResourceAmount(this.enemy, RESOURCE_HEALTH);
+ if (hlth < ASSAULT_VALUE_INACTIVE)
{
- if(GetResourceAmount(this.enemy, RESOURCE_HEALTH) - this.dmg > 0.5)
+ if (hlth - this.dmg > 0.5)
{
GameRules_scoring_add_team(actor, SCORE, this.dmg);
TakeResource(this.enemy, RESOURCE_HEALTH, this.dmg);
}
else
{
- GameRules_scoring_add_team(actor, SCORE, GetResourceAmount(this.enemy, RESOURCE_HEALTH));
+ GameRules_scoring_add_team(actor, SCORE, hlth);
GameRules_scoring_add_team(actor, ASSAULT_OBJECTIVES, 1);
SetResourceAmountExplicit(this.enemy, RESOURCE_HEALTH, -1);
}
// 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);
+ if (hlth <= 0 || hlth >= true_limit)
+ return false;
+
+ GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit);
+ if(targ.sprite)
+ {
+ WaypointSprite_UpdateHealth(targ.sprite, GetResourceAmount(targ, RESOURCE_HEALTH));
+ }
+ func_breakable_colormod(targ);
+ return true;
+}
+
spawnfunc(func_breakable);
spawnfunc(func_assault_destructible)
{
this.spawnflags = 3;
this.classname = "func_assault_destructible";
+ this.event_heal = destructible_heal;
IL_PUSH(g_assault_destructibles, this);
if(assault_attacker_team == NUM_TEAM_1)
entity destr = it;
IL_EACH(g_assault_objectivedecreasers, it.targetname == destr.target,
{
- if(GetResourceAmount(it.enemy, RESOURCE_HEALTH) > 0 && GetResourceAmount(it.enemy, RESOURCE_HEALTH) < ASSAULT_VALUE_INACTIVE)
+ float hlth = GetResourceAmount(it.enemy, RESOURCE_HEALTH);
+ if (hlth > 0 && hlth < ASSAULT_VALUE_INACTIVE)
{
found = true;
break;