]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/minigames/minigame/pong.qc
Merge branch 'master' into Mario/target_teleporter_v2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / minigames / minigame / pong.qc
1 #include "pong.qh"
2 REGISTER_MINIGAME(pong, "Pong");
3
4 // minigame flags
5 const int PONG_STATUS_WAIT = 0x0010; // waiting for players to join
6 const int PONG_STATUS_PLAY = 0x0020; // playing
7
8 // send flags
9 // (minigame_player) sent when reporting scores
10 const int PONG_SF_PLAYERSCORE = MINIG_SF_CUSTOM;
11 // (pong_ball) sent when changing team
12 const int PONG_SF_BALLTEAM = MINIG_SF_CUSTOM;
13
14 // keys
15 const int PONG_KEY_INCREASE = 0x01; // Move down/right
16 const int PONG_KEY_DECREASE = 0x02; // Move up/left
17 const int PONG_KEY_BOTH     = 0x03; // Player jamming keys at ramdom
18
19 // fields
20 const int PONG_MAX_PLAYERS = 4;
21 .int    pong_score;                    // (minigame_player) number of goals
22 .int    pong_keys;                     // (client) pressed keys
23 .entity pong_paddles[PONG_MAX_PLAYERS];// (minigame) paddles
24 .float  pong_length;                   // (pong_paddle/pong_ball) size (0,1)
25 .entity pong_ai_paddle;                // (pong_ai) controlled paddle entity
26
27 #ifdef SVQC
28
29 float autocvar_sv_minigames_pong_paddle_size;
30 float autocvar_sv_minigames_pong_paddle_speed;
31
32 float autocvar_sv_minigames_pong_ball_wait;
33 float autocvar_sv_minigames_pong_ball_speed;
34 float autocvar_sv_minigames_pong_ball_radius;
35 float autocvar_sv_minigames_pong_ball_number;
36
37 float autocvar_sv_minigames_pong_ai_thinkspeed;
38 float autocvar_sv_minigames_pong_ai_tolerance;
39
40 void pong_ball_think(entity this);
41
42 // Throws a ball in a random direction and sets the think function
43 void pong_ball_throw(entity ball)
44 {
45         float angle;
46         do
47                 angle = random()*M_PI*2;
48         while ( fabs(sin(angle)) < 0.17 || fabs(cos(angle)) < 0.17 );
49         ball.velocity_x = cos(angle)*autocvar_sv_minigames_pong_ball_speed;
50         ball.velocity_y = sin(angle)*autocvar_sv_minigames_pong_ball_speed;
51         setthink(ball, pong_ball_think);
52         ball.nextthink = time;
53         ball.team = 0;
54         ball.SendFlags |= MINIG_SF_UPDATE|PONG_SF_BALLTEAM;
55 }
56
57 // Think equivalent of pong_ball_throw, used to delay throws
58 void pong_ball_throwthink(entity this)
59 {
60         pong_ball_throw(this);
61 }
62
63 // Moves ball to the center and stops its motion
64 void pong_ball_reset(entity ball)
65 {
66         ball.velocity = '0 0 0';
67         ball.origin = '0.5 0.5 0';
68         setthink(ball, SUB_NullThink);
69         ball.team = 0;
70         ball.SendFlags |= MINIG_SF_UPDATE|PONG_SF_BALLTEAM;
71         setthink(ball, pong_ball_throwthink);
72         ball.nextthink = time + autocvar_sv_minigames_pong_ball_wait;
73 }
74
75 // Add the score to the given team in the minigame
76 void pong_add_score(entity minigame, int team_thrower, int team_receiver, int delta)
77 {
78         if ( !minigame )
79                 return;
80
81         if ( team_thrower == 0 )
82                 team_thrower = team_receiver;
83
84         if ( team_thrower == team_receiver )
85                 delta *= -1;
86
87         entity paddle_thrower = minigame.pong_paddles[team_thrower-1];
88         if ( paddle_thrower.realowner.minigame_players )
89         {
90                 paddle_thrower.realowner.minigame_players.pong_score += delta;
91                 paddle_thrower.realowner.minigame_players.SendFlags |= PONG_SF_PLAYERSCORE;
92         }
93 }
94
95 // get point in the box nearest to the given one (2D)
96 vector box_nearest(vector box_min, vector box_max, vector p)
97 {
98         return vec2( p.x > box_max.x  ? box_max.x  : ( p.x < box_min.x ? box_min.x : p.x ),
99                 p.y > box_max.y  ? box_max.y  : ( p.y < box_min.y ? box_min.y : p.y ) );
100 }
101
102 void pong_paddle_bounce(entity ball, int pteam)
103 {
104         switch(pteam)
105         {
106                 case 1: ball.velocity_x = -fabs(ball.velocity_x); break;
107                 case 2: ball.velocity_x = fabs(ball.velocity_x); break;
108                 case 3: ball.velocity_y = fabs(ball.velocity_y); break;
109                 case 4: ball.velocity_y = -fabs(ball.velocity_y); break;
110         }
111
112         float angle = atan2(ball.velocity_y, ball.velocity_x);
113         angle += ( random() - 0.5 ) * 2 * M_PI/6;
114         float speed = vlen(ball.velocity);
115
116         ball.velocity_y = speed * sin(angle);
117         ball.velocity_x = speed * cos(angle);
118 }
119
120 // checks if the ball hit the paddle for the given team
121 bool pong_paddle_hit(entity ball, int pteam)
122 {
123         entity paddle = ball.owner.pong_paddles[pteam-1];
124         if (!paddle)
125                 return false;
126
127 #if 1
128         vector near_point = box_nearest(paddle.m_mins+paddle.origin,
129                                                                         paddle.m_maxs+paddle.origin, ball.origin);
130         return vdist(near_point - ball.origin, <=, ball.pong_length);
131 #else
132         return boxesoverlap(paddle.m_mins + paddle.origin, paddle.m_maxs + paddle.origin, ball.m_mins + ball.origin, ball.m_maxs + ball.origin);
133 #endif
134 }
135
136 // Checks for a goal, when that happes adds scores and resets the ball
137 bool pong_goal(entity ball, int pteam)
138 {
139         entity paddle = ball.owner.pong_paddles[pteam-1];
140         if (!paddle)
141                 return false;
142
143         if ( !pong_paddle_hit(ball, pteam) )
144         {
145                 pong_add_score(ball.owner ,ball.team, pteam, 1);
146                 pong_ball_reset(ball);
147                 return true;
148         }
149
150         return false;
151 }
152
153 // Moves the ball around
154 void pong_ball_think(entity this)
155 {
156         float think_speed = autocvar_sys_ticrate;
157         this.nextthink = time + think_speed;
158
159         this.origin_x += this.velocity_x * think_speed;
160         this.origin_y += this.velocity_y * think_speed;
161         this.SendFlags |= MINIG_SF_UPDATE;
162
163         int i;
164         for ( i = 1; i <= PONG_MAX_PLAYERS; i++ )
165                 if ( pong_paddle_hit(this, i) )
166                 {
167                         pong_paddle_bounce(this,i);
168                         this.team = i;
169                         this.SendFlags |= PONG_SF_BALLTEAM;
170                         return;
171                 }
172
173         if ( this.origin_y <= this.pong_length )
174         {
175                 if ( !pong_goal(this,3) )
176                 {
177                         this.origin_y = this.pong_length;
178                         this.velocity_y *= -1;
179                 }
180         }
181         else if ( this.origin_y >= 1-this.pong_length )
182         {
183                 if ( !pong_goal(this,4) )
184                 {
185                         this.origin_y = 1-this.pong_length;
186                         this.velocity_y *= -1;
187                 }
188         }
189
190         if ( this.origin_x <= this.pong_length )
191         {
192                 if ( !pong_goal(this,2) )
193                 {
194                          this.origin_x = this.pong_length;
195                          this.velocity_x *= -1;
196                 }
197         }
198         else if ( this.origin_x >= 1-this.pong_length )
199         {
200                 if ( !pong_goal(this,1) )
201                 {
202                          this.origin_x = 1-this.pong_length;
203                          this.velocity_x *= -1;
204                 }
205         }
206
207 }
208
209 // AI action
210 void pong_ai_think(entity this)
211 {
212         float think_speed = autocvar_sv_minigames_pong_ai_thinkspeed;
213         this.nextthink = time + think_speed;
214
215         float distance;
216         float next_distance;
217         float min_distance = 1;
218         entity ball = NULL;
219         entity mayball = NULL;
220         while ( ( mayball = findentity(mayball,owner,this.owner) ) )
221                 if ( mayball.classname == "pong_ball" )
222                 {
223                         distance = vlen(mayball.origin-this.pong_ai_paddle.origin);
224                         next_distance = vlen(mayball.origin+mayball.velocity-this.pong_ai_paddle.origin);
225                         if (  distance < min_distance && ( distance < 0.5 || next_distance < distance ) )
226                         {
227                                 min_distance = distance;
228                                 ball = mayball;
229                         }
230                 }
231
232         float target = 0.5;
233         float my_pos;
234
235
236         if ( this.team <= 2 )
237         {
238                 if ( ball )
239                         target = ball.origin_y + ball.velocity_y*think_speed;
240                 my_pos = this.pong_ai_paddle.origin_y;
241         }
242         else
243         {
244                 if ( ball )
245                         target = ball.origin_x + ball.velocity_x*think_speed;
246                 my_pos = this.pong_ai_paddle.origin_x;
247         }
248
249         distance = this.pong_length/2 * autocvar_sv_minigames_pong_ai_tolerance
250                 + autocvar_sv_minigames_pong_paddle_speed * think_speed;
251
252         if (target < my_pos - distance)
253                 this.pong_keys = PONG_KEY_DECREASE;
254         else if (target > my_pos + distance)
255                 this.pong_keys = PONG_KEY_INCREASE;
256         else
257                 this.pong_keys = 0;
258 }
259
260 entity pong_ai_spawn(entity paddle)
261 {
262         entity ai = msle_spawn(paddle.owner,"pong_ai");
263         ai.minigame_players = ai;
264         ai.team = paddle.team;
265         setthink(ai, pong_ai_think);
266         ai.nextthink = time;
267         ai.pong_ai_paddle = paddle;
268
269         paddle.realowner = ai;
270
271         return ai;
272 }
273
274 // Moves the paddle
275 void pong_paddle_think(entity this)
276 {
277         float think_speed = autocvar_sys_ticrate;
278         this.nextthink = time + think_speed;
279
280         if ( this.realowner.minigame_players.pong_keys == PONG_KEY_INCREASE ||
281                  this.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
282         {
283                 float pmovement = autocvar_sv_minigames_pong_paddle_speed * think_speed;
284                 float halflen = this.pong_length/2;
285
286                 if ( this.realowner.minigame_players.pong_keys == PONG_KEY_DECREASE )
287                         pmovement *= -1;
288
289                 if ( this.team > 2 )
290                         this.origin_x = bound(halflen, this.origin_x+pmovement, 1-halflen);
291                 else
292                         this.origin_y = bound(halflen, this.origin_y+pmovement, 1-halflen);
293
294                 this.SendFlags |= MINIG_SF_UPDATE;
295         }
296 }
297
298 vector pong_team_to_box_halfsize(int nteam, float length, float width)
299 {
300         if ( nteam > 2 )
301                 return vec2(length/2, width/2);
302         return vec2(width/2, length/2);
303 }
304
305 vector pong_team_to_paddlepos(int nteam)
306 {
307         switch(nteam)
308         {
309                 case 1: return '0.99 0.5 0';
310                 case 2: return '0.01 0.5 0';
311                 case 3: return '0.5 0.01 0';
312                 case 4: return '0.5 0.99 0';
313                 default:return '0 0 0';
314         }
315 }
316
317 // Spawns a pong paddle
318 // if real_player is NULL, the paddle is controlled by AI
319 entity pong_paddle_spawn(entity minigame, int pl_team, entity real_player)
320 {
321         entity paddle = msle_spawn(minigame,"pong_paddle");
322         paddle.pong_length = autocvar_sv_minigames_pong_paddle_size;
323         paddle.origin = pong_team_to_paddlepos(pl_team);
324         setthink(paddle, pong_paddle_think);
325         paddle.nextthink = time;
326         paddle.team = pl_team;
327         paddle.m_mins = pong_team_to_box_halfsize(pl_team,-paddle.pong_length,-1/16);
328         paddle.m_maxs = pong_team_to_box_halfsize(pl_team,paddle.pong_length,1/16);
329
330         if ( real_player == NULL )
331                 pong_ai_spawn(paddle);
332         else
333                 paddle.realowner = real_player;
334
335         minigame.pong_paddles[pl_team-1] = paddle;
336
337         return paddle;
338
339 }
340
341 // required function, handle server side events
342 int pong_server_event(entity minigame, string event, ...)
343 {
344         switch (event)
345         {
346                 case "start":
347                 {
348                         minigame.minigame_flags |= PONG_STATUS_WAIT;
349                         return true;
350                 }
351                 case "join":
352                 {
353                         // Don't allow joining a match that is already running
354                         if ( minigame.minigame_flags & PONG_STATUS_PLAY )
355                                 return false;
356
357                         entity player = ...(0,entity);
358                         int i;
359                         for ( i = 0; i < PONG_MAX_PLAYERS; i++ )
360                         {
361                                 if ( minigame.pong_paddles[i] == NULL )
362                                 {
363                                         pong_paddle_spawn(minigame,i+1,player);
364                                         return i+1;
365                                 }
366                         }
367
368                         return false;
369                 }
370                 case "part":
371                 {
372                         entity player = ...(0,entity);
373                         entity paddle;
374                         entity ai;
375                         int i;
376                         for ( i = 0; i < PONG_MAX_PLAYERS; i++ )
377                         {
378                                 paddle = minigame.pong_paddles[i];
379                                 if ( paddle != NULL && paddle.realowner == player )
380                                 {
381                                         ai = pong_ai_spawn(paddle);
382                                         ai.pong_score = player.minigame_players.pong_score;
383                                         break;
384                                 }
385
386                         }
387                         return false;
388                 }
389                 case "cmd":
390                 {
391                         entity player = ...(0,entity);
392                         switch(argv(0))
393                         {
394                                 case "throw":
395                                         if ( minigame.minigame_flags & PONG_STATUS_WAIT )
396                                         {
397                                                 minigame.minigame_flags = PONG_STATUS_PLAY |
398                                                         (minigame.minigame_flags & ~PONG_STATUS_WAIT);
399                                                 minigame.SendFlags |= MINIG_SF_UPDATE;
400
401                                                 entity ball;
402                                                 for ( int j = 0; j < autocvar_sv_minigames_pong_ball_number; j++ )
403                                                 {
404                                                         ball = msle_spawn(minigame,"pong_ball");
405                                                         ball.pong_length = autocvar_sv_minigames_pong_ball_radius;
406                                                         ball.m_mins = vec2(-ball.pong_length, -ball.pong_length);
407                                                         ball.m_maxs = vec2(ball.pong_length, ball.pong_length);
408                                                         pong_ball_reset(ball);
409                                                 }
410                                         }
411                                         return true;
412                                 case "+movei":
413                                         player.pong_keys |= PONG_KEY_INCREASE;
414                                         return true;
415                                 case "+moved":
416                                         player.pong_keys |= PONG_KEY_DECREASE;
417                                         return true;
418                                 case "-movei":
419                                         player.pong_keys &= ~PONG_KEY_INCREASE;
420                                         return true;
421                                 case "-moved":
422                                         player.pong_keys &= ~PONG_KEY_DECREASE;
423                                         return true;
424                                 case "move":
425                                         if(argv(1))
426                                                 player.pong_keys = stoi(argv(1));
427                                         return true;
428                                 case "pong_aimore":
429                                 {
430                                         // keep declaration here, moving it into for() reverses weapon order
431                                         // potentially compiler bug
432                                         int j;
433                                         if ( minigame.minigame_flags & PONG_STATUS_WAIT )
434                                                 for ( j = 0; j < PONG_MAX_PLAYERS; j++ )
435                                                 //for ( int j = 0; j < PONG_MAX_PLAYERS; j++ )
436                                                 {
437                                                         if ( minigame.pong_paddles[j] == NULL )
438                                                         {
439                                                                 pong_paddle_spawn(minigame,j+1,NULL);
440                                                                 return true;
441                                                         }
442                                                 }
443                                         sprint(player.minigame_players,"Cannot spawn AI\n");
444                                         return true;
445                                 }
446                                 case "pong_ailess":
447                                 {
448                                         if ( minigame.minigame_flags & PONG_STATUS_WAIT )
449                                         {
450                                                 entity paddle;
451                                                 for ( int j = PONG_MAX_PLAYERS-1; j >= 0; j-- )
452                                                 {
453                                                         paddle = minigame.pong_paddles[j];
454                                                         if ( paddle != NULL &&
455                                                                 paddle.realowner.classname == "pong_ai" )
456                                                         {
457                                                                 minigame.pong_paddles[j] = NULL;
458                                                                 delete(paddle.realowner);
459                                                                 delete(paddle);
460                                                                 return true;
461                                                         }
462                                                 }
463                                         }
464                                         sprint(player.minigame_players,"Cannot remove AI\n");
465                                         return true;
466                                 }
467
468                         }
469                         return false;
470                 }
471                 case "network_send":
472                 {
473                         entity sent = ...(0,entity);
474                         int sf = ...(1,int);
475                         if ( sent.classname == "minigame_player" && (sf & PONG_SF_PLAYERSCORE ) )
476                         {
477                                 WriteLong(MSG_ENTITY,sent.pong_score);
478                         }
479                         return false;
480                 }
481         }
482         return false;
483 }
484
485
486 #elif defined(CSQC)
487
488 void drawrotpic(vector org, float rot, string pic, vector sz, vector hotspot, vector rgb, float a, float f);
489
490 float pong_team_to_angle(int nteam)
491 {
492         switch(nteam)
493         {
494                 default:
495                 case 1: return 0;
496                 case 2: return M_PI;
497                 case 3: return M_PI*3/2;
498                 case 4: return M_PI/2;
499         }
500 }
501
502 vector pong_team_to_color(int nteam)
503 {
504         switch(nteam)
505         {
506                 case 1: return '1 0 0';
507                 case 2: return '0 0 1';
508                 case 3: return '1 1 0';
509                 case 4: return '1 0 1';
510                 default:return '1 1 1';
511         }
512 }
513
514 int pong_keys_pressed;
515 int pong_keys_pressed_old;
516
517 // Required function, draw the game board
518 void pong_hud_board(vector pos, vector mySize)
519 {
520         if(pong_keys_pressed != pong_keys_pressed_old)
521                 minigame_cmd(strcat("move ", itos(pong_keys_pressed)));
522         pong_keys_pressed_old = pong_keys_pressed;
523
524         minigame_hud_fitsqare(pos, mySize);
525         minigame_hud_simpleboard(pos,mySize,minigame_texture("pong/board"));
526
527         entity e;
528         vector obj_pos;
529         vector obj_size;
530         FOREACH_MINIGAME_ENTITY(e)
531         {
532                 if ( e.classname == "pong_ball" )
533                 {
534                         // Note: 4*radius = 2*diameter because the image is large enough to fit the glow around the ball
535                         obj_size =  minigame_hud_denormalize_size('4 4 0'*e.pong_length,pos,mySize);
536                         obj_pos = minigame_hud_denormalize(e.origin,pos,mySize);
537
538                         minigame_drawpic_centered( obj_pos, minigame_texture("pong/ball"),
539                                         obj_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL );
540
541                         minigame_drawpic_centered( obj_pos, minigame_texture("pong/ball-glow"),
542                                         obj_size, pong_team_to_color(e.team),
543                                         panel_fg_alpha, DRAWFLAG_ADDITIVE );
544                 }
545                 else if ( e.classname == "pong_paddle" )
546                 {
547                         obj_pos = minigame_hud_denormalize(e.origin,pos,mySize);
548                         obj_size = minigame_hud_denormalize_size(eX / 16 + eY*e.pong_length,pos,mySize);
549
550                         drawrotpic(obj_pos, pong_team_to_angle(e.team), minigame_texture("pong/paddle-glow"),
551                                 obj_size, obj_size/2, pong_team_to_color(e.team),
552                                 panel_fg_alpha, DRAWFLAG_ADDITIVE );
553
554                         drawrotpic(obj_pos, pong_team_to_angle(e.team), minigame_texture("pong/paddle"),
555                                 obj_size, obj_size/2, '1 1 1',
556                                 panel_fg_alpha, DRAWFLAG_NORMAL );
557
558                 }
559         }
560 }
561
562 // Required function, draw the game status panel
563 void pong_hud_status(vector pos, vector mySize)
564 {
565         HUD_Panel_DrawBg();
566         vector ts;
567         ts = minigame_drawstring_wrapped(mySize_x,pos,active_minigame.descriptor.message,
568                 hud_fontsize * 2, '0.25 0.47 0.72', panel_fg_alpha, DRAWFLAG_NORMAL,0.5);
569         ts_y += hud_fontsize_y;
570         pos_y += ts_y;
571         mySize_y -= ts_y;
572
573         vector player_fontsize = hud_fontsize * 1.75;
574         ts_y = ( mySize_y - PONG_MAX_PLAYERS*player_fontsize_y ) / PONG_MAX_PLAYERS;
575         ts_x = mySize_x;
576         vector mypos;
577
578         entity e;
579         FOREACH_MINIGAME_ENTITY(e)
580         {
581                 if ( e.classname == "minigame_player" || e.classname == "pong_ai" )
582                 {
583                         mypos = pos;
584                         mypos_y  += (e.team-1) * (player_fontsize_y + ts_y);
585
586                         drawfill(mypos, ts, pong_team_to_color(e.team), 0.25, DRAWFLAG_ADDITIVE);
587
588                         minigame_drawcolorcodedstring_trunc(mySize_x,mypos,
589                                 (e.minigame_playerslot ? entcs_GetName(e.minigame_playerslot-1) : _("AI")),
590                                 player_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
591
592                         drawstring(mypos+eY*player_fontsize_y,ftos(e.pong_score),'48 48 0',
593                                            '0.7 0.84 1', panel_fg_alpha, DRAWFLAG_NORMAL);
594
595                         if ( e == minigame_self )
596                                 drawborderlines(1, mypos, ts, pong_team_to_color(e.team), 1, DRAWFLAG_NORMAL);
597                 }
598         }
599 }
600
601 // convert minigame flags to a message
602 string pong_message(int mgflags)
603 {
604         string rmessage = "";
605         if (mgflags & PONG_STATUS_WAIT)
606                 rmessage = _("Press ^1Start Match^7 to start the match with the current players");
607         return rmessage;
608 }
609
610 // Required function, handle client events
611 int pong_client_event(entity minigame, string event, ...)
612 {
613         switch(event)
614         {
615                 case "activate":
616                         return false;
617                 case "key_pressed":
618                         switch ( ...(0,int) )
619                         {
620                                 case K_UPARROW:
621                                 case K_KP_UPARROW:
622                                 case K_LEFTARROW:
623                                 case K_KP_LEFTARROW:
624                                         //minigame_cmd("+moved");
625                                         pong_keys_pressed |= PONG_KEY_DECREASE;
626                                         return true;
627                                 case K_DOWNARROW:
628                                 case K_KP_DOWNARROW:
629                                 case K_RIGHTARROW:
630                                 case K_KP_RIGHTARROW:
631                                         //minigame_cmd("+movei");
632                                         pong_keys_pressed |= PONG_KEY_INCREASE;
633                                         return true;
634                         }
635                         return false;
636                 case "key_released":
637                         switch ( ...(0,int) )
638                         {
639                                 case K_UPARROW:
640                                 case K_KP_UPARROW:
641                                 case K_LEFTARROW:
642                                 case K_KP_LEFTARROW:
643                                         //minigame_cmd("-moved");
644                                         pong_keys_pressed &= ~PONG_KEY_DECREASE;
645                                         return true;
646                                 case K_DOWNARROW:
647                                 case K_KP_DOWNARROW:
648                                 case K_RIGHTARROW:
649                                 case K_KP_RIGHTARROW:
650                                         //minigame_cmd("-movei");
651                                         pong_keys_pressed &= ~PONG_KEY_INCREASE;
652                                         return true;
653                         }
654                         return false;
655                 case "network_receive":
656                 {
657                         entity sent = ...(0,entity);
658                         int sf = ...(1,int);
659                         if ( sent.classname == "minigame_player" && (sf & PONG_SF_PLAYERSCORE ) )
660                         {
661                                 sent.pong_score = ReadLong();
662                         }
663                         else if ( sent.classname == "minigame" )
664                         {
665                                 if ( sf & MINIG_SF_UPDATE )
666                                 {
667                                         sent.message = pong_message(sent.minigame_flags);
668                                 }
669                         }
670                         return false;
671                 }
672                 case "menu_show":
673                 {
674                         HUD_MinigameMenu_CustomEntry(...(0,entity),_("Start Match"),"pong_throw");
675                         HUD_MinigameMenu_CustomEntry(...(0,entity),_("Add AI player"),"pong_aimore");
676                         HUD_MinigameMenu_CustomEntry(...(0,entity),_("Remove AI player"),"pong_ailess");
677                         return false;
678                 }
679                 case "menu_click":
680                 {
681                         string cmd = ...(0,string);
682                         if( cmd == "pong_throw" && minigame.minigame_flags & PONG_STATUS_WAIT )
683                         {
684                                 minigame_cmd("throw");
685                         }
686                         else if ( cmd == "pong_aimore" || cmd == "pong_ailess" )
687                         {
688                                 minigame_cmd(cmd);
689                         }
690                         return false;
691                 }
692         }
693
694         return false;
695 }
696 #endif