1 void ka_SpawnBall(void);
2 void ka_TouchEvent(entity);
3 void ka_RespawnBall(void);
7 print("^4ka_Initialize was just called!\n");
12 precache_sound("keepaway/pickedup.wav");
13 precache_sound("keepaway/dropped.wav");
15 ScoreRules_keepaway();
19 e.think = ka_SpawnBall;
23 void ka_SpawnBall() // self = the ball
30 self.model = "models/orbs/orbblue.md3";
34 precache_model(self.model);
35 setmodel(self, self.model);
36 setsize(self, BALL_MINS, BALL_MAXS);
37 ball_scale = self.scale;
38 self.classname = "keepawayball";
39 self.damageforcescale = cvar("g_keepawayball_damageforcescale");
40 self.effects = self.effects | EF_FULLBRIGHT;
41 self.movetype = MOVETYPE_BOUNCE;
42 self.touch = ka_TouchEvent;
43 self.think = ka_RespawnBall;
44 self.nextthink = time;
46 //self.reset = ka_Reset;
49 // todo: Waypoints and radar
50 WaypointSprite_AttachCarrier("nb-ball", self);
51 //bprint("^4ka_SpawnBall was just called!\n");
56 if(MoveToRandomMapLocation(self, DPCONTENTS_SOLID | DPCONTENTS_CORPSE | DPCONTENTS_PLAYERCLIP, DPCONTENTS_SLIME | DPCONTENTS_LAVA | DPCONTENTS_SKY | DPCONTENTS_BODY | DPCONTENTS_DONOTENTER, Q3SURFACEFLAG_SKY, 10, 1024, 256))
58 makevectors(self.angles);
59 self.movetype = MOVETYPE_BOUNCE;
60 self.velocity = '0 0 200';
61 self.angles = '0 0 0';
62 self.solid = SOLID_TRIGGER;
63 //self.touch = ka_TouchEvent;
64 self.think = ka_RespawnBall;
65 self.nextthink = time + cvar("g_keepawayball_respawntime");
69 // sorry, can't spawn, better luck next frame
70 self.think = ka_RespawnBall;
71 self.nextthink = time;
73 //bprint("^4ka_RespawnBall was just called!\n");
76 void ka_TouchEvent(entity plyr)
78 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_NOIMPACT)
80 self.think = ka_SpawnBall;
81 self.nextthink = time;
88 if(other.classname != "player" || other.health < 1)
92 //if(time > self.ctf_droptime + cvar("g_keepawayball_respawntime"))
96 other.kaballcarried = self;
97 setattachment(self, other, "");
98 setorigin(self, BALL_ATTACHORG);
100 self.velocity = '0 0 0';
101 self.movetype = MOVETYPE_NONE;
102 self.touch = SUB_Null;
105 self.think = SUB_Null;
108 self.glow_color = cvar("g_keepawayball_trail_color");
109 self.glow_trail = TRUE;
113 bprint(other.netname, "^7 has picked up the ball!\n");
114 WriteByte(MSG_BROADCAST, SVC_CENTERPRINT);
115 WriteString(MSG_BROADCAST, strcat("\n\n", other.netname, "^7 has picked up the ball!\n"));
116 sound(self.owner, CHAN_AUTO, "keepaway/pickedup.wav", VOL_BASE, ATTN_NORM);
118 PlayerScore_Add(other, SP_KEEPAWAY_PICKUPS, 1);
120 // todo: Waypoints and radar
123 MUTATOR_HOOKFUNCTION(ka_RemovePlayer)
125 if(self.kaballcarried) {
127 ball = self.kaballcarried;
129 setattachment(ball, world, "");
130 ball.movetype = MOVETYPE_BOUNCE;
131 ball.solid = SOLID_TRIGGER;
132 ball.wait = time + 1;
133 ball.ctf_droptime = time;
134 ball.think = ka_SpawnBall;
135 ball.nextthink = time + cvar("g_keepawayball_respawntime");
136 ball.touch = ka_TouchEvent;
137 self.effects = EF_LOWPRECISION;
140 setorigin(ball, self.origin + '0 0 10');
141 ball.velocity = '0 0 200' + '0 100 0'*crandom() + '100 0 0'*crandom();
143 bprint(self.netname, "^7 has dropped the ball!\n");
144 WriteByte(MSG_BROADCAST, SVC_CENTERPRINT);
145 WriteString(MSG_BROADCAST, strcat("\n\n", self.netname, "^7 has dropped the ball!\n"));
146 sound(other, CHAN_AUTO, "keepaway/dropped.wav", VOL_BASE, ATTN_NORM);
148 PlayerScore_Add(self, SP_KEEPAWAY_DROPS, 1);
151 WaypointSprite_AttachCarrier("nb-ball", ball);
152 WaypointSprite_Kill(self.waypointsprite_attachedforcarrier);
154 ball.owner.kaballcarried = world;
158 if((frag_attacker || frag_target) && !(frag_attacker == frag_target)) {
159 if(frag_target.kaballcarried) // get amount of times killing carrier
160 PlayerScore_Add(frag_attacker, SP_KEEPAWAY_CARRIERKILLS, 1);
161 else if not(frag_attacker.kaballcarried)
162 if(cvar("g_keepaway_noncarrier_warn"))
163 centerprint_atprio(frag_attacker, (CENTERPRIO_SPAM + 5), "Killing people while you don't have the ball gives no points!");
165 if(frag_attacker.kaballcarried) // get kills as carrier
166 PlayerScore_Add(frag_attacker, SP_KEEPAWAY_SCORE, 1);
171 MUTATOR_HOOKFUNCTION(ka_Scoring)
173 if not(frag_attacker == frag_target)
175 if(frag_target.kaballcarried) { // get amount of times killing carrier
176 PlayerScore_Add(frag_attacker, SP_KEEPAWAY_CARRIERKILLS, 1);
179 else if not(frag_attacker.kaballcarried)
180 if(cvar("g_keepaway_noncarrier_warn"))
181 centerprint_atprio(frag_attacker, (CENTERPRIO_SPAM + 5), "Killing people while you don't have the ball gives no points!");
183 if(frag_attacker.kaballcarried) // get kills as carrier
184 PlayerScore_Add(frag_attacker, SP_KEEPAWAY_SCORE, 1);
190 MUTATOR_HOOKFUNCTION(ka_PlayerDies)
195 float temp_tag_players_count;
196 temp_tag_players_count = tag_players_count;
198 if(frag_target.tagcolor == frag_target.tagcolor_original) // if this is the first time we die... (our tagcolor remained unchanged)
200 for(i = 0; i < temp_tag_players_count; ++i) // check other players...
203 if(e == world) // empty slot, skip to next
205 if(temp_tag_players_count < TAGCOLOR_MAX - 1) // just in case
206 ++temp_tag_players_count;
210 if(e.tagcolor == frag_target.tagcolor_original) // and see if they have our original tag color
212 tag_GetFragAttackers_ColorOwner();
213 centerprint(e, strcat("^1Your master ^7", frag_target.netname, "^1 was tagged by ^7", frag_attacker.netname, " ^1with ^7", color_owner_red, " ^1color.\n"));
214 e.tagcolor = frag_attacker.tagcolor; // if so, remove it, our tag color has now "died out" from this round and we can not win anymore. The attacker will "summon" all of our previously fragged targets, and also us.
215 setcolor(e, 16 * e.tagcolor + e.tagcolor);
221 frag_target.tagcolor = frag_attacker.tagcolor;
222 setcolor(frag_target, 16 * frag_target.tagcolor + frag_target.tagcolor);
225 tag_GetFragAttackers_ColorOwner();
228 color_owner_green = "^2your own";
229 centerprint(frag_attacker, strcat("^2You tagged ^7", frag_target.netname, " ^2with ^7", color_owner_green, " ^2color.\n"));
232 color_owner_red = "^1their own";
233 centerprint(frag_target, strcat("^1You were tagged by ^7", frag_attacker.netname, " ^1with ^7", color_owner_red, " ^1color.\n"));
234 bprint("^7", frag_target.netname, "^1 was tagged by ^7", frag_attacker.netname, " ^1with ^7", color_owner_red, " ^1color.\n");
236 frag_target.health = cvar("g_balance_health_start"); // "respawn" the player :P
245 MUTATOR_DEFINITION(gamemode_keepaway)
247 MUTATOR_HOOK(MakePlayerObserver, ka_RemovePlayer, CBC_ORDER_ANY);
248 MUTATOR_HOOK(ClientDisconnect, ka_RemovePlayer, CBC_ORDER_ANY);
249 MUTATOR_HOOK(PlayerDies, ka_RemovePlayer, CBC_ORDER_ANY);
250 //MUTATOR_HOOK(PlayerSpawn, ka_PlayerSpawn, CBC_ORDER_ANY);
251 //MUTATOR_HOOK(GiveFragsForKill, ka_GiveFragsForKill, CBC_ORDER_FIRST);
252 //MUTATOR_HOOK(PlayerPreThink, ka_PlayerPreThink, CBC_ORDER_FIRST);
256 if(time > 1) // game loads at time 1
257 error("This is a game type and it cannot be added at runtime.");
265 error("This is a game type and it cannot be removed at runtime.");