aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-21 08:48:36 +0100
committerEugene Sandulenko2016-02-14 17:12:49 +0100
commitc7eed7f0ad4b3c23694c1b97578a4b8b86be54f9 (patch)
tree5c0fa0b6c8cc52be64e3779258872e1e4a2d8f22
parentefdf51d3ddbb89f2fc1858c9f13ee6bb1a8b005a (diff)
downloadscummvm-rg350-c7eed7f0ad4b3c23694c1b97578a4b8b86be54f9.tar.gz
scummvm-rg350-c7eed7f0ad4b3c23694c1b97578a4b8b86be54f9.tar.bz2
scummvm-rg350-c7eed7f0ad4b3c23694c1b97578a4b8b86be54f9.zip
WAGE: Implement getWeapons(). Got rid of class Weapon
-rw-r--r--engines/wage/combat.cpp4
-rw-r--r--engines/wage/entities.cpp50
-rw-r--r--engines/wage/entities.h30
-rw-r--r--engines/wage/menu.cpp4
-rw-r--r--engines/wage/script.cpp8
-rw-r--r--engines/wage/script.h4
-rw-r--r--engines/wage/wage.h3
7 files changed, 66 insertions, 37 deletions
diff --git a/engines/wage/combat.cpp b/engines/wage/combat.cpp
index 17b03d1d4a..be765a8488 100644
--- a/engines/wage/combat.cpp
+++ b/engines/wage/combat.cpp
@@ -106,7 +106,7 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
bool winning = (npc->_context._statVariables[PHYS_HIT_CUR] > player->_context._statVariables[PHYS_HIT_CUR]);
int validMoves = getValidMoveDirections(npc);
- WeaponArray *weapons = npc->getWeapons(false);
+ ObjArray *weapons = npc->getWeapons(false);
ObjArray *magics = npc->getMagicalObjects();
// TODO: Figure out under what circumstances we need to add +1
// for the chance (e.g. only when all values were set to 0?).
@@ -177,7 +177,7 @@ void WageEngine::performCombatAction(Chr *npc, Chr *player) {
delete magics;
}
-void WageEngine::performAttack(Chr *attacker, Chr *victim, Weapon *weapon) {
+void WageEngine::performAttack(Chr *attacker, Chr *victim, Obj *weapon) {
warning("STUB: performAttack()");
}
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 7f40353ba8..0503b8573a 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -361,6 +361,32 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
for (int i = 0; i < NUMBER_OF_ARMOR_TYPES; i++)
_armor[i] = NULL;
+ _weapon1 = NULL;
+ _weapon2 = NULL;
+
+ // Create native weapons
+ if (_nativeWeapon1.size() && _operativeVerb1.size()) {
+ _weapon1 = new Obj;
+
+ _weapon1->_name = _nativeWeapon1;
+ _weapon1->_operativeVerb = _operativeVerb1;
+ _weapon1->_type = Obj::REGULAR_WEAPON;
+ _weapon1->_accuracy = 0;
+ _weapon1->_damage = _weaponDamage1;
+ _weapon1->_sound = _weaponSound1;
+ }
+
+ if (_nativeWeapon2.size() && _operativeVerb2.size()) {
+ _weapon2 = new Obj;
+
+ _weapon2->_name = _nativeWeapon2;
+ _weapon2->_operativeVerb = _operativeVerb2;
+ _weapon2->_type = Obj::REGULAR_WEAPON;
+ _weapon2->_accuracy = 0;
+ _weapon2->_damage = _weaponDamage2;
+ _weapon2->_sound = _weaponSound2;
+ }
+
delete data;
}
@@ -378,10 +404,28 @@ void Chr::resetState() {
_context._statVariables[PHYS_SPE_BAS] = _context._statVariables[PHYS_SPE_CUR] = _runningSpeed;
}
-WeaponArray *Chr::getWeapons(bool includeMagic) {
- WeaponArray *list = new WeaponArray;
+ObjArray *Chr::getWeapons(bool includeMagic) {
+ ObjArray *list = new ObjArray;
+
+ if (_weapon1)
+ list->push_back(_weapon1);
+
+ if (_weapon2)
+ list->push_back(_weapon2);
- warning("STUB: getWeapons");
+ for (uint i = 0; i < _inventory.size(); i++)
+ switch (_inventory[i]->_type) {
+ case Obj::REGULAR_WEAPON:
+ case Obj::THROW_WEAPON:
+ list->push_back(_inventory[i]);
+ break;
+ case Obj::MAGICAL_OBJECT:
+ if (includeMagic)
+ list->push_back(_inventory[i]);
+ break;
+ default:
+ break;
+ }
return list;
}
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index 6a97abf39e..5fc1a08b36 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -58,9 +58,7 @@ class Design;
class Obj;
class Scene;
class Script;
-class Weapon;
-typedef Common::Array<Weapon *> WeaponArray;
typedef Common::Array<Obj *> ObjArray;
typedef Common::Array<Chr *> ChrArray;
typedef Common::List<Obj *> ObjList;
@@ -219,18 +217,14 @@ public:
Context _context;
- WeaponArray *getWeapons(bool includeMagic);
+ ObjArray *getWeapons(bool includeMagic);
ObjArray *getMagicalObjects();
const char *getDefiniteArticle(bool capitalize);
-public:
- bool hasNativeWeapon1() {
- return (_nativeWeapon1.size() > 0 && _operativeVerb1.size() > 0);
- }
+ Obj *_weapon1;
+ Obj *_weapon2;
- bool hasNativeWeapon2() {
- return (_nativeWeapon2.size() > 0 && _operativeVerb2.size() > 0);
- }
+public:
int wearObjIfPossible(Obj *obj);
void wearObjs();
@@ -299,21 +293,13 @@ public:
_currentOwner = NULL;
}
- Chr *removeFromChr();
- Designed *removeFromCharOrScene();
-};
-
-class Weapon : public Obj {
-public:
- int _numberOfUses;
-
- Weapon() : _numberOfUses(0) {}
-
void decrementNumberOfUses() {
- if (_numberOfUses != -1) {
+ if (_numberOfUses != -1)
_numberOfUses--;
- }
}
+
+ Chr *removeFromChr();
+ Designed *removeFromCharOrScene();
};
class Scene : public Designed {
diff --git a/engines/wage/menu.cpp b/engines/wage/menu.cpp
index 0577ad566e..e9cecfc2f0 100644
--- a/engines/wage/menu.cpp
+++ b/engines/wage/menu.cpp
@@ -278,10 +278,10 @@ void Menu::regenWeaponsMenu() {
void Menu::createWeaponsMenu(MenuItem *menu) {
Chr *player = _gui->_engine->_world->_player;
- WeaponArray *weapons = player->getWeapons(true);
+ ObjArray *weapons = player->getWeapons(true);
for (int i = 0; i < weapons->size(); i++) {
- Weapon *obj = (*weapons)[i];
+ Obj *obj = (*weapons)[i];
if (obj->_type == Obj::REGULAR_WEAPON ||
obj->_type == Obj::THROW_WEAPON ||
obj->_type == Obj::MAGICAL_OBJECT) {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 6ccb7b3696..52e0dbf4c3 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -199,8 +199,8 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
handleAcceptCommand();
} else {
Chr *player = _world->_player;
- WeaponArray *weapons = player->getWeapons(true);
- for (WeaponArray::const_iterator weapon = weapons->begin(); weapon != weapons->end(); ++weapon) {
+ ObjArray *weapons = player->getWeapons(true);
+ for (ObjArray::const_iterator weapon = weapons->begin(); weapon != weapons->end(); ++weapon) {
if (tryAttack(*weapon, input)) {
handleAttack(*weapon);
break;
@@ -1076,13 +1076,13 @@ void Script::handleOfferCommand(const char *target) {
warning("STUB: handleOfferCommand");
}
-bool Script::tryAttack(Weapon *weapon, Common::String &input) {
+bool Script::tryAttack(Obj *weapon, Common::String &input) {
warning("STUB: tryAttack");
return false;
}
-void Script::handleAttack(Weapon *weapon) {
+void Script::handleAttack(Obj *weapon) {
warning("STUB: handleAttack");
}
diff --git a/engines/wage/script.h b/engines/wage/script.h
index ed2772568f..788188d506 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -186,8 +186,8 @@ private:
void handleWearCommand(const char *target);
void handleOfferCommand(const char *target);
- bool tryAttack(Weapon *weapon, Common::String &input);
- void handleAttack(Weapon *weapon);
+ bool tryAttack(Obj *weapon, Common::String &input);
+ void handleAttack(Obj *weapon);
Common::Array<ScriptText *> _scriptText;
void convertToText();
diff --git a/engines/wage/wage.h b/engines/wage/wage.h
index 0d540d3c0b..06304d0752 100644
--- a/engines/wage/wage.h
+++ b/engines/wage/wage.h
@@ -67,7 +67,6 @@ class Dialog;
class Gui;
class Obj;
class Scene;
-class Weapon;
class World;
using Common::String;
@@ -131,7 +130,7 @@ private:
void processTurnInternal(Common::String *textInput, Designed *clickInput);
void performCombatAction(Chr *npc, Chr *player);
int getValidMoveDirections(Chr *npc);
- void performAttack(Chr *attacker, Chr *victim, Weapon *weapon);
+ void performAttack(Chr *attacker, Chr *victim, Obj *weapon);
void performMagic(Chr *attacker, Chr *victim, Obj *magicalObject);
void performMove(Chr *chr, int validMoves);
void performOffer(Chr *attacker, Chr *victim);