Port of cosmo-engine to TempleOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

4792 lines
122 KiB

extern U0 actor_add_new(I64 image_index, I64 x_pos, I64 y_pos);
extern U0 map_write_tile_cell(U16 map_tile_cell, I64 x, I64 y);
extern U0 map_write_row_of_tiles(U16 map_tile_cell, U16 length_in_tiles, I64 x, I64 y);
extern U8 byte_2E21C;
extern U0 ingame_hint_dialogs(U16 hint_number);
extern U0 end_game_dialog(U16 dialog_number);
extern U0 push_player_around(I64 push_direction, I64 push_anim_duration, I64 push_duration, I64 player_frame_num,
U8 dont_push_while_jumping_flag, I64 check_for_blocking_flag);
extern U0 write_tile_row_to_tilemap(U16 map_tile_cell,
U16 map_tile_cell2,
U16 map_tile_cell3,
U16 map_tile_cell4,
I64 x,
I64 y);
I16 purple_boss_y_offset_tbl[14] = {2, 2, 1, 0, -1, -2, -2, -2, -2, -1, 0, 1, 2, 2};
U0 actor_wt_133_boss_purple_15411(ActorData *actor)
{
actor_tile_display_func_index = 1;
if(word_2E21E == 0)
{
word_2E21E = 1;
actor_add_new(0xf4, player_x_pos - 1, player_y_pos - 5);
stop_music();
load_music(2);
}
if (actor->has_moved_right_flag > 0)
{
actor->has_moved_right_flag = actor->has_moved_right_flag - 1;
if(actor->has_moved_right_flag < 0x28)
{
actor->y = actor->y - 1;
}
actor->can_fall_down_flag = 0;
actor->falling_counter = 0;
if(actor->has_moved_right_flag == 1 || actor->y == 0 || (is_sprite_on_screen(0x66, 0, actor->x, actor->y) == 0 && actor->has_moved_right_flag < 0x1e))
{
finished_level_flag_maybe = 1;
player_add_to_score(0x186a0);
}
if(actor->has_moved_right_flag < 0x28 && actor->has_moved_right_flag != 0)
{
if(actor->has_moved_right_flag % 3 == 0)
{
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y, 2, 1);
play_sfx(0x38);
}
}
if((actor->has_moved_right_flag & 1) == 0)
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 0);
display_actor_sprite_maybe(0x66, 5, actor->x, actor->y - 4, 0);
}
else
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 2);
display_actor_sprite_maybe(0x66, 5, actor->x, actor->y - 4, 2);
if(actor->has_moved_right_flag > 0x27)
{
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y, 2, 1);
}
}
return;
}
if (actor->data_5 == 12)
{
if(sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + 1) == 0)
{
actor->y = actor->y + 1;
if((actor->y & 1) == 0)
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 0);
display_actor_sprite_maybe(0x66, 5, actor->x, actor->y - 4, 0);
}
else
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 2);
display_actor_sprite_maybe(0x66, 5, actor->x, actor->y - 4, 2);
}
}
if(sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + 1) != NOT_BLOCKED)
{
actor->has_moved_right_flag = 0x50;
}
return;
}
if(actor->has_moved_left_flag != 0)
{
I64 frame_num = Cond(actor->data_5 <= 3, 1, 5);
actor->has_moved_left_flag = actor->has_moved_left_flag - 1;
if((actor->has_moved_left_flag & 1) == 0)
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 0);
display_actor_sprite_maybe(0x66, frame_num, actor->x, actor->y - 4, 0);
}
else
{
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 2);
display_actor_sprite_maybe(0x66, frame_num, actor->x, actor->y - 4, 2);
}
}
if (actor->data_1 != 0)
{
if (actor->data_1 != 1)
{
if (actor->data_1 == 2)
{
if(sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + purple_boss_y_offset_tbl[actor->data_3 % 14]) != NOT_BLOCKED)
{
if(purple_boss_y_offset_tbl[actor->data_3 % 14] == 2)
{
actor->y = actor->y - 2;
}
}
if (sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + purple_boss_y_offset_tbl[actor->data_3 % 14]) == NOT_BLOCKED || purple_boss_y_offset_tbl[actor->data_3 % 14] != 1)
{
actor->y += purple_boss_y_offset_tbl[actor->data_3 % 14];
}
else
{
actor->y = actor->y - 1;
}
actor->data_3 = actor->data_3 + 1;
if(actor->data_3 % 14 == 1)
{
play_sfx(0x38);
}
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 > 0x1e && actor->data_2 < 0xc9)
{
if(actor->data_4 == 0)
{
if(sprite_blocking_check(2, 0x66, 0, actor->x - 1, actor->y) != NOT_BLOCKED)
{
actor->data_4 = 1;
play_sfx(0x25);
effect_add_sprite(0x61, 6, actor->x, actor->y - 2, 5, 1);
}
else
{
actor->x = actor->x - 1;
}
}
else
{
if(sprite_blocking_check(3, 0x66, 0, actor->x + 1, actor->y) == NOT_BLOCKED)
{
actor->x = actor->x + 1;
}
else
{
actor->data_4 = 0;
play_sfx(0x25);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y - 2, 5, 1);
}
}
}
else
{
if(actor->data_2 > 0xc7)
{
actor->data_1 = 3;
actor->data_2 = 0;
actor->data_3 = 8;
}
}
}
else
{
if (actor->data_1 == 3)
{
actor->data_2 = actor->data_2 + 1;
if (actor->data_3 >= 6)
{
if (actor->data_2 < 0x66)
{
actor->can_fall_down_flag = 1;
if(sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + 1) == 0)
{
if(actor->x + 1 <= player_x_pos)
{
if(actor->x + 3 < player_x_pos)
{
if(sprite_blocking_check(3, 0x66, 0, actor->x + 1, actor->y) == NOT_BLOCKED)
{
actor->x = actor->x + 1;
}
}
}
else
{
if(sprite_blocking_check(2, 0x66, 0, actor->x - 1, actor->y) == NOT_BLOCKED)
{
actor->x = actor->x - 1;
}
}
}
else
{
actor->data_3 = 0;
actor->can_fall_down_flag = 0;
actor->falling_counter = 0;
play_sfx(0x32);
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y, 2, 1);
}
}
else
{
if (sprite_blocking_check(1, 0x66, 0, actor->x, actor->y + 1) != 0 || sprite_blocking_check(1, 0x66, 0, actor->x, actor->y) != 0)
{
actor->data_1 = 4;
actor->data_2 = 0;
actor->data_3 = 0;
actor->can_fall_down_flag = 0;
actor->falling_counter = 0;
play_sfx(0x25);
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 1);
effect_add_sprite(0x61, 6, actor->x + 3, actor->y, 2, 1);
}
else
{
actor->y = actor->y + 1;
}
}
}
else
{
actor->data_3 = actor->data_3 + 1;
actor->y = actor->y - 2;
}
}
else
{
if(actor->data_1 == 4)
{
actor->can_fall_down_flag = 0;
actor->falling_counter = 0;
actor->y = actor->y - 1;
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 == 6)
{
actor->data_1 = 2;
actor->data_3 = 0;
actor->data_2 = 0;
}
}
}
}
}
else
{
if(actor->data_2 == 0)
{
actor->data_1 = 2;
}
else
{
actor->data_2 = actor->data_2 - 1;
}
}
}
else
{
actor->y = actor->y - 2;
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 == 6)
{
actor->data_1 = 1;
}
}
if(actor->has_moved_left_flag != 0)
{
return;
}
display_actor_sprite_maybe(0x66, 0, actor->x, actor->y, 0);
if(actor->data_5 < 4)
{
display_actor_sprite_maybe(0x66, 1, actor->x, actor->y - 4, 0);
return;
}
if(actor->x + 1 > player_x_pos)
{
display_actor_sprite_maybe(0x66, 2, actor->x + 1, actor->y - 4, 0);
return;
}
if(actor->x + 1 + 1 >= player_x_pos)
{
display_actor_sprite_maybe(0x66, 3, actor->x + 1, actor->y - 4, 0);
}
else
{
display_actor_sprite_maybe(0x66, 4, actor->x + 1, actor->y - 4, 0);
}
}
U0 actor_wt_159_unknown(ActorData *actor)
{
if(actor->data_5 != 0)
{
actor->data_5--;
return;
}
if(actor->frame_num == 8)
{
actor->frame_num = 1;
return;
}
actor->frame_num++;
return;
}
U8 acid_frame_num_tbl[7] = {0, 1, 2, 3, 2, 1, 0};
U0 actor_wt_acid(ActorData *actor)
{
if(actor->data_5 != 0)
{
if(actor->data_4 == 0)
{
actor->frame_num = acid_frame_num_tbl[actor->data_3 % 6];
actor->data_3++;
if(actor->data_3 != 15)
{
return;
}
actor->data_4 = 1;
actor->data_3 = 0;
actor->frame_num = 4;
if(is_sprite_on_screen(0x2b, 6, actor->x, actor->data_2) != 0)
{
play_sfx(0x15);
}
return;
}
if(actor->frame_num < 6)
{
actor->frame_num = actor->frame_num + 1;
return;
}
actor->y = actor->y + 1;
if(is_sprite_on_screen(0x2b, 6, actor->x, actor->y) == 0)
{
actor->y = actor->data_2;
actor->data_4 = 0;
actor->frame_num = 0;
return;
}
}
else
{
actor->frame_num = acid_frame_num_tbl[actor->data_3];
actor->data_3++;
if(actor->data_3 == 6)
{
actor->data_3 = 0;
}
}
return;
}
U8 alien_eating_space_plant_f_num_tbl[4] = {5, 6, 7, 8};
U8 alien_eating_space_plant_f_num_2_tbl[16] = {
1, 1, 1, 1, 1, 1, 1, 2,
3, 4, 1, 1, 1, 1, 1, 1
};
U0 actor_wt_alien_eating_space_plant(ActorData *actor)
{
if(actor->data_3 != 0)
{
actor->data_3--;
actor->frame_num = 1;
if(actor->data_3 != 0)
{
return;
}
actor->frame_num = 0;
}
if(actor->frame_num == 0 && actor->data_5 == 0)
{
display_actor_sprite_maybe(0xba, alien_eating_space_plant_f_num_tbl[actor->data_1 & 3], actor->x + 1 + 1, actor->y - 3, 0);
actor->data_1++;
}
if(actor->data_5 != 0)
{
actor->frame_num = alien_eating_space_plant_f_num_2_tbl[actor->data_5 - 1];
if(actor->data_5 != 0x10)
{
actor->data_5++;
}
else
{
finished_level_flag_maybe = 1;
}
}
if(is_sprite_on_screen(0xba, 1, actor->x, actor->y) == 0)
{
actor->data_3 = 0x1e;
actor->data_5 = 0;
actor->frame_num = 1;
}
return;
}
U0 actor_wt_angry_moon(ActorData *actor)
{
actor->data_3 = Cond(actor->data_3, -1, 0) + 1;
if(actor->data_3 == 0)
{
actor->data_2++;
if(actor->x >= player_x_pos)
{
actor->frame_num = actor->data_2 & 1;
}
else
{
actor->frame_num = (actor->data_2 & 1) + 2;
}
}
return;
}
I8 red_jumper_tbl[40] = {
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1,
0, 1, -2, 2, -2, 2, -2, 2,
-2, 2, -1, 2, -1, 2, -1, 2,
0, 2, 0, 2, 1, 1, 1, 1
};
U0 actor_wt_big_red_jumper(ActorData *actor)
{
if(actor->data_2 >= 5)
{
if(actor->data_2 != 14 || is_sprite_on_screen(0x65, 0, actor->x, actor->y) == 0)
{
if(actor->data_2 > 0x10 && actor->data_2 < 0x27)
{
if(actor->data_1 != 0 || sprite_blocking_check(2, 0x65, 0, actor->x - 1, actor->y) != NOT_BLOCKED)
{
if(actor->data_1 == 3 && sprite_blocking_check(3, 0x65, 0, actor->x + 1, actor->y) == NOT_BLOCKED)
{
actor->x = actor->x + 1;
}
}
else
{
actor->x = actor->x - 1;
}
}
}
else
{
play_sfx(0x1f);
}
}
else
{
if(actor->x <= player_x_pos)
{
actor->data_1 = 3;
}
else
{
actor->data_1 = 0;
}
}
if (actor->data_2 <= 0x27) //goto loc_15546;
{
// node 00015546-0001561d #insn=6 use={} def={} in={} out={} pred={ 153F7} CONDJUMP target=0001566d follow=0001561f
//loc_15546:
//si = * ((actor->data_2 << 1) + word_28356);
I8 si = red_jumper_tbl[actor->data_2];
if(si == -1)
{
if(sprite_blocking_check(0, 0x65, 0, actor->x, actor->y - 1) != 0)
{
actor->data_2 = 0x22;
}
else
{
actor->y = actor->y - 1;
}
}
if(si == -2)
{
if(sprite_blocking_check(0, 0x65, 0, actor->x, actor->y - 1) != 0)
{
actor->data_2 = 0x22;
}
else
{
actor->y = actor->y - 1;
}
if(sprite_blocking_check(0, 0x65, 0, actor->x, actor->y - 1) != 0)
{
actor->data_2 = 0x22;
}
else
{
actor->y = actor->y - 1;
}
}
if(si == 1)
{
if(sprite_blocking_check(1, 0x65, 0, actor->x, actor->y + 1) == 0)
{
actor->y = actor->y + 1;
}
}
if (si != 2) //goto loc_1566D;
{
// node 0001566d-0001568e #insn=6 use={} def={} in={} out={} pred={ 15546} FALLTHROUGH follow=00015698
//loc_1566D:
actor->frame_num = actor->data_1 + red_jumper_tbl[actor->data_2 + 1];
if(actor->data_2 < 0x27)
{
actor->data_2 = actor->data_2 + 2;
}
return;
}
else
{
//0001561f
// node 0001561f-0001563b #insn=3 use={} def={ax, bx} in={} out={ax} pred={ 15546} CONDJUMP target=00015662 follow=0001563d
if (sprite_blocking_check(1, 0x65, 0, actor->x, actor->y - 1) != NOT_BLOCKED) //goto loc_15662;
{
// node 00015662-0001566b #insn=3 use={} def={bx} in={ax} out={ax} pred={ 1561F} JUMP target=00015698
//loc_15662:
actor->data_2 = 0;
//goto loc_15698;
return;
}
else
{
// 0001563d
// node 0001563d-0001565d #insn=4 use={} def={ax, bx} in={} out={ax} pred={ 1561F} CONDJUMP target=00015662 follow=0001550f
actor->y = actor->y + 1;
if (sprite_blocking_check(1, 0x65, 0, actor->x, actor->y - 1) != NOT_BLOCKED) //goto loc_15662;
{
// node 00015662-0001566b #insn=3 use={} def={bx} in={ax} out={ax} pred={ 1563D} JUMP target=00015698
// loc_15662:
actor->data_2 = 0;
//goto loc_15698;
return;
}
else
{
// 0001550f
// node 0001550f-00015516 #insn=3 use={} def={bx} in={} out={} pred={ 154ED 1563D} JUMP target=0001566d
// loc_1550F:
actor->y = actor->y + 1;
// goto loc_1566D;
// node 0001566d-0001568e #insn=6 use={} def={} in={} out={} pred={ 1550F } FALLTHROUGH follow=00015698
// loc_1566D:
actor->frame_num = actor->data_1 + red_jumper_tbl[actor->data_2 + 1];
if(actor->data_2 < 0x27)
{
actor->data_2 = actor->data_2 + 2;
}
return;
}
}
}
}
else
{
//000154d2
// node 000154d2-000154eb #insn=1 use={bx} def={ax} in={bx} out={} pred={ 153F7} CONDJUMP target=00015519 follow=000154ed
if (sprite_blocking_check(1, 0x65, 0, actor->x, actor->y + 1) != NOT_BLOCKED) //goto loc_15519;
{
// node 00015519-00015537 #insn=5 use={} def={} in={} out={} pred={ 154ED} FALLTHROUGH follow=00015698
// loc_15519:
actor->data_2 = 0;
if(is_sprite_on_screen(0x65, 0, actor->x, actor->y) != 0)
{
play_sfx(0x20);
}
return;
}
else
{
// 00154ed
// node 000154ed-0001550d #insn=3 use={} def={ax, bx} in={} out={} pred={ 154D2} CONDJUMP target=00015519 follow=0001550f
actor->y = actor->y + 1;
if (sprite_blocking_check(1, 0x65, 0, actor->x, actor->y + 1) != NOT_BLOCKED) //goto loc_15519;
{
// node 00015519-00015537 #insn=5 use={} def={} in={} out={} pred={ 154ED} FALLTHROUGH follow=00015698
// loc_15519:
actor->data_2 = 0;
if(is_sprite_on_screen(0x65, 0, actor->x, actor->y) != 0)
{
play_sfx(0x20);
}
}
else
{
// 0001550f
// node 0001550f-00015516 #insn=3 use={} def={bx} in={} out={} pred={ 154ED } JUMP target=0001566d
// loc_1550F:
actor->y = actor->y + 1;
// goto loc_1566D;
// node 0001566d-0001568e #insn=6 use={} def={} in={} out={} pred={ 1550F } FALLTHROUGH follow=00015698
// loc_1566D:
actor->frame_num = actor->data_1 + red_jumper_tbl[actor->data_2 + 1];
if(actor->data_2 < 0x27)
{
actor->data_2 = actor->data_2 + 2;
}
return;
}
}
}
// node 00015698-0001569a #insn=3 use={ax} def={si} in={ax} out={} pred={ 15519 15662 15662 1566D} RETURN
// loc_15698:
/* pop */
}
U8 big_red_plant_frame_num_tbl[5] ={0, 2, 1, 0, 1};
U0 actor_wt_big_red_plant(ActorData *actor)
{
if(actor->has_moved_right_flag > 0 && actor->has_moved_right_flag < 7)
{
return;
}
if(actor->data_3 != 0)
{
actor->data_3--;
if((actor->data_3 & 1) != 0)
{
actor_tile_display_func_index = 2;
}
return;
}
if (struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) == 0)
{
if(actor->data_2 != 0)
{
actor->frame_num = 1;
actor->data_2--;
}
else
{
actor->frame_num = big_red_plant_frame_num_tbl[actor->data_1];
actor->data_1++;
if(actor->data_1 == 2 && actor->has_moved_left_flag == 0)
{
actor_toss_add_new(0x56, actor->x + 2, actor->y - 5);
play_sfx(0x2f);
}
if(actor->data_1 == 5)
{
actor->data_2 = 0x64;
actor->data_1 = 0;
actor->has_moved_left_flag = 0;
}
}
}
else
{
actor->data_3 = 15;
actor->data_5++;
if (actor->data_5 == 2)
{
actor->is_deactivated_flag_maybe = 1;
explode_effect_add_sprite(0x56, 0, actor->x + 2, actor->y - 5);
explode_effect_add_sprite(0x56, 2, actor->x + 2, actor->y - 5);
explode_effect_add_sprite(0x56, 4, actor->x + 2, actor->y - 5);
explode_effect_add_sprite(0x56, 9, actor->x + 2, actor->y - 5);
explode_effect_add_sprite(0x56, 3, actor->x + 2, actor->y - 5);
explode_effect_add_sprite(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y);
}
else
{
if(actor->data_2 != 0)
{
actor->frame_num = 1;
actor->data_2--;
}
else
{
actor->frame_num = big_red_plant_frame_num_tbl[actor->data_1];
actor->data_1++;
if(actor->data_1 == 2 && actor->has_moved_left_flag == 0)
{
actor_toss_add_new(0x56, actor->x + 2, actor->y - 5);
play_sfx(0x2f);
}
if(actor->data_1 == 5)
{
actor->data_2 = 0x64;
actor->data_1 = 0;
actor->has_moved_left_flag = 0;
}
}
}
}
return;
}
U0 actor_wt_big_saw_blade(ActorData *actor)
{
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0)
{
play_sfx(0x23);
}
if(actor->data_1 != 0)
{
if(sprite_blocking_check(0, actor->actorInfoIndex, 0, actor->x, actor->y - 1) == NOT_BLOCKED)
{
actor->y = actor->y - 1;
}
else
{
actor->data_1 = 0;
}
return;
}
if(sprite_blocking_check(1, actor->actorInfoIndex, 0, actor->x, actor->y + 1) == NOT_BLOCKED)
{
actor->y = actor->y + 1;
}
else
{
actor->data_1 = 1;
}
return;
}
U0 actor_wt_big_yellow_spike(ActorData *actor)
{
if(actor->data_5 == 0)
{
if(actor->data_1 != 0)
{
if(sprite_blocking_check(1, actor->actorInfoIndex, 0, actor->x, actor->y + 1) != NOT_BLOCKED)
{
actor->is_deactivated_flag_maybe = 1;
effect_add_sprite(0x61, 6, actor->x, actor->y, 1, 3);
play_sfx(0x1b);
actor_tile_display_func_index = 1;
}
}
else
{
if(actor->y < player_y_pos)
{
if(actor->x <= player_x_pos + 6)
{
if(actor->x + 5 > player_x_pos)
{
actor->data_1 = 1;
actor->can_fall_down_flag = 1;
}
}
}
}
}
else
{
actor_tile_display_func_index = 4;
}
if(actor->is_deactivated_flag_maybe != 0)
{
return;
}
if(struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0)
{
actor->data_2 = 3;
}
if(actor->data_2 != 0)
{
actor->data_2--;
if(actor->data_2 == 0)
{
struct6_add_sprite(actor->x - 1, actor->y + 1);
actor->is_deactivated_flag_maybe = 1;
player_add_to_score(0xc8);
explode_effect_add_sprite(actor->actorInfoIndex, 0, actor->x, actor->y);
}
}
return;
}
U8 blue_ball_frame_num_tbl[27] = {
2, 2, 2, 0, 3, 3, 3, 0, 0, 2, 2, 0, 0, 1, 1, 0, 1, 3, 3, 3, 0, 1, 1, 0, 1, 1, 1
};
U8 blue_ball_moving_left_frame_num_tbl[4] = {7, 6, 5, 4};
U8 blue_ball_moving_right_frame_num_tbl[4] = {4, 5, 6, 7};
U0 check_actor_move_left_or_right(ActorData *actor, I64 direction_of_movement)
{
U16 sprite_width = actor_get_tile_info(actor->actorInfoIndex, actor->frame_num)->width;
I64 block_status;
U8 tile_attr;
if(direction_of_movement == LEFT)
{
block_status = sprite_blocking_check(2, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y);
actor->has_moved_left_flag = Cond(block_status != NOT_BLOCKED, -1, 0) + 1;
if(actor->has_moved_left_flag == 0 && block_status != SLOPE)
{
actor->x = actor->x + 1;
return;
}
if(block_status != SLOPE)
{
if(sprite_blocking_check(1, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y + 1) == NOT_BLOCKED)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x + sprite_width, actor->y + 1) / 8];
if((tile_attr & TILE_ATTR_SLOPED) != 0)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x + sprite_width - 1, actor->y + 1 + 1) / 8];
if((tile_attr & TILE_ATTR_SLOPED) != 0)
{
tile_attr = tileattr_mni_data[ map_get_tile_cell(actor->x + sprite_width - 1, actor->y + 1) / 8];
if((tile_attr & TILE_ATTR_BLOCK_DOWN) != 0)
{
return;
}
actor->has_moved_left_flag = 1;
if((tile_attr & TILE_ATTR_SLOPED) == 0)
{
actor->y = actor->y + 1;
}
return;
}
}
if(actor->has_moved_left_flag == 0)
{
actor->x = actor->x + 1;
return;
}
if(actor->non_blocking_flag_maybe != 0 || sprite_blocking_check(2, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y + 1) != 0)
{
return;
}
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x + sprite_width - 1, actor->y + 1)/ 8];
if((tile_attr & TILE_ATTR_SLOPED) == 0)
{
actor->x = actor->x + 1;
actor->has_moved_left_flag = 0;
}
}
else
{
actor->has_moved_left_flag = 1;
}
}
else
{
actor->has_moved_left_flag = 1;
actor->y = actor->y - 1;
}
}
else
{
block_status = sprite_blocking_check(3, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y);
actor->has_moved_right_flag = Cond(block_status != NOT_BLOCKED, -1, 0) + 1;
if(actor->has_moved_right_flag == 0 && block_status != SLOPE)
{
actor->x = actor->x - 1;
return;
}
if(block_status != SLOPE)
{
if(sprite_blocking_check(1, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y + 1) == NOT_BLOCKED)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x - 1, actor->y + 1) /8];
if((tile_attr & TILE_ATTR_SLOPED) != 0)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x, actor->y + 1 + 1) / 8];
if((tile_attr & TILE_ATTR_SLOPED) != 0)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x, actor->y + 1) / 8];
if((tile_attr & TILE_ATTR_BLOCK_DOWN) != 0)
{
return;
}
actor->has_moved_right_flag = 1;
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x, actor->y + 1) / 8];
if((tile_attr & TILE_ATTR_SLOPED) == 0)
{
actor->y = actor->y + 1;
return;
}
return;
}
}
if(actor->has_moved_right_flag == 0)
{
actor->x = actor->x - 1;
return;
}
if(actor->non_blocking_flag_maybe == 0 && sprite_blocking_check(3, actor->actorInfoIndex, actor->frame_num, actor->x, actor->y + 1) == NOT_BLOCKED)
{
tile_attr = tileattr_mni_data[map_get_tile_cell(actor->x, actor->y + 1) / 8];
if((tile_attr & TILE_ATTR_SLOPED) == 0)
{
actor->x = actor->x - 1;
actor->has_moved_right_flag = 0;
return;
}
return;
}
}
else
{
actor->has_moved_right_flag = 1;
}
}
else
{
actor->has_moved_right_flag = 1;
actor->y = actor->y - 1;
}
}
return;
}
U0 actor_wt_blue_ball(ActorData *actor)
{
if(actor->falling_counter != 0)
{
actor->data_1 = 0;
actor->data_2 = 0x14;
if(actor->falling_counter < 2)
{
actor->frame_num = 1;
actor->frame_num = 10;
return;
}
if(actor->falling_counter < 2 || actor->falling_counter > 4)
{
actor->y = actor->y - 1;
display_actor_sprite_maybe(0x56, 9, actor->x, actor->y - 2, 0);
actor->frame_num = 10;
}
else
{
display_actor_sprite_maybe(0x56, 8, actor->x, actor->y - 2, 0);
actor->frame_num = 10;
}
return;
}
if (actor->data_1 == 0)
{
actor->data_2 = actor->data_2 + 1;
actor->frame_num = blue_ball_frame_num_tbl[actor->data_2];
if (actor->data_2 == 0x1a)
{
actor->data_2 = 0;
if (actor->y == player_y_pos || (sub_1106F() & 1) == 0)
{
if(actor->x < player_x_pos + 1 + 1)
{
if(actor->x + 2 <= player_x_pos)
{
actor->data_1 = 2;
actor->data_2 = 0;
actor->frame_num = 3;
actor->data_3 = 6;
}
}
else
{
actor->data_1 = 1;
actor->data_2 = 0;
actor->frame_num = 2;
actor->data_3 = 6;
}
}
}
}
if(actor->data_3 != 0)
{
actor->data_3 = actor->data_3 - 1;
return;
}
if (actor->data_1 == 1)
{
actor->x--;
check_actor_move_left_or_right(actor, LEFT);
if(actor->has_moved_left_flag != 0)
{
actor->frame_num = blue_ball_moving_left_frame_num_tbl[actor->data_2 & 3];
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 == 0x10)
{
actor->data_1 = 0;
actor->data_2 = 0;
}
return;
}
actor->data_1 = 0;
actor->data_2 = 0;
actor->frame_num = 0;
return;
}
else
{
if (actor->data_1 != 2)
{
return;
}
actor->x++;
check_actor_move_left_or_right(actor, RIGHT);
if (actor->has_moved_right_flag != 0)
{
actor->frame_num = blue_ball_moving_right_frame_num_tbl[actor->data_2 & 3];
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 == 12)
{
actor->data_1 = 0;
actor->data_2 = 0;
}
}
else
{
actor->data_1 = 0;
actor->data_2 = 0;
actor->frame_num = 0;
}
}
return;
}
I8 bird_swoop_y_offset_tbl[15] = {
2, 2, 2, 1, 1, 1, 0, 0, 0, -1, -1, -1, -2, -2, -2
};
U0 actor_wt_blue_bird(ActorData *actor)
{
if(actor->data_1 == 0)
{
if(actor->x + 1 <= player_x_pos)
{
if(cosmo_rand % 10 != 0)
{
actor->data_2 = 4;
}
else
{
actor->data_2 = 5;
}
}
else
{
if(cosmo_rand() % 10 != 0)
{
actor->data_2 = 0;
}
else
{
actor->data_2 = 1;
}
}
actor->frame_num = actor->data_2;
actor->data_3 = actor->data_3 + 1;
if(actor->data_3 == 0x1e)
{
actor->data_1 = 1;
actor->data_3 = 0;
}
}
else
{
if(actor->data_1 == 1)
{
actor->data_3 = actor->data_3 + 1;
if(actor->data_3 != 0x14)
{
if((actor->data_3 & 1) != 0 && actor->data_3 < 10)
{
actor->y = actor->y - 1;
}
}
else
{
actor->data_3 = 0;
actor->data_1 = 2;
if(actor->x + 1 <= player_x_pos)
{
actor->data_4 = 1;
}
else
{
actor->data_4 = 0;
}
}
if(actor->x + 1 <= player_x_pos)
{
actor->frame_num = (actor->data_3 & 1) + 6;
}
else
{
actor->frame_num = (actor->data_3 & 1) + 2;
}
}
else
{
if(actor->data_1 == 2)
{
actor->data_3 = actor->data_3 + 1;
if(actor->data_4 != 0)
{
actor->frame_num = (actor->data_3 & 1) + 6;
actor->x = actor->x + 1;
}
else
{
actor->frame_num = (actor->data_3 & 1) + 1 + 1;
actor->x = actor->x - 1;
}
actor->y = actor->y + bird_swoop_y_offset_tbl[actor->data_3 - 1];
if(actor->data_3 == 15)
{
actor->data_1 = 1;
actor->data_3 = 10;
}
}
}
}
return;
}
U0 actor_wt_blue_cube_platform(ActorData *actor)
{
if(sprite_blocking_check(1, 0xa3, 0, actor->x, actor->y + 1) != NOT_BLOCKED)
{
actor->is_deactivated_flag_maybe = 1;
explode_effect_add_sprite(0xa3, 1, actor->x, actor->y);
explode_effect_add_sprite(0xa3, 2, actor->x, actor->y);
play_sfx(0x19);
actor_tile_display_func_index = 2;
return;
}
if(actor->data_1 == 0)
{
actor->has_moved_left_flag = map_get_tile_cell(actor->x, actor->y - 1);
actor->has_moved_right_flag = map_get_tile_cell(actor->x + 1, actor->y - 1);
map_write_tile_cell(0x50, actor->x, actor->y - 1);
map_write_tile_cell(0x50, actor->x + 1, actor->y - 1);
actor->data_1 = 1;
}
if(actor->y - 2 == player_y_pos)
{
if(actor->x <= player_x_pos + 1 + 1)
{
if(actor->x + 1 >= player_x_pos)
{
actor->data_2 = 7;
}
}
}
if(actor->data_2 != 0)
{
actor->data_2--;
if(actor->data_2 == 0)
{
actor->can_fall_down_flag = 1;
map_write_tile_cell(actor->has_moved_left_flag, actor->x, actor->y - 1);
map_write_tile_cell(actor->has_moved_right_flag, actor->x + 1, actor->y - 1);
}
}
return;
}
U0 actor_wt_blue_mobile_trampoline_car(ActorData *actor)
{
if(actor->data_1 <= 0)
{
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
if(actor->data_2 == 0)
{
actor->x = actor->x - 1;
check_actor_move_left_or_right(actor, LEFT);
if(actor->has_moved_left_flag == 0)
{
actor->data_2 = 1;
}
}
else
{
actor->x = actor->x + 1;
check_actor_move_left_or_right(actor, RIGHT);
if(actor->has_moved_right_flag == 0)
{
actor->data_2 = 0;
}
}
}
else
{
actor->frame_num = 2;
actor->data_1--;
}
if(is_sprite_on_screen(0x10, 2, actor->x, actor->y) == 0)
{
actor->frame_num = 0;
return;
}
return;
}
U0 actor_wt_blue_platform(ActorData *actor)
{
actor->has_moved_left_flag = actor->has_moved_left_flag + 1;
if(actor->data_1 == 0)
{
actor->data_1 = 1;
map_write_row_of_tiles(0x3dd0, 4, actor->x, actor->y - 1);
}
else
{
if (actor->data_1 != 1 || actor->y - 2 != player_y_pos)
{
if (actor->data_1 == 2)
{
if ((actor->has_moved_left_flag & 1) != 0)
{
actor->data_2 = actor->data_2 + 1;
}
if (actor->data_2 == 5)
{
map_write_row_of_tiles(0, 4, actor->x, actor->y - 1);
}
if (actor->data_2 >= 5 && actor->data_2 < 8)
{
actor_tile_display_func_index = 1;
display_actor_sprite_maybe(0x5b, 1, actor->x - (actor->data_2 - 5), actor->y, 0);
display_actor_sprite_maybe(0x5b, 2, actor->x + actor->data_2 - 3, actor->y, 0);
}
if (actor->data_2 == 7)
{
actor->data_1 = 3;
actor->data_2 = 0;
}
}
}
else
{
if (actor->x > player_x_pos || actor->x + 3 < player_x_pos)
{
if (actor->x <= player_x_pos + 2)
{
if (actor->x + 3 >= player_x_pos + 2)
{
actor->data_1 = 2;
actor->data_2 = 0;
sub_11062();
}
}
}
else
{
actor->data_1 = 2;
actor->data_2 = 0;
sub_11062();
}
}
}
if(actor->data_1 != 3)
{
return;
}
actor_tile_display_func_index = 1;
display_actor_sprite_maybe(0x5b, 1, actor->x + actor->data_2 - 2, actor->y, 0);
display_actor_sprite_maybe(0x5b, 2, actor->x + 4 - actor->data_2, actor->y, 0);
if((actor->has_moved_left_flag & 1) != 0)
{
actor->data_2 = actor->data_2 + 1;
}
if(actor->data_2 == 3)
{
actor_tile_display_func_index = 0;
map_write_row_of_tiles(0, 4, actor->x, actor->y - 1);
actor->data_1 = 0;
}
}
U0 actor_wt_blue_turret_alien(ActorData *actor)
{
actor->data_2--;
if(actor->data_2 == 0)
{
actor->data_1++;
actor->data_2 = 3;
if(actor->data_1 != 3)
{
actor->frame_num++;
switch (actor->frame_num - 2)
{
case 0:
actor_add_new(0x6d, actor->x - 1, actor->y - 1);
break;
case 3:
actor_add_new(0x42, actor->x - 1, actor->y + 1);
break;
case 6:
actor_add_new(0x44, actor->x + 1, actor->y + 1);
break;
case 9:
actor_add_new(0x43, actor->x + 5, actor->y + 1);
break;
case 12:
actor_add_new(0x6e, actor->x + 5, actor->y - 1);
break;
default : break;
}
}
}
if(actor->data_1 == 0)
{
if(actor->y < player_y_pos - 2)
{
if(actor->y < player_y_pos - 2)
{
if(actor->x - 2 <= player_x_pos)
{
if(actor->x + 3 >= player_x_pos)
{
if(actor->x - 2 < player_x_pos && actor->x + 3 >= player_x_pos)
{
actor->frame_num = 6;
actor->x = actor->data_3 + 1;
}
}
else
{
actor->frame_num = 9;
actor->x = actor->data_3 + 1;
}
}
else
{
actor->frame_num = 3;
actor->x = actor->data_3;
}
if(actor->x - 2 == player_x_pos)
{
actor->frame_num = 6;
actor->x = actor->data_3 + 1;
}
}
}
else
{
if(actor->x + 1 <= player_x_pos)
{
if(actor->x + 2 <= player_x_pos)
{
actor->frame_num = 12;
actor->x = actor->data_3 + 1;
}
}
else
{
actor->frame_num = 0;
actor->x = actor->data_3;
}
}
}
if(actor->data_1 == 3)
{
actor->data_2 = 0x1b;
actor->data_1 = 0;
}
if(actor->frame_num > 14)
{
actor->frame_num = 14;
}
return;
}
U0 actor_wt_bomb(ActorData *actor)
{
if(actor->frame_num == 3)
{
actor->data_2 = actor->data_2 + 1;
actor->data_1 = actor->data_1 + 1;
if((actor->data_1 & 1) != 0 && actor->frame_num == 3)
{
actor_tile_display_func_index = 2;
}
if(actor->data_2 == 10)
{
actor->is_deactivated_flag_maybe = 1;
exploding_balls_effect(actor->x - 2, actor->y + 1 + 1);
actor_tile_display_func_index = 1;
struct6_add_sprite(actor->x - 2, actor->y);
if((actor->data_1 & 1) != 0 && actor->frame_num == 3)
{
display_actor_sprite_maybe(0x18, actor->frame_num, actor->x, actor->y, 2);
}
}
}
else
{
actor->data_1 = actor->data_1 + 1;
if(actor->data_1 == 5)
{
actor->data_1 = 0;
actor->frame_num++;
}
}
if(sprite_blocking_check(1, 0x18, 0, actor->x, actor->y) != NOT_BLOCKED)
{
actor->y--;
}
return;
}
U0 actor_wt_bonus_bomb(ActorData *actor)
{
if(actor->data_1 == 2)
{
struct6_add_sprite(actor->x - 2, actor->y);
actor->is_deactivated_flag_maybe = 1;
return;
}
if(actor->data_1 != 0)
{
actor->data_1 = actor->data_1 + 1;
}
if(actor->data_1 == 0)
{
if(struct6_1B4FC(0x39, 0, actor->x, actor->y) != 0)
{
actor->data_1 = 1;
}
}
}
U0 actor_wt_bonus_item(ActorData *actor)
{
if(actor->data_1 != 0)
{
actor_tile_display_func_index = 4;
}
if (actor->data_4 == 0)
{
actor->frame_num = actor->frame_num + 1;
}
else
{
actor->data_3 = Cond(actor->data_3, -1, 0) + 1;
if (actor->data_3 != 0)
{
actor->frame_num = actor->frame_num + 1;
}
}
if(actor->frame_num == actor->data_5)
{
actor->frame_num = 0;
}
if(actor->data_5 == 1 && actor->actorInfoIndex != 0xca && actor->data_4 == 0)
{
if((cosmo_rand() & 0x3f) == 0)
{
effect_add_sprite(0x17, 8, cosmo_rand() % actor->data_1 + actor->x, cosmo_rand() % actor->data_2 + actor->y, 0, 1);
}
}
}
U8 clam_trap_frame_num_tbl[27] = {
0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 0
};
U0 actor_wt_clam_trap(ActorData *actor)
{
if(actor->data_2 != 0)
{
if(actor->data_3 == 1)
{
play_sfx(0x28);
}
actor->frame_num = clam_trap_frame_num_tbl[actor->data_3];
actor->data_3++;
if(actor->data_3 >= 0x18)
{
byte_2E17C = 0;
}
if(actor->data_3 == 0x1b)
{
actor->data_3 = 0;
actor->data_2 = 0;
byte_2E17C = 0;
}
if(struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0)
{
player_add_to_score(0xfa);
explode_effect_add_sprite(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y);
actor->is_deactivated_flag_maybe = 1;
byte_2E17C = 0;
}
}
else
{
if(struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0)
{
player_add_to_score(0xfa);
explode_effect_add_sprite(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y);
actor->is_deactivated_flag_maybe = 1;
}
}
}
U0 actor_wt_container(ActorData *actor)
{
if(struct6_1B4FC(0x1d, 0, actor->x, actor->y) != 0)
{
actor_explode_container(actor);
player_add_to_score(0x640);
actor_add_new(0xb5, actor->x, actor->y);
}
}
U0 actor_wt_crate_bomb_box(ActorData *actor)
{
if(actor->data_4 == 0)
{
map_write_row_of_tiles(0x50, 4, actor->x, actor->y - 2);
actor->data_4 = 1;
return;
}
if(sprite_blocking_check(1, 0x82, 0, actor->x, actor->y + 1) == 0)
{
map_write_row_of_tiles(0, 4, actor->x, actor->y - 2);
actor->y = actor->y + 1;
if(sprite_blocking_check(1, 0x82, 0, actor->x, actor->y + 1) != NOT_BLOCKED)
{
map_write_row_of_tiles(0x50, 4, actor->x, actor->y - 2);
}
return;
}
if(is_sprite_on_screen(0x82, 0, actor->x, actor->y) == 0)
{
return;
}
if(struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0)
{
actor->data_5 = 1;
actor->has_moved_right_flag = 0xf1f1;
}
if(actor->data_5 != 0)
{
actor->data_5--;
return;
}
actor->is_deactivated_flag_maybe = 1;
if(actor->has_moved_right_flag == 0xf1f1)
{
struct6_add_sprite(actor->x - 1, actor->y - 1);
return;
}
map_write_row_of_tiles(0, 4, actor->x, actor->y - 2);
actor_add_new(0x7c, actor->x, actor->y);
actor_tile_display_func_index = 2;
explode_effect_add_sprite(0x83, 0, actor->x - 1, actor->y + 3);
explode_effect_add_sprite(0x83, 1, actor->x, actor->y - 1);
explode_effect_add_sprite(0x83, 2, actor->x + 1, actor->y);
explode_effect_add_sprite(0x83, 3, actor->x, actor->y);
explode_effect_add_sprite(0x83, 4, actor->x + 3, actor->y + 1 + 1);
explode_effect_add_sprite(0x83, 5, actor->x, actor->y);
explode_effect_add_sprite(0x83, 6, actor->x + 5, actor->y + 5);
play_sfx(0x19);
}
U0 actor_wt_cyan_spitting_plant(ActorData *actor)
{
actor->data_4++;
if(actor->data_4 == 0x32)
{
actor->data_4 = 0;
actor->frame_num = 0;
}
if(actor->data_4 == 0x2a)
{
actor->frame_num = 1;
}
if(actor->data_4 == 0x2d)
{
actor->frame_num = 2;
if(actor->data_5 != 2)
{
actor_add_new(0x6e, actor->x + 4, actor->y - 1);
}
else
{
actor_add_new(0x6d, actor->x - 1, actor->y - 1);
}
}
}
U0 actor_wt_destructable_pedestal(ActorData *actor)
{
actor_tile_display_func_index = 1;
I64 i=0;
for(; i < actor->data_1;i++)
{
display_actor_sprite_maybe(0xc0, 1, actor->x, actor->y - i, 0);
}
display_actor_sprite_maybe(0xc0, 0, actor->x - 2, actor->y - i, 0);
map_write_row_of_tiles(0x48, 5, actor->x - 2, actor->y - i);
if(actor->data_2 == 0)
{
if(struct6_1B4FC(0xc0, 1, actor->x, actor->y) != 0)
{
actor->data_2 = 3;
}
}
if(actor->data_2 > 1)
{
actor->data_2--;
}
if(actor->data_2 != 1)
{
return;
}
actor->data_2 = 3;
map_write_row_of_tiles(0, 5, actor->x - 2, actor->y - i);
actor->data_1--;
if(actor->data_1 != 1)
{
explode_effect_add_sprite(0xc0, 1, actor->x, actor->y);
effect_add_sprite(0x61, 6, actor->x - 1, actor->y + 1, 1, 1);
}
else
{
actor->is_deactivated_flag_maybe = 1;
explode_effect_add_sprite(0xc0, 0, actor->x, actor->y);
}
}
U0 actor_wt_door(ActorData *actor)
{
I64 si;
if (actor->has_moved_left_flag != 0)
{
return;
}
actor->has_moved_left_flag = 1;
actor->data_1 = map_get_tile_cell(actor->x + 1, actor->y);
actor->data_2 = map_get_tile_cell(actor->x + 1, actor->y - 1);
actor->data_3 = map_get_tile_cell(actor->x + 1, actor->y - 2);
actor->data_4 = map_get_tile_cell(actor->x + 1, actor->y - 3);
actor->data_5 = map_get_tile_cell(actor->x + 1, actor->y - 4);
for(si=0; si < 5; si++)
{
map_write_tile_cell(0x3dc8, actor->x + 1, actor->y - si);
}
return;
}
U0 actor_wt_dragonfly(ActorData *actor)
{
if(actor->data_1 != 0)
{
if(sprite_blocking_check(3, 0x81, 0, actor->x + 1, actor->y) == NOT_BLOCKED)
{
actor->x = actor->x + 1;
actor->data_2 = Cond(actor->data_2, -1, 0) + 1;
actor->frame_num = actor->data_2 + 2;
}
else
{
actor->data_1 = 0;
}
return;
}
if(sprite_blocking_check(2, 0x81, 0, actor->x - 1, actor->y) == NOT_BLOCKED)
{
actor->x = actor->x - 1;
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
}
else
{
actor->data_1 = 1;
}
}
U0 actor_wt_egg_head(ActorData *actor)
{
if(actor->data_2 == 0)
{
if(sub_1106F() % 0x46 == 0 && actor->data_3 == 0)
{
actor->data_3 = 2;
}
else
{
actor->frame_num = 0;
}
}
else
{
actor->frame_num = 2;
}
if(actor->data_3 != 0)
{
actor->data_3--;
actor->frame_num = 1;
}
if(actor->data_5 == 0 && actor->data_1 == 0)
{
if(actor->y <= player_y_pos)
{
if(actor->x - 6 < player_x_pos)
{
if(actor->x + 4 > player_x_pos)
{
actor->data_1 = 1;
actor->data_2 = 0x14;
play_sfx(0x21);
}
}
}
}
if(actor->data_2 > 1)
{
actor->data_2--;
return;
}
if(actor->data_2 == 1)
{
actor->is_deactivated_flag_maybe = 1;
actor_tile_display_func_index = 1;
actor_add_new(0x41, actor->x, actor->y);
effect_add_sprite(0x4c, 1, actor->x, actor->y - 1, 8, 5);
effect_add_sprite(0x4d, 1, actor->x + 1, actor->y - 1, 2, 5);
effect_add_sprite(0x84, 1, actor->x, actor->y, 3, 5);
effect_add_sprite(0x85, 1, actor->x + 1, actor->y, 7, 5);
play_sfx(0x22);
}
}
U0 actor_wt_end_of_level_marker(ActorData *actor)
{
if(actor->y <= player_y_pos && actor->data_1 == 0)
{
finished_level_flag_maybe = 1;
}
else
{
if(actor->y >= player_y_pos && actor->data_1 != 0)
{
finished_game_flag_maybe = 1;
}
}
actor_tile_display_func_index = 1;
return;
}
U0 actor_wt_energy_beam(ActorData *actor)
{
I64 i;
actor->data_1 = 0;
actor->data_4++;
if(actor->data_4 == 3)
{
actor->data_4 = 0;
}
actor_tile_display_func_index = 1;
if(energy_beam_enabled_flag == 0)
{
actor->is_deactivated_flag_maybe = 1;
return;
}
if (actor->data_5 != 0)
{
for(i=1;i==i;actor->data_1++)
{
if(player_check_collision_with_actor(actor->actorInfoIndex, 0, actor->x + actor->data_1, actor->y) != 0)
{
player_decrease_health();
break;
}
if((tileattr_mni_data[map_get_tile_cell(actor->x + actor->data_1, actor->y)/8] & TILE_ATTR_BLOCK_RIGHT) != 0)
{
break;
}
display_actor_sprite_maybe(actor->actorInfoIndex, actor->data_4, actor->x + actor->data_1, actor->y, 0);
}
}
else
{
for(i=1;i==i;actor->data_1++)
{
if (player_check_collision_with_actor(actor->actorInfoIndex, 0, actor->x, actor->y - actor->data_1) != 0)
{
player_decrease_health();
break;
}
if((tileattr_mni_data[map_get_tile_cell(actor->x, actor->y - actor->data_1)/8] & TILE_ATTR_BLOCK_UP) != 0)
{
break;
}
display_actor_sprite_maybe(actor->actorInfoIndex, actor->data_4, actor->x, actor->y - actor->data_1, 0);
}
}
}
U0 actor_wt_extending_arrow(ActorData *actor)
{
if(actor->data_1 >= 0x1f)
{
actor->data_1 = 0;
}
else
{
actor->data_1++;
}
if(actor->data_1 == 0x1d || actor->data_1 == 0x1a)
{
if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0)
{
play_sfx(9);
}
}
if(actor->data_5 == 0)
{
if(actor->data_1 > 0x1c)
{
actor->x = actor->x + 1;
}
else
{
if(actor->data_1 > 0x19)
{
actor->x = actor->x - 1;
return;
}
}
return;
}
if(actor->data_1 > 0x1c)
{
actor->x = actor->x - 1;
return;
}
if(actor->data_1 > 0x19)
{
actor->x = actor->x + 1;
return;
}
return;
}
U0 actor_wt_frozen_duke_nukum(ActorData *actor)
{
//TODO
}
U0 actor_wt_ghost(ActorData *actor)
{
actor->data_4++;
if(actor->data_4 % 3 == 0)
{
actor->data_1++;
}
if(actor->data_1 == 4)
{
actor->data_1 = 0;
}
if (player_direction == 0)
{
if (actor->x <= player_x_pos + 1 + 1 || player_hanging_on_wall_direction != 2 || right_key_pressed == 0)
{
if (actor->x <= player_x_pos)
{
if(cosmo_rand() % 0x23 != 0)
{
actor->frame_num = 5;
}
else
{
actor->frame_num = 7;
}
return;
}
else
{
actor->frame_num = actor->data_1 & 1;
if(actor->data_1 != 0)
{
return;
}
actor->x = actor->x - 1;
if(actor->y < player_y_pos)
{
actor->y = actor->y + 1;
return;
}
if(actor->y > player_y_pos)
{
actor->y = actor->y - 1;
}
return;
}
}
else
{
if(cosmo_rand() % 0x23 != 0)
{
actor->frame_num = 2;
}
else
{
actor->frame_num = 6;
}
return;
}
}
else
{
if (actor->x >= player_x_pos || player_hanging_on_wall_direction != 3 || left_key_pressed == 0)
{
if (actor->x >= player_x_pos)
{
if(cosmo_rand() % 0x23 != 0)
{
actor->frame_num = 2;
}
else
{
actor->frame_num = 6;
}
}
else
{
actor->frame_num = (actor->data_1 & 1) + 3;
if (actor->data_1 == 0)
{
actor->x = actor->x + 1;
if(actor->y < player_y_pos)
{
actor->y = actor->y + 1;
return;
}
if(actor->y > player_y_pos)
{
actor->y = actor->y - 1;
}
}
return;
}
}
else
{
if(cosmo_rand() % 0x23 != 0)
{
actor->frame_num = 5;
}
else
{
actor->frame_num = 7;
}
}
}
}
U0 actor_wt_green_plant(ActorData *actor)
{
if(actor->data_2 != 0)
{
actor->y = actor->y + 1;
actor->data_4 = actor->data_4 + 1;
if(actor->data_4 == 7)
{
actor->data_2 = 0;
actor->data_3 = 0;
actor->data_1 = 12;
}
return;
}
if(actor->data_3 < actor->data_1)
{
actor->data_3 = actor->data_3 + 1;
return;
}
actor->data_5 = Cond(actor->data_5, -1, 0) + 1;
actor->frame_num = actor->frame_num + 1;
if(actor->frame_num == 4)
{
actor->frame_num = 0;
}
if(actor->data_4 != 0)
{
if(actor->data_4 == 7)
{
play_sfx(0x35);
}
actor->data_4 = actor->data_4 - 1;
actor->y = actor->y - 1;
}
if(struct6_1B4FC(0x91, 0, actor->x, actor->y) != 0)
{
actor->data_2 = 1;
}
}
I8 cabbage_ball_y_tbl[4] = {-1, -1, 0, 0};
U0 actor_wt_green_pruny_cabbage_ball(ActorData *actor)
{
if(actor->data_2 == 10 && actor->data_3 == 3)
{
if(sprite_blocking_check(1, 0x19, 0, actor->x, actor->y + 1) == NOT_BLOCKED)
{
if(actor->data_4 == 0)
{
actor->frame_num = 1;
}
else
{
actor->frame_num = 3;
}
return;
}
}
if(actor->data_2 < 10)
{
if(sprite_blocking_check(1, 0x19, 0, actor->x, actor->y + 1) != NOT_BLOCKED)
{
actor->data_2 = actor->data_2 + 1;
if(actor->x <= player_x_pos)
{
actor->frame_num = 2;
actor->data_4 = 2;
}
else
{
actor->frame_num = 0;
actor->data_4 = 0;
}
return;
}
}
if(actor->data_3 < 3)
{
actor->y = actor->y + cabbage_ball_y_tbl[actor->data_3];
if(actor->data_4 == 0)
{
actor->x = actor->x - 1;
check_actor_move_left_or_right(actor, 2);
}
else
{
actor->x = actor->x + 1;
check_actor_move_left_or_right(actor, 3);
}
actor->data_3++;
if(actor->data_4 == 0)
{
actor->frame_num = 1;
}
else
{
actor->frame_num = 3;
}
return;
}
actor->data_2 = 0;
actor->data_3 = 0;
if(actor->x <= player_x_pos)
{
actor->frame_num = 2;
actor->data_4 = 2;
}
else
{
actor->frame_num = 0;
actor->data_4 = 0;
}
}
U0 actor_wt_green_roamer_worm(ActorData *actor)
{
if(actor->data_5 != 0)
{
I64 si = sub_1106F() & 3;
if(si == 0)
{
if(sprite_blocking_check(0, 0x45, 0, actor->x, actor->y - 1) == 0)
{
actor->data_5 = 0;
actor->data_1 = 0;
}
}
if(si == 1)
{
if(sprite_blocking_check(1, 0x45, 0, actor->x, actor->y + 1) == 0)
{
actor->data_5 = 0;
actor->data_1 = 1;
}
}
if(si == 2)
{
if(sprite_blocking_check(2, 0x45, 0, actor->x - 1, actor->y) == 0)
{
actor->data_5 = 0;
actor->data_1 = 2;
}
}
if(si == 3)
{
if(sprite_blocking_check(3, 0x45, 0, actor->x + 1, actor->y) == 0)
{
actor->data_5 = 0;
actor->data_1 = 3;
}
}
}
else
{
switch (actor->data_1)
{
case 0:
if(sprite_blocking_check(0, 0x45, 0, actor->x, actor->y - 1) == NOT_BLOCKED)
{
actor->y = actor->y - 1;
}
else
{
actor->data_5 = 1;
}
actor->data_3 = 0;
break;
case 1:
if(sprite_blocking_check(1, 0x45, 0, actor->x, actor->y + 1) == 0)
{
actor->y = actor->y + 1;
}
else
{
actor->data_5 = 1;
}
actor->data_3 = 4;
break;
case 2:
if(sprite_blocking_check(2, 0x45, 0, actor->x - 1, actor->y) == 0)
{
actor->x = actor->x - 1;
}
else
{
actor->data_5 = 1;
}
actor->data_3 = 6;
break;
case 3:
if(sprite_blocking_check(3, 0x45, 0, actor->x + 1, actor->y) == 0)
{
actor->x = actor->x + 1;
}
else
{
actor->data_5 = 1;
}
actor->data_3 = 2;
break;
}
}
actor->data_4 = Cond(actor->data_4, -1, 0) + 1;
actor->frame_num = actor->data_3 + actor->data_4;
}
U8 byte_28EFE[6] = { 0, 4, 5, 6, 5, 4};
U0 actor_wt_hint_dialog(ActorData *actor)
{
actor->data_4 = Cond(actor->data_4, -1, 0) + 1;
if(actor->data_4 != 0)
{
actor->data_3 = actor->data_3 + 1;
}
display_actor_sprite_maybe(0x7d, byte_28EFE[actor->data_3 % 6], actor->x, actor->y - 2, 0);
actor->data_2 = actor->data_2 + 1;
if(actor->data_2 == 4)
{
actor->data_2 = 1;
}
display_actor_sprite_maybe(0x7d, actor->data_2, actor->x, actor->y, 0);
actor_tile_display_func_index = 1;
if(player_check_collision_with_actor(0x7d, 0, actor->x, actor->y - 2) != 0)
{
word_32EAC = 1;
if(game_play_mode != 0)
{
byte_2E21C = 1;
}
if((up_key_pressed != 0 && player_hoverboard_counter == 0) || byte_2E21C == 0)
{
play_sfx(0x1e);
ingame_hint_dialogs(actor->data_5);
}
byte_2E21C = 1;
}
return;
}
U8 flame_frame_num_tbl[17] = {
0, 1, 0, 1, 0, 1, 0, 1, 2, 3, 2, 3, 2, 3, 1, 0, 0
};
U0 actor_wt_horizontal_flame(ActorData *actor)
{
if(actor->data_1 != 0)
{
actor->data_1--;
actor_tile_display_func_index = 1;
}
else
{
actor->frame_num = flame_frame_num_tbl[actor->data_2];
if(actor->frame_num == 2)
{
effect_add_sprite(0x61, 6, actor->x - actor->data_5, actor->y - 3, 1, 1);
play_sfx(0x36);
}
actor->data_2++;
if(actor->data_2 == 0x10)
{
actor->data_1 = 0x1e;
actor->data_2 = 0;
}
}
return;
}
U0 actor_wt_hoverboard(ActorData *actor)
{
actor->frame_num = actor->frame_num + 1;
actor->frame_num = actor->frame_num & 3;
if(player_hoverboard_counter != 0)
{
actor->x = player_x_pos;
actor->y = player_y_pos + 1;
return;
}
actor->data_2++;
if(actor->data_2 % 10 == 0)
{
if(sprite_blocking_check(1, 0x72, 0, actor->x, actor->y + 1) != NOT_BLOCKED)
{
actor->y = actor->y - 1;
}
else
{
actor->y = actor->y + 1;
if(sprite_blocking_check(1, 0x72, 0, actor->x, actor->y + 1) != NOT_BLOCKED)
{
actor->y = actor->y - 1;
return;
}
}
return;
}
return;
}
U0 actor_wt_invisible_exit_marker_right(ActorData *actor)
{
if(actor->x <= player_x_pos + 3)
{
finished_level_flag_maybe = 1;
return;
}
actor_tile_display_func_index = 1;
return;
}
U8 jaws_and_tongue_frame_num_tbl[4] = {2, 3, 4, 3};
U0 actor_wt_jaws_and_tongue(ActorData *actor)
{
if(actor->data_1 == 0)
{
actor->data_2++;
}
if(actor->data_2 == 10)
{
actor->data_1 = 1;
actor->data_2 = 11;
actor->frame_num = 1;
actor->data_5 = 1;
play_sfx(0x26);
}
if(actor->frame_num != 0)
{
display_actor_sprite_maybe(0x95, jaws_and_tongue_frame_num_tbl[actor->data_3 & 3], actor->x + 6 - actor->data_5, actor->y - 3, 0);
actor->data_3++;
}
if(is_sprite_on_screen(0x95, 1, actor->x, actor->y) == 0)
{
actor->frame_num = 0;
actor->data_2 = 0;
actor->data_1 = 0;
actor->data_5 = 0;
}
actor_tile_display_func_index = 1;
display_actor_sprite_maybe(actor->actorInfoIndex, 1, actor->x, actor->y, 0);
if(actor->data_5 != 0 && actor->data_5 < 4)
{
actor->data_5++;
return;
}
display_actor_sprite_maybe(actor->actorInfoIndex, 0, actor->x, actor->y - 1 - actor->data_5, 0);
return;
}
I16 bullet_head_y_tbl[16] = {-2, -2, -2, -2, -1, -1, -1, 0, 0, 1, 1, 1, 2, 2, 2, 2};
U0 actor_wt_jumping_bullet_head(ActorData *actor)
{
if(actor->data_2 != 0)
{
actor->x = actor->x + 1;
}
else
{
actor->x = actor->x - 1;
}
actor->y = actor->y + bullet_head_y_tbl[actor->data_3];
actor->data_3++;
if(actor->data_3 == 0x10)
{
actor->data_2 = Cond(actor->data_2, -1, 0) + 1;
if(is_sprite_on_screen(0x2e, 0, actor->x, actor->y) != 0)
{
play_sfx(0x25);
}
actor->data_3 = 0;
}
}
U0 actor_wt_mini_ghost(ActorData *actor)
{
if(actor->data_4 != 0)
{
actor->data_4--;
return;
}
if(actor->data_1 == 0)
{
if(sprite_blocking_check(1, 0x41, 0, actor->x, actor->y + 1) != NOT_BLOCKED)
{
actor->can_fall_down_flag = 0;
actor->data_1 = 1;
actor->data_4 = 3;
actor->data_2 = 4;
actor->frame_num = 1;
actor->data_3 = 1;
if(is_sprite_on_screen(0x41, 0, actor->x, actor->y) != 0)
{
play_sfx(0x3b);
}
return;
}
if(actor->data_5 != 0)
{
actor->data_5--;
}
else
{
actor->frame_num = 1;
if(actor->data_3 == 0)
{
actor->data_4++;
return;
}
}
}
else
{
if(actor->data_1 == 1)
{
actor->y = actor->y - 1;
actor->frame_num = 0;
if(actor->data_2 == 4)
{
if(is_sprite_on_screen(0x41, 0, actor->x, actor->y) != 0)
{
play_sfx(0x3a);
}
}
actor->data_2--;
if(actor->data_2 == 0)
{
actor->data_1 = 0;
actor->data_5 = 3;
actor->can_fall_down_flag = 1;
}
}
}
return;
}
U0 actor_wt_pink_eye_plant(ActorData *actor)
{
actor_tile_display_func_index = actor->data_5;
actor->data_2 = cosmo_rand() % 0x28;
if(actor->data_2 <= 0x25)
{
actor->data_2 = 0;
}
else
{
actor->data_2 = 3;
}
if(actor->x - 2 > player_x_pos)
{
actor->frame_num = actor->data_2;
return;
}
if(actor->x + 1 >= player_x_pos)
{
actor->frame_num = actor->data_2 + 1;
}
else
{
actor->frame_num = actor->data_2 + 2;
}
return;
}
U0 actor_wt_pink_slug(ActorData *actor)
{
if(actor->data_5 == 0)
{
actor->data_4 = Cond(actor->data_4, -1, 0) + 1;
if(actor->data_4 != 0)
{
return;
}
}
if(cosmo_rand() % 0x28 > 0x25)
{
if(actor->data_3 == 0 && actor->data_2 == 0)
{
actor->data_3 = 4;
}
}
if(actor->data_3 != 0)
{
actor->data_3--;
if(actor->data_3 == 2)
{
if(actor->data_1 == 0)
{
actor->frame_num = 2;
return;
}
if(actor->data_2 == 0)
{
actor->frame_num = 5;
}
return;
}
if(actor->data_1 != 0)
{
actor->frame_num = 3;
}
else
{
actor->frame_num = 0;
}
return;
}
if(actor->data_1 == 0)
{
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
if(actor->frame_num != 0)
{
actor->x--;
check_actor_move_left_or_right(actor, 2);
if(actor->has_moved_left_flag == 0)
{
actor->data_1 = 1;
}
}
return;
}
actor->data_2 = Cond(actor->data_2, -1, 0) + 1;
if(actor->data_2 == 0)
{
actor->x = actor->x + 1;
actor->frame_num = 1;
check_actor_move_left_or_right(actor, 3);
if(actor->has_moved_right_flag == 0)
{
actor->data_1 = 0;
}
return;
}
actor->frame_num = actor->data_2 + 3;
}
U0 actor_wt_pipe_transit_direction(ActorData *actor)
{
actor_tile_display_func_index = 1;
}
U0 actor_wt_plasma_energy_blue_sprite(ActorData *actor)
{
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
if(actor->data_1 >= 0x3f)
{
actor->data_1 = 0;
}
else
{
actor->data_1++;
}
if(actor->data_1 > 0x32)
{
actor->y = actor->y + 2;
if(actor->data_1 < 0x37)
{
actor->y = actor->y - 1;
}
actor_tile_display_func_index = 4;
return;
}
if(actor->data_1 > 0x22)
{
if(actor->data_1 < 0x2f)
{
actor->y = actor->y - 1;
}
if(actor->data_1 < 0x2d)
{
actor->y = actor->y - 1;
}
}
}
U0 actor_wt_plasma_fireball(ActorData *actor)
{
if(actor->data_1 == 0x1d)
{
play_sfx(0x24);
}
if(actor->data_1 >= 0x1e)
{
if(actor->data_5 != 0)
{
actor->x = actor->x + 1;
actor->has_moved_right_flag = Cond(sprite_blocking_check(3, actor->actorInfoIndex, 0, actor->x, actor->y) != NOT_BLOCKED, -1, 0) + 1;
if(actor->has_moved_right_flag == 0)
{
actor->data_1 = 0;
effect_add_sprite(0x61, 6, actor->x - 2, actor->y, 1, 1);
actor->x = actor->data_2;
actor->y = actor->data_3;
play_sfx(0x1b);
}
}
else
{
actor->x = actor->x - 1;
actor->has_moved_left_flag = Cond(sprite_blocking_check(2, actor->actorInfoIndex, 0, actor->x, actor->y) != NOT_BLOCKED, -1, 0) + 1;
if(actor->has_moved_left_flag == 0)
{
actor->data_1 = 0;
effect_add_sprite(0x61, 6, actor->x + 1, actor->y, 1, 1);
actor->x = actor->data_2;
actor->y = actor->data_3;
play_sfx(0x1b);
}
}
}
else
{
actor->data_1++;
}
if(is_sprite_on_screen(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) == 0)
{
actor->data_1 = 0;
actor->x = actor->data_2;
actor->y = actor->data_3;
return;
}
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
return;
}
U0 actor_wt_pneumatic_pipe(ActorData *actor)
{
if(actor->data_2 != 0)
{
actor->data_1++;
actor->data_3++;
if((actor->data_3 & 1) == 0)
{
actor->frame_num = 0;
}
else
{
actor->frame_num = 4;
}
if(actor->data_1 == 4)
{
actor->data_1 = 1;
}
display_actor_sprite_maybe(0x69, actor->data_1, actor->x, actor->y + 3, 0);
return;
}
return;
}
U0 actor_wt_projectile_flashing_ball(ActorData *actor)
{
if(is_sprite_on_screen(0x44, 0, actor->x, actor->y) == 0)
{
actor->is_deactivated_flag_maybe = 1;
return;
}
if(actor->data_1 == 0)
{
actor->data_1 = 1;
play_sfx(0x1a);
}
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
switch (actor->data_5)
{
case 0:
actor->x = actor->x - 1;
break;
case 1:
actor->x = actor->x - 1;
actor->y = actor->y + 1;
break;
case 2:
actor->y = actor->y + 1;
break;
case 3:
actor->x = actor->x + 1;
actor->y = actor->y + 1;
break;
case 4:
actor->x = actor->x + 1;
break;
default : break;
}
}
U0 actor_wt_question_mark_block(ActorData *actor)
{
if(word_2E17E != 0)
{
actor->data_1 = 1;
actor->update_while_off_screen_flag = 1;
}
if(actor->data_1 == 0)
{
return;
}
if((actor->data_1 & 1) != 0)
{
map_write_tile_cell(0x3df8, actor->x, actor->y - 1);
map_write_tile_cell(0x3e00, actor->x + 1, actor->y - 1);
map_write_tile_cell(0x3e08, actor->x, actor->y);
map_write_tile_cell(0x3e10, actor->x + 1, actor->y);
}
if(sprite_blocking_check(0, actor->actorInfoIndex, 0, actor->x, actor->y - 1) != NOT_BLOCKED)
{
if((actor->data_1 & 1) == 0)
{
map_write_tile_cell(0x3e08, actor->x, actor->y - 1);
map_write_tile_cell(0x3e10, actor->x + 1, actor->y - 1);
}
actor->is_deactivated_flag_maybe = 1;
}
else
{
if((actor->data_1 & 1) == 0)
{
effect_add_sprite(15, 4, actor->x - 1, actor->y - 1, 0, 1);
}
actor->data_1++;
actor->y--;
}
}
U0 actor_wt_red_blue_plant(ActorData *actor)
{
actor_tile_display_func_index = actor->data_5;
if(actor->data_2 == 1)
{
actor->frame_num = actor->frame_num + 1;
if(actor->frame_num == 1)
{
play_sfx(0x3f);
}
if(actor->frame_num == 4)
{
actor->data_2 = 2;
}
return;
}
if(actor->data_2 == 2)
{
actor->frame_num = actor->frame_num - 1;
if(actor->frame_num == 1)
{
actor->data_2 = 0;
actor->data_1 = 1;
}
return;
}
if(actor->data_1 >= 0x10)
{
actor->data_1 = 0;
}
else
{
actor->data_1++;
}
if(actor->data_1 != 0)
{
actor->frame_num = 0;
}
else
{
actor->data_2 = 1;
}
return;
}
U8 word_28EE6[6] = { 8, 9, 10, 10, 9, 8};
U8 word_28EF2[6] = { 10, 9, 8, 8, 9, 10};
U0 actor_wt_red_chomper_alien(ActorData *actor)
{
actor->data_4 = Cond(actor->data_4, -1, 0) + 1;
if(sub_1106F() % 0x5f != 0)
{
if(sub_1106F() % 0x64 == 0)
{
actor->data_5 = 11;
}
}
else
{
actor->data_5 = 10;
}
if(actor->data_5 < 11 && actor->data_5 != 0)
{
actor->data_5--;
if(actor->data_5 <= 8)
{
if(actor->data_5 != 8)
{
actor->data_2 = Cond(actor->data_2, -1, 0) + 1;
actor->frame_num = actor->data_2 + 6;
}
else
{
actor->frame_num = 5;
}
}
else
{
actor->frame_num = 6;
}
if(actor->data_5 != 0)
{
return;
}
if((sub_1106F() & 1) == 0)
{
return;
}
if(actor->x < player_x_pos)
{
actor->data_1 = 1;
}
else
{
actor->data_1 = 0;
}
}
else
{
if(actor->data_5 > 10)
{
if(actor->data_1 != 0)
{
actor->frame_num = word_28EF2[actor->data_5 - 11];
}
else
{
actor->frame_num = word_28EE6[actor->data_5 - 11];
}
actor->data_5++;
if(actor->data_5 == 0x11)
{
actor->data_5 = 0;
}
return;
}
if(actor->data_1 == 0)
{
if(actor->data_4 != 0)
{
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
actor->x = actor->x - 1;
check_actor_move_left_or_right(actor, LEFT);
if(actor->has_moved_left_flag == 0)
{
actor->data_1 = 1;
actor->frame_num = 4;
}
}
return;
}
if(actor->data_4 != 0)
{
actor->data_3 = Cond(actor->data_3, -1, 0) + 1;
actor->frame_num = actor->data_3 + 2;
actor->x++;
check_actor_move_left_or_right(actor, RIGHT);
if(actor->has_moved_right_flag == 0)
{
actor->data_1 = 0;
actor->frame_num = 4;
}
}
}
return;
}
U0 actor_wt_retracting_spikes(ActorData *actor)
{
actor->data_2++;
if(actor->data_2 == 0x14)
{
actor->data_2 = 0;
}
if(actor->frame_num != 0 || actor->data_2 != 0)
{
if(actor->frame_num != 2 || actor->data_2 != 0)
{
if(actor->data_1 == 0)
{
if(actor->frame_num < 2)
{
actor->frame_num = actor->frame_num + 1;
}
}
else
{
if(actor->frame_num > 0)
{
actor->frame_num = actor->frame_num - 1;
}
}
}
else
{
actor->data_1 = 1;
play_sfx(9);
actor_tile_display_func_index = 1;
}
}
else
{
actor->data_1 = 0;
play_sfx(9);
}
if(actor->frame_num == 2)
{
actor_tile_display_func_index = 1;
return;
}
return;
}
U0 actor_wt_robot_with_blue_arc(ActorData *actor)
{
static U16 spark_frame_num = 0;
I64 si;
actor_tile_display_func_index = 1;
if (actor->data_2 == 0)
{
actor->data_5 = Cond(actor->data_5, -1, 0) + 1;
actor->data_4++;
if(actor->data_1 == 0)
{
if((actor->data_4 & 1) != 0)
{
actor->x++;
}
check_actor_move_left_or_right(actor, RIGHT);
if(actor->has_moved_right_flag == 0)
{
actor->data_1 = 1;
}
}
else
{
if((actor->data_4 & 1) != 0)
{
actor->x--;
}
check_actor_move_left_or_right(actor, LEFT);
if(actor->has_moved_left_flag == 0)
{
actor->data_1 = 0;
}
}
display_actor_sprite_maybe(0x5a, actor->data_5, actor->x, actor->y, 0);
if(player_check_collision_with_actor(0x5a, 0, actor->x, actor->y) != 0)
{
player_decrease_health();
}
spark_frame_num++;
for(si=2; si < 21 && sprite_blocking_check(0, 0x5a, 2, actor->x + 1, actor->y - si) == NOT_BLOCKED; si++)
{
display_actor_sprite_maybe(0x5a, (spark_frame_num & 3) + 4, actor->x + 1, actor->y - si, 0);
if(player_check_collision_with_actor(0x5a, 4, actor->x + 1, actor->y - si) != 0)
{
player_decrease_health();
}
}
display_actor_sprite_maybe(0x5a, actor->data_5 + 1 + 1, actor->x + 1, actor->y - si + 1, 0);
if(player_check_collision_with_actor(0x5a, 0, actor->x, actor->y + 1) != 0)
{
player_decrease_health();
}
if(struct6_1B4FC(actor->actorInfoIndex, actor->frame_num, actor->x, actor->y) != 0)
{
actor->data_2 = si;
}
}
else
{
for(si = 0; si < actor->data_2; si += 4)
{
struct6_add_sprite(actor->x, actor->y - si);
actor_add_new(1, actor->x, actor->y - si);
}
actor->is_deactivated_flag_maybe = 1;
}
}
U0 actor_wt_robotic_spike_ceiling(ActorData *actor)
{
actor->data_3 = Cond(actor->data_3, -1, 0) + 1;
if(actor->data_3 == 0)
{
return;
}
if(actor->data_4 != 0)
{
actor->data_4--;
return;
}
if(actor->data_2 == 1)
{
if(sprite_blocking_check(3, 0x50, 0, actor->x + 1, actor->y) != 0)
{
actor->data_4 = 4;
actor->data_2 = 0;
}
else
{
if(sprite_blocking_check(3, 0x50, 0, actor->x + 1, actor->y - 1) != 0)
{
actor->x = actor->x + 1;
}
else
{
actor->data_4 = 4;
actor->data_2 = 0;
}
}
return;
}
if(sprite_blocking_check(2, 0x50, 0, actor->x - 1, actor->y) != 0)
{
actor->data_4 = 4;
actor->data_2 = 1;
}
else
{
if(sprite_blocking_check(2, 0x50, 0, actor->x - 1, actor->y - 1) != 0)
{
actor->x = actor->x - 1;
}
else
{
actor->data_4 = 4;
actor->data_2 = 1;
}
}
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
return;
}
U0 actor_wt_robotic_spike_ground(ActorData *actor)
{
actor->data_3 = Cond(actor->data_3, -1, 0) + 1;
if(actor->actorInfoIndex == 0x14)
{
actor->data_3 = 1;
if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0)
{
play_sfx(0x23);
}
}
if(actor->data_4 != 0)
{
actor->data_4--;
}
if(actor->data_3 == 0)
{
return;
}
if(actor->data_4 == 0)
{
if(actor->data_2 == 0)
{
actor->x = actor->x - 1;
check_actor_move_left_or_right(actor, LEFT);
if(actor->has_moved_left_flag == 0)
{
actor->data_2 = 1;
actor->data_4 = actor->data_1;
}
}
else
{
actor->x = actor->x + 1;
check_actor_move_left_or_right(actor, RIGHT);
if(actor->has_moved_right_flag == 0)
{
actor->data_2 = 0;
actor->data_4 = actor->data_1;
}
}
}
actor->frame_num++;
if(actor->frame_num > actor->data_5)
{
actor->frame_num = 0;
}
return;
}
U0 actor_wt_rocket(ActorData *actor)
{
if(actor->data_1 != 0)
{
actor->data_1--;
if(actor->data_1 >= 0x1e)
{
return;
}
if((actor->data_1 & 1) == 0)
{
effect_add_sprite(0x61, 6, actor->x + 1, actor->y + 1, 2, 1);
}
else
{
effect_add_sprite(0x61, 6, actor->x - 1, actor->y + 1, 8, 1);
}
return;
}
if(actor->data_2 != 0)
{
if(actor->data_2 > 7)
{
effect_add_sprite(0x61, 6, actor->x - 1, actor->y + 1, 7, 1);
effect_add_sprite(0x61, 6, actor->x + 1, actor->y + 1, 3, 1);
play_sfx(0x31);
}
if(actor->data_2 > 1)
{
actor->data_2--;
}
if(actor->data_2 < 10)
{
if(sprite_blocking_check(0, 0xbc, 0, actor->x, actor->y - 1) != 0)
{
actor->data_5 = 1;
}
else
{
actor->y = actor->y - 1;
}
if(is_sprite_on_screen(actor->actorInfoIndex, 0, actor->x, actor->y) != 0)
{
play_sfx(0x31);
}
}
if(actor->data_2 < 5)
{
if(sprite_blocking_check(0, 0xbc, 0, actor->x, actor->y - 1) != 0)
{
actor->data_5 = 1;
}
else
{
actor->y = actor->y - 1;
}
actor->data_4 = Cond(actor->data_4, -1, 0) + 1;
display_actor_sprite_maybe(0xbc, actor->data_4 + 4, actor->x, actor->y + 6, 0);
if(player_check_collision_with_actor(0xbc, 4, actor->x, actor->y + 6) != 0)
{
player_decrease_health();
}
if(actor->data_4 != 0)
{
effect_add_sprite(0x61, 6, actor->x, actor->y + 6, 5, 1);
}
}
if(actor->x == player_x_pos)
{
if(actor->y - 7 <= player_y_pos)
{
if(actor->y - 4 >= player_y_pos)
{
player_bounce_height_counter = 0x10;
player_bounce_flag_maybe = 1;
sub_11062();
word_2E1DE = 0;
if(actor->y - 7 == player_y_pos)
{
player_y_pos = player_y_pos + 1;
}
if(actor->y - 6 == player_y_pos)
{
player_y_pos = player_y_pos + 1;
}
if(actor->y - 4 == player_y_pos)
{
player_y_pos = player_y_pos - 1;
}
}
}
}
if(actor->data_2 > 4 && (actor->data_2 & 1) != 0)
{
effect_add_sprite(0x61, 6, actor->x, actor->y + 1 + 1, 5, 1);
}
}
if(actor->data_5 != 0)
{
actor->is_deactivated_flag_maybe = 1;
explode_effect_add_sprite(0xbc, 1, actor->x, actor->y);
explode_effect_add_sprite(0xbc, 2, actor->x + 1, actor->y);
explode_effect_add_sprite(0xbc, 3, actor->x + 1 + 1, actor->y);
struct6_add_sprite(actor->x - 4, actor->y);
struct6_add_sprite(actor->x + 1, actor->y);
actor_tile_display_func_index = 2;
}
return;
}
U0 actor_wt_rubber_wall(ActorData *actor)
{
if (actor->data_2 != 0)
{
actor->is_deactivated_flag_maybe = 1;
actor_tile_display_func_index = 1;
explode_effect_add_sprite(0x40, 3, actor->x, actor->y - 8);
explode_effect_add_sprite(0x40, 3, actor->x, actor->y - 7);
explode_effect_add_sprite(0x40, 3, actor->x, actor->y - 6);
explode_effect_add_sprite(0x40, 3, actor->x, actor->y);
explode_effect_add_sprite(0x40, 3, actor->x + 1, actor->y);
explode_effect_add_sprite(0x40, 3, actor->x + 1 + 1, actor->y);
effect_add_sprite(0x61, 6, actor->x, actor->y, 1, 2);
effect_add_sprite(0x61, 6, actor->x, actor->y, 2, 2);
effect_add_sprite(0x61, 6, actor->x, actor->y, 8, 2);
effect_add_sprite(0x61, 6, actor->x, actor->y - 4, 1, 3);
player_add_to_score(0x6400);
actor_add_new(0xb8, actor->x - 2, actor->y - 9);
actor_add_new(0xb8, actor->x + 1 + 1, actor->y - 9);
play_sfx(0x19);
return;
}
I64 i;
if (actor->has_moved_left_flag == 0)
{
actor->has_moved_left_flag = 1;
for(i=0; i < 9; i++)
{
map_write_tile_cell(0x3d88, actor->x + 1, actor->y - i);
}
}
if(actor->data_1 != 0)
{
actor->data_1--;
if((actor->data_1 & 1) != 0)
{
actor_tile_display_func_index = 2;
}
}
if (struct6_1B4FC(0x40, 0, actor->x, actor->y) != 0 && actor->data_1 == 0)
{
actor->data_1 = 10;
actor->frame_num++;
if (actor->frame_num == 3)
{
actor->frame_num = 2;
actor->data_2 = 1;
for(i=0; i < 9; i ++)
{
map_write_tile_cell(0, actor->x + 1, actor->y - i);
}
}
}
return;
}
U0 actor_wt_satellite(ActorData *actor)
{
if(actor->data_2 != 0)
{
actor->data_2--;
if(actor->data_2 != 0)
{
if((actor->data_2 & 1) != 0)
{
actor_tile_display_func_index = 2;
}
return;
}
}
if(struct6_1B4FC(0x8f, 0, actor->x, actor->y) == 0)
{
return;
}
if(actor->data_1 == 0)
{
actor->data_1 = 1;
actor->data_2 = 15;
return;
}
actor->is_deactivated_flag_maybe = 1;
actor_tile_display_func_index = 2;
play_sfx(0x12);
actor->data_1 = 1;
for(; actor->data_1 < 9; actor->data_1++)
{
effect_add_sprite(0x61, 6, actor->x + 3, actor->y - 3, actor->data_1, 3);
}
exploding_balls_effect(actor->x, actor->y + 5);
explode_effect_add_sprite(0x90, 0, actor->x, actor->y - 2);
explode_effect_add_sprite(0x90, 1, actor->x + 1, actor->y - 2);
explode_effect_add_sprite(0x90, 2, actor->x + 7, actor->y + 1 + 1);
explode_effect_add_sprite(0x90, 3, actor->x + 3, actor->y - 2);
explode_effect_add_sprite(0x90, 4, actor->x - 1, actor->y - 8);
explode_effect_add_sprite(0x90, 5, actor->x + 1 + 1, actor->y + 3);
explode_effect_add_sprite(0x90, 6, actor->x + 6, actor->y - 2);
explode_effect_add_sprite(0x90, 7, actor->x - 4, actor->y + 1);
actor_toss_add_new(0x52, actor->x + 4, actor->y);
}
U0 actor_wt_security_robot(ActorData *actor)
{
if(actor->count_down_timer != 0)
{
return;
}
actor->data_3 = Cond(actor->data_3, -1, 0) + 1;
if(actor->data_3 != 0)
{
return;
}
if(brightness_effect_enabled_flag != 0)
{
if(sub_1106F() % 0x32 > 0x30)
{
if(actor->data_4 == 0)
{
actor->data_4 = 10;
}
}
}
if(actor->data_4 != 0)
{
actor->data_2 = Cond(actor->data_2, -1, 0) + 1;
actor->data_4--;
if(actor->data_4 == 1)
{
if(actor->x + 1 <= player_x_pos)
{
actor->data_1 = 1;
}
else
{
actor->data_1 = 0;
}
if(actor->data_1 == 0)
{
actor_add_new(0x6d, actor->x - 1, actor->y - 1);
}
else
{
actor_add_new(0x6e, actor->x + 3, actor->y - 1);
}
}
if(actor->data_1 != 0)
{
if(actor->data_2 == 0)
{
actor->frame_num = 0;
}
else
{
actor->frame_num = 5;
}
return;
}
if(actor->data_2 == 0)
{
actor->frame_num = 2;
}
else
{
actor->frame_num = 6;
}
}
else
{
if(actor->data_1 == 0)
{
actor->x = actor->x - 1;
check_actor_move_left_or_right(actor, LEFT);
if(actor->has_moved_left_flag != 0)
{
actor->data_2 = Cond(actor->data_2, -1, 0) + 1;
actor->frame_num = actor->data_2 + 2;
}
else
{
actor->data_1 = 1;
actor->frame_num = 4;
}
return;
}
actor->x = actor->x + 1;
check_actor_move_left_or_right(actor, RIGHT);
if(actor->has_moved_right_flag != 0)
{
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
}
else
{
actor->data_1 = 0;
actor->frame_num = 4;
}
}
}
U0 actor_wt_short_dialog(ActorData *actor)
{
actor_tile_display_func_index = 1;
if(actor->data_2 == 0)
{
if(actor->y <= player_y_pos)
{
if(actor->y >= player_y_pos - 4)
{
end_game_dialog(actor->data_1);
actor->data_2 = 1;
}
}
}
}
U0 actor_wt_silver_robot(ActorData *actor)
{
actor_tile_display_func_index = 3;
if(actor->data_5 == 1)
{
actor_tile_display_func_index = 0;
}
if(actor->data_2 != 0)
{
actor->data_2--;
actor_tile_display_func_index = 0;
return;
}
if(actor->data_4 != 0)
{
actor->data_4--;
}
actor->data_3 = Cond(actor->data_3, -1, 0) + 1;
if(actor->data_1 == 0)
{
if(actor->y == player_y_pos)
{
if(actor->x - 3 == player_x_pos && actor->data_4 == 0)
{
actor->frame_num = 2;
actor->data_2 = 8;
push_player_around(7, 5, 2, 0x28, 0, 1);
play_sfx(0x14);
player_direction = 0x17;
actor->data_4 = 3;
actor_tile_display_func_index = 0;
if(word_2E238 == 0)
{
word_2E238 = 1;
actor_add_new(0xf5, player_x_pos - 1, player_y_pos - 5);
}
return;
}
}
if(actor->data_3 == 0)
{
return;
}
actor->x = actor->x - 1;
check_actor_move_left_or_right(actor, LEFT);
if(actor->has_moved_left_flag != 0)
{
actor->frame_num = Cond(actor->frame_num, -1, 0) + 1;
}
else
{
actor->data_1 = 1;
actor->frame_num = (actor->x & 1) + 3;
}
}
else
{
if(actor->y == player_y_pos)
{
if(actor->x + 4 == player_x_pos && actor->data_4 == 0)
{
actor->frame_num = 5;
actor->data_2 = 8;
push_player_around(3, 5, 2, 0x11, 0, 1);
play_sfx(0x14);
player_direction = 0;
actor->data_4 = 3;
actor_tile_display_func_index = 0;
if(word_2E238 == 0)
{
word_2E238 = 1;
actor_add_new(0xf5, player_x_pos - 1, player_y_pos - 5);
}
return;
}
}
if(actor->data_3 != 0)
{
actor->x++;