float autocvar_g_onslaught_spawn_choose;
float autocvar_g_onslaught_click_radius;
-void FixSize(entity e);
entity cam;
// =======================
// Junk Pile
// ==========
-void setmodel_fixsize(entity e, Model m)
-{
- setmodel(e, m);
- FixSize(e);
-}
-
void onslaught_updatelinks()
{
entity l;
this.owner.waslinked = this.owner.islinked;
if(this.owner.model != "models/onslaught/controlpoint_pad.md3")
- setmodel_fixsize(this.owner, MDL_ONS_CP_PAD1);
+ setmodel(this.owner, MDL_ONS_CP_PAD1);
//setsize(this, '-32 -32 0', '32 32 8');
delete(this);
bool ons_ControlPoint_Icon_Heal(entity targ, entity inflictor, float amount, float limit)
{
- float true_limit = ((limit) ? limit : targ.max_health);
- if(GetResourceAmount(targ, RESOURCE_HEALTH) <= 0 || GetResourceAmount(targ, RESOURCE_HEALTH) >= true_limit)
+ float hlth = GetResourceAmount(targ, RESOURCE_HEALTH);
+ float true_limit = ((limit != RESOURCE_LIMIT_NONE) ? limit : targ.max_health);
+ if (hlth <= 0 || hlth >= true_limit)
return false;
GiveResourceWithLimit(targ, RESOURCE_HEALTH, amount, true_limit);
+ hlth = GetResourceAmount(targ, RESOURCE_HEALTH);
if(targ.owner.iscaptured)
- WaypointSprite_UpdateHealth(targ.owner.sprite, GetResourceAmount(targ, RESOURCE_HEALTH));
+ WaypointSprite_UpdateHealth(targ.owner.sprite, hlth);
else
- WaypointSprite_UpdateBuildFinished(targ.owner.sprite, time + (targ.max_health - GetResourceAmount(targ, RESOURCE_HEALTH)) / (targ.count / ONS_CP_THINKRATE));
+ WaypointSprite_UpdateBuildFinished(targ.owner.sprite, time + (targ.max_health - hlth) / (targ.count / ONS_CP_THINKRATE));
targ.SendFlags |= CPSF_STATUS;
return true;
}
this.SendFlags |= CPSF_SETUP;
}
if(this.owner.model != MDL_ONS_CP_PAD2.model_str())
- setmodel_fixsize(this.owner, MDL_ONS_CP_PAD2);
+ setmodel(this.owner, MDL_ONS_CP_PAD2);
if(random() < 0.9 - GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health)
Send_Effect(EFFECT_RAGE, this.origin + 10 * randomvec(), '0 0 -1', 1);
int attackable;
if(IS_VEHICLE(toucher) && toucher.owner)
- if(autocvar_g_onslaught_allow_vehicle_touch)
+ {
+ if (!autocvar_g_onslaught_allow_vehicle_touch)
+ return;
toucher = toucher.owner;
- else
- return;
+ }
if(!IS_PLAYER(toucher)) { return; }
if(STAT(FROZEN, toucher)) { return; }
setthink(this, ons_ControlPoint_Think);
this.ons_toucher = NULL;
this.nextthink = time + ONS_CP_THINKRATE;
- setmodel_fixsize(this, MDL_ONS_CP_PAD1);
+ setmodel(this, MDL_ONS_CP_PAD1);
WaypointSprite_UpdateMaxHealth(this.sprite, 0);
WaypointSprite_UpdateRule(this.sprite,this.team,SPRITERULE_TEAMPLAY);
if(cp.message == "") { cp.message = "a"; }
// appearence
- setmodel_fixsize(cp, MDL_ONS_CP_PAD1);
+ setmodel(cp, MDL_ONS_CP_PAD1);
// control point placement
if((cp.spawnflags & 1) || cp.noalign) // don't drop to floor, just stay at fixed location
}
}
TakeResource(this, RESOURCE_HEALTH, damage);
- WaypointSprite_UpdateHealth(this.sprite, GetResourceAmount(this, RESOURCE_HEALTH));
+ float hlth = GetResourceAmount(this, RESOURCE_HEALTH);
+ WaypointSprite_UpdateHealth(this.sprite, hlth);
// choose an animation frame based on health
- this.frame = 10 * bound(0, (1 - GetResourceAmount(this, RESOURCE_HEALTH) / this.max_health), 1);
+ this.frame = 10 * bound(0, (1 - hlth / this.max_health), 1);
// see if the generator is still functional, or dying
- if (GetResourceAmount(this, RESOURCE_HEALTH) > 0)
+ if (hlth > 0)
{
- this.lasthealth = GetResourceAmount(this, RESOURCE_HEALTH);
+ this.lasthealth = hlth;
}
else
{
bool ons_GeneratorHeal(entity targ, entity inflictor, float amount, float limit)
{
- float true_limit = ((limit) ? limit : targ.max_health);
- if(GetResourceAmount(targ, RESOURCE_HEALTH) <= 0 || GetResourceAmount(targ, RESOURCE_HEALTH) >= true_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);
- WaypointSprite_UpdateHealth(targ.sprite, GetResourceAmount(targ, RESOURCE_HEALTH));
- targ.frame = 10 * bound(0, (1 - GetResourceAmount(targ, RESOURCE_HEALTH) / targ.max_health), 1);
- targ.lasthealth = GetResourceAmount(targ, RESOURCE_HEALTH);
+ hlth = GetResourceAmount(targ, RESOURCE_HEALTH);
+ WaypointSprite_UpdateHealth(targ.sprite, hlth);
+ targ.frame = 10 * bound(0, (1 - hlth / targ.max_health), 1);
+ targ.lasthealth = hlth;
targ.SendFlags |= GSF_STATUS;
return true;
}
void Onslaught_count_generators()
{
entity e;
- total_generators = redowned = blueowned = yellowowned = pinkowned = 0;
+ total_generators = 0;
+ for (int i = 1; i <= NUM_TEAMS; ++i)
+ {
+ Team_SetNumberOfControlPoints(Team_GetTeamFromIndex(i), 0);
+ }
for(e = ons_worldgeneratorlist; e; e = e.ons_worldgeneratornext)
{
++total_generators;
- redowned += (e.team == NUM_TEAM_1 && GetResourceAmount(e, RESOURCE_HEALTH) > 0);
- blueowned += (e.team == NUM_TEAM_2 && GetResourceAmount(e, RESOURCE_HEALTH) > 0);
- yellowowned += (e.team == NUM_TEAM_3 && GetResourceAmount(e, RESOURCE_HEALTH) > 0);
- pinkowned += (e.team == NUM_TEAM_4 && GetResourceAmount(e, RESOURCE_HEALTH) > 0);
+ if (GetResourceAmount(e, RESOURCE_HEALTH) < 1)
+ {
+ continue;
+ }
+ entity team_ = Entity_GetTeam(e);
+ int num_control_points = Team_GetNumberOfControlPoints(team_);
+ ++num_control_points;
+ Team_SetNumberOfControlPoints(team_, num_control_points);
}
}
int Onslaught_GetWinnerTeam()
{
int winner_team = 0;
- if(redowned > 0)
- winner_team = NUM_TEAM_1;
- if(blueowned > 0)
+ if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(1)) >= 1)
{
- if(winner_team) return 0;
- winner_team = NUM_TEAM_2;
+ winner_team = NUM_TEAM_1;
}
- if(yellowowned > 0)
+ for (int i = 2; i <= NUM_TEAMS; ++i)
{
- if(winner_team) return 0;
- winner_team = NUM_TEAM_3;
+ if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(i)) >= 1)
+ {
+ if (winner_team != 0)
+ {
+ return 0;
+ }
+ winner_team = Team_IndexToTeam(i);
+ }
}
- if(pinkowned > 0)
+ if (winner_team)
{
- if(winner_team) return 0;
- winner_team = NUM_TEAM_4;
- }
- if(winner_team)
return winner_team;
+ }
return -1; // no generators left?
}
void nades_Clear(entity e);
-#define ONS_OWNED_GENERATORS() ((redowned > 0) + (blueowned > 0) + (yellowowned > 0) + (pinkowned > 0))
-#define ONS_OWNED_GENERATORS_OK() (ONS_OWNED_GENERATORS() > 1)
bool Onslaught_CheckWinner()
{
if ((autocvar_timelimit && time > game_starttime + autocvar_timelimit * 60) || (round_handler_GetEndTime() > 0 && round_handler_GetEndTime() - time <= 0))
Onslaught_count_generators();
- if(ONS_OWNED_GENERATORS_OK())
+ if (Team_GetNumberOfTeamsWithControlPoints() > 1)
+ {
return 0;
+ }
int winner_team = Onslaught_GetWinnerTeam();
// NOTE: LEGACY CODE, needs to be re-written!
-void havocbot_goalrating_ons_offenseitems(entity this, float ratingscale, vector org, float sradius)
-{
- bool needarmor = false, needweapons = false;
-
- // Needs armor/health?
- if(GetResourceAmount(this, RESOURCE_HEALTH) < 100)
- needarmor = true;
-
- // Needs weapons?
- int c = 0;
- FOREACH(Weapons, it != WEP_Null, {
- if(STAT(WEAPONS, this) & (it.m_wepset))
- if(++c >= 4)
- break;
- });
-
- if(c<4)
- needweapons = true;
-
- if(!needweapons && !needarmor)
- return;
-
- LOG_DEBUG(this.netname, " needs weapons ", ftos(needweapons));
- LOG_DEBUG(this.netname, " needs armor ", ftos(needarmor));
-
- // See what is around
- IL_EACH(g_items, it.bot_pickup,
- {
- // gather health and armor only
- if (it.solid)
- if ( ((GetResourceAmount(it, RESOURCE_HEALTH) || GetResourceAmount(it, RESOURCE_ARMOR)) && needarmor) || (STAT(WEAPONS, it) && needweapons ) )
- if (vdist(it.origin - org, <, sradius))
- {
- int t = it.bot_pickupevalfunc(this, it);
- if (t > 0)
- navigation_routerating(this, it, t * ratingscale, 500);
- }
- });
-}
-
void havocbot_role_ons_setrole(entity this, int role)
{
- LOG_DEBUG(this.netname," switched to ");
switch(role)
{
case HAVOCBOT_ONS_ROLE_DEFENSE:
- LOG_DEBUG("defense");
+ LOG_DEBUG(this.netname, " switched to defense");
this.havocbot_role = havocbot_role_ons_defense;
- this.havocbot_role_flags = HAVOCBOT_ONS_ROLE_DEFENSE;
this.havocbot_role_timeout = 0;
break;
case HAVOCBOT_ONS_ROLE_ASSISTANT:
- LOG_DEBUG("assistant");
+ LOG_DEBUG(this.netname, " switched to assistant");
this.havocbot_role = havocbot_role_ons_assistant;
- this.havocbot_role_flags = HAVOCBOT_ONS_ROLE_ASSISTANT;
this.havocbot_role_timeout = 0;
break;
case HAVOCBOT_ONS_ROLE_OFFENSE:
- LOG_DEBUG("offense");
+ LOG_DEBUG(this.netname, " switched to offense");
this.havocbot_role = havocbot_role_ons_offense;
- this.havocbot_role_flags = HAVOCBOT_ONS_ROLE_OFFENSE;
this.havocbot_role_timeout = 0;
break;
}
- LOG_DEBUG("");
}
void havocbot_goalrating_ons_controlpoints_attack(entity this, float ratingscale)
// Count team mates interested in this control point
// (easier and cleaner than keeping counters per cp and teams)
- FOREACH_CLIENT(IS_PLAYER(it), {
+ FOREACH_CLIENT(it != this && IS_PLAYER(it), {
if(SAME_TEAM(it, this))
- if(it.havocbot_role_flags & HAVOCBOT_ONS_ROLE_OFFENSE)
+ if(it.havocbot_role == havocbot_role_ons_offense)
if(it.havocbot_ons_target == cp2)
++c;
});
}
// We'll consider only the best case
- bestvalue = 99999999999;
+ bestvalue = FLOAT_MAX;
cp = NULL;
for(cp1 = ons_worldcplist; cp1; cp1 = cp1.ons_worldcpnext)
{
// Rate waypoints near it
found = false;
best = NULL;
- bestvalue = 99999999999;
- for(radius=0; radius<1000 && !found; radius+=500)
+ bestvalue = FLOAT_MAX;
+ for (radius = 500; radius <= 1000 && !found; radius += 500)
{
- for(wp=findradius(cp.origin,radius); wp; wp=wp.chain)
+ IL_EACH(g_waypoints, vdist(cp.origin - it.origin, <, radius),
{
- if(!(wp.wpflags & WAYPOINTFLAG_GENERATED))
- if(wp.classname=="waypoint")
- if(checkpvs(wp.origin,cp))
+ if (!(it.wpflags & WAYPOINTFLAG_GENERATED) && checkpvs(it.origin, cp))
{
found = true;
- if(wp.cnt<bestvalue)
+ if (it.cnt < bestvalue)
{
- best = wp;
- bestvalue = wp.cnt;
+ best = it;
+ bestvalue = it.cnt;
}
}
- }
+ });
}
if(best)
{
// Should be touched
LOG_DEBUG(this.netname, " found a touchable controlpoint at ", vtos(cp.origin));
- found = false;
-
- // Look for auto generated waypoint
- if (!bot_waypoints_for_items)
- for (wp = findradius(cp.origin,100); wp; wp = wp.chain)
- {
- if(wp.classname=="waypoint")
- {
- navigation_routerating(this, wp, ratingscale, 10000);
- found = true;
- }
- }
-
- // Nothing found, rate the controlpoint itself
- if (!found)
- navigation_routerating(this, cp, ratingscale, 10000);
+ navigation_routerating(this, cp, ratingscale * 2, 10000);
}
}
{
entity g, wp, bestwp;
bool found;
- int best;
+ int bestvalue;
for(g = ons_worldgeneratorlist; g; g = g.ons_worldgeneratornext)
{
// Rate waypoints near it
found = false;
bestwp = NULL;
- best = 99999999999;
+ bestvalue = FLOAT_MAX;
- for(wp=findradius(g.origin,400); wp; wp=wp.chain)
+ IL_EACH(g_waypoints, vdist(g.origin - it.origin, <, 400),
{
- if(wp.classname=="waypoint")
- if(checkpvs(wp.origin,g))
+ if (checkpvs(it.origin, g))
{
found = true;
- if(wp.cnt<best)
+ if (it.cnt < bestvalue)
{
- bestwp = wp;
- best = wp.cnt;
+ bestwp = it;
+ bestvalue = it.cnt;
}
}
- }
+ });
if(bestwp)
{
{
navigation_goalrating_start(this);
havocbot_goalrating_enemyplayers(this, 20000, this.origin, 650);
- if(!havocbot_goalrating_ons_generator_attack(this, 20000))
- havocbot_goalrating_ons_controlpoints_attack(this, 20000);
- havocbot_goalrating_ons_offenseitems(this, 10000, this.origin, 10000);
+ if(!havocbot_goalrating_ons_generator_attack(this, 10000))
+ havocbot_goalrating_ons_controlpoints_attack(this, 10000);
+ havocbot_goalrating_items(this, 25000, this.origin, 10000);
navigation_goalrating_end(this);
navigation_goalrating_timeout_set(this);
player.angles = '0 1 0' * ( theta * RAD2DEG + 180 );
makevectors(player.angles);
player.fixangle = true;
+ if (IS_BOT_CLIENT(player))
+ {
+ player.v_angle = player.angles;
+ bot_aim_reset(player);
+ }
player.teleport_antispam = time + autocvar_g_onslaught_teleport_wait;
if ( tele_effects )
for(tmp_entity = ons_worldcplist; tmp_entity; tmp_entity = tmp_entity.ons_worldcpnext)
{
if(SAME_TEAM(tmp_entity, player))
- if(random_target)
- RandomSelection_AddEnt(tmp_entity, 1, 1);
- else if(vlen2(tmp_entity.origin - spawn_loc) <= vlen2(closest_target.origin - spawn_loc) || closest_target == NULL)
- closest_target = tmp_entity;
+ {
+ if(random_target)
+ RandomSelection_AddEnt(tmp_entity, 1, 1);
+ else if(vlen2(tmp_entity.origin - spawn_loc) <= vlen2(closest_target.origin - spawn_loc) || closest_target == NULL)
+ closest_target = tmp_entity;
+ }
}
if(random_target) { closest_target = RandomSelection_chosen_ent; }
return true;
}
-MUTATOR_HOOKFUNCTION(ons, CheckAllowedTeams)
+MUTATOR_HOOKFUNCTION(ons, TeamBalance_CheckAllowedTeams)
{
// onslaught is special
for(entity tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext)
{
- switch(tmp_entity.team)
+ if (Team_IsValidTeam(tmp_entity.team))
{
- case NUM_TEAM_1: c1 = 0; break;
- case NUM_TEAM_2: c2 = 0; break;
- case NUM_TEAM_3: c3 = 0; break;
- case NUM_TEAM_4: c4 = 0; break;
+ M_ARGV(0, float) |= Team_TeamToBit(tmp_entity.team);
}
}
// scoreboard setup
void ons_ScoreRules()
{
- CheckAllowedTeams(NULL);
- int teams = 0;
- if(c1 >= 0) teams |= BIT(0);
- if(c2 >= 0) teams |= BIT(1);
- if(c3 >= 0) teams |= BIT(2);
- if(c4 >= 0) teams |= BIT(3);
+ entity balance = TeamBalance_CheckAllowedTeams(NULL);
+ int teams = TeamBalance_GetAllowedTeams(balance);
+ TeamBalance_Destroy(balance);
GameRules_scoring(teams, SFL_SORT_PRIO_PRIMARY, 0, {
field_team(ST_ONS_CAPS, "destroyed", SFL_SORT_PRIO_PRIMARY);
field(SP_ONS_CAPS, "caps", SFL_SORT_PRIO_SECONDARY);