X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=0244e944d3d0f0d9644ef82a989ecd8b4be8cd14;hb=7373e992fb880976e1dc7c559bcd7a19b8bcfe80;hp=e28f068e467df5a93d88eb2f8f06fd53d67be701;hpb=891c39ca37c4fea5f6cc4ca40f913a56c68ef495;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index e28f068e..0244e944 100644 --- a/src/tools.c +++ b/src/tools.c @@ -529,6 +529,85 @@ void DrawLevelElementAnimationIfNeeded(int x, int y, int element) DrawLevelFieldCrumbledSand(x, y); } +static int getPlayerAction(struct PlayerInfo *player, int move_dir) +{ + int action = (player->is_pushing ? ACTION_PUSHING : + player->is_digging ? ACTION_DIGGING : + player->is_collecting ? ACTION_COLLECTING : + player->is_moving ? ACTION_MOVING : + player->is_snapping ? ACTION_SNAPPING : + player->is_sleeping ? ACTION_SLEEPING : + player->is_bored ? ACTION_BORING : + player->is_waiting ? ACTION_WAITING : ACTION_DEFAULT); + + if (player->is_sleeping) + { + if (player->num_special_action_sleeping > 0) + { + if (player->anim_delay_counter == 0 && player->post_delay_counter == 0) + { + int special_action = + ACTION_BORING_1 + SimpleRND(player->num_special_action_sleeping); + int special_graphic = + el_act_dir2img(player->element_nr, special_action, move_dir); + + player->anim_delay_counter = + graphic_info[special_graphic].anim_delay_fixed + + SimpleRND(graphic_info[special_graphic].anim_delay_random); + player->post_delay_counter = + graphic_info[special_graphic].post_delay_fixed + + SimpleRND(graphic_info[special_graphic].post_delay_random); + + player->special_action_sleeping = special_action; + } + + if (player->anim_delay_counter > 0) + { + action = player->special_action_sleeping; + player->anim_delay_counter--; + } + else if (player->post_delay_counter > 0) + { + player->post_delay_counter--; + } + } + } + else if (player->is_bored) + { + if (player->num_special_action_bored > 0) + { + if (player->anim_delay_counter == 0 && player->post_delay_counter == 0) + { + int special_action = + ACTION_BORING_1 + SimpleRND(player->num_special_action_bored); + int special_graphic = + el_act_dir2img(player->element_nr, special_action, move_dir); + + player->anim_delay_counter = + graphic_info[special_graphic].anim_delay_fixed + + SimpleRND(graphic_info[special_graphic].anim_delay_random); + player->post_delay_counter = + graphic_info[special_graphic].post_delay_fixed + + SimpleRND(graphic_info[special_graphic].post_delay_random); + + player->special_action_bored = special_action; + } + + if (player->anim_delay_counter > 0) + { + action = player->special_action_bored; + player->anim_delay_counter--; + } + else if (player->post_delay_counter > 0) + { + player->post_delay_counter--; + } + } + } + + return action; +} + static int getPlayerGraphic(struct PlayerInfo *player, int move_dir) { if (player->use_murphy_graphic) @@ -628,6 +707,12 @@ void DrawPlayer(struct PlayerInfo *player) if (element == EL_EXPLOSION) return; +#if 1 + + action = getPlayerAction(player, move_dir); + +#else + action = (player->is_pushing ? ACTION_PUSHING : player->is_digging ? ACTION_DIGGING : player->is_collecting ? ACTION_COLLECTING : @@ -637,10 +722,36 @@ void DrawPlayer(struct PlayerInfo *player) player->is_bored ? ACTION_BORING : player->is_waiting ? ACTION_WAITING : ACTION_DEFAULT); - if (player->is_bored || player->is_sleeping) + if (player->is_bored && player->num_special_action_bored > 0) { - /* ... */ + if (player->anim_delay_counter == 0 && player->post_delay_counter == 0) + { + int graphic_waiting; + + action = ACTION_BORING_1 + SimpleRND(player->num_special_action_bored); + special_graphic = el_act_dir2img(EL_SP_MURPHY, action, move_dir); + + player->anim_delay_counter = + graphic_info[special_graphic].anim_delay_fixed + + SimpleRND(graphic_info[special_graphic].anim_delay_random); + player->post_delay_counter = + graphic_info[special_graphic].post_delay_fixed + + SimpleRND(graphic_info[special_graphic].post_delay_random); + player->special_action_bored = action; + } + + if (player->anim_delay_counter > 0) + { + action = player->special_action_bored; + player->anim_delay_counter--; + } + + if (player->post_delay_counter > 0) + { + player->post_delay_counter--; + } } +#endif #if 0 printf("::: '%s'\n", element_action_info[action].suffix);