From d8b2b3542a70175f1fcd3fbca19149b88ce4bbf1 Mon Sep 17 00:00:00 2001 From: NyakoFox Date: Sun, 25 Aug 2024 20:19:07 -0300 Subject: [PATCH] Add enemy speed as a room property Currently, you can change platform speed, but not enemy speed, which is always hardcoded to be 4. This commit fixes that, by adding the "enemyv" property, which is an offset to the speed of 4. Since it defaults to 0, older levels are not broken by this change. --- desktop_version/lang/ar/strings.xml | 1 + desktop_version/lang/ca/strings.xml | 1 + desktop_version/lang/cy/strings.xml | 1 + desktop_version/lang/de/strings.xml | 1 + desktop_version/lang/en/strings.xml | 1 + desktop_version/lang/eo/strings.xml | 1 + desktop_version/lang/es/strings.xml | 1 + desktop_version/lang/es_419/strings.xml | 1 + desktop_version/lang/es_AR/strings.xml | 1 + desktop_version/lang/fr/strings.xml | 1 + desktop_version/lang/ga/strings.xml | 1 + desktop_version/lang/it/strings.xml | 1 + desktop_version/lang/ja/strings.xml | 1 + desktop_version/lang/ko/strings.xml | 1 + desktop_version/lang/nl/strings.xml | 1 + desktop_version/lang/pl/strings.xml | 1 + desktop_version/lang/pt_BR/strings.xml | 1 + desktop_version/lang/pt_PT/strings.xml | 1 + desktop_version/lang/ru/strings.xml | 1 + desktop_version/lang/szl/strings.xml | 1 + desktop_version/lang/tr/strings.xml | 1 + desktop_version/lang/uk/strings.xml | 1 + desktop_version/lang/zh/strings.xml | 1 + desktop_version/lang/zh_TW/strings.xml | 1 + desktop_version/src/CustomLevels.cpp | 4 +++ desktop_version/src/CustomLevels.h | 1 + desktop_version/src/Editor.cpp | 37 ++++++++++++++++++++++--- desktop_version/src/Map.cpp | 2 +- 28 files changed, 63 insertions(+), 5 deletions(-) diff --git a/desktop_version/lang/ar/strings.xml b/desktop_version/lang/ar/strings.xml index dc4ab172..3788d484 100644 --- a/desktop_version/lang/ar/strings.xml +++ b/desktop_version/lang/ar/strings.xml @@ -630,6 +630,7 @@ + diff --git a/desktop_version/lang/ca/strings.xml b/desktop_version/lang/ca/strings.xml index 9067a50d..9e4d58ed 100644 --- a/desktop_version/lang/ca/strings.xml +++ b/desktop_version/lang/ca/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/cy/strings.xml b/desktop_version/lang/cy/strings.xml index 75233e0a..3db5fbab 100644 --- a/desktop_version/lang/cy/strings.xml +++ b/desktop_version/lang/cy/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/de/strings.xml b/desktop_version/lang/de/strings.xml index 8bc440f8..d08033a4 100644 --- a/desktop_version/lang/de/strings.xml +++ b/desktop_version/lang/de/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/en/strings.xml b/desktop_version/lang/en/strings.xml index 86a4217f..5ce4803b 100644 --- a/desktop_version/lang/en/strings.xml +++ b/desktop_version/lang/en/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/eo/strings.xml b/desktop_version/lang/eo/strings.xml index 6c085043..4884154b 100644 --- a/desktop_version/lang/eo/strings.xml +++ b/desktop_version/lang/eo/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/es/strings.xml b/desktop_version/lang/es/strings.xml index 68c8a246..493b2b1e 100644 --- a/desktop_version/lang/es/strings.xml +++ b/desktop_version/lang/es/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/es_419/strings.xml b/desktop_version/lang/es_419/strings.xml index 827a3b97..ea50cfc3 100644 --- a/desktop_version/lang/es_419/strings.xml +++ b/desktop_version/lang/es_419/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/es_AR/strings.xml b/desktop_version/lang/es_AR/strings.xml index e2cdc457..ff360450 100644 --- a/desktop_version/lang/es_AR/strings.xml +++ b/desktop_version/lang/es_AR/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/fr/strings.xml b/desktop_version/lang/fr/strings.xml index 411cc564..f074c748 100644 --- a/desktop_version/lang/fr/strings.xml +++ b/desktop_version/lang/fr/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/ga/strings.xml b/desktop_version/lang/ga/strings.xml index cbdf9987..07168eb3 100644 --- a/desktop_version/lang/ga/strings.xml +++ b/desktop_version/lang/ga/strings.xml @@ -624,6 +624,7 @@ Déan cóip chúltaca, ar eagla na heagla." explanation="translation maintenance + diff --git a/desktop_version/lang/it/strings.xml b/desktop_version/lang/it/strings.xml index f4798b2b..ca6cf2b3 100644 --- a/desktop_version/lang/it/strings.xml +++ b/desktop_version/lang/it/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/ja/strings.xml b/desktop_version/lang/ja/strings.xml index f7fe0042..b1cdf6ac 100644 --- a/desktop_version/lang/ja/strings.xml +++ b/desktop_version/lang/ja/strings.xml @@ -658,6 +658,7 @@ Steam Deckには対応していません。" explanation="" max="38*5" max_local + diff --git a/desktop_version/lang/ko/strings.xml b/desktop_version/lang/ko/strings.xml index e7b69f1f..443fc638 100755 --- a/desktop_version/lang/ko/strings.xml +++ b/desktop_version/lang/ko/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/nl/strings.xml b/desktop_version/lang/nl/strings.xml index 6d1aeebc..10935c08 100644 --- a/desktop_version/lang/nl/strings.xml +++ b/desktop_version/lang/nl/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/pl/strings.xml b/desktop_version/lang/pl/strings.xml index 059bd1ed..5a41019d 100644 --- a/desktop_version/lang/pl/strings.xml +++ b/desktop_version/lang/pl/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/pt_BR/strings.xml b/desktop_version/lang/pt_BR/strings.xml index 0d084ab8..7d361b27 100644 --- a/desktop_version/lang/pt_BR/strings.xml +++ b/desktop_version/lang/pt_BR/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/pt_PT/strings.xml b/desktop_version/lang/pt_PT/strings.xml index 3d24a84f..76b74963 100644 --- a/desktop_version/lang/pt_PT/strings.xml +++ b/desktop_version/lang/pt_PT/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/ru/strings.xml b/desktop_version/lang/ru/strings.xml index 04c6476b..c09caf4b 100644 --- a/desktop_version/lang/ru/strings.xml +++ b/desktop_version/lang/ru/strings.xml @@ -647,6 +647,7 @@ + diff --git a/desktop_version/lang/szl/strings.xml b/desktop_version/lang/szl/strings.xml index 3eadda25..688ad9f8 100644 --- a/desktop_version/lang/szl/strings.xml +++ b/desktop_version/lang/szl/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/tr/strings.xml b/desktop_version/lang/tr/strings.xml index c7cfdf82..681feb6d 100644 --- a/desktop_version/lang/tr/strings.xml +++ b/desktop_version/lang/tr/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/uk/strings.xml b/desktop_version/lang/uk/strings.xml index dbfc81a9..fb6ae76d 100644 --- a/desktop_version/lang/uk/strings.xml +++ b/desktop_version/lang/uk/strings.xml @@ -622,6 +622,7 @@ + diff --git a/desktop_version/lang/zh/strings.xml b/desktop_version/lang/zh/strings.xml index d437c5ba..403405d7 100644 --- a/desktop_version/lang/zh/strings.xml +++ b/desktop_version/lang/zh/strings.xml @@ -632,6 +632,7 @@ + diff --git a/desktop_version/lang/zh_TW/strings.xml b/desktop_version/lang/zh_TW/strings.xml index 157c0cba..d78acc4b 100644 --- a/desktop_version/lang/zh_TW/strings.xml +++ b/desktop_version/lang/zh_TW/strings.xml @@ -632,6 +632,7 @@ + diff --git a/desktop_version/src/CustomLevels.cpp b/desktop_version/src/CustomLevels.cpp index 704bed37..347bff9a 100644 --- a/desktop_version/src/CustomLevels.cpp +++ b/desktop_version/src/CustomLevels.cpp @@ -57,6 +57,7 @@ RoomProperty::RoomProperty(void) enemyx2=320; enemyy2=240; enemytype=0; + enemyv=0; directmode=0; } @@ -389,6 +390,7 @@ void customlevelclass::reset(void) roomproperties[i+(j*maxwidth)].enemyx2=320; roomproperties[i+(j*maxwidth)].enemyy2=240; roomproperties[i+(j*maxwidth)].enemytype=0; + roomproperties[i+(j*maxwidth)].enemyv=0; roomproperties[i+(j*maxwidth)].directmode=0; } } @@ -1264,6 +1266,7 @@ bool customlevelclass::load(std::string _path) edLevelClassElement->QueryIntAttribute("enemyx2", &roomproperties[i].enemyx2); edLevelClassElement->QueryIntAttribute("enemyy2", &roomproperties[i].enemyy2); edLevelClassElement->QueryIntAttribute("enemytype", &roomproperties[i].enemytype); + edLevelClassElement->QueryIntAttribute("enemyv", &roomproperties[i].enemyv); edLevelClassElement->QueryIntAttribute("directmode", &roomproperties[i].directmode); edLevelClassElement->QueryIntAttribute("warpdir", &roomproperties[i].warpdir); @@ -1645,6 +1648,7 @@ bool customlevelclass::save(const std::string& _path) roompropertyElement->SetAttribute( "enemyx2", roomproperties[i].enemyx2); roompropertyElement->SetAttribute( "enemyy2", roomproperties[i].enemyy2); roompropertyElement->SetAttribute( "enemytype", roomproperties[i].enemytype); + roompropertyElement->SetAttribute( "enemyv", roomproperties[i].enemyv); roompropertyElement->SetAttribute( "directmode", roomproperties[i].directmode); roompropertyElement->SetAttribute( "warpdir", roomproperties[i].warpdir); diff --git a/desktop_version/src/CustomLevels.h b/desktop_version/src/CustomLevels.h index 97e3448d..b728d412 100644 --- a/desktop_version/src/CustomLevels.h +++ b/desktop_version/src/CustomLevels.h @@ -31,6 +31,7 @@ public: FOREACH_PROP(enemyx2, int) \ FOREACH_PROP(enemyy2, int) \ FOREACH_PROP(enemytype, int) \ + FOREACH_PROP(enemyv, int) \ FOREACH_PROP(directmode, int) class RoomProperty diff --git a/desktop_version/src/Editor.cpp b/desktop_version/src/Editor.cpp index 322510bf..2a04509e 100644 --- a/desktop_version/src/Editor.cpp +++ b/desktop_version/src/Editor.cpp @@ -3096,12 +3096,22 @@ static void handle_draw_input() const int room = ed.levx + ed.levy * cl.maxwidth; const int plat_speed = cl.roomproperties[room].platv; + const int enemy_speed = cl.roomproperties[room].enemyv; + const bool ctrl = key.keymap[SDLK_LCTRL] || key.keymap[SDLK_RCTRL]; + const bool shift = key.keymap[SDLK_LSHIFT] || key.keymap[SDLK_RSHIFT]; if (key.keymap[SDLK_COMMA]) { - if (key.keymap[SDLK_LCTRL] || key.keymap[SDLK_RCTRL]) + if (ctrl) { - cl.roomproperties[room].platv = plat_speed - 1; + if (shift) + { + cl.roomproperties[room].enemyv = enemy_speed - 1; + } + else + { + cl.roomproperties[room].platv = plat_speed - 1; + } } else { @@ -3111,9 +3121,16 @@ static void handle_draw_input() } else if (key.keymap[SDLK_PERIOD]) { - if (key.keymap[SDLK_LCTRL] || key.keymap[SDLK_RCTRL]) + if (ctrl) { - cl.roomproperties[room].platv = plat_speed + 1; + if (shift) + { + cl.roomproperties[room].enemyv = enemy_speed + 1; + } + else + { + cl.roomproperties[room].platv = plat_speed + 1; + } } else { @@ -3134,6 +3151,18 @@ static void handle_draw_input() ed.show_note(buffer); } + if (enemy_speed != cl.roomproperties[room].enemyv) + { + char buffer[3 * SCREEN_WIDTH_CHARS + 1]; + vformat_buf( + buffer, sizeof(buffer), + loc::gettext("Enemy speed is now {speed}"), + "speed:int", + cl.roomproperties[room].enemyv + 4 + ); + ed.show_note(buffer); + } + if (key.keymap[SDLK_SPACE]) { ed.toolbox_open = !ed.toolbox_open; diff --git a/desktop_version/src/Map.cpp b/desktop_version/src/Map.cpp index 747ebc38..ee7a904f 100644 --- a/desktop_version/src/Map.cpp +++ b/desktop_version/src/Map.cpp @@ -1850,7 +1850,7 @@ void mapclass::loadlevel(int rx, int ry) { case 1: // Enemies obj.customenemy = room->enemytype; - obj.createentity(ex, ey, 56, ent.p1, 4, bx1, by1, bx2, by2); + obj.createentity(ex, ey, 56, ent.p1, 4 + room->enemyv, bx1, by1, bx2, by2); break; case 2: // Platforms and conveyors if (ent.p1 <= 4)