#include "sv_controlpoint.qh"
#include "sv_generator.qh"
+#include <server/bot/api.qh>
+#include <server/campaign.qh>
+#include <server/command/vote.qh>
+#include <server/damage.qh>
+#include <server/items/items.qh>
+#include <server/world.qh>
+#include <common/mapobjects/defs.qh>
+#include <common/mapobjects/triggers.qh>
+
bool g_onslaught;
float autocvar_g_onslaught_teleport_wait;
WriteVector(MSG_ENTITY, this.origin);
- WriteAngle(MSG_ENTITY, this.angles_x);
- WriteAngle(MSG_ENTITY, this.angles_y);
- WriteAngle(MSG_ENTITY, this.angles_z);
+ WriteAngleVector(MSG_ENTITY, this.angles);
return true;
}
this.team = this.enemy.team;
}
-void ons_CaptureShield_Spawn(entity generator, bool is_generator)
+void ons_CaptureShield_Spawn(entity this, Model shield_model)
{
entity shield = new(ons_captureshield);
IL_PUSH(g_onsshields, shield);
- shield.enemy = generator;
- shield.team = generator.team;
- shield.colormap = generator.colormap;
+ shield.enemy = this;
+ shield.team = this.team;
+ shield.colormap = this.colormap;
shield.reset = ons_CaptureShield_Reset;
settouch(shield, ons_CaptureShield_Touch);
setcefc(shield, ons_CaptureShield_Customize);
set_movetype(shield, MOVETYPE_NOCLIP);
shield.solid = SOLID_TRIGGER;
shield.avelocity = '7 0 11';
- shield.scale = 1;
- shield.model = ((is_generator) ? "models/onslaught/generator_shield.md3" : "models/onslaught/controlpoint_shield.md3");
+ shield.scale = this.scale;
- precache_model(shield.model);
- setorigin(shield, generator.origin);
- _setmodel(shield, shield.model);
- setsize(shield, shield.scale * shield.mins, shield.scale * shield.maxs);
+ float shield_extra_size = 1.20; // hitbox is 20% larger than the object itself
+ setorigin(shield, this.origin);
+ setmodel(shield, shield_model);
+ setsize(shield, shield_extra_size * this.mins, shield_extra_size * this.maxs);
}
// Main Control Point Functions
// =============================
-int ons_ControlPoint_CanBeLinked(entity cp, int teamnumber)
+int ons_ControlPoint_CanBeLinked(entity cp, int teamnum)
{
- if(cp.aregensneighbor & BIT(teamnumber)) return 2;
- if(cp.arecpsneighbor & BIT(teamnumber)) return 1;
+ if(cp.aregensneighbor & BIT(teamnum)) return 2;
+ if(cp.arecpsneighbor & BIT(teamnum)) return 1;
return 0;
}
-int ons_ControlPoint_Attackable(entity cp, int teamnumber)
+int ons_ControlPoint_Attackable(entity cp, int teamnum)
// -2: SAME TEAM, attackable by enemy!
// -1: SAME TEAM!
// 0: off limits
else if(cp.goalentity)
{
// if there's already an icon built, nothing happens
- if(cp.team == teamnumber)
+ if(cp.team == teamnum)
{
- a = ons_ControlPoint_CanBeLinked(cp, teamnumber);
+ a = ons_ControlPoint_CanBeLinked(cp, teamnum);
if(a) // attackable by enemy?
return -2; // EMERGENCY!
return -1;
}
// we know it can be linked, so no need to check
// but...
- a = ons_ControlPoint_CanBeLinked(cp, teamnumber);
+ a = ons_ControlPoint_CanBeLinked(cp, teamnum);
if(a == 2) // near our generator?
return 3; // EMERGENCY!
return 1;
else
{
// free point
- if(ons_ControlPoint_CanBeLinked(cp, teamnumber))
+ if(ons_ControlPoint_CanBeLinked(cp, teamnum))
{
- a = ons_ControlPoint_CanBeLinked(cp, teamnumber); // why was this here NUM_TEAM_1 + NUM_TEAM_2 - t
+ a = ons_ControlPoint_CanBeLinked(cp, teamnum); // why was this here NUM_TEAM_1 + NUM_TEAM_2 - t
if(a == 2)
return 4; // GET THIS ONE NOW!
else
{
sound(this, CH_TRIGGER, SND_GRENADE_IMPACT, VOL_BASE, ATTEN_NORM);
pointparticles(EFFECT_ROCKET_EXPLODE, this.origin, '0 0 0', 1);
- Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_ONSLAUGHT_CPDESTROYED), this.owner.message, attacker.netname);
+ if (this.owner.message != "")
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_ONSLAUGHT_CPDESTROYED), this.owner.message, attacker.netname);
+ else
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, APP_TEAM_NUM(this.team, INFO_ONSLAUGHT_CPDESTROYED_NONAME), attacker.netname);
GameRules_scoring_add(attacker, ONS_TAKES, 1);
GameRules_scoring_add(attacker, SCORE, 10);
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_TEAM), this.owner.message);
- Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, this.owner.message);
+ if(this.owner.message != "")
+ {
+ 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_TEAM), this.owner.message);
+ Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, this.owner.message);
+ }
+ else
+ {
+ Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ONSLAUGHT_CAPTURE_NONAME, this.owner.ons_toucher.netname);
+ Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE_TEAM_NONAME));
+ Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE_NONAME);
+ }
GameRules_scoring_add(this.owner.ons_toucher, ONS_CAPS, 1);
GameRules_scoring_add_team(this.owner.ons_toucher, SCORE, 10);
}
onslaught_updatelinks();
// captureshield setup
- ons_CaptureShield_Spawn(this, false);
+ ons_CaptureShield_Spawn(this, MDL_ONS_CP_SHIELD);
CSQCMODEL_AUTOINIT(this);
}
cp.islinked = false;
cp.isshielded = true;
- if(cp.message == "") { cp.message = "a"; }
-
// appearence
setmodel(cp, MDL_ONS_CP_PAD1);
FOREACH_CLIENT(true, it.clientcamera = cam;);
+ // NOTE: engine networked
WriteByte(MSG_ALL, SVC_SETVIEWANGLES);
WriteAngle(MSG_ALL, cam.angles_x);
WriteAngle(MSG_ALL, cam.angles_y);
{
Send_Notification(NOTIF_ONE, it, MSG_CENTER, CENTER_ONS_NOTSHIELDED_TEAM);
msg_entity = it;
- soundto(MSG_ONE, this, CHAN_AUTO, SND(ONS_GENERATOR_ALARM), VOL_BASE, ATTEN_NONE);
+ soundto(MSG_ONE, this, CHAN_AUTO, SND(ONS_GENERATOR_ALARM), VOL_BASE, ATTEN_NONE, 0);
}
else
Send_Notification(NOTIF_ONE, it, MSG_CENTER, APP_TEAM_NUM(this.team, CENTER_ONS_NOTSHIELDED));
this.bot_basewaypoint = this.nearestwaypoint;
// captureshield setup
- ons_CaptureShield_Spawn(this, true);
+ ons_CaptureShield_Spawn(this, MDL_ONS_GEN_SHIELD);
onslaught_updatelinks();
void ons_GeneratorSetup(entity gen) // called when spawning a generator entity on the map as a spawnfunc
{
// declarations
- int teamnumber = gen.team;
+ int teamnum = gen.team;
// main setup
gen.ons_worldgeneratornext = ons_worldgeneratorlist; // link generator into ons_worldgeneratorlist
ons_worldgeneratorlist = gen;
- gen.netname = sprintf("%s generator", Team_ColoredFullName(teamnumber));
- gen.classname = "onslaught_generator";
+ gen.netname = sprintf("%s generator", Team_ColoredFullName(teamnum));
gen.solid = SOLID_BBOX;
- gen.team_saved = teamnumber;
+ gen.team_saved = teamnum;
IL_PUSH(g_saved_team, gen);
set_movetype(gen, MOVETYPE_NONE);
gen.lasthealth = gen.max_health = autocvar_g_onslaught_gen_health;
// model handled by CSQC
setsize(gen, GENERATOR_MIN, GENERATOR_MAX);
setorigin(gen, (gen.origin + CPGEN_SPAWN_OFFSET));
- gen.colormap = 1024 + (teamnumber - 1) * 17;
+ gen.colormap = 1024 + (teamnum - 1) * 17;
// generator placement
droptofloor(gen);
total_generators = 0;
for (int i = 1; i <= NUM_TEAMS; ++i)
{
- Team_SetNumberOfControlPoints(Team_GetTeamFromIndex(i), 0);
+ Team_SetNumberOfOwnedItems(Team_GetTeamFromIndex(i), 0);
}
for(e = ons_worldgeneratorlist; e; e = e.ons_worldgeneratornext)
{
continue;
}
entity team_ = Entity_GetTeam(e);
- int num_control_points = Team_GetNumberOfControlPoints(team_);
- ++num_control_points;
- Team_SetNumberOfControlPoints(team_, num_control_points);
+ int num_generators = Team_GetNumberOfOwnedItems(team_);
+ ++num_generators;
+ Team_SetNumberOfOwnedItems(team_, num_generators);
}
}
-int Onslaught_GetWinnerTeam()
-{
- int winner_team = 0;
- if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(1)) >= 1)
- {
- winner_team = NUM_TEAM_1;
- }
- for (int i = 2; i <= NUM_TEAMS; ++i)
- {
- if (Team_GetNumberOfControlPoints(Team_GetTeamFromIndex(i)) >= 1)
- {
- if (winner_team != 0)
- {
- return 0;
- }
- winner_team = Team_IndexToTeam(i);
- }
- }
- if (winner_team)
- {
- return winner_team;
- }
- return -1; // no generators left?
-}
-
void nades_Clear(entity e);
bool Onslaught_CheckWinner()
else { wpforenemy_announced = false; ons_stalemate = false; }
Onslaught_count_generators();
-
- if (Team_GetNumberOfTeamsWithControlPoints() > 1)
- {
+ int winner_team = Team_GetWinnerTeam_WithOwnedItems(1);
+ if (!winner_team)
return 0;
- }
-
- int winner_team = Onslaught_GetWinnerTeam();
if(winner_team > 0)
{
void ons_Initialize()
{
g_onslaught = true;
+ g_onsshields = IL_NEW();
ons_captureshield_force = autocvar_g_onslaught_shield_force;
cam = new(objective_camera);