float autocvar_g_onslaught_click_radius;
void FixSize(entity e);
+entity cam;
// =======================
// CaptureShield Functions
// =======================
+bool clientcamera_send(entity this, entity to, int sf)
+{
+ WriteHeader(MSG_ENTITY, ENT_ONSCAMERA);
+
+ WriteCoord(MSG_ENTITY, this.origin_x);
+ WriteCoord(MSG_ENTITY, this.origin_y);
+ WriteCoord(MSG_ENTITY, this.origin_z);
+
+ WriteAngle(MSG_ENTITY, this.angles_x);
+ WriteAngle(MSG_ENTITY, this.angles_y);
+ WriteAngle(MSG_ENTITY, this.angles_z);
+
+ return true;
+}
+
bool ons_CaptureShield_Customize(entity this, entity client)
{
entity e = WaypointSprite_getviewentity(client);
void ons_CaptureShield_Spawn(entity generator, bool is_generator)
{
entity shield = new(ons_captureshield);
+ IL_PUSH(g_onsshields, shield);
shield.enemy = generator;
shield.team = generator.team;
{
LOG_DEBUG(etos(l), " (generator) is shielded");
l.takedamage = DAMAGE_NO;
+ if(l.bot_attack)
+ IL_REMOVE(g_bot_targets, l);
l.bot_attack = false;
}
else
{
LOG_DEBUG(etos(l), " (generator) is not shielded");
l.takedamage = DAMAGE_AIM;
+ if(!l.bot_attack)
+ IL_PUSH(g_bot_targets, l);
l.bot_attack = true;
}
if (l.goalentity)
{
l.goalentity.takedamage = DAMAGE_NO;
+ if(l.goalentity.bot_attack)
+ IL_REMOVE(g_bot_targets, l.goalentity);
l.goalentity.bot_attack = false;
}
}
if (l.goalentity)
{
l.goalentity.takedamage = DAMAGE_AIM;
+ if(!l.goalentity.bot_attack)
+ IL_PUSH(g_bot_targets, l.goalentity);
l.goalentity.bot_attack = true;
}
}
ons_ControlPoint_UpdateSprite(l);
}
- FOREACH_ENTITY_CLASS("ons_captureshield", true,
+ IL_EACH(g_onsshields, true,
{
it.team = it.enemy.team;
it.colormap = it.enemy.colormap;
if(IS_PLAYER(this.owner.ons_toucher))
{
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, this.owner.ons_toucher.netname, this.owner.message);
- Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE), this.owner.message);
+ Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE_TEAM), this.owner.message);
Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, this.owner.message);
PlayerScore_Add(this.owner.ons_toucher, SP_ONS_CAPS, 1);
PlayerTeamScore_AddScore(this.owner.ons_toucher, 10);
e.solid = SOLID_NOT;
e.takedamage = DAMAGE_AIM;
e.bot_attack = true;
+ IL_PUSH(g_bot_targets, e);
e.event_damage = ons_ControlPoint_Icon_Damage;
e.team = player.team;
e.colormap = 1024 + (e.team - 1) * 17;
}
}
+void ons_camSetup(entity this)
+{
+ vector dir;
+ vector ang = '0 0 0';
+ vector best_ang = '0 0 0';
+ float best_trace_fraction = 0;
+ while(ang.y < 360)
+ {
+ dir = eX * cos(ang.y * DEG2RAD) + eY * sin(ang.y * DEG2RAD);
+ dir *= 500;
+ traceline(this.origin, this.origin - dir, MOVE_WORLDONLY, this);
+ if(trace_fraction > best_trace_fraction)
+ {
+ best_trace_fraction = trace_fraction;
+ best_ang = ang;
+ if(trace_fraction == 1)
+ break;
+ }
+ ang.y += 90;
+ if(ang.y == 360)
+ ang.y = 45;
+ }
+ cam.origin = this.origin;
+ setorigin(cam, cam.origin);
+ cam.angles = best_ang;
+ Net_LinkEntity(cam, false, 0, clientcamera_send);
+
+ FOREACH_CLIENT(true, it.clientcamera = cam;);
+
+ WriteByte(MSG_ALL, SVC_SETVIEWANGLES);
+ WriteAngle(MSG_ALL, cam.angles_x);
+ WriteAngle(MSG_ALL, cam.angles_y);
+ WriteAngle(MSG_ALL, cam.angles_z);
+}
+
void ons_GeneratorDamage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
{
- if(damage <= 0) { return; }
- if(warmup_stage || gameover) { return; }
- if(!round_handler_IsRoundStarted()) { return; }
+ if(damage <= 0) return;
+ if(warmup_stage || game_stopped) return;
+ if(!round_handler_IsRoundStarted()) return;
if (attacker != this)
{
if (this.isshielded)
{
- // this is protected by a shield, so ignore the damage
+ // generator is protected by a shield, so ignore the damage
if (time > this.pain_finished)
if (IS_PLAYER(attacker))
{
//WaypointSprite_Kill(this.sprite); // can't do this yet, code too poor
onslaught_updatelinks();
+
+ ons_camSetup(this);
}
// Throw some flaming gibs on damage, more damage = more chance for gib
void ons_GeneratorThink(entity this)
{
this.nextthink = time + GEN_THINKRATE;
- if (!gameover)
+ if (!game_stopped)
{
if(!this.isshielded && this.wait < time)
{
this.lasthealth = this.max_health = this.health = autocvar_g_onslaught_gen_health;
this.takedamage = DAMAGE_AIM;
this.bot_attack = true;
+ if(!IL_CONTAINS(g_bot_targets, this))
+ IL_PUSH(g_bot_targets, this);
this.iscaptured = true;
this.islinked = true;
this.isshielded = true;
gen.lasthealth = gen.max_health = gen.health = autocvar_g_onslaught_gen_health;
gen.takedamage = DAMAGE_AIM;
gen.bot_attack = true;
+ IL_PUSH(g_bot_targets, gen);
gen.event_damage = ons_GeneratorDamage;
gen.reset = ons_GeneratorReset;
setthink(gen, ons_GeneratorThink);
nades_Clear(it);
});
+ game_stopped = true;
return 1;
}
LOG_DEBUG(this.netname, " needs armor ", ftos(needarmor));
// See what is around
- FOREACH_ENTITY_FLOAT(bot_pickup, true,
+ IL_EACH(g_items, it.bot_pickup,
{
// gather health and armor only
if (it.solid)
entity ons_Nearest_ControlPoint(entity this, vector pos, float max_dist)
{
entity closest_target = NULL;
- FOREACH_ENTITY_CLASS("onslaught_controlpoint", true,
+ for(entity cp = ons_worldcplist; cp; cp = cp.ons_worldcpnext)
{
- if(SAME_TEAM(it, this))
- if(it.iscaptured)
- if(max_dist <= 0 || vdist(it.origin - pos, <=, max_dist))
- if(vlen2(it.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == NULL)
- closest_target = it;
- });
- FOREACH_ENTITY_CLASS("onslaught_generator", true,
+ if(SAME_TEAM(cp, this))
+ if(cp.iscaptured)
+ if(max_dist <= 0 || vdist(cp.origin - pos, <=, max_dist))
+ if(vlen2(cp.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == NULL)
+ closest_target = cp;
+ }
+ for(entity gen = ons_worldgeneratorlist; gen; gen = gen.ons_worldgeneratornext)
{
- if(SAME_TEAM(it, this))
- if(max_dist <= 0 || vdist(it.origin - pos, <, max_dist))
- if(vlen2(it.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == NULL)
- closest_target = it;
- });
+ if(SAME_TEAM(gen, this))
+ if(max_dist <= 0 || vdist(gen.origin - pos, <, max_dist))
+ if(vlen2(gen.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == NULL)
+ closest_target = gen;
+ }
return closest_target;
}
vector delta;
float smallest_distance = 0, distance;
- FOREACH_ENTITY_CLASS("onslaught_controlpoint", true,
+ for(entity cp = ons_worldcplist; cp; cp = cp.ons_worldcpnext)
{
- delta = it.origin - pos;
+ delta = cp.origin - pos;
delta_z = 0;
distance = vlen(delta);
- if(SAME_TEAM(it, this))
- if(it.iscaptured)
+ if(SAME_TEAM(cp, this))
+ if(cp.iscaptured)
if(max_dist <= 0 || distance <= max_dist)
if(closest_target == NULL || distance <= smallest_distance )
{
- closest_target = it;
+ closest_target = cp;
smallest_distance = distance;
}
- });
- FOREACH_ENTITY_CLASS("onslaught_generator", true,
+ }
+ for(entity gen = ons_worldgeneratorlist; gen; gen = gen.ons_worldgeneratornext)
{
- delta = it.origin - pos;
+ delta = gen.origin - pos;
delta_z = 0;
distance = vlen(delta);
- if(SAME_TEAM(it, this))
+ if(SAME_TEAM(gen, this))
if(max_dist <= 0 || distance <= max_dist)
if(closest_target == NULL || distance <= smallest_distance )
{
- closest_target = it;
+ closest_target = gen;
smallest_distance = distance;
}
- });
+ }
return closest_target;
}
int ons_Count_SelfControlPoints(entity this)
{
int n = 0;
- FOREACH_ENTITY_CLASS("onslaught_controlpoint", true,
+ for(entity cp = ons_worldcplist; cp; cp = cp.ons_worldcpnext)
{
- if(SAME_TEAM(it, this))
- if(it.iscaptured)
+ if(SAME_TEAM(cp, this))
+ if(cp.iscaptured)
n++;
- });
- FOREACH_ENTITY_CLASS("onslaught_generator", true,
+ }
+ for(entity gen = ons_worldgeneratorlist; gen; gen = gen.ons_worldgeneratornext)
{
- if(SAME_TEAM(it, this))
+ if(SAME_TEAM(gen, this))
n++;
- });
+ }
return n;
}
loc += tele_target.origin + '0 0 128' * iteration_scale;
- tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player);
+ tracebox(loc, STAT(PL_MIN, player), STAT(PL_MAX, player), loc, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(tele_target.origin, loc, MOVE_NOMONSTERS, tele_target); // double check to make sure we're not spawning outside the NULL
STAT(ROUNDLOST, it) = false;
it.ons_deathloc = '0 0 0';
PutClientInServer(it);
+ it.clientcamera = it;
});
return false;
}
{
if(SAME_TEAM(tmp_entity, player))
if(random_target)
- RandomSelection_Add(tmp_entity, 0, string_null, 1, 1);
+ 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;
}
iteration_scale -= i / 10;
loc = closest_target.origin + '0 0 96' * iteration_scale;
loc += ('0 1 0' * random()) * 128 * iteration_scale;
- tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player);
+ tracebox(loc, STAT(PL_MIN, player), STAT(PL_MAX, player), loc, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(closest_target.origin, loc, MOVE_NOMONSTERS, closest_target); // double check to make sure we're not spawning outside the NULL
for(tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext)
{
if(random_target)
- RandomSelection_Add(tmp_entity, 0, string_null, 1, 1);
+ RandomSelection_AddEnt(tmp_entity, 1, 1);
else
{
if(SAME_TEAM(tmp_entity, player))
iteration_scale -= i / 10;
loc = closest_target.origin + '0 0 128' * iteration_scale;
loc += ('0 1 0' * random()) * 256 * iteration_scale;
- tracebox(loc, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), loc, MOVE_NORMAL, player);
+ tracebox(loc, STAT(PL_MIN, player), STAT(PL_MAX, player), loc, MOVE_NORMAL, player);
if(trace_fraction == 1.0 && !trace_startsolid)
{
traceline(closest_target.origin, loc, MOVE_NOMONSTERS, closest_target); // double check to make sure we're not spawning outside the NULL
return true;
}
-MUTATOR_HOOKFUNCTION(ons, GetTeamCount)
+MUTATOR_HOOKFUNCTION(ons, CheckAllowedTeams)
{
// onslaught is special
for(entity tmp_entity = ons_worldgeneratorlist; tmp_entity; tmp_entity = tmp_entity.ons_worldgeneratornext)
MUTATOR_HOOKFUNCTION(ons, PlayerUseKey)
{
- if(MUTATOR_RETURNVALUE || gameover) { return false; }
+ if(MUTATOR_RETURNVALUE || game_stopped) return false;
entity player = M_ARGV(0, entity);
g_onslaught = true;
ons_captureshield_force = autocvar_g_onslaught_shield_force;
+ cam = new(objective_camera);
+
InitializeEntity(NULL, ons_DelayedInit, INITPRIO_GAMETYPE);
}