Skip to content

Commit c92c545

Browse files
committed
Hack to make player 2 in netplay AI
1 parent 9604f0e commit c92c545

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

src/game/scenes/arena.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ void arena_har_defeat_hook(int loser_player_id, scene *scene) {
738738
}
739739
score->rounds++;
740740
if(player_winner->ctrl->type != CTRL_TYPE_AI && player_loser->ctrl->type == CTRL_TYPE_AI) {
741-
chr_score_victory(score, har_health_percent(winner_har));
741+
// chr_score_victory(score, har_health_percent(winner_har));
742742
}
743743
if(score->rounds >= ceilf(local->rounds / 2.0f)) {
744744
winner_har->state = STATE_VICTORY;

src/game/scenes/mainmenu/menu_connect.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,13 @@ void menu_connect_tick(component *c) {
142142
p1->pilot->har_id = HAR_JAGUAR;
143143
p1->pilot->pilot_id = 0;
144144
p1->pilot->name[0] = '\0';
145-
p2->pilot->har_id = HAR_JAGUAR;
146-
p2->pilot->pilot_id = 0;
145+
p2->pilot->har_id = HAR_PYROS;
146+
p2->pilot->pilot_id = 9;
147147
p2->pilot->name[0] = '\0';
148148

149+
150+
p1->sp_wins = 0;
151+
149152
player1_ctrl = omf_calloc(1, sizeof(controller));
150153
controller_init(player1_ctrl, gs);
151154
player1_ctrl->har_obj_id = p1->har_obj_id;
@@ -158,16 +161,19 @@ void menu_connect_tick(component *c) {
158161
game_player_set_ctrl(p1, player1_ctrl);
159162

160163
// Player 2 controller -- Local
161-
settings_keyboard *k = &settings_get()->keys;
164+
/*settings_keyboard *k = &settings_get()->keys;
162165
if(k->ctrl_type1 == CTRL_TYPE_KEYBOARD) {
163166
_setup_keyboard(gs, 1, 0);
164167
} else if(k->ctrl_type1 == CTRL_TYPE_GAMEPAD) {
165168
_setup_joystick(gs, 1, k->joy_name1, k->joy_offset1);
166169
}
167170
if(!controller_set_delay(game_player_get_ctrl(game_state_get_player(gs, 1)), NET_INPUT_DELAY)) {
168171
log_error("unable to set network controller delay");
169-
}
170-
game_player_set_selectable(p2, 1);
172+
}*/
173+
ai_controller_create(player2_ctrl, 4, p2->pilot, 9);
174+
game_player_set_ctrl(p2, player2_ctrl);
175+
176+
game_player_set_selectable(p2, 0);
171177

172178
chr_score_set_difficulty(game_player_get_score(game_state_get_player(gs, 0)), AI_DIFFICULTY_CHAMPION);
173179
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
p1->pilot->har_id = HAR_JAGUAR;
5757
p1->pilot->pilot_id = 0;
5858
p1->pilot->name[0] = '\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
p2->pilot->name[0] = '\0';
6262

6363
player1_ctrl = omf_calloc(1, sizeof(controller));
@@ -81,7 +81,7 @@ void menu_listen_tick(component *c) {
8181
// Player 2 controller -- Network
8282
net_controller_create(player2_ctrl, local->host, event.peer, NULL, ROLE_SERVER);
8383
game_player_set_ctrl(p2, player2_ctrl);
84-
game_player_set_selectable(p2, 1);
84+
game_player_set_selectable(p2, 0);
8585

8686
chr_score_set_difficulty(game_player_get_score(game_state_get_player(gs, 0)), AI_DIFFICULTY_CHAMPION);
8787
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
@@ -511,7 +511,7 @@ void handle_action(scene *scene, int player, int action) {
511511
player2->pilot->har_id = HAR_NOVA;
512512
} else {
513513
// pick an opponent we have not yet beaten
514-
while(1) {
514+
while(0) {
515515
int i = rand_int(10);
516516
if((2 << i) & player1->sp_wins || i == player1->pilot->pilot_id) {
517517
continue;

0 commit comments

Comments
 (0)