aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-01-29 08:42:31 -0500
committerPaul Gilbert2015-01-29 08:42:31 -0500
commitbe327cb7672652a44294a13b9fa4215ae6358b6a (patch)
tree95ac1eb0f12553925d4a4a649be5280ea65f8df8
parente34429207c9d632a1f72680a08409992e81d95a5 (diff)
downloadscummvm-rg350-be327cb7672652a44294a13b9fa4215ae6358b6a.tar.gz
scummvm-rg350-be327cb7672652a44294a13b9fa4215ae6358b6a.tar.bz2
scummvm-rg350-be327cb7672652a44294a13b9fa4215ae6358b6a.zip
XEEN: Implemented setSpellText for spells dialog
-rw-r--r--engines/xeen/module.mk1
-rw-r--r--engines/xeen/party.cpp7
-rw-r--r--engines/xeen/party.h2
-rw-r--r--engines/xeen/resources.cpp70
-rw-r--r--engines/xeen/resources.h18
-rw-r--r--engines/xeen/spells.cpp12
-rw-r--r--engines/xeen/spells.h7
-rw-r--r--engines/xeen/town.cpp12
-rw-r--r--engines/xeen/town.h2
9 files changed, 117 insertions, 14 deletions
diff --git a/engines/xeen/module.mk b/engines/xeen/module.mk
index c361c472cf..9d252b14c2 100644
--- a/engines/xeen/module.mk
+++ b/engines/xeen/module.mk
@@ -11,6 +11,7 @@ MODULE_OBJS := \
dialogs_error.o \
dialogs_options.o \
dialogs_input.o \
+ dialogs_spells.o \
dialogs_whowill.o \
dialogs_yesno.o \
events.o \
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index 66ba405909..2138ca6154 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -27,6 +27,7 @@
#include "xeen/files.h"
#include "xeen/resources.h"
#include "xeen/saves.h"
+#include "xeen/spells.h"
#include "xeen/xeen.h"
namespace Xeen {
@@ -52,7 +53,7 @@ Character::Character() {
_tempAge = 0;
Common::fill(&_skills[0], &_skills[18], 0);
Common::fill(&_awards[0], &_awards[128], false);
- Common::fill(&_spells[9], &_spells[312], false);
+ Common::fill(&_spells[0], &_spells[39], 0);
_lloydMap = 0;
_hasSpells = false;
_currentSpell = 0;
@@ -110,8 +111,8 @@ void Character::synchronize(Common::Serializer &s) {
}
// Synchronize spell list
- SavesManager::syncBitFlags(s, &_spells[0], &_spells[312]);
-
+ for (int i = 0; i < MAX_SPELLS_PER_CLASS - 1; ++i)
+ s.syncAsByte(_spells[i]);
s.syncAsByte(_lloydMap);
s.syncAsByte(_lloydPosition.x);
s.syncAsByte(_lloydPosition.y);
diff --git a/engines/xeen/party.h b/engines/xeen/party.h
index 10f4027dfe..035e76c098 100644
--- a/engines/xeen/party.h
+++ b/engines/xeen/party.h
@@ -108,7 +108,7 @@ public:
int _tempAge;
int _skills[18];
bool _awards[128];
- bool _spells[312];
+ int _spells[39];
int _lloydMap;
Common::Point _lloydPosition;
bool _hasSpells;
diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp
index 5eec5be89e..57e16d74d0 100644
--- a/engines/xeen/resources.cpp
+++ b/engines/xeen/resources.cpp
@@ -713,4 +713,74 @@ const char *const AMOUNT = "\x03""c\x09""000\x0B""051Amount\x03l\n";
const char *const FOOD_PACKS_FULL = "\v007Your food packs are already full!";
+const char *const BUY_SPELLS =
+ "\x03""c\x0B""027\x09""039%s\x03l\x0B""046\n"
+ "\x09""012\x0C""37B\x0C""duy Spells\n"
+ "\x09""012\x0C""37S\x0C""dpell Info";
+
+const char *const GUILD_OPTIONS =
+ "\x0D\x0C""00\x03""c\x0B""000\x09""000Guild Options for%s"
+ "\x03l\x09""000\x0B""090Gold"
+ "\x03r\x09""000%s\x02\x03""c\x0B""122\x09""040ESC\x01";
+
+const int SPELL_COSTS[77] = {
+ 8, 1, 5, -2, 5, -2, 20, 10, 12, 8, 3,
+ - 3, 75, 40, 12, 6, 200, 10, 100, 30, -1, 30,
+ 15, 25, 10, -2, 1, 2, 7, 20, -2, -2, 100,
+ 15, 5, 100, 35, 75, 5, 20, 4, 5, 1, -2,
+ 6, 2, 75, 40, 60, 6, 4, 25, -2, -2, 60,
+ - 1, 50, 15, 125, 2, -1, 3, -1, 200, 35, 150,
+ 15, 5, 4, 10, 8, 30, 4, 5, 7, 5, 0
+};
+
+const int DARK_SPELL_RANGES[12][2] = {
+ { 0, 20 }, { 16, 35 }, { 27, 37 }, { 29, 39 },
+ { 0, 17 }, { 14, 34 }, { 26, 37 }, { 29, 39 },
+ { 0, 20 }, { 16, 35 }, { 27, 37 }, { 29, 39 }
+};
+
+const int CLOUDS_SPELL_OFFSETS[5][20] = {
+ {
+ 1, 10, 20, 26, 27, 38, 40, 42, 45, 50,
+ 55, 59, 60, 61, 62, 68, 72, 75, 77, 77
+ }, {
+ 3, 4, 5, 14, 15, 25, 30, 31, 34, 41,
+ 49, 51, 53, 67, 73, 75, -1, -1, -1, -1
+ }, {
+ 4, 8, 9, 12, 13, 22, 23, 24, 28, 34,
+ 41, 44, 52, 70, 73, 74, -1, -1, -1, -1
+ }, {
+ 6, 7, 9, 11, 12, 13, 17, 21, 22, 24,
+ 29, 36, 56, 58, 64, 71, -1, -1, -1, -1
+ }, {
+ 6, 7, 9, 11, 12, 13, 18, 21, 29, 32,
+ 36, 37, 46, 51, 56, 58, 69, -1, -1, -1
+ }
+};
+
+const int DARK_SPELL_OFFSETS[3][39] = {
+ {
+ 42, 1, 26, 59, 27, 10, 50, 68, 55, 62, 67, 73, 2,
+ 5, 3, 31, 30, 52, 49, 28, 74, 0, 9, 7, 14, 8,
+ 33, 6, 23, 71, 64, 56, 48, 46, 12, 32, 58, 65, 16
+ }, {
+ 42, 1, 45, 61, 72, 40, 20, 60, 38, 41, 75, 34, 4,
+ 43, 25, 53, 44, 15, 70, 17, 24, 69, 22, 66, 57, 11,
+ 29, 39, 51, 21, 19, 36, 47, 13, 54, 37, 18, 35, 63
+ }, {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
+ 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
+ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38
+ }
+};
+
+const int SPELL_GEM_COST[77] = {
+ 0, 0, 2, 1, 2, 4, 5, 0, 0, 0, 0, 10, 10, 10, 0, 0, 20, 4, 10, 20, 1, 10,
+ 5, 5, 4, 2, 0, 0, 0, 10, 3, 1, 20, 4, 0, 20, 10, 10, 1, 10, 0, 0, 0, 2,
+ 2, 0, 10, 10, 10, 0, 0, 10, 3, 2, 10, 1, 10, 10, 20, 0, 0, 1, 1, 20, 5, 20,
+ 5, 0, 0, 0, 0, 5, 1, 2, 0, 2, 0
+};
+
+extern const char *NOT_A_SPELL_CASTER = "Not a spell caster...";
+
} // End of namespace Xeen
diff --git a/engines/xeen/resources.h b/engines/xeen/resources.h
index 497b02515b..60f4848c00 100644
--- a/engines/xeen/resources.h
+++ b/engines/xeen/resources.h
@@ -210,6 +210,24 @@ extern const char *const AMOUNT;
extern const char *const FOOD_PACKS_FULL;
+extern const char *const BUY_SPELLS;
+
+extern const char *const GUILD_OPTIONS;
+
+extern const int SPELL_COSTS[77];
+
+extern const int CLOUDS_SPELL_OFFSETS[5][20];
+
+extern const int DARK_SPELL_OFFSETS[3][39];
+
+extern const int DARK_SPELL_RANGES[12][2];
+
+extern const int SPELL_LEVEL_OFFSETS[3][39];
+
+extern const int SPELL_GEM_COST[77];
+
+extern const char *NOT_A_SPELL_CASTER;
+
} // End of namespace Xeen
#endif /* XEEN_RESOURCES_H */
diff --git a/engines/xeen/spells.cpp b/engines/xeen/spells.cpp
index 29c22b1e0b..922f6fcb84 100644
--- a/engines/xeen/spells.cpp
+++ b/engines/xeen/spells.cpp
@@ -22,6 +22,7 @@
#include "xeen/spells.h"
#include "xeen/files.h"
+#include "xeen/resources.h"
#include "xeen/xeen.h"
namespace Xeen {
@@ -42,4 +43,15 @@ void Spells::load() {
f2.close();
}
+int Spells::calcSpellCost(int spellId, int expenseFactor) const {
+ int amount = SPELL_COSTS[spellId];
+ return (amount >= 0) ? (amount * 100) << expenseFactor :
+ (amount * -500) << expenseFactor;
+}
+
+int Spells::calcSpellPoints(int spellId, int expenseFactor) const {
+ int amount = SPELL_COSTS[spellId];
+ return (amount >= 0) ? amount : amount * -1 * expenseFactor;
+}
+
} // End of namespace Xeen
diff --git a/engines/xeen/spells.h b/engines/xeen/spells.h
index 48c0f9a897..97e3c80bba 100644
--- a/engines/xeen/spells.h
+++ b/engines/xeen/spells.h
@@ -30,6 +30,8 @@ namespace Xeen {
class XeenEngine;
+#define MAX_SPELLS_PER_CLASS 40
+
class Spells {
private:
XeenEngine *_vm;
@@ -40,6 +42,11 @@ public:
Common::StringArray _maeNames;
public:
Spells(XeenEngine *vm);
+
+ int calcSpellCost(int spellId, int expenseFactor) const;
+
+ int calcSpellPoints(int spellId, int expenseFactor) const;
+
};
} // End of namespace Xeen
diff --git a/engines/xeen/town.cpp b/engines/xeen/town.cpp
index f90ffbd481..d773f6d4f2 100644
--- a/engines/xeen/town.cpp
+++ b/engines/xeen/town.cpp
@@ -23,6 +23,7 @@
#include "xeen/town.h"
#include "xeen/dialogs_input.h"
#include "xeen/dialogs_yesno.h"
+#include "xeen/dialogs_spells.h"
#include "xeen/resources.h"
#include "xeen/xeen.h"
@@ -563,15 +564,14 @@ Character *Town::doGuildOptions(Character *c) {
sound.playSample(&f, 1);
}
}
- }
- else if (_buttonValue == Common::KEYCODE_s) {
+ } else if (_buttonValue == Common::KEYCODE_s) {
if (c->guildMember())
- c = showAvailableSpells(c, 0x80);
+ c = SpellsScroll::show(_vm, c, 0x80);
_buttonValue = 0;
} else if (_buttonValue == Common::KEYCODE_c) {
if (!c->noActions()) {
if (c->guildMember())
- c = showAvailableSpells(c, 0);
+ c = SpellsScroll::show(_vm, c, 0);
_buttonValue = 0;
}
}
@@ -1260,8 +1260,4 @@ Character *Town::showItems(Character *c, int v2) {
error("TODO: showItems");
}
-Character *Town::showAvailableSpells(Character *c, int v2) {
- error("TODO: showAvailableSpells");
-}
-
} // End of namespace Xeen
diff --git a/engines/xeen/town.h b/engines/xeen/town.h
index f6c67ab102..27b1fe2121 100644
--- a/engines/xeen/town.h
+++ b/engines/xeen/town.h
@@ -101,8 +101,6 @@ private:
int subtract(int mode, uint amount, int whereId, ErrorWaitType wait);
Character *showItems(Character *c, int v2);
-
- Character *showAvailableSpells(Character *c, int v2);
public:
Town(XeenEngine *vm);