Skip to content

Commit f65aa43

Browse files
committed
Hack to make player 2 in netplay AI
1 parent 6eec4c7 commit f65aa43

4 files changed

Lines changed: 14 additions & 11 deletions

File tree

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);
@@ -141,9 +143,10 @@ void menu_connect_tick(component *c) {
141143
keys->punch = SDL_GetScancodeFromName(k->key1_punch);
142144
keys->kick = SDL_GetScancodeFromName(k->key1_kick);
143145
keys->escape = SDL_GetScancodeFromName(k->key1_escape);
144-
keyboard_create(player2_ctrl, keys, 0);
146+
keyboard_create(player2_ctrl, keys, 0);*/
147+
ai_controller_create(player2_ctrl, 4, p2->pilot, 9);
145148
game_player_set_ctrl(p2, player2_ctrl);
146-
game_player_set_selectable(p2, 1);
149+
game_player_set_selectable(p2, 0);
147150

148151
chr_score_set_difficulty(game_player_get_score(game_state_get_player(gs, 0)), AI_DIFFICULTY_CHAMPION);
149152
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);
@@ -86,7 +86,7 @@ void menu_listen_tick(component *c) {
8686
// Player 2 controller -- Network
8787
net_controller_create(player2_ctrl, local->host, event.peer, NULL, ROLE_SERVER);
8888
game_player_set_ctrl(p2, player2_ctrl);
89-
game_player_set_selectable(p2, 1);
89+
game_player_set_selectable(p2, 0);
9090

9191
chr_score_set_difficulty(game_player_get_score(game_state_get_player(gs, 0)), AI_DIFFICULTY_CHAMPION);
9292
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
@@ -372,7 +372,7 @@ void handle_action(scene *scene, int player, int action) {
372372
player2->pilot->har_id = HAR_NOVA;
373373
} else {
374374
// pick an opponent we have not yet beaten
375-
while(1) {
375+
while(0) {
376376
int i = rand_int(10);
377377
if((2 << i) & player1->sp_wins || i == player1->pilot->pilot_id) {
378378
continue;

src/game/scenes/vs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ int vs_create(scene *scene) {
566566
local->arena = 0;
567567
} else {
568568
// pick a random arena for 1 player mode
569-
local->arena = rand_int(5); // srand was done in melee
569+
local->arena = 0; //rand_int(5); // srand was done in melee
570570
}
571571

572572
// Arena

0 commit comments

Comments
 (0)