aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/xeen/combat.cpp7
-rw-r--r--engines/xeen/combat.h1
-rw-r--r--engines/xeen/interface.cpp12
-rw-r--r--engines/xeen/party.cpp2
-rw-r--r--engines/xeen/scripts.cpp27
-rw-r--r--engines/xeen/scripts.h1
6 files changed, 27 insertions, 23 deletions
diff --git a/engines/xeen/combat.cpp b/engines/xeen/combat.cpp
index 32fa59297b..549f7739f3 100644
--- a/engines/xeen/combat.cpp
+++ b/engines/xeen/combat.cpp
@@ -125,6 +125,7 @@ Combat::Combat(XeenEngine *vm): _vm(vm), _missVoc("miss.voc"), _pow1Voc("pow1.vo
_dangerPresent = false;
_moveMonsters = false;
_rangeType = RT_SINGLE;
+ _combatTarget = 0;
}
void Combat::clearAttackers() {
@@ -154,7 +155,7 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
windows.closeAll();
int idx = (int)party._activeParty.size();
- if (scripts._v2 == 2) {
+ if (_combatTarget == 2) {
for (idx = 0; idx < (int)party._activeParty.size(); ++idx) {
Character &c = party._activeParty[idx];
Condition condition = c.worstCondition();
@@ -171,12 +172,12 @@ void Combat::giveCharDamage(int damage, DamageType attackType, int charIndex) {
}
}
if (idx == (int)party._activeParty.size()) {
- if (!scripts._v2)
+ if (!_combatTarget)
selectedIndex1 = 0;
}
for (;;) {
- for (; selectedIndex1 < (scripts._v2 ? charIndex1 : (int)party._activeParty.size()); ++selectedIndex1) {
+ for (; selectedIndex1 < (_combatTarget ? charIndex1 : (int)party._activeParty.size()); ++selectedIndex1) {
Character &c = party._activeParty[selectedIndex1];
c._conditions[ASLEEP] = 0; // Force attacked character to be awake
diff --git a/engines/xeen/combat.h b/engines/xeen/combat.h
index 015f41e6a1..e8121bee46 100644
--- a/engines/xeen/combat.h
+++ b/engines/xeen/combat.h
@@ -142,6 +142,7 @@ public:
bool _moveMonsters;
RangeType _rangeType;
ShootType _shootType;
+ int _combatTarget;
public:
Combat(XeenEngine *vm);
diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 5d667e3a2c..ef6dbc9577 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -676,11 +676,11 @@ void Interface::doStepCode() {
_flipGround = !_flipGround;
draw3d(true);
- int oldVal = scripts._v2;
- scripts._v2 = 0;
+ int oldTarget = combat._combatTarget;
+ combat._combatTarget = 0;
combat.giveCharDamage(damage, combat._damageType, 0);
- scripts._v2 = oldVal;
+ combat._combatTarget = oldTarget;
_flipGround = !_flipGround;
} else if (party._partyDead) {
draw3d(true);
@@ -888,11 +888,11 @@ void Interface::startFalling(bool flag) {
_flipGround ^= 1;
draw3d(true);
- int tempVal = scripts._v2;
- scripts._v2 = 0;
+ int oldTarget = combat._combatTarget;
+ combat._combatTarget = 0;
combat.giveCharDamage(party._fallDamage, DT_PHYSICAL, 0);
- scripts._v2 = tempVal;
+ combat._combatTarget = oldTarget;
_flipGround ^= 1;
}
}
diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp
index 346011838c..f6bd5ca7fc 100644
--- a/engines/xeen/party.cpp
+++ b/engines/xeen/party.cpp
@@ -686,7 +686,7 @@ void Party::giveTreasure() {
_treasure._armor[idx].clear();
}
- scripts._v2 = 1;
+ combat._combatTarget = 1;
}
bool Party::arePacksFull() const {
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 &params) {
}
bool Scripts::cmdIf(ParamsIterator &params) {
+ Combat &combat = *_vm->_combat;
Party &party = *_vm->_party;
uint32 val;
int newLineNum;
@@ -561,7 +561,7 @@ bool Scripts::cmdIf(ParamsIterator &params) {
} 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 &params) {
}
bool Scripts::cmdTakeOrGive(ParamsIterator &params) {
+ 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 &params) {
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 &params) {
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 &params) {
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 &params) {
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 &params) {
}
bool Scripts::cmdSetChar(ParamsIterator &params) {
+ 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 &params) {
}
bool Scripts::cmdSetVar(ParamsIterator &params) {
+ Combat &combat = *_vm->_combat;
Party &party = *_vm->_party;
uint val;
_refreshIcons = true;
@@ -1068,7 +1071,7 @@ bool Scripts::cmdSetVar(ParamsIterator &params) {
} 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);
}
}
diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h
index 9332018092..e0b3999205 100644
--- a/engines/xeen/scripts.h
+++ b/engines/xeen/scripts.h
@@ -546,7 +546,6 @@ public:
int _whoWill;
DamageType _nEdamageType;
int _itemType;
- int _v2;
Common::Array<MirrorEntry> _mirror;
public:
Scripts(XeenEngine *vm);