rnd-20031125-1-src
authorHolger Schemel <info@artsoft.org>
Mon, 24 Nov 2003 23:46:03 +0000 (00:46 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:44:43 +0000 (10:44 +0200)
src/conf_gfx.c
src/conftime.h
src/game.c
src/init.c
src/main.c
src/main.h
src/tools.c

index 1bca3da12807cd569b8432c09aa40f928b9ce795..412c52d51263bd98e958474db29b414cdfb107fc 100644 (file)
@@ -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                    }
 };
index 9f4d9c1a3589353fded2393a4d9dd333c84f5a76..c2a8e58e76cb088dede9a33740a2893ef8f75dcd 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2003-11-24 02:22]"
+#define COMPILE_DATE_STRING "[2003-11-25 00:01]"
index 3e8a721b7fc743ea31aade60c3f63ab0322a3e1f..f5558fdb57e8ea0a87f7975c8650490102cce5bb 100644 (file)
@@ -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; i<MAX_PLAYERS; i++)
+  for (i=0; i < MAX_PLAYERS; i++)
   {
     struct PlayerInfo *player = &stored_player[i];
 
@@ -1030,7 +1030,7 @@ void InitGame()
     player->lights_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;
   }
 }
 
index 2f5bd60df686df939d9cff8bf9a4ef1a9c89fe72..0e7680a4a4aec84111ebecedcd47c10f3008ceb9 100644 (file)
@@ -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 */
index ee4271d03637f58437856246fb5adea172431cc2..f2251073255f878e9129a96419995488c5c28ef6 100644 (file)
@@ -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   },
index 3c6527ab01c3abd652178e794e2b6822445df9fa..fac1302f60cd1282f81d2c742e75a2f7ca95583e 100644 (file)
@@ -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;
index e28f068e467df5a93d88eb2f8f06fd53d67be701..0244e944d3d0f0d9644ef82a989ecd8b4be8cd14 100644 (file)
@@ -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);