fixed element scores for MM style elements (MM engine)
authorHolger Schemel <info@artsoft.org>
Wed, 10 May 2017 15:53:29 +0000 (17:53 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 23 Mar 2018 22:21:13 +0000 (23:21 +0100)
src/editor.c
src/files.c
src/game_mm/mm_files.c
src/game_mm/mm_game.c
src/game_mm/mm_game.h
src/game_mm/mm_main.h
src/main.h

index 8a093cbc9c3eabed7d85dc32c52f34f0528a76f6..92b35d0f5f4f135fd8536dc2288bca9f7eb27a4e 100644 (file)
@@ -9195,6 +9195,15 @@ static struct
   { EL_EMC_KEY_7,      &level.score[SC_KEY],           TEXT_COLLECTING },
   { EL_EMC_KEY_8,      &level.score[SC_KEY],           TEXT_COLLECTING },
   { EL_DC_KEY_WHITE,   &level.score[SC_KEY],           TEXT_COLLECTING },
+  { EL_MM_KETTLE,      &level.score[SC_EMERALD],       TEXT_COLLECTING },
+  { EL_DF_CELL,                &level.score[SC_EMERALD],       TEXT_COLLECTING },
+  { EL_MM_KEY,         &level.score[SC_KEY],           TEXT_COLLECTING },
+  { EL_MM_LIGHTBALL,   &level.score[SC_ELEM_BONUS],    TEXT_COLLECTING },
+  { EL_MM_PACMAN,      &level.score[SC_PACMAN],        TEXT_SMASHING   },
+  { EL_MM_PACMAN_RIGHT,        &level.score[SC_PACMAN],        TEXT_SMASHING   },
+  { EL_MM_PACMAN_UP,   &level.score[SC_PACMAN],        TEXT_SMASHING   },
+  { EL_MM_PACMAN_LEFT, &level.score[SC_PACMAN],        TEXT_SMASHING   },
+  { EL_MM_PACMAN_DOWN, &level.score[SC_PACMAN],        TEXT_SMASHING   },
   { EL_AMOEBA_WET,     &level.amoeba_speed,            TEXT_AMOEBA_SPEED },
   { EL_AMOEBA_DRY,     &level.amoeba_speed,            TEXT_AMOEBA_SPEED },
   { EL_AMOEBA_FULL,    &level.amoeba_speed,            TEXT_AMOEBA_SPEED },
index 649bf1b746fa1e4ed143bb2022afdc65586e1a0b..d42a2cd55e9effbcbdbb942dd06a167749b9354c 100644 (file)
@@ -843,17 +843,17 @@ static struct LevelFileConfigInfo chunk_config_ELEM[] =
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
     &li.mm_time_fuse,                  0
   },
+  {
+    EL_MM_LIGHTBALL,                   -1,
+    TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
+    &li.score[SC_ELEM_BONUS],          10
+  },
 
   /* ---------- unused values ----------------------------------------------- */
 
   {
     EL_UNKNOWN,                                SAVE_CONF_NEVER,
     TYPE_INTEGER,                      CONF_VALUE_16_BIT(1),
-    &li.score[SC_UNKNOWN_14],          10
-  },
-  {
-    EL_UNKNOWN,                                SAVE_CONF_NEVER,
-    TYPE_INTEGER,                      CONF_VALUE_16_BIT(2),
     &li.score[SC_UNKNOWN_15],          10
   },
 
@@ -3990,9 +3990,11 @@ void CopyNativeLevel_RND_to_MM(struct LevelInfo *level)
   strcpy(level_mm->name, level->name);
   strcpy(level_mm->author, level->author);
 
+  level_mm->score[SC_EMERALD]    = level->score[SC_EMERALD];
   level_mm->score[SC_PACMAN]     = level->score[SC_PACMAN];
   level_mm->score[SC_KEY]        = level->score[SC_KEY];
   level_mm->score[SC_TIME_BONUS] = level->score[SC_TIME_BONUS];
+  level_mm->score[SC_ELEM_BONUS] = level->score[SC_ELEM_BONUS];
 
   level_mm->amoeba_speed = level->amoeba_speed;
   level_mm->time_fuse = level->mm_time_fuse;
@@ -4025,9 +4027,11 @@ void CopyNativeLevel_MM_to_RND(struct LevelInfo *level)
   if (!strEqual(level_mm->author, ANONYMOUS_NAME))
     strcpy(level->author, level_mm->author);
 
+  level->score[SC_EMERALD]    = level_mm->score[SC_EMERALD];
   level->score[SC_PACMAN]     = level_mm->score[SC_PACMAN];
   level->score[SC_KEY]        = level_mm->score[SC_KEY];
   level->score[SC_TIME_BONUS] = level_mm->score[SC_TIME_BONUS];
+  level->score[SC_ELEM_BONUS] = level_mm->score[SC_ELEM_BONUS];
 
   level->amoeba_speed = level_mm->amoeba_speed;
   level->mm_time_fuse = level_mm->time_fuse;
index 8e6a72bdf761cee3e3ff78b75fd40c95c638765c..0b88735ec920e8bcac421222359fdc7bf4882ec6 100644 (file)
 #define SCORE_COOKIE           "MIRRORMAGIC_SCORE_FILE_VERSION_1.4"
 
 
+int default_score[LEVEL_SCORE_ELEMENTS] =
+{
+  [SC_COLLECTIBLE]     = 10,
+  [SC_PACMAN]          = 50,
+  [SC_KEY]             = 10,
+  [SC_TIME_BONUS]      = 1,
+  [SC_LIGHTBALL]       = 10,
+};
+
+
 /* ========================================================================= */
 /* level file functions                                                      */
 /* ========================================================================= */
@@ -162,6 +172,12 @@ static int LoadLevel_MM_HEAD(File *file, int chunk_size,
   for (i = 0; i < LEVEL_SCORE_ELEMENTS; i++)
     level->score[i] = getFile8Bit(file);
 
+  // scores were 0 and hardcoded in game engine in level files up to 2.0.x
+  if (level->file_version <= MM_FILE_VERSION_2_0)
+    for (i = 0; i < LEVEL_SCORE_ELEMENTS; i++)
+      if (level->score[i] == 0)
+       level->score[i] = default_score[i];
+
   level->auto_count_kettles    = (getFile8Bit(file) == 1 ? TRUE : FALSE);
   level->amoeba_speed          = getFile8Bit(file);
   level->time_fuse             = getFile8Bit(file);
index 8d9743c6df6fc5cdfec7c9ad9cd54f511d38781f..e2a2e5f8745093c0387e208640e44a1128d6c26f 100644 (file)
@@ -92,6 +92,7 @@
 static int MovingOrBlocked2Element_MM(int, int);
 static void Bang_MM(int, int);
 static void RaiseScore_MM(int);
+static void RaiseScoreElement_MM(int);
 static void RemoveMovingField_MM(int, int);
 static void InitMovingField_MM(int, int, int);
 static void ContinueMoving_MM(int, int);
@@ -1527,8 +1528,6 @@ boolean HitElement(int element, int hit_mask)
       if (game_mm.kettles_still_needed > 0)
        game_mm.kettles_still_needed--;
 
-      RaiseScore_MM(10);
-
       if (game_mm.kettles_still_needed == 0)
       {
        CheckExitMM();
@@ -1540,16 +1539,13 @@ boolean HitElement(int element, int hit_mask)
     {
       game_mm.num_keys++;
     }
-    else if (element == EL_LIGHTBALL)
-    {
-      RaiseScore_MM(10);
-    }
     else if (IS_PACMAN(element))
     {
       DeletePacMan(ELX, ELY);
-      RaiseScore_MM(50);
     }
 
+    RaiseScoreElement_MM(element);
+
     return FALSE;
   }
 
@@ -2821,7 +2817,7 @@ void ClickElement(int x, int y, int button)
   else if (element == EL_LIGHTBALL)
   {
     Bang_MM(x, y);
-    RaiseScore_MM(10);
+    RaiseScoreElement_MM(element);
     DrawLaser(0, DL_LASER_ENABLED);
   }
 
@@ -3893,7 +3889,7 @@ void GameWon_MM()
       if (!setup.sound_loops)
        PlaySoundStereo(SND_SIRR, SOUND_MAX_RIGHT);
       if (TimePlayed < 999 && !(TimePlayed % 10))
-       RaiseScore_MM(native_mm_level.score[SC_ZEITBONUS]);
+       RaiseScore_MM(native_mm_level.score[SC_TIME_BONUS]);
       if (TimePlayed < 900 && !(TimePlayed % 10))
        TimePlayed += 10;
       else
@@ -4162,6 +4158,10 @@ void RaiseScoreElement_MM(int element)
   switch(element)
   {
     case EL_PACMAN:
+    case EL_PACMAN_RIGHT:
+    case EL_PACMAN_UP:
+    case EL_PACMAN_LEFT:
+    case EL_PACMAN_DOWN:
       RaiseScore_MM(native_mm_level.score[SC_PACMAN]);
       break;
 
@@ -4169,6 +4169,15 @@ void RaiseScoreElement_MM(int element)
       RaiseScore_MM(native_mm_level.score[SC_KEY]);
       break;
 
+    case EL_KETTLE:
+    case EL_CELL:
+      RaiseScore_MM(native_mm_level.score[SC_COLLECTIBLE]);
+      break;
+
+    case EL_LIGHTBALL:
+      RaiseScore_MM(native_mm_level.score[SC_LIGHTBALL]);
+      break;
+
     default:
       break;
   }
index 845968207026ad82822f777f53b4c4c90838a3aa..682d8aabcbdfa1873ba574ea0fb5dceeab67c220 100644 (file)
 #include "main_mm.h"
 
 
-/* score for elements (also used by editor.c) */
-#define SC_EDELSTEIN           0
-#define SC_DIAMANT             1
-#define SC_KAEFER              2
-#define SC_FLIEGER             3
-#define SC_MAMPFER             4
-#define SC_ROBOT               5
-#define SC_PACMAN              6
-#define SC_KOKOSNUSS           7
-#define SC_DYNAMIT             8
-#define SC_KEY                 9
-#define SC_ZEITBONUS           10
-
-
 void InitAmoebaNr(int, int);
 void GameWon_MM(void);
 int NewHiScore_MM(void);
index 7688cca13c79394056f22fd9451d0ea608dd9c7b..3322a57e5d0b447307338ed3f0efe82d07fc1adf 100644 (file)
 #define MAX_SCORE_ENTRIES      100
 #define MAX_ELEMENTS           700             /* 500 static + 200 runtime */
 
-#define LEVEL_SCORE_ELEMENTS   16      /* level elements with score */
-
 #define MICROLEVEL_SCROLL_DELAY        50      /* delay for scrolling micro level */
 #define MICROLEVEL_LABEL_DELAY 250     /* delay for micro level label */
 
+/* score for elements */
+#define SC_COLLECTIBLE         0
+#define SC_UNUSED_1            1
+#define SC_UNUSED_2            2
+#define SC_UNUSED_3            3
+#define SC_UNUSED_4            4
+#define SC_UNUSED_5            5
+#define SC_PACMAN              6
+#define SC_UNUSED_7            7
+#define SC_UNUSED_8            8
+#define SC_KEY                 9
+#define SC_TIME_BONUS          10
+#define SC_UNUSED_11           11
+#define SC_UNUSED_12           12
+#define SC_UNUSED_13           13
+#define SC_LIGHTBALL           14
+#define SC_UNUSED_15           15
+
+#define LEVEL_SCORE_ELEMENTS   16      /* level elements with score */
+
+
 struct HiScore_MM
 {
   char Name[MAX_PLAYER_NAME_LEN + 1];
index b84872de4d24db49432b0e830747e95ff2c6e341..da76f7df76c26d96fc22ea35d9db4d97e2300635 100644 (file)
 #define SC_CRYSTAL             11
 #define SC_PEARL               12
 #define SC_SHIELD              13
-#define SC_UNKNOWN_14          14
+#define SC_ELEM_BONUS          14
 #define SC_UNKNOWN_15          15
 
 #define LEVEL_SCORE_ELEMENTS   16      /* level elements with score */