void assault_objective_use(entity this, entity actor, entity trigger)
{
// activate objective
- this.health = 100;
+ SetResourceAmountExplicit(this, RESOURCE_HEALTH, 100);
//print("^2Activated objective ", this.targetname, "=", etos(this), "\n");
//print("Activator is ", actor.classname, "\n");
vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current)
{
- if(this.health < 0 || this.health >= ASSAULT_VALUE_INACTIVE)
+ float hlth = GetResourceAmount(this, RESOURCE_HEALTH);
+ if (hlth < 0 || hlth >= ASSAULT_VALUE_INACTIVE)
return '-1 0 0';
return current;
}
// and when a new round starts
void assault_objective_reset(entity this)
{
- this.health = ASSAULT_VALUE_INACTIVE;
+ SetResourceAmountExplicit(this, RESOURCE_HEALTH, ASSAULT_VALUE_INACTIVE);
}
// decrease the health of targeted objectives
else
return; // already activated! cannot activate again!
- if(this.enemy.health < ASSAULT_VALUE_INACTIVE)
+ float hlth = GetResourceAmount(this.enemy, RESOURCE_HEALTH);
+ if (hlth < ASSAULT_VALUE_INACTIVE)
{
- if(this.enemy.health - this.dmg > 0.5)
+ if (hlth - this.dmg > 0.5)
{
GameRules_scoring_add_team(actor, SCORE, this.dmg);
- this.enemy.health = this.enemy.health - this.dmg;
+ TakeResource(this.enemy, RESOURCE_HEALTH, this.dmg);
}
else
{
- GameRules_scoring_add_team(actor, SCORE, this.enemy.health);
+ GameRules_scoring_add_team(actor, SCORE, hlth);
GameRules_scoring_add_team(actor, ASSAULT_OBJECTIVES, 1);
- this.enemy.health = -1;
+ SetResourceAmountExplicit(this.enemy, RESOURCE_HEALTH, -1);
if(this.enemy.message)
FOREACH_CLIENT(IS_PLAYER(it), { centerprint(it, this.enemy.message); });
bool assault_decreaser_sprite_visible(entity this, entity player, entity view)
{
- if(this.assault_decreaser.enemy.health >= ASSAULT_VALUE_INACTIVE)
+ if(GetResourceAmount(this.assault_decreaser.enemy, RESOURCE_HEALTH) >= ASSAULT_VALUE_INACTIVE)
return false;
return true;
{
WaypointSprite_UpdateSprites(spr, WP_AssaultDefend, WP_AssaultDestroy, WP_AssaultDestroy);
WaypointSprite_UpdateMaxHealth(spr, it.max_health);
- WaypointSprite_UpdateHealth(spr, it.health);
+ WaypointSprite_UpdateHealth(spr, GetResourceAmount(it, RESOURCE_HEALTH));
it.sprite = spr;
}
else
void assault_wall_think(entity this)
{
- if(this.enemy.health < 0)
+ if(GetResourceAmount(this.enemy, RESOURCE_HEALTH) < 0)
{
this.model = "";
this.solid = SOLID_NOT;
this.dmg = 101;
this.use = assault_objective_decrease_use;
- this.health = ASSAULT_VALUE_INACTIVE;
+ SetResourceAmountExplicit(this, RESOURCE_HEALTH, ASSAULT_VALUE_INACTIVE);
this.max_health = ASSAULT_VALUE_INACTIVE;
this.enemy = NULL;
}
// 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(it.enemy.health > 0 && it.enemy.health < ASSAULT_VALUE_INACTIVE)
+ float hlth = GetResourceAmount(it.enemy, RESOURCE_HEALTH);
+ if (hlth > 0 && hlth < ASSAULT_VALUE_INACTIVE)
{
found = true;
break;
// Find and rate waypoints around it
found = false;
entity best = NULL;
- float bestvalue = 99999999999;
+ float bestvalue = FLOAT_MAX;
entity des = it;
- for(float radius = 0; radius < 1500 && !found; radius += 500)
+ for (float radius = 500; radius <= 1500 && !found; radius += 500)
{
FOREACH_ENTITY_RADIUS(p, radius, it.classname == "waypoint" && !(it.wpflags & WAYPOINTFLAG_GENERATED),
{
if (navigation_goalrating_timeout(this))
{
+ // role: offense
navigation_goalrating_start(this);
- havocbot_goalrating_enemyplayers(this, 20000, this.origin, 650);
+ havocbot_goalrating_enemyplayers(this, 10000, this.origin, 650);
havocbot_goalrating_ast_targets(this, 20000);
- havocbot_goalrating_items(this, 15000, this.origin, 10000);
+ havocbot_goalrating_items(this, 30000, this.origin, 10000);
navigation_goalrating_end(this);
navigation_goalrating_timeout_set(this);
if (navigation_goalrating_timeout(this))
{
+ // role: defense
navigation_goalrating_start(this);
- havocbot_goalrating_enemyplayers(this, 20000, this.origin, 3000);
+ havocbot_goalrating_enemyplayers(this, 10000, this.origin, 3000);
havocbot_goalrating_ast_targets(this, 20000);
- havocbot_goalrating_items(this, 15000, this.origin, 10000);
+ havocbot_goalrating_items(this, 30000, this.origin, 10000);
navigation_goalrating_end(this);
navigation_goalrating_timeout_set(this);
{
case HAVOCBOT_AST_ROLE_DEFENSE:
this.havocbot_role = havocbot_role_ast_defense;
- this.havocbot_role_flags = HAVOCBOT_AST_ROLE_DEFENSE;
this.havocbot_role_timeout = 0;
break;
case HAVOCBOT_AST_ROLE_OFFENSE:
this.havocbot_role = havocbot_role_ast_offense;
- this.havocbot_role_flags = HAVOCBOT_AST_ROLE_OFFENSE;
this.havocbot_role_timeout = 0;
break;
}