35 if ( e.classname ==
"minigame_board_piece" && e.netname == tile )
77 entity current = minigame.pp_curr_piece;
101 if ( pos && player.team == (minigame.minigame_flags &
PP_TURN_TEAM) )
107 if(existing && existing.team != 5)
109 if(existing.team == 1)
110 minigame.pp_team1_score++;
111 if(existing.team == 2)
112 minigame.pp_team2_score++;
115 if(minigame.pp_curr_piece)
117 minigame.pp_curr_piece.cnt = 0;
118 minigame.pp_curr_piece.team = 5;
130 piece.team = player.team;
135 minigame.pp_curr_piece = piece;
138 if(minigame.pp_team1_score == minigame.pp_team2_score)
141 minigame.minigame_flags =
PP_TURN_WIN | ((minigame.pp_team1_score > minigame.pp_team2_score) ? 1 : 2);
144 minigame.minigame_flags =
PP_TURN_PLACE | minigame.pp_nexteam;
155 bool t2_true = ((i == 0 || i == 6) && t > 0 && t < 6);
156 bool t1_true = (i > 0 && i < 6 && (t == 0 || t == 6));
158 if(t1_true || t2_true)
161 piece.team = ((t1_true) ? 1 : 2);
168 minigame.pp_curr_piece =
NULL;
182 !( minigame.minigame_flags & player.team ) )
185 minigame.minigame_flags =
PP_TURN_PLACE | minigame.pp_nexteam;
189 if ( e.classname ==
"minigame_board_piece" )
191 minigame.pp_team1_score = 0;
192 minigame.pp_team2_score = 0;
216 if(e.classname ==
"minigame_board_piece")
231 if(minigame.minigame_players)
266 else if(sent.classname ==
"minigame_board_piece")
287 pp_boardsize = mySize;
297 if(e.classname ==
"minigame_board_piece")
306 if ( e.classname ==
"minigame_board_piece" )
311 vector tile_color =
'1 1 1';
314 case 1: tile_color =
'1 0.3 0.3';
break;
315 case 2: tile_color =
'0.3 0.3 1';
break;
319 string tile_name =
strcat(
"pp/piece",
ftos(e.team));
320 if(e.team == 5) { tile_name =
"pp/piece_taken"; }
324 tile_name =
"pp/piece_current";
361 if ( e.classname ==
"minigame_player" &&
365 vector win_pos = pos+
eY*(mySize_y-winfs_y)/2;
368 sprintf(_(
"%s^7 won the game!"), pname),
374 sprintf(_(
"%s^7 won the game!"), pname),
394 ts_y = ( mySize_y - 2*player_fontsize_y ) / 2;
397 vector tile_size =
'48 48 0';
403 mypos_y += player_fontsize_y + ts_y;
405 mypos_y += player_fontsize_y;
414 vector tile_color =
'1 1 1';
417 case 1: tile_color =
'1 0.3 0.3';
break;
418 case 2: tile_color =
'0.3 0.3 1';
break;
424 mypos_y += player_fontsize_y + ts_y;
429 mypos_y += player_fontsize_y;
434 mypos_x += tile_size_x;
446string pp_turn_to_string(
int turnflags)
449 return _(
"You are spectating");
458 return strcat(_(
"You lost the game!"),
"\n", _(
"Select \"^1Next Match^7\" on the menu for a rematch!"));
459 return strcat(_(
"You win!"),
"\n", _(
"Select \"^1Next Match^7\" on the menu to start a new match!"));
465 return _(
"Select \"^1Next Match^7\" on the menu to start a new match!");
466 return _(
"Wait for your opponent to confirm the rematch");
470 return _(
"Wait for your opponent to make their move");
473 return _(
"Click on the game board to place your piece");
479void pp_make_move(
entity minigame)
487void pp_set_curr_pos(
string s)
496int pp_client_event(
entity minigame,
string event, ...)
503 strcpy(minigame.message, pp_turn_to_string(minigame.minigame_flags));
514 bool event_blocked = ((
event ==
"key_released")
518 switch ( ...(0,
int) )
525 pp_set_curr_pos(
"a3");
534 pp_set_curr_pos(
"c3");
543 pp_set_curr_pos(
"a1");
552 pp_set_curr_pos(
"a3");
561 pp_make_move(minigame);
568 case "mouse_pressed":
572 pp_client_event(minigame,
"mouse_moved");
573 pp_make_move(minigame);
589 case "network_receive":
593 if ( sent.classname ==
"minigame" )
597 strcpy(sent.message, pp_turn_to_string(sent.minigame_flags));
604 else if(sent.classname ==
"minigame_board_piece")
608 minigame.pp_curr_piece = sent;
620 if(...(0,
string) ==
"next")
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
void minigame_drawcolorcodedstring_trunc(float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags)
void minigame_show_allspecs(vector boardpos, vector boardsize)
vector minigame_drawstring_wrapped(float maxwidth, vector pos, string text, vector fontsize, vector color, float theAlpha, int drawflags, float align)
void minigame_hud_simpleboard(vector pos, vector mySize, string board_texture)
string minigame_texture(string name)
vector minigame_hud_denormalize_size(vector v, vector pos, vector mySize)
vector minigame_drawcolorcodedstring_wrapped(float maxwidth, vector pos, string text, vector fontsize, float theAlpha, int drawflags, float align)
vector minigame_hud_denormalize(vector v, vector pos, vector mySize)
vector minigame_hud_normalize(vector v, vector pos, vector mySize)
void minigame_drawpic_centered(vector pos, string texture, vector sz, vector color, float thealpha, int drawflags)
#define REGISTER_MINIGAME(name, nicename)
#define minigame_hud_fitsqare(pos, mySize)
#define minigame_cmd(...)
#define FOREACH_MINIGAME_ENTITY(entityvar)
void HUD_MinigameMenu_CustomEntry(entity parent, string menumessage, string event_arg)
#define drawstring(position, text, scale, rgb, alpha, flag)
#define drawpic(position, pic, size, rgb, alpha, flag)
#define drawfill(position, size, rgb, alpha, flag)
const float DRAWFLAG_NORMAL
const float DRAWFLAG_ADDITIVE
string entcs_GetName(int i)
#define HUD_Panel_DrawBg()
entity msle_spawn(entity minigame_session, entity e)
string minigame_relative_tile(string start_id, int dx, int dy, int rows, int columns)
void minigame_server_sendflags(entity ent, int mgflags)
int minigame_count_players(entity minigame)
int minigame_next_team(int curr_team, int n_teams)
int minigame_tile_letter(string id)
string minigame_tile_name(vector pos, int rows, int columns)
vector minigame_tile_pos(string id, int rows, int columns)
string minigame_tile_buildname(int letter, int number)
int minigame_tile_number(string id)
const int MINIG_SF_UPDATE
strcat(_("^F4Countdown stopped!"), "\n^BG", _("Teams are too unbalanced."))
entity pp_find_piece(entity minig, string tile)
const int PP_SPECTATOR_TEAM
bool pp_valid_move(entity minigame, string pos)
void pp_setup_pieces(entity minigame)
void pp_next_match(entity minigame, entity player)
void pp_move(entity minigame, entity player, string pos)
bool pp_winning_piece(entity piece)
int pp_server_event(entity minigame, string event,...)
bool pp_valid_tile(string tile)