diff options
author | Paul Gilbert | 2018-01-27 16:27:03 -0500 |
---|---|---|
committer | Paul Gilbert | 2018-01-27 16:27:03 -0500 |
commit | 540f47294a0274e2aaa9178a11997b4b975a6234 (patch) | |
tree | b3de9be891447b0158933dedf73148605e55346d /engines/xeen/scripts.cpp | |
parent | c74700e2f7a85113fffc8ff5a4d7d2623d025740 (diff) | |
download | scummvm-rg350-540f47294a0274e2aaa9178a11997b4b975a6234.tar.gz scummvm-rg350-540f47294a0274e2aaa9178a11997b4b975a6234.tar.bz2 scummvm-rg350-540f47294a0274e2aaa9178a11997b4b975a6234.zip |
XEEN: Move Scripts _v2 to Combat _damageTarget
The _damageTarget field is wonky. In most places, such as in
giveCharDamage, it's treated like an enum. But in the if opcode
logic (cmdIf), it's definitely treated a character index
Diffstat (limited to 'engines/xeen/scripts.cpp')
-rw-r--r-- | engines/xeen/scripts.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp index e597cf7dbc..3a3e0c2578 100644 --- a/engines/xeen/scripts.cpp +++ b/engines/xeen/scripts.cpp @@ -116,7 +116,6 @@ Scripts::Scripts(XeenEngine *vm) : _vm(vm) { _treasureItems = 0; _lineNum = 0; _charIndex = 0; - _v2 = 0; _nEdamageType = DT_PHYSICAL; _animCounter = 0; _eventSkipped = false; @@ -169,7 +168,7 @@ int Scripts::checkEvents() { _redrawDone = false; _currentPos = party._mazePosition; _charIndex = 1; - _v2 = 1; + combat._combatTarget = 1; _nEdamageType = DT_PHYSICAL; // int var40 = -1; @@ -266,7 +265,7 @@ int Scripts::checkEvents() { party._treasure = party._savedTreasure; } - _v2 = 1; + combat._combatTarget = 1; Common::fill(&intf._charFX[0], &intf._charFX[6], 0); return _scriptResult; @@ -532,6 +531,7 @@ bool Scripts::cmdTeleport(ParamsIterator ¶ms) { } bool Scripts::cmdIf(ParamsIterator ¶ms) { + Combat &combat = *_vm->_combat; Party &party = *_vm->_party; uint32 val; int newLineNum; @@ -561,7 +561,7 @@ bool Scripts::cmdIf(ParamsIterator ¶ms) { } else { result = false; for (int idx = 0; idx < (int)party._activeParty.size() && !result; ++idx) { - if (_charIndex == 0 || (_charIndex == 8 && (int)idx != _v2)) { + if (_charIndex == 0 || (_charIndex == 8 && (int)idx != combat._combatTarget)) { result = ifProc(mode, val, _event->_opcode - 8, idx); } } @@ -591,6 +591,7 @@ bool Scripts::cmdMoveObj(ParamsIterator ¶ms) { } bool Scripts::cmdTakeOrGive(ParamsIterator ¶ms) { + Combat &combat = *_vm->_combat; Party &party = *_vm->_party; Windows &windows = *_vm->_windows; int mode1, mode2, mode3, param2; @@ -658,7 +659,7 @@ bool Scripts::cmdTakeOrGive(ParamsIterator ¶ms) { case OP_TakeOrGive_2: if (_charIndex == 0 || _charIndex == 8) { for (uint idx = 0; idx < party._activeParty.size(); ++idx) { - if (_charIndex == 0 || (_charIndex == 8 && (int)idx != _v2)) { + if (_charIndex == 0 || (_charIndex == 8 && (int)idx != combat._combatTarget)) { if (ifProc(mode1, val1, _event->_opcode == OP_TakeOrGive_4 ? 2 : 1, idx)) { party.giveTake(0, 0, mode2, val2, idx); if (mode2 == 82) @@ -674,7 +675,7 @@ bool Scripts::cmdTakeOrGive(ParamsIterator ¶ms) { case OP_TakeOrGive_3: if (_charIndex == 0 || _charIndex == 8) { for (uint idx = 0; idx < party._activeParty.size(); ++idx) { - if (_charIndex == 0 || (_charIndex == 8 && (int)idx != _v2)) { + if (_charIndex == 0 || (_charIndex == 8 && (int)idx != combat._combatTarget)) { if (ifProc(mode1, val1, 1, idx) && ifProc(mode2, val2, 1, idx)) { party.giveTake(0, 0, mode2, val3, idx); if (mode2 == 82) @@ -691,7 +692,7 @@ bool Scripts::cmdTakeOrGive(ParamsIterator ¶ms) { case OP_TakeOrGive_4: if (_charIndex == 0 || _charIndex == 8) { for (uint idx = 0; idx < party._activeParty.size(); ++idx) { - if (_charIndex == 0 || (_charIndex == 8 && (int)idx != _v2)) { + if (_charIndex == 0 || (_charIndex == 8 && (int)idx != combat._combatTarget)) { if (ifProc(mode1, val1, _event->_opcode == OP_TakeOrGive_4 ? 2 : 1, idx)) { party.giveTake(0, 0, mode2, val2, idx); if (mode2 == 82) @@ -707,7 +708,7 @@ bool Scripts::cmdTakeOrGive(ParamsIterator ¶ms) { default: if (_charIndex == 0 || _charIndex == 8) { for (uint idx = 0; idx < party._activeParty.size(); ++idx) { - if (_charIndex == 0 || (_charIndex == 8 && (int)idx != _v2)) { + if (_charIndex == 0 || (_charIndex == 8 && (int)idx != combat._combatTarget)) { party.giveTake(mode1, val1, mode2, val2, idx); switch (mode1) { @@ -805,16 +806,17 @@ bool Scripts::cmdRemove(ParamsIterator ¶ms) { } bool Scripts::cmdSetChar(ParamsIterator ¶ms) { + Combat &combat = *_vm->_combat; int charId = params.readByte(); if (charId == 0) { _charIndex = 0; - _v2 = 0; + combat._combatTarget = 0; } else if (charId < 7) { - _v2 = charId; + combat._combatTarget = charId; } else if (charId == 7) { _charIndex = _vm->getRandomNumber(1, _vm->_party->_activeParty.size()); - _v2 = 1; + combat._combatTarget = 1; } else { _charIndex = WhoWill::show(_vm, 22, 3, false); if (_charIndex == 0) @@ -1041,6 +1043,7 @@ bool Scripts::cmdReturn(ParamsIterator ¶ms) { } bool Scripts::cmdSetVar(ParamsIterator ¶ms) { + Combat &combat = *_vm->_combat; Party &party = *_vm->_party; uint val; _refreshIcons = true; @@ -1068,7 +1071,7 @@ bool Scripts::cmdSetVar(ParamsIterator ¶ms) { } else { // Set value for entire party for (int idx = 0; idx < (int)party._activeParty.size(); ++idx) { - if (_charIndex == 0 || (_charIndex == 8 && _v2 != idx)) { + if (_charIndex == 0 || (_charIndex == 8 && combat._combatTarget != idx)) { party._activeParty[idx].setValue(mode, val); } } |