From: Holger Schemel Date: Mon, 24 Nov 2003 23:46:03 +0000 (+0100) Subject: rnd-20031125-1-src X-Git-Tag: 3.0.8^2~17 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7373e992fb880976e1dc7c559bcd7a19b8bcfe80;p=rocksndiamonds.git rnd-20031125-1-src --- diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 1bca3da1..412c52d5 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -3708,10 +3708,10 @@ struct ConfigInfo image_config[] = { "door_2.step_delay", "10" }, { "door_2.anim_mode", "default" }, - { "[player].boring_delay_fixed", "0" }, - { "[player].boring_delay_random", "0" }, - { "[player].sleeping_delay_fixed", "0" }, - { "[player].sleeping_delay_random", "0" }, + { "[player].boring_delay_fixed", "-1" }, + { "[player].boring_delay_random", "-1" }, + { "[player].sleeping_delay_fixed", "-1" }, + { "[player].sleeping_delay_random", "-1" }, { NULL, NULL } }; diff --git a/src/conftime.h b/src/conftime.h index 9f4d9c1a..c2a8e58e 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-11-24 02:22]" +#define COMPILE_DATE_STRING "[2003-11-25 00:01]" diff --git a/src/game.c b/src/game.c index 3e8a721b..f5558fdb 100644 --- a/src/game.c +++ b/src/game.c @@ -993,7 +993,7 @@ void InitGame() boolean emulate_bd = TRUE; /* unless non-BOULDERDASH elements found */ boolean emulate_sb = TRUE; /* unless non-SOKOBAN elements found */ boolean emulate_sp = TRUE; /* unless non-SUPAPLEX elements found */ - int i, j, x, y; + int i, j, k, x, y; InitGameEngine(); @@ -1010,7 +1010,7 @@ void InitGame() /* don't play tapes over network */ network_playing = (options.network && !tape.playing); - for (i=0; ilights_still_needed = 0; player->friends_still_needed = 0; - for (j=0; j<4; j++) + for (j=0; j < 4; j++) player->key[j] = FALSE; player->dynabomb_count = 0; @@ -1066,6 +1066,45 @@ void InitGame() player->frame_counter_bored = -1; player->frame_counter_sleeping = -1; + player->anim_delay_counter = 0; + player->post_delay_counter = 0; + + player->special_action_bored = ACTION_DEFAULT; + player->special_action_sleeping = ACTION_DEFAULT; + + player->num_special_action_bored = 0; + player->num_special_action_sleeping = 0; + + /* determine number of special actions for bored and sleeping animation */ + for (j=ACTION_BORING_1; j <= ACTION_BORING_8; j++) + { + boolean found = FALSE; + + for (k=0; k < NUM_DIRECTIONS; k++) + if (el_act_dir2img(player->element_nr, j, k) != + el_act_dir2img(player->element_nr, ACTION_DEFAULT, k)) + found = TRUE; + + if (found) + player->num_special_action_bored++; + else + break; + } + for (j=ACTION_SLEEPING_1; j <= ACTION_SLEEPING_3; j++) + { + boolean found = FALSE; + + for (k=0; k < NUM_DIRECTIONS; k++) + if (el_act_dir2img(player->element_nr, j, k) != + el_act_dir2img(player->element_nr, ACTION_DEFAULT, k)) + found = TRUE; + + if (found) + player->num_special_action_sleeping++; + else + break; + } + player->switch_x = -1; player->switch_y = -1; @@ -5964,25 +6003,29 @@ static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting) if (!was_waiting) /* not waiting -> waiting */ { player->is_waiting = TRUE; - player->is_bored = FALSE; - player->is_sleeping = FALSE; player->frame_counter_bored = - (FrameCounter + - game.player_boring_delay_fixed + - SimpleRND(game.player_boring_delay_random)); + FrameCounter + + game.player_boring_delay_fixed + + SimpleRND(game.player_boring_delay_random); player->frame_counter_sleeping = - (FrameCounter + - game.player_sleeping_delay_fixed + - SimpleRND(game.player_sleeping_delay_random)); + FrameCounter + + game.player_sleeping_delay_fixed + + SimpleRND(game.player_sleeping_delay_random); InitPlayerGfxAnimation(player, ACTION_WAITING, player->MovDir); } - if (FrameCounter >= player->frame_counter_bored) - player->is_bored = TRUE; - if (FrameCounter >= player->frame_counter_sleeping) + if (game.player_sleeping_delay_fixed != -1 && + game.player_sleeping_delay_random != -1 && + player->anim_delay_counter == 0 && + player->post_delay_counter == 0 && + FrameCounter >= player->frame_counter_sleeping) player->is_sleeping = TRUE; + else if (game.player_boring_delay_fixed != -1 && + game.player_boring_delay_random != -1 && + FrameCounter >= player->frame_counter_bored) + player->is_bored = TRUE; action = (player->is_sleeping ? ACTION_SLEEPING : player->is_bored ? ACTION_BORING : ACTION_WAITING); @@ -6000,6 +6043,9 @@ static void SetPlayerWaiting(struct PlayerInfo *player, boolean is_waiting) player->frame_counter_bored = -1; player->frame_counter_sleeping = -1; + + player->anim_delay_counter = 0; + player->post_delay_counter = 0; } } diff --git a/src/init.c b/src/init.c index 2f5bd60d..0e7680a4 100644 --- a/src/init.c +++ b/src/init.c @@ -930,13 +930,13 @@ static void set_graphic_parameters(int graphic, char **parameter_raw) graphic_info[graphic].anim_delay_fixed = parameter[GFX_ARG_ANIM_DELAY_FIXED]; if (parameter[GFX_ARG_ANIM_DELAY_RANDOM] != ARG_UNDEFINED_VALUE) - graphic_info[graphic].anim_delay_fixed = + graphic_info[graphic].anim_delay_random = parameter[GFX_ARG_ANIM_DELAY_RANDOM]; if (parameter[GFX_ARG_POST_DELAY_FIXED] != ARG_UNDEFINED_VALUE) - graphic_info[graphic].anim_delay_fixed = + graphic_info[graphic].post_delay_fixed = parameter[GFX_ARG_POST_DELAY_FIXED]; if (parameter[GFX_ARG_POST_DELAY_RANDOM] != ARG_UNDEFINED_VALUE) - graphic_info[graphic].anim_delay_fixed = + graphic_info[graphic].post_delay_random = parameter[GFX_ARG_POST_DELAY_RANDOM]; /* this is only used for toon animations */ diff --git a/src/main.c b/src/main.c index ee4271d0..f2251073 100644 --- a/src/main.c +++ b/src/main.c @@ -3714,18 +3714,18 @@ struct ElementActionInfo element_action_info[NUM_ACTIONS + 1 + 1] = { ".changing", ACTION_CHANGING, FALSE }, { ".exploding", ACTION_EXPLODING, FALSE }, { ".boring", ACTION_BORING, FALSE }, - { ".boring:1", ACTION_BORING_1, FALSE }, - { ".boring:2", ACTION_BORING_2, FALSE }, - { ".boring:3", ACTION_BORING_3, FALSE }, - { ".boring:4", ACTION_BORING_4, FALSE }, - { ".boring:5", ACTION_BORING_5, FALSE }, - { ".boring:6", ACTION_BORING_6, FALSE }, - { ".boring:7", ACTION_BORING_7, FALSE }, - { ".boring:8", ACTION_BORING_8, FALSE }, + { ".boring[1]", ACTION_BORING_1, FALSE }, + { ".boring[2]", ACTION_BORING_2, FALSE }, + { ".boring[3]", ACTION_BORING_3, FALSE }, + { ".boring[4]", ACTION_BORING_4, FALSE }, + { ".boring[5]", ACTION_BORING_5, FALSE }, + { ".boring[6]", ACTION_BORING_6, FALSE }, + { ".boring[7]", ACTION_BORING_7, FALSE }, + { ".boring[8]", ACTION_BORING_8, FALSE }, { ".sleeping", ACTION_SLEEPING, FALSE }, - { ".sleeping:1", ACTION_SLEEPING_1, FALSE }, - { ".sleeping:2", ACTION_SLEEPING_2, FALSE }, - { ".sleeping:3", ACTION_SLEEPING_3, FALSE }, + { ".sleeping[1]", ACTION_SLEEPING_1, FALSE }, + { ".sleeping[2]", ACTION_SLEEPING_2, FALSE }, + { ".sleeping[3]", ACTION_SLEEPING_3, FALSE }, { ".dying", ACTION_DYING, FALSE }, { ".turning", ACTION_TURNING, FALSE }, { ".turning_from_left", ACTION_TURNING_FROM_LEFT, FALSE }, diff --git a/src/main.h b/src/main.h index 3c6527ab..fac1302f 100644 --- a/src/main.h +++ b/src/main.h @@ -1199,6 +1199,15 @@ struct PlayerInfo int frame_counter_bored; int frame_counter_sleeping; + int anim_delay_counter; + int post_delay_counter; + + int special_action_bored; + int special_action_sleeping; + + int num_special_action_bored; + int num_special_action_sleeping; + int switch_x, switch_y; int show_envelope; 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);