+#include "gamemode_nexball.qh"
+#include "../_all.qh"
+
+#include "gamemode.qh"
+
float autocvar_g_nexball_safepass_turnrate;
float autocvar_g_nexball_safepass_maxdist;
float autocvar_g_nexball_safepass_holdtime;
void basketball_touch();
void football_touch();
void ResetBall();
-#define NBM_NONE 0
-#define NBM_FOOTBALL 2
-#define NBM_BASKETBALL 4
+const float NBM_NONE = 0;
+const float NBM_FOOTBALL = 2;
+const float NBM_BASKETBALL = 4;
float nexball_mode;
float OtherTeam(float t) //works only if there are two teams on the map!
return e.team;
}
+const float ST_NEXBALL_GOALS = 1;
+const float SP_NEXBALL_GOALS = 4;
+const float SP_NEXBALL_FAULTS = 5;
+void nb_ScoreRules(float teams)
+{
+ ScoreRules_basics(teams, 0, 0, true);
+ ScoreInfo_SetLabel_TeamScore( ST_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
+ ScoreInfo_SetLabel_PlayerScore( SP_NEXBALL_GOALS, "goals", SFL_SORT_PRIO_PRIMARY);
+ ScoreInfo_SetLabel_PlayerScore(SP_NEXBALL_FAULTS, "faults", SFL_SORT_PRIO_SECONDARY | SFL_LOWER_IS_BETTER);
+ ScoreRules_basics_end();
+}
void LogNB(string mode, entity actor)
{
void relocate_nexball(void)
{
- tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, TRUE, self);
+ tracebox(self.origin, BALL_MINS, BALL_MAXS, self.origin, true, self);
if(trace_startsolid)
{
vector o;
o = self.origin;
if(!move_out_of_solid(self))
objerror("could not get out of solid at all!");
- print("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
- print(" needs to be moved out of solid, e.g. by '", ftos(self.origin_x - o_x));
- print(" ", ftos(self.origin_y - o_y));
- print(" ", ftos(self.origin_z - o_z), "'\n");
+ LOG_INFO("^1NOTE: this map needs FIXING. ", self.classname, " at ", vtos(o - '0 0 1'));
+ LOG_INFO(" needs to be moved out of solid, e.g. by '", ftos(self.origin.x - o.x));
+ LOG_INFO(" ", ftos(self.origin.y - o.y));
+ LOG_INFO(" ", ftos(self.origin.z - o.z), "'\n");
self.origin = o;
}
}
entity ownr;
ownr = self.owner;
DropBall(self, ownr.origin, ownr.velocity);
- makevectors(ownr.v_angle_y * '0 1 0');
+ makevectors(ownr.v_angle.y * '0 1 0');
ownr.velocity += ('0 0 0.75' - v_forward) * 1000;
ownr.flags &= ~FL_ONGROUND;
}
ball.effects |= EF_NOSHADOW;
ball.scale = 1; // scale down.
- WaypointSprite_AttachCarrier("nb-ball", plyr, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR);
+ WaypointSprite_AttachCarrier(WP_NbBall, plyr, RADARICON_FLAGCARRIER);
WaypointSprite_UpdateRule(plyr.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
if(autocvar_g_nexball_basketball_delay_hold)
self.weaponentity.weapons = self.weapons;
self.weaponentity.switchweapon = self.weapon;
self.weapons = WEPSET_PORTO;
- weapon_action(WEP_PORTO, WR_RESETPLAYER);
- self.switchweapon = WEP_PORTO;
- W_SwitchWeapon(WEP_PORTO);
+ WEP_ACTION(WEP_PORTO.m_id, WR_RESETPLAYER);
+ self.switchweapon = WEP_PORTO.m_id;
+ W_SwitchWeapon(WEP_PORTO.m_id);
self = ownr;
}
}
WaypointSprite_Kill(ball.owner.waypointsprite_attachedforcarrier);
- WaypointSprite_Spawn("nb-ball", 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, FALSE, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // no health bar please
+ WaypointSprite_Spawn(WP_NbBall, 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER); // no health bar please
WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
ball.owner.ballcarried = world;
self.nextthink = time + autocvar_g_nexball_delay_idle + 3;
self.teamtime = 0;
self.pusher = world;
- self.team = FALSE;
+ self.team = false;
sound(self, CH_TRIGGER, self.noise1, VOL_BASE, ATTEN_NORM);
WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
LogNB("init", world);
{
// dprint("Step 4: time: ", ftos(time), "\n");
if(vlen(self.origin - self.spawnorigin) > 10) // should not happen anymore
- dprint("The ball moved too far away from its spawn origin.\nOffset: ",
+ LOG_TRACE("The ball moved too far away from its spawn origin.\nOffset: ",
vtos(self.origin - self.spawnorigin), " Velocity: ", vtos(self.velocity), "\n");
self.velocity = '0 0 0';
setorigin(self, self.spawnorigin); // make sure it's positioned correctly anyway
}
else if(autocvar_g_nexball_football_physics == 2) // 2nd mod try: totally independant. Really playable!
{
- makevectors(other.v_angle_y * '0 1 0');
+ makevectors(other.v_angle.y * '0 1 0');
self.velocity = other.velocity + v_forward * autocvar_g_nexball_football_boost_forward + v_up * autocvar_g_nexball_football_boost_up;
}
else // Revenant's original style (from the original mod's disassembly, acknowledged by Revenant)
football_touch();
return;
}
- if(!self.cnt && IS_PLAYER(other) && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
+ if(!self.cnt && IS_PLAYER(other) && !other.frozen && !other.deadflag && (other != self.nb_dropper || time > self.nb_droptime + autocvar_g_nexball_delay_collect))
{
if(other.health <= 0)
return;
void nb_spawnteam(string teamname, float teamcolor)
{
- dprint("^2spawned team ", teamname, "\n");
+ LOG_TRACE("^2spawned team ", teamname, "\n");
entity e;
e = spawn();
e.classname = "nexball_team";
void nb_spawnteams(void)
{
- float t_r = 0, t_b = 0, t_y = 0, t_p = 0;
+ bool t_red = false, t_blue = false, t_yellow = false, t_pink = false;
entity e;
for(e = world; (e = find(e, classname, "nexball_goal"));)
{
switch(e.team)
{
case NUM_TEAM_1:
- if(!t_r)
+ if(!t_red)
{
nb_spawnteam("Red", e.team-1) ;
- t_r = 1;
+ t_red = true;
}
break;
case NUM_TEAM_2:
- if(!t_b)
+ if(!t_blue)
{
nb_spawnteam("Blue", e.team-1) ;
- t_b = 1;
+ t_blue = true;
}
break;
case NUM_TEAM_3:
- if(!t_y)
+ if(!t_yellow)
{
nb_spawnteam("Yellow", e.team-1);
- t_y = 1;
+ t_yellow = true;
}
break;
case NUM_TEAM_4:
- if(!t_p)
+ if(!t_pink)
{
nb_spawnteam("Pink", e.team-1) ;
- t_p = 1;
+ t_pink = true;
}
break;
}
{
if(find(world, classname, "nexball_team") == world)
nb_spawnteams();
- ScoreRules_nexball(nb_teams);
+ nb_ScoreRules(nb_teams);
}
void SpawnBall(void)
{
- if(!g_nexball)
- {
- remove(self);
- return;
- }
+ if(!g_nexball) { remove(self); return; }
// balls += 4; // using the remaining bits to count balls will leave more than the max edict count, so it's fine
if(cvar(strcat("g_", self.classname, "_trail"))) //nexball_basketball :p
{
self.glow_color = autocvar_g_nexball_trail_color;
- self.glow_trail = TRUE;
+ self.glow_trail = true;
}
self.movetype = MOVETYPE_FLY;
precache_sound(self.noise1);
precache_sound(self.noise2);
- WaypointSprite_AttachCarrier("nb-ball", self, RADARICON_FLAGCARRIER, BALL_SPRITECOLOR); // the ball's team is not set yet, no rule update needed
+ WaypointSprite_AttachCarrier(WP_NbBall, self, RADARICON_FLAGCARRIER); // the ball's team is not set yet, no rule update needed
self.reset = ball_restart;
self.think = InitBall;
SpawnBall();
}
+float nb_Goal_Customize()
+{
+ entity e, wp_owner;
+ e = WaypointSprite_getviewentity(other);
+ wp_owner = self.owner;
+ if(SAME_TEAM(e, wp_owner)) { return false; }
+
+ return true;
+}
+
void SpawnGoal(void)
{
- if(!g_nexball)
+ if(!g_nexball) { remove(self); return; }
+
+ EXACTTRIGGER_INIT;
+
+ if(self.team != GOAL_OUT && Team_TeamToNumber(self.team) != -1)
{
- remove(self);
- return;
+ entity wp = WaypointSprite_SpawnFixed(WP_NbGoal, (self.absmin + self.absmax) * 0.5, self, sprite, RADARICON_NONE);
+ wp.colormod = ((self.team) ? Team_ColorRGB(self.team) : '1 0.5 0');
+ self.sprite.customizeentityforclient = nb_Goal_Customize;
}
- EXACTTRIGGER_INIT;
+
self.classname = "nexball_goal";
if(self.noise == "")
self.noise = "ctf/respawn.wav";
PROJECTILE_TOUCH;
if(attacker.team != other.team || autocvar_g_nexball_basketball_teamsteal)
- if((ball = other.ballcarried) && (IS_PLAYER(attacker)))
+ if((ball = other.ballcarried) && !other.frozen && !other.deadflag && (IS_PLAYER(attacker)))
{
other.velocity = other.velocity + normalize(self.velocity) * other.damageforcescale * autocvar_g_balance_nexball_secondary_force;
other.flags &= ~FL_ONGROUND;
LogNB("stole", attacker);
sound(other, CH_TRIGGER, ball.noise2, VOL_BASE, ATTEN_NORM);
- if(attacker.team == other.team && time > attacker.teamkill_complain)
+ if(SAME_TEAM(attacker, other) && time > attacker.teamkill_complain)
{
attacker.teamkill_complain = time + 5;
attacker.teamkill_soundtime = time + 0.4;
if(!(ball = self.ballcarried))
return;
- W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
+ W_SetupShot(self, false, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
tracebox(w_shotorg, BALL_MINS, BALL_MAXS, w_shotorg, MOVE_WORLDONLY, world);
if(trace_startsolid)
{
mi = autocvar_g_nexball_basketball_meter_minpower;
ma = max(mi, autocvar_g_nexball_basketball_meter_maxpower); // avoid confusion
//One triangle wave period with 1 as max
- mul = 2 * mod(t, g_nexball_meter_period) / g_nexball_meter_period;
+ mul = 2 * (t % g_nexball_meter_period) / g_nexball_meter_period;
if(mul > 1)
mul = 2 - mul;
mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power
}
- DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, FALSE));
+ DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(self.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false));
//TODO: use the speed_up cvar too ??
if(self.ballcarried.enemy)
{
entity _ball = self.ballcarried;
- W_SetupShot(self, FALSE, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
+ W_SetupShot(self, false, 4, "nexball/shoot1.wav", CH_WEAPON_A, 0);
DropBall(_ball, w_shotorg, trigger_push_calculatevelocity(_ball.origin, _ball.enemy, 32));
_ball.think = W_Nexball_Think;
_ball.nextthink = time;
entity missile;
if(!(balls & BALL_BASKET))
return;
- W_SetupShot(self, FALSE, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0);
-// pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
+ W_SetupShot(self, false, 2, "nexball/shoot2.wav", CH_WEAPON_A, 0);
missile = spawn();
missile.owner = self;
missile.movetype = MOVETYPE_FLY;
PROJECTILE_MAKETRIGGER(missile);
- setmodel(missile, "models/elaser.mdl"); // precision set below
+ //setmodel(missile, "models/elaser.mdl"); // precision set below
setsize(missile, '0 0 0', '0 0 0');
setorigin(missile, w_shotorg);
- W_SetupProjectileVelocity(missile, autocvar_g_balance_nexball_secondary_speed, 0);
+ W_SetupProjVelocity_Basic(missile, autocvar_g_balance_nexball_secondary_speed, 0);
missile.angles = vectoangles(missile.velocity);
missile.touch = W_Nexball_Touch;
missile.think = SUB_Remove;
missile.effects = EF_BRIGHTFIELD | EF_LOWPRECISION;
missile.flags = FL_PROJECTILE;
+
+ CSQCProjectile(missile, true, PROJECTILE_ELECTRO, true);
}
float ball_customize()
self.effects &= ~EF_FLAME;
self.scale = 1;
self.customizeentityforclient = func_null;
- return TRUE;
+ return true;
}
if(other == self.owner)
self.scale = 1;
}
- return TRUE;
+ return true;
}
float w_nexball_weapon(float req)
weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
}
}
- else if(req == WR_PRECACHE)
+ else if(req == WR_INIT)
{
- precache_model("models/weapons/g_porto.md3");
- precache_model("models/weapons/v_porto.md3");
- precache_model("models/weapons/h_porto.iqm");
+ precache_model(W_Model("g_porto.md3"));
+ precache_model(W_Model("v_porto.md3"));
+ precache_model(W_Model("h_porto.iqm"));
precache_model("models/elaser.mdl");
precache_sound("nexball/shoot1.wav");
precache_sound("nexball/shoot2.wav");
}
else if(req == WR_SETUP)
{
- weapon_setup(WEP_PORTO);
+ //weapon_setup(WEP_PORTO.m_id);
}
- // No need to check WR_CHECKAMMO* or WR_AIM, it should always return TRUE
- return TRUE;
+ // No need to check WR_CHECKAMMO* or WR_AIM, it should always return true
+ return true;
}
MUTATOR_HOOKFUNCTION(nexball_BallDrop)
return 0;
}
-MUTATOR_HOOKFUNCTION(nexball_BuildMutatorsString)
-{
- ret_string = strcat(ret_string, ":NB");
- return 0;
-}
-
-MUTATOR_HOOKFUNCTION(nexball_BuildMutatorsPrettyString)
-{
- ret_string = strcat(ret_string, ", NexBall");
- return 0;
-}
-
MUTATOR_HOOKFUNCTION(nexball_PlayerPreThink)
{
makevectors(self.v_angle);
self.ballcarried.customizeentityforclient = ball_customize;
setorigin(self.ballcarried, self.origin + self.view_ofs +
- v_forward * autocvar_g_nexball_viewmodel_offset_x +
- v_right * autocvar_g_nexball_viewmodel_offset_y +
- v_up * autocvar_g_nexball_viewmodel_offset_z);
+ v_forward * autocvar_g_nexball_viewmodel_offset.x +
+ v_right * autocvar_g_nexball_viewmodel_offset.y +
+ v_up * autocvar_g_nexball_viewmodel_offset.z);
// 'safe passing'
if(autocvar_g_nexball_safepass_maxdist)
if(self.weaponentity.weapons)
{
self.weapons = self.weaponentity.weapons;
- weapon_action(WEP_PORTO, WR_RESETPLAYER);
+ WEP_ACTION(WEP_PORTO.m_id, WR_RESETPLAYER);
self.switchweapon = self.weaponentity.switchweapon;
W_SwitchWeapon(self.switchweapon);
nexball_setstatus();
- return FALSE;
+ return false;
}
MUTATOR_HOOKFUNCTION(nexball_PlayerSpawn)
else
self.weapons = '0 0 0';
- return FALSE;
+ return false;
+}
+
+MUTATOR_HOOKFUNCTION(nexball_PlayerPhysics)
+{
+ if(self.ballcarried)
+ {
+ self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed;
+ self.stat_sv_maxspeed *= autocvar_g_nexball_basketball_carrier_highspeed;
+ }
+ return false;
}
MUTATOR_HOOKFUNCTION(nexball_SetStartItems)
{
start_items |= IT_UNLIMITED_SUPERWEAPONS; // FIXME BAD BAD BAD BAD HACK, NEXBALL SHOULDN'T ABUSE PORTO'S WEAPON SLOT
- return FALSE;
+ return false;
+}
+
+MUTATOR_HOOKFUNCTION(nexball_ForbidThrowing)
+{
+ if(self.weapon == WEP_MORTAR.m_id)
+ return true;
+
+ return false;
+}
+
+MUTATOR_HOOKFUNCTION(nexball_FilterItem)
+{
+ if(self.classname == "droppedweapon")
+ if(self.weapon == WEP_MORTAR.m_id)
+ return true;
+
+ return false;
}
MUTATOR_DEFINITION(gamemode_nexball)
MUTATOR_HOOK(PlayerDies, nexball_BallDrop, CBC_ORDER_ANY);
MUTATOR_HOOK(MakePlayerObserver, nexball_BallDrop, CBC_ORDER_ANY);
MUTATOR_HOOK(ClientDisconnect, nexball_BallDrop, CBC_ORDER_ANY);
- MUTATOR_HOOK(BuildMutatorsPrettyString, nexball_BuildMutatorsPrettyString, CBC_ORDER_ANY);
- MUTATOR_HOOK(BuildMutatorsString, nexball_BuildMutatorsString, CBC_ORDER_ANY);
MUTATOR_HOOK(PlayerSpawn, nexball_PlayerSpawn, CBC_ORDER_ANY);
MUTATOR_HOOK(PlayerPreThink, nexball_PlayerPreThink, CBC_ORDER_ANY);
+ MUTATOR_HOOK(PlayerPhysics, nexball_PlayerPhysics, CBC_ORDER_ANY);
MUTATOR_HOOK(SetStartItems, nexball_SetStartItems, CBC_ORDER_ANY);
+ MUTATOR_HOOK(ForbidThrowCurrentWeapon, nexball_ForbidThrowing, CBC_ORDER_ANY);
+ MUTATOR_HOOK(FilterItem, nexball_FilterItem, CBC_ORDER_ANY);
MUTATOR_ONADD
{
MUTATOR_ONREMOVE
{
- print("This is a game type and it cannot be removed at runtime.");
+ LOG_INFO("This is a game type and it cannot be removed at runtime.");
return -1;
}