Skip to content

Commit

Permalink
XEEN: Add spells debugger command to give party all the spells
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 17, 2018
1 parent 9518fd7 commit 2410da0
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 6 deletions.
2 changes: 1 addition & 1 deletion engines/xeen/character.cpp
Expand Up @@ -702,7 +702,7 @@ void Character::clear() {
_tempAge = 0;
Common::fill(&_skills[0], &_skills[18], 0);
Common::fill(&_awards[0], &_awards[128], 0);
Common::fill(&_spells[0], &_spells[39], 0);
Common::fill(&_spells[0], &_spells[39], false);
_lloydMap = 0;
_hasSpells = false;
_currentSpell = 0;
Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/character.h
Expand Up @@ -334,7 +334,7 @@ class Character {
int _tempAge;
int _skills[18];
int _awards[128];
int _spells[MAX_SPELLS_PER_CLASS];
bool _spells[MAX_SPELLS_PER_CLASS];
int _lloydMap;
Common::Point _lloydPosition;
bool _hasSpells;
Expand Down
14 changes: 14 additions & 0 deletions engines/xeen/debugger.cpp
Expand Up @@ -47,6 +47,7 @@ static int strToInt(const char *s) {
Debugger::Debugger(XeenEngine *vm) : GUI::Debugger(), _vm(vm) {
registerCmd("continue", WRAP_METHOD(Debugger, cmdExit));
registerCmd("spell", WRAP_METHOD(Debugger, cmdSpell));
registerCmd("spells", WRAP_METHOD(Debugger, cmdSpells));
registerCmd("dump", WRAP_METHOD(Debugger, cmdDump));
registerCmd("gold", WRAP_METHOD(Debugger, cmdGold));
registerCmd("gems", WRAP_METHOD(Debugger, cmdGems));
Expand Down Expand Up @@ -87,6 +88,19 @@ bool Debugger::cmdSpell(int argc, const char **argv) {
return true;
}

bool Debugger::cmdSpells(int argc, const char **argv) {
Party &party = *_vm->_party;

for (uint charIdx = 0; charIdx < party._activeParty.size(); ++charIdx) {
Character &c = party._activeParty[charIdx];
Common::fill(c._spells, c._spells + MAX_SPELLS_PER_CLASS, true);
c._currentSp = 500;
}

party._gems += 500;
return false;
}

bool Debugger::cmdDump(int argc, const char **argv) {
File f;

Expand Down
31 changes: 31 additions & 0 deletions engines/xeen/debugger.h
Expand Up @@ -35,15 +35,46 @@ class Debugger : public GUI::Debugger {
XeenEngine *_vm;
int _spellId;

/**
* Casts a spell
*/
bool cmdSpell(int argc, const char **argv);

/**
* Gives all the characters a full spellbook
*/
bool cmdSpells(int argc, const char **argv);

/**
* Dumps a resource to a file
*/
bool cmdDump(int argc, const char **argv);

/**
* Gives gold to the party or bank
*/
bool cmdGold(int argc, const char **argv);

/**
* Gives gems to the party or bank
*/
bool cmdGems(int argc, const char **argv);

/**
* Jumps to a given map, and optionally a given position
*/
bool cmdMap(int argc, const char **argv);

/**
* Changes the party's position in the current map
*/
bool cmdPos(int argc, const char **argv);
public:
Debugger(XeenEngine *vm);

/**
* Updates the debugger window if active
*/
void update();
};

Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/dialogs_party.cpp
Expand Up @@ -1031,7 +1031,7 @@ bool PartyDialog::saveCharacter(Character &c, int classId,
if (Res.NEW_CHARACTER_SPELLS[c._class][idx] != -1) {
c._hasSpells = true;
c._currentSpell = Res.NEW_CHARACTER_SPELLS[c._class][idx];
c._spells[c._currentSpell] = 1;
c._spells[c._currentSpell] = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/dialogs_spells.cpp
Expand Up @@ -237,7 +237,7 @@ Character *SpellsDialog::execute(ButtonContainer *priorDialog, Character *c, int

if (Confirm::show(_vm, msg, castingCopy + 1)) {
if (party.subtract(CONS_GOLD, spellCost, WHERE_PARTY, WT_FREEZE_WAIT)) {
++c->_spells[spellIndex];
c->_spells[spellIndex] = true;
sound.stopSound();
intf._overallFrame = 0;
sound.playSound(isDarkCc ? "guild12.voc" : "parrot2.voc", 1);
Expand Down
4 changes: 2 additions & 2 deletions engines/xeen/party.cpp
Expand Up @@ -817,7 +817,7 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int

for (int idx = 0; idx < 39; ++idx) {
if (Res.SPELLS_ALLOWED[idx2][idx] == takeVal) {
ps._spells[idx] = 0;
ps._spells[idx] = false;
break;
}
}
Expand Down Expand Up @@ -1086,7 +1086,7 @@ bool Party::giveTake(int takeMode, uint takeVal, int giveMode, uint giveVal, int

for (int idx = 0; idx < 39; ++idx) {
if (Res.SPELLS_ALLOWED[idx2][idx] == giveVal) {
ps._spells[idx] = 1;
ps._spells[idx] = true;
intf.spellFX(&ps);
break;
}
Expand Down

0 comments on commit 2410da0

Please sign in to comment.