Skip to content

Commit 73c52a1

Browse files
committed
Hack to make player 2 in netplay AI
1 parent fdc0c33 commit 73c52a1

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

src/game/scenes/mainmenu/menu_connect.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void menu_connect_tick(component *c) {
104104

105105
DEBUG("connected to server!");
106106
controller *player1_ctrl, *player2_ctrl;
107-
keyboard_keys *keys;
107+
//keyboard_keys *keys;
108108
game_player *p1 = game_state_get_player(gs, 0);
109109
game_player *p2 = game_state_get_player(gs, 1);
110110

@@ -113,8 +113,10 @@ void menu_connect_tick(component *c) {
113113

114114
p1->pilot->har_id = HAR_JAGUAR;
115115
p1->pilot->pilot_id = 0;
116-
p2->pilot->har_id = HAR_JAGUAR;
117-
p2->pilot->pilot_id = 0;
116+
p2->pilot->har_id = HAR_PYROS;
117+
p2->pilot->pilot_id = 9;
118+
119+
p1->sp_wins = 0;
118120

119121
player1_ctrl = omf_calloc(1, sizeof(controller));
120122
controller_init(player1_ctrl, gs);
@@ -128,7 +130,7 @@ void menu_connect_tick(component *c) {
128130
game_player_set_ctrl(p1, player1_ctrl);
129131

130132
// Player 2 controller -- Keyboard
131-
settings_keyboard *k = &settings_get()->keys;
133+
/*settings_keyboard *k = &settings_get()->keys;
132134
keys = omf_calloc(1, sizeof(keyboard_keys));
133135
keys->jump_up = SDL_GetScancodeFromName(k->key1_jump_up);
134136
keys->jump_right = SDL_GetScancodeFromName(k->key1_jump_right);
@@ -140,9 +142,10 @@ void menu_connect_tick(component *c) {
140142
keys->jump_left = SDL_GetScancodeFromName(k->key1_jump_left);
141143
keys->punch = SDL_GetScancodeFromName(k->key1_punch);
142144
keys->kick = SDL_GetScancodeFromName(k->key1_kick);
143-
keyboard_create(player2_ctrl, keys, 0);
145+
keyboard_create(player2_ctrl, keys, 0);*/
146+
ai_controller_create(player2_ctrl, 4, p2->pilot, 9);
144147
game_player_set_ctrl(p2, player2_ctrl);
145-
game_player_set_selectable(p2, 1);
148+
game_player_set_selectable(p2, 0);
146149

147150
chr_score_set_difficulty(game_player_get_score(game_state_get_player(gs, 0)), AI_DIFFICULTY_CHAMPION);
148151
chr_score_set_difficulty(game_player_get_score(game_state_get_player(gs, 1)), AI_DIFFICULTY_CHAMPION);

src/game/scenes/mainmenu/menu_listen.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ void menu_listen_tick(component *c) {
5656

5757
p1->pilot->har_id = HAR_JAGUAR;
5858
p1->pilot->pilot_id = 0;
59-
p2->pilot->har_id = HAR_JAGUAR;
60-
p2->pilot->pilot_id = 0;
59+
p2->pilot->har_id = HAR_PYROS;
60+
p2->pilot->pilot_id = 9;
6161

6262
player1_ctrl = omf_calloc(1, sizeof(controller));
6363
controller_init(player1_ctrl, gs);
@@ -85,7 +85,7 @@ void menu_listen_tick(component *c) {
8585
// Player 2 controller -- Network
8686
net_controller_create(player2_ctrl, local->host, event.peer, NULL, ROLE_SERVER);
8787
game_player_set_ctrl(p2, player2_ctrl);
88-
game_player_set_selectable(p2, 1);
88+
game_player_set_selectable(p2, 0);
8989

9090
chr_score_set_difficulty(game_player_get_score(game_state_get_player(gs, 0)), AI_DIFFICULTY_CHAMPION);
9191
chr_score_set_difficulty(game_player_get_score(game_state_get_player(gs, 1)), AI_DIFFICULTY_CHAMPION);

src/game/scenes/melee.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ void handle_action(scene *scene, int player, int action) {
378378
player2->pilot->har_id = HAR_NOVA;
379379
} else {
380380
// pick an opponent we have not yet beaten
381-
while(1) {
381+
while(0) {
382382
int i = rand_int(10);
383383
if((2 << i) & player1->sp_wins || i == player1->pilot->pilot_id) {
384384
continue;

src/game/scenes/vs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ int vs_create(scene *scene) {
573573
local->arena = 0;
574574
} else {
575575
// pick a random arena for 1 player mode
576-
local->arena = rand_int(5); // srand was done in melee
576+
local->arena = 0; //rand_int(5); // srand was done in melee
577577
}
578578

579579
// Arena

0 commit comments

Comments
 (0)