Skip to content

Commit

Permalink
XEEN: Fix to cmdSpawn, and implemented cmdSetValue
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 25, 2015
1 parent fe6b580 commit 2a9c00c
Show file tree
Hide file tree
Showing 4 changed files with 252 additions and 3 deletions.
209 changes: 208 additions & 1 deletion engines/xeen/party.cpp
Expand Up @@ -182,7 +182,7 @@ int Character::getMaxHP() const {
int Character::getMaxSP() const {
int result = 0;
bool flag = false;
int amount;
int amount = 0;
Attribute attrib;
Skill skill;

Expand Down Expand Up @@ -550,6 +550,213 @@ int Character::conditionMod(Attribute attrib) const {
return v[attrib];
}

void Character::setValue(int id, uint value) {
Party &party = *Party::_vm->_party;
Scripts &scripts = *Party::_vm->_scripts;

switch (id) {
case 3:
// Set character sex
_sex = (Sex)value;
break;
case 4:
// Set race
_race = (Race)value;
break;
case 5:
// Set class
_class = (CharacterClass)value;
break;
case 8:
// Set the current Hp
_currentHp = value;
break;
case 9:
// Set the current Sp
_currentSp = value;
break;
case 10:
case 77:
// Set temporary armor class
_ACTemp = value;
break;
case 11:
// Set temporary level
_level._temporary = value;
break;
case 12:
// Set the character's temporary age
_tempAge = value;
break;
case 16:
// Set character experience
_experience = value;
break;
case 17:
// Set party poison resistence
party._poisonResistence = value;
break;
case 18:
// Set condition
if (value == 16) {
// Clear all the conditions
Common::fill(&_conditions[CURSED], &_conditions[NO_CONDITION], false);
} else if (value == 6) {
_conditions[value] = 1;
} else {
++_conditions[value];
}

if (value >= DEAD && value <= ERADICATED && _currentHp > 0)
_currentHp = 0;
break;
case 25:
// Set time of day in minutes (0-1440)
party._minutes = value;
break;
case 34:
// Set party gold
party._gold = value;
break;
case 35:
// Set party gems
party._gems = value;
break;
case 37:
_might._temporary = value;
break;
case 38:
_intellect._temporary = value;
break;
case 39:
_personality._temporary = value;
break;
case 40:
_endurance._temporary = value;
break;
case 41:
_speed._temporary = value;
break;
case 42:
_accuracy._temporary = value;
break;
case 43:
_luck._temporary = value;
break;
case 45:
_might._permanent = value;
break;
case 46:
_intellect._permanent = value;
break;
case 47:
_personality._permanent = value;
break;
case 48:
_endurance._permanent = value;
break;
case 49:
_speed._permanent = value;
break;
case 50:
_accuracy._permanent = value;
break;
case 51:
_luck._permanent = value;
break;
case 52:
_fireResistence._permanent = value;
break;
case 53:
_electricityResistence._permanent = value;
break;
case 54:
_coldResistence._permanent = value;
break;
case 55:
_poisonResistence._permanent = value;
break;
case 56:
_energyResistence._permanent = value;
break;
case 57:
_magicResistence._permanent = value;
break;
case 58:
_fireResistence._temporary = value;
break;
case 59:
_electricityResistence._temporary = value;
break;
case 60:
_coldResistence._temporary = value;
break;
case 61:
_poisonResistence._temporary = value;
break;
case 62:
_energyResistence._temporary = value;
break;
case 63:
_magicResistence._temporary = value;
break;
case 64:
_level._permanent = value;
break;
case 65:
// Set party food
party._food = value;
break;
case 69:
// Set levitate active
party._levitateActive = value != 0;
break;
case 70:
party._lightCount = value;
break;
case 71:
party._fireResistence = value;
break;
case 72:
party._electricityResistence = value;
break;
case 73:
party._coldResistence = value;
break;
case 74:
party._walkOnWaterActive = value != 0;
party._poisonResistence = value;
party._wizardEyeActive = value != 0;
party._coldResistence = value;
party._electricityResistence = value;
party._fireResistence = value;
party._lightCount = value;
party._levitateActive = value != 0;
break;
case 76:
// Set day of the year (0-99)
party._day = value;
break;
case 79:
party._wizardEyeActive = true;
break;
case 83:
scripts._nEdamageType = value;
break;
case 84:
party._mazeDirection = (Direction)value;
break;
case 85:
party._year = value;
break;
case 94:
party._walkOnWaterActive = value != 0;
break;
default:
break;
}
}

/*------------------------------------------------------------------------*/

void Roster::synchronize(Common::Serializer &s) {
Expand Down
2 changes: 2 additions & 0 deletions engines/xeen/party.h
Expand Up @@ -165,6 +165,8 @@ class Character {
int getCurrentLevel() const;

int itemScan(int itemId) const;

void setValue(int id, uint value);
};

class Roster: public Common::Array<Character> {
Expand Down
42 changes: 41 additions & 1 deletion engines/xeen/scripts.cpp
Expand Up @@ -381,6 +381,10 @@ void Scripts::cmdSetChar(Common::Array<byte> &params) {
* Spawn a monster
*/
void Scripts::cmdSpawn(Common::Array<byte> &params) {
Map &map = *_vm->_map;
if (params[0] >= map._mobData._monsters.size())
map._mobData._monsters.resize(params[0] + 1);

MazeMonster &monster = _vm->_map->_mobData._monsters[params[0]];
MonsterStruct &monsterData = _vm->_map->_monsterData[monster._spriteId];
monster._position.x = params[1];
Expand Down Expand Up @@ -580,7 +584,43 @@ void Scripts::cmdReturn(Common::Array<byte> &params) {
cmdNoAction(params);
}

void Scripts::cmdSetVar(Common::Array<byte> &params) { error("TODO"); }
void Scripts::cmdSetVar(Common::Array<byte> &params) {
Party &party = *_vm->_party;
bool flag = true;
uint val;

switch (params[0]) {
case 25:
case 35:
case 101:
case 106:
val = (params[2] << 8) | params[1];
break;
case 16:
case 34:
case 100:
val = (params[4] << 24) | (params[3] << 16) | (params[2] << 8) | params[3];
break;
default:
val = params[1];
break;
}

if (_charIndex != 0 && _charIndex != 8) {
party._activeParty[_charIndex - 1].setValue(params[0], val);
} else {
// Set value for entire party
for (int idx = 0; idx < party._partyCount; ++idx) {
if (_charIndex == 0 || (_charIndex == 8 && _v2 != idx)) {
party._activeParty[idx].setValue(params[0], val);
}
}
}

_var4F = true;
cmdNoAction(params);
}

void Scripts::cmdCutsceneEndClouds(Common::Array<byte> &params) { error("TODO"); }

void Scripts::cmdWhoWill(Common::Array<byte> &params) {
Expand Down
2 changes: 1 addition & 1 deletion engines/xeen/scripts.h
Expand Up @@ -137,7 +137,6 @@ class Scripts {

int _v2;
int _var4F;
int _nEdamageType;
MazeEvent *_event;
Common::Point _currentPos;
Common::Stack<StackEntry> _stack;
Expand Down Expand Up @@ -214,6 +213,7 @@ class Scripts {
int _animCounter;
bool _eventSkipped;
int _whoWill;
int _nEdamageType;
public:
Scripts(XeenEngine *vm);

Expand Down

0 comments on commit 2a9c00c

Please sign in to comment.