+
+// ==============
+// Initialization
+// ==============
+
+void ka_SpawnBall() // loads various values for the ball, runs only once at start of match
+{
+ if(!g_keepaway) { return; }
+
+ entity e;
+ e = spawn();
+ e.model = "models/orbs/orbblue.md3";
+ precache_model(e.model);
+ setmodel(e, e.model);
+ setsize(e, '-16 -16 -20', '16 16 20'); // 20 20 20 was too big, player is only 16 16 24... gotta cheat with the Z (20) axis so that the particle isn't cut off
+ e.classname = "keepawayball";
+ e.damageforcescale = autocvar_g_keepawayball_damageforcescale;
+ e.takedamage = DAMAGE_YES;
+ e.solid = SOLID_TRIGGER;
+ e.movetype = MOVETYPE_BOUNCE;
+ e.glow_color = autocvar_g_keepawayball_trail_color;
+ e.glow_trail = TRUE;
+ e.flags = FL_ITEM;
+ e.reset = ka_Reset;
+ e.touch = ka_TouchEvent;
+ e.owner = world;
+ ka_ball = e;
+
+ InitializeEntity(e, ka_RespawnBall, INITPRIO_SETLOCATION); // is this the right priority? Neh, I have no idea.. Well-- it works! So.
+}
+
+void ka_ScoreRules()
+{
+ 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);
+ ScoreRules_basics_end();
+}
+
+void ka_Initialize() // run at the start of a match, initiates game mode
+{
+ if(!g_keepaway)
+ return;
+
+ precache_sound("keepaway/pickedup.wav");
+ precache_sound("keepaway/dropped.wav");
+ precache_sound("keepaway/respawn.wav");
+ precache_sound("keepaway/touch.wav");
+
+ ka_ScoreRules();
+ ka_SpawnBall();
+}
+
+