aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/he/logic/moonbase_logic.cpp2
-rw-r--r--engines/scumm/he/moonbase/ai_defenseunit.cpp16
-rw-r--r--engines/scumm/he/moonbase/ai_main.cpp6
-rw-r--r--engines/scumm/he/moonbase/ai_main.h8
-rw-r--r--engines/scumm/he/moonbase/ai_targetacquisition.cpp28
-rw-r--r--engines/scumm/he/moonbase/moonbase.cpp12
-rw-r--r--engines/scumm/he/moonbase/moonbase.h4
7 files changed, 37 insertions, 39 deletions
diff --git a/engines/scumm/he/logic/moonbase_logic.cpp b/engines/scumm/he/logic/moonbase_logic.cpp
index 0d1c3c5a78..ce5009f72e 100644
--- a/engines/scumm/he/logic/moonbase_logic.cpp
+++ b/engines/scumm/he/logic/moonbase_logic.cpp
@@ -232,7 +232,7 @@ int LogicHEmoonbase::op_ai_master_control_program(int op, int numArgs, int32 *ar
void LogicHEmoonbase::op_ai_reset(int op, int numArgs, int32 *args) {
warning("op_ai_reset())");
- _vm->_moonbase->_ai->resetAI(_vm);
+ _vm->_moonbase->_ai->resetAI();
}
void LogicHEmoonbase::op_ai_set_type(int op, int numArgs, int32 *args) {
diff --git a/engines/scumm/he/moonbase/ai_defenseunit.cpp b/engines/scumm/he/moonbase/ai_defenseunit.cpp
index ad9792d0b9..37ce303bc5 100644
--- a/engines/scumm/he/moonbase/ai_defenseunit.cpp
+++ b/engines/scumm/he/moonbase/ai_defenseunit.cpp
@@ -133,13 +133,13 @@ int AntiAirUnit::selectWeapon(int index) {
case 2:
if (getState() == DUS_OFF) {
if (_ai->getPlayerEnergy() > 6) {
- if (!_vm->_rnd.getRandomNumber(3)) {
+ if (!_ai->_vm->_rnd.getRandomNumber(3)) {
return ITEM_VIRUS;
}
}
if (_ai->getPlayerEnergy() > 2) {
- if (!_vm->_rnd.getRandomNumber(1)) {
+ if (!_ai->_vm->_rnd.getRandomNumber(1)) {
return ITEM_SPIKE;
}
}
@@ -358,19 +358,19 @@ int HubUnit::selectWeapon(int index) {
}
if (energy > 2) {
- if (!_vm->_rnd.getRandomNumber(3)) {
+ if (!_ai->_vm->_rnd.getRandomNumber(3)) {
return ITEM_SPIKE;
}
- if (!_vm->_rnd.getRandomNumber(4)) {
+ if (!_ai->_vm->_rnd.getRandomNumber(4)) {
return ITEM_GUIDED;
}
- if (!_vm->_rnd.getRandomNumber(4)) {
+ if (!_ai->_vm->_rnd.getRandomNumber(4)) {
return ITEM_MINE;
}
- if (!_vm->_rnd.getRandomNumber(9)) {
+ if (!_ai->_vm->_rnd.getRandomNumber(9)) {
return ITEM_EMP;
}
}
@@ -506,7 +506,7 @@ int EnergyUnit::selectWeapon(int index) {
}
if (energy > 2) {
- if (!_vm->_rnd.getRandomNumber(3)) {
+ if (!_ai->_vm->_rnd.getRandomNumber(3)) {
return ITEM_EMP;
}
}
@@ -617,7 +617,7 @@ int CrawlerUnit::selectWeapon(int index) {
}
if (energy > 2) {
- if (_vm->_rnd.getRandomNumber(1)) {
+ if (_ai->_vm->_rnd.getRandomNumber(1)) {
return ITEM_MINE;
} else {
return ITEM_TIME_EXPIRED;
diff --git a/engines/scumm/he/moonbase/ai_main.cpp b/engines/scumm/he/moonbase/ai_main.cpp
index d7e86d52fb..326da21b5d 100644
--- a/engines/scumm/he/moonbase/ai_main.cpp
+++ b/engines/scumm/he/moonbase/ai_main.cpp
@@ -31,8 +31,6 @@
namespace Scumm {
-ScummEngine_v90he *_vm;
-
enum {
F_GET_SCUMM_DATA = 0,
F_GET_WORLD_DIST = 1,
@@ -166,9 +164,7 @@ int *storedLaunchAction[5] = {NULL};
const int32 *MCP_params;
-void AI::resetAI(ScummEngine_v90he *vm) {
- _vm = vm;
-
+void AI::resetAI() {
AIstate = STATE_CHOOSE_BEHAVIOR;
warning("----------------------> Resetting AI");
diff --git a/engines/scumm/he/moonbase/ai_main.h b/engines/scumm/he/moonbase/ai_main.h
index 7bd9a8f550..619ff1610a 100644
--- a/engines/scumm/he/moonbase/ai_main.h
+++ b/engines/scumm/he/moonbase/ai_main.h
@@ -30,8 +30,6 @@ namespace Scumm {
class ScummEngine_v90he;
-extern ScummEngine_v90he *_vm;
-
enum {
TERRAIN_TYPE_GOOD = 0,
TERRAIN_TYPE_SLOPE = 1,
@@ -85,7 +83,9 @@ enum {
class AI {
public:
- void resetAI(ScummEngine_v90he *vm);
+ AI(ScummEngine_v90he *vm) : _vm(vm) {}
+
+ void resetAI();
void cleanUpAI();
void setAIType(const int paramCount, const int32 *params);
int masterControlProgram(const int paramCount, const int32 *params);
@@ -190,6 +190,8 @@ private:
public:
Common::Array<int> lastXCoord[5];
Common::Array<int> lastYCoord[5];
+
+ ScummEngine_v90he *_vm;
};
} // End of namespace Scumm
diff --git a/engines/scumm/he/moonbase/ai_targetacquisition.cpp b/engines/scumm/he/moonbase/ai_targetacquisition.cpp
index d91660c693..938a02dba3 100644
--- a/engines/scumm/he/moonbase/ai_targetacquisition.cpp
+++ b/engines/scumm/he/moonbase/ai_targetacquisition.cpp
@@ -46,7 +46,7 @@ void Sortie::setEnemyDefenses(int enemyDefensesScummArray, int defendX, int defe
int currentPlayer = _ai->getCurrentPlayer();
for (int i = 0; i < 200; i++) {
- int thisElement = _vm->_moonbase->readFromArray(enemyDefensesScummArray, 0, i);
+ int thisElement = _ai->_vm->_moonbase->readFromArray(enemyDefensesScummArray, 0, i);
if (thisElement) {
if (_ai->getBuildingOwner(thisElement)) {
@@ -223,7 +223,7 @@ IContainedObject *Sortie::createChildObj(int index, int &completionFlag) {
if ((AAcounter != 3) && (currentWeapon->getTypeID() == ITEM_CLUSTER))
thisDamage = 0;
- if (!_vm->_rnd.getRandomNumber(4))
+ if (!_ai->_vm->_rnd.getRandomNumber(4))
currentWeapon->setTypeID(ITEM_MINE);
(*i)->setDamage(thisDamage);
@@ -331,7 +331,7 @@ int Defender::calculateDefenseUnitPosition(int targetX, int targetY, int index)
int hubIndex = 0;
for (int i = 0; i < 200; i++) {
- int thisUnit = _vm->_moonbase->readFromArray(unitsArray, 0, i);
+ int thisUnit = _ai->_vm->_moonbase->readFromArray(unitsArray, 0, i);
if (thisUnit) {
if (((_ai->getBuildingType(thisUnit) == BUILDING_MAIN_BASE) || (_ai->getBuildingType(thisUnit) == BUILDING_OFFENSIVE_LAUNCHER)) && (_ai->getBuildingOwner(thisUnit) == currentPlayer)) {
@@ -361,7 +361,7 @@ int Defender::calculateDefenseUnitPosition(int targetX, int targetY, int index)
}
}
- _vm->_moonbase->deallocateArray(unitsArray);
+ _ai->_vm->_moonbase->deallocateArray(unitsArray);
//Check if repair is needed
int targetUnit = _ai->getClosestUnit(targetX + 5, targetY, 15, currentPlayer, 1, 0, 0, 0);
@@ -374,7 +374,7 @@ int Defender::calculateDefenseUnitPosition(int targetX, int targetY, int index)
int defCount = 0;
for (int i = 0; i < 200; i++) {
- int thisUnit = _vm->_moonbase->readFromArray(unitsArray, 0, i);
+ int thisUnit = _ai->_vm->_moonbase->readFromArray(unitsArray, 0, i);
if (thisUnit) {
if (((_ai->getBuildingType(thisUnit) == BUILDING_SHIELD) || (_ai->getBuildingType(thisUnit) == BUILDING_ANTI_AIR)) && (_ai->getBuildingOwner(thisUnit) == currentPlayer) && (_ai->getBuildingState(thisUnit) == 0)) {
@@ -384,7 +384,7 @@ int Defender::calculateDefenseUnitPosition(int targetX, int targetY, int index)
}
}
- _vm->_moonbase->deallocateArray(unitsArray);
+ _ai->_vm->_moonbase->deallocateArray(unitsArray);
if (defCount) {
//repair
@@ -428,8 +428,8 @@ int Defender::calculateDefenseUnitPosition(int targetX, int targetY, int index)
//Number of random chances to land
for (int j = 0; j < 3; j++) {
//Pick random angle and dist within semicircle (-90 to +90) and (40 to 150)
- int randAngle = directAngleToHub + _vm->_rnd.getRandomNumber(179) - 90;
- int randDist = _vm->_rnd.getRandomNumber(109) + 40;
+ int randAngle = directAngleToHub + _ai->_vm->_rnd.getRandomNumber(179) - 90;
+ int randDist = _ai->_vm->_rnd.getRandomNumber(109) + 40;
int x = targetX + randDist * cos(_ai->degToRad(randAngle));
int y = targetY + randDist * sin(_ai->degToRad(randAngle));
@@ -459,7 +459,7 @@ int Defender::calculateDefenseUnitPosition(int targetX, int targetY, int index)
int shieldCount = 0;
for (int k = 0; k < 200; k++) {
- int thisUnit = _vm->_moonbase->readFromArray(unitsArray2, 0, k);
+ int thisUnit = _ai->_vm->_moonbase->readFromArray(unitsArray2, 0, k);
if (thisUnit) {
if ((_ai->getBuildingType(thisUnit) == BUILDING_SHIELD) && (_ai->getBuildingOwner(thisUnit) == currentPlayer))
@@ -472,7 +472,7 @@ int Defender::calculateDefenseUnitPosition(int targetX, int targetY, int index)
}
}
- if ((_vm->_rnd.getRandomNumber((int)pow(3.0f, shieldCount + 1) - 1) == 0) && (_ai->getPlayerEnergy() > 6))
+ if ((_ai->_vm->_rnd.getRandomNumber((int)pow(3.0f, shieldCount + 1) - 1) == 0) && (_ai->getPlayerEnergy() > 6))
setUnit(ITEM_SHIELD);
else
setUnit(ITEM_ANTIAIR);
@@ -480,7 +480,7 @@ int Defender::calculateDefenseUnitPosition(int targetX, int targetY, int index)
setPower(power);
setAngle(angle);
- _vm->_moonbase->deallocateArray(unitsArray2);
+ _ai->_vm->_moonbase->deallocateArray(unitsArray2);
return 1;
}
@@ -527,14 +527,14 @@ int Defender::calculateDefenseUnitPosition(int targetX, int targetY, int index)
if (hubIndex == 0) return -3;
do {
- int sourceHub = hubArray[_vm->_rnd.getRandomNumber(hubIndex - 1)];
+ int sourceHub = hubArray[_ai->_vm->_rnd.getRandomNumber(hubIndex - 1)];
setSourceX(_ai->getHubX(sourceHub));
setSourceY(_ai->getHubY(sourceHub));
setSourceUnit(sourceHub);
setUnit(ITEM_HUB);
- setPower(_vm->_rnd.getRandomNumber(299) + 200);
- setAngle(_vm->_rnd.getRandomNumber(359));
+ setPower(_ai->_vm->_rnd.getRandomNumber(299) + 200);
+ setAngle(_ai->_vm->_rnd.getRandomNumber(359));
count++;
if (count > (NUM_HUBS * 3)) break;
diff --git a/engines/scumm/he/moonbase/moonbase.cpp b/engines/scumm/he/moonbase/moonbase.cpp
index be845c7cd3..d61aa18344 100644
--- a/engines/scumm/he/moonbase/moonbase.cpp
+++ b/engines/scumm/he/moonbase/moonbase.cpp
@@ -26,10 +26,10 @@
namespace Scumm {
-Moonbase::Moonbase(ScummEngine_v71he *vm) : _vm(vm) {
+Moonbase::Moonbase(ScummEngine_v90he *vm) : _vm(vm) {
initFOW();
- _ai = new AI;
+ _ai = new AI(_vm);
}
Moonbase::~Moonbase() {
@@ -37,15 +37,15 @@ Moonbase::~Moonbase() {
}
int Moonbase::readFromArray(int array, int y, int x) {
- _vm->VAR(((ScummEngine_v90he *)_vm)->VAR_U32_ARRAY_UNK) = array;
+ _vm->VAR(_vm->VAR_U32_ARRAY_UNK) = array;
- return _vm->readArray(((ScummEngine_v90he *)_vm)->VAR_U32_ARRAY_UNK, y, x);
+ return _vm->readArray(_vm->VAR_U32_ARRAY_UNK, y, x);
}
void Moonbase::deallocateArray(int array) {
- _vm->VAR(((ScummEngine_v90he *)_vm)->VAR_U32_ARRAY_UNK) = array;
+ _vm->VAR(_vm->VAR_U32_ARRAY_UNK) = array;
- return _vm->nukeArray(((ScummEngine_v90he *)_vm)->VAR_U32_ARRAY_UNK);
+ return _vm->nukeArray(_vm->VAR_U32_ARRAY_UNK);
}
int Moonbase::callScummFunction(int scriptNumber, int paramCount,...) {
diff --git a/engines/scumm/he/moonbase/moonbase.h b/engines/scumm/he/moonbase/moonbase.h
index 1150fec470..cdb70ad19b 100644
--- a/engines/scumm/he/moonbase/moonbase.h
+++ b/engines/scumm/he/moonbase/moonbase.h
@@ -33,7 +33,7 @@ class AI;
class Moonbase {
public:
- Moonbase(ScummEngine_v71he *vm);
+ Moonbase(ScummEngine_v90he *vm);
~Moonbase();
int readFromArray(int array, int y, int x);
@@ -71,7 +71,7 @@ public:
AI *_ai;
private:
- ScummEngine_v71he *_vm;
+ ScummEngine_v90he *_vm;
int _fowFrameBaseNumber;
int _fowAnimationFrames;