+#include "gamemode_keepaway.qh"
+#include "../_all.qh"
+
+#include "gamemode.qh"
+
// ===========================================================
// Keepaway game mode coding, written by Samual and Diabolik
// Last updated: September, 2012
{
if(e.ballcarried)
if(IS_SPEC(other))
- return FALSE; // we don't want spectators of the ballcarrier to see the attached waypoint on the top of their screen
+ return false; // we don't want spectators of the ballcarrier to see the attached waypoint on the top of their screen
// TODO: Make the ballcarrier lack a waypointsprite whenever they have the invisibility powerup
- return TRUE;
+ return true;
}
void ka_EventLog(string mode, entity actor) // use an alias for easy changing and quick editing later
GameLogEcho(strcat(":ka:", mode, ((actor != world) ? (strcat(":", ftos(actor.playerid))) : "")));
}
+void ka_TouchEvent();
void ka_RespawnBall() // runs whenever the ball needs to be relocated
{
if(gameover) { return; }
if(!MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
{
- entity spot = SelectSpawnPoint(TRUE);
+ entity spot = SelectSpawnPoint(true);
setorigin(self, spot.origin);
self.angles = spot.angles;
}
self.velocity = '0 0 200';
self.angles = '0 0 0';
self.effects = autocvar_g_keepawayball_effects;
+ self.touch = ka_TouchEvent;
self.think = ka_RespawnBall;
self.nextthink = time + autocvar_g_keepawayball_respawntime;
- pointparticles(particleeffectnum("electro_combo"), oldballorigin, '0 0 0', 1);
- pointparticles(particleeffectnum("electro_combo"), self.origin, '0 0 0', 1);
+ Send_Effect(EFFECT_ELECTRO_COMBO, oldballorigin, '0 0 0', 1);
+ Send_Effect(EFFECT_ELECTRO_COMBO, self.origin, '0 0 0', 1);
- WaypointSprite_Spawn("ka-ball", 0, 0, self, '0 0 64', world, self.team, self, waypointsprite_attachedforcarrier, FALSE, RADARICON_FLAGCARRIER, '0 1 1');
+ WaypointSprite_Spawn(WP_KaBall, 0, 0, self, '0 0 64', world, self.team, self, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER);
WaypointSprite_Ping(self.waypointsprite_attachedforcarrier);
sound(self, CH_TRIGGER, "keepaway/respawn.wav", VOL_BASE, ATTEN_NONE); // ATTEN_NONE (it's a sound intended to be heard anywhere)
return;
}
if(other.deadflag != DEAD_NO) { return; }
+ if(other.frozen) { return; }
if (!IS_PLAYER(other))
{ // The ball just touched an object, most likely the world
- pointparticles(particleeffectnum("kaball_sparks"), self.origin, '0 0 0', 1);
+ Send_Effect(EFFECT_BALL_SPARKS, self.origin, '0 0 0', 1);
sound(self, CH_TRIGGER, "keepaway/touch.wav", VOL_BASE, ATTEN_NORM);
return;
}
// apply effects to player
other.glow_color = autocvar_g_keepawayball_trail_color;
- other.glow_trail = TRUE;
+ other.glow_trail = true;
other.effects |= autocvar_g_keepaway_ballcarrier_effects;
// messages and sounds
PlayerScore_Add(other, SP_KEEPAWAY_PICKUPS, 1);
// waypoints
- WaypointSprite_AttachCarrier("ka-ballcarrier", other, RADARICON_FLAGCARRIER, '1 0 0');
+ WaypointSprite_AttachCarrier(WP_KaBallCarrier, other, RADARICON_FLAGCARRIER);
other.waypointsprite_attachedforcarrier.waypointsprite_visible_for_player = ka_ballcarrier_waypointsprite_visible_for_player;
WaypointSprite_UpdateRule(other.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
WaypointSprite_Ping(other.waypointsprite_attachedforcarrier);
ball.owner = world;
// reset the player effects
- plyr.glow_trail = FALSE;
+ plyr.glow_trail = false;
plyr.effects &= ~autocvar_g_keepaway_ballcarrier_effects;
// messages and sounds
// PlayerScore_Add(plyr, SP_KEEPAWAY_DROPS, 1); Not anymore, this is 100% the same as pickups and is useless.
// waypoints
- WaypointSprite_Spawn("ka-ball", 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, FALSE, RADARICON_FLAGCARRIER, '0 1 1');
+ WaypointSprite_Spawn(WP_KaBall, 0, 0, ball, '0 0 64', world, ball.team, ball, waypointsprite_attachedforcarrier, false, RADARICON_FLAGCARRIER);
WaypointSprite_UpdateRule(ball.waypointsprite_attachedforcarrier, 0, SPRITERULE_DEFAULT);
WaypointSprite_Ping(ball.waypointsprite_attachedforcarrier);
WaypointSprite_Kill(plyr.waypointsprite_attachedforcarrier);
if((self.owner) && (IS_PLAYER(self.owner)))
ka_DropEvent(self.owner);
- ka_RespawnBall();
+ if(time < game_starttime)
+ {
+ self.think = ka_RespawnBall;
+ self.touch = func_null;
+ self.nextthink = game_starttime;
+ }
+ else
+ ka_RespawnBall();
}
t = (self.health + self.armorvalue) / (ball_owner.health + ball_owner.armorvalue);
navigation_routerating(ball_owner, t * ratingscale, 2000);
}
-
- // Ball has been dropped so collect.
- navigation_routerating(ka_ball, ratingscale, 2000);
+ else // Ball has been dropped so collect.
+ navigation_routerating(ka_ball, ratingscale, 2000);
}
void havocbot_role_ka_carrier()
return 0;
}
+MUTATOR_HOOKFUNCTION(ka_PlayerPhysics)
+{
+ if(self.ballcarried)
+ {
+ self.stat_sv_airspeedlimit_nonqw *= autocvar_g_keepaway_ballcarrier_highspeed;
+ self.stat_sv_maxspeed *= autocvar_g_keepaway_ballcarrier_highspeed;
+ }
+ return false;
+}
+
+MUTATOR_HOOKFUNCTION(ka_BotShouldAttack)
+{
+ // if neither player has ball then don't attack unless the ball is on the ground
+ if(!checkentity.ballcarried && !self.ballcarried && ka_ball.owner)
+ return true;
+ return false;
+}
+
MUTATOR_HOOKFUNCTION(ka_BotRoles)
{
if (self.ballcarried)
self.havocbot_role = havocbot_role_ka_carrier;
else
self.havocbot_role = havocbot_role_ka_collector;
- return TRUE;
+ return true;
}
e.solid = SOLID_TRIGGER;
e.movetype = MOVETYPE_BOUNCE;
e.glow_color = autocvar_g_keepawayball_trail_color;
- e.glow_trail = TRUE;
+ e.glow_trail = true;
e.flags = FL_ITEM;
e.reset = ka_Reset;
e.touch = ka_TouchEvent;
void ka_ScoreRules()
{
- ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY, 0, TRUE); // SFL_SORT_PRIO_PRIMARY
+ ScoreRules_basics(0, SFL_SORT_PRIO_PRIMARY, 0, true); // SFL_SORT_PRIO_PRIMARY
ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_PICKUPS, "pickups", 0);
ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_CARRIERKILLS, "bckills", 0);
ScoreInfo_SetLabel_PlayerScore(SP_KEEPAWAY_BCTIME, "bctime", SFL_SORT_PRIO_SECONDARY);
MUTATOR_HOOK(PlayerDamage_Calculate, ka_PlayerDamage, CBC_ORDER_ANY);
MUTATOR_HOOK(PlayerPowerups, ka_PlayerPowerups, CBC_ORDER_ANY);
MUTATOR_HOOK(PlayerUseKey, ka_PlayerUseKey, CBC_ORDER_ANY);
+ MUTATOR_HOOK(PlayerPhysics, ka_PlayerPhysics, CBC_ORDER_ANY);
+ MUTATOR_HOOK(BotShouldAttack, ka_BotShouldAttack, CBC_ORDER_ANY);
MUTATOR_HOOK(HavocBot_ChooseRole, ka_BotRoles, 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;
}