aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorEugene Sandulenko2015-12-24 14:12:19 +0100
committerEugene Sandulenko2015-12-27 15:41:01 +0100
commitf76eb1831cce8177a3cc477fb1e5d4954635f982 (patch)
tree8143b0b71bbcdbc36c5b7d8ec9008719ce73ebed /engines
parent88faad5d08bc10272f04ebc1ce122b8b446d31a8 (diff)
downloadscummvm-rg350-f76eb1831cce8177a3cc477fb1e5d4954635f982.tar.gz
scummvm-rg350-f76eb1831cce8177a3cc477fb1e5d4954635f982.tar.bz2
scummvm-rg350-f76eb1831cce8177a3cc477fb1e5d4954635f982.zip
WAGE: Implemented object taking logic
Diffstat (limited to 'engines')
-rw-r--r--engines/wage/entities.cpp37
-rw-r--r--engines/wage/entities.h14
-rw-r--r--engines/wage/script.cpp31
-rw-r--r--engines/wage/script.h1
-rw-r--r--engines/wage/world.cpp4
-rw-r--r--engines/wage/world.h1
6 files changed, 76 insertions, 12 deletions
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index e6ce4e9e5a..15fbbb99a7 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -192,6 +192,9 @@ Chr::Chr(String name, Common::SeekableReadStream *data) {
_weaponSound1 = readPascalString(data);
_weaponSound2 = readPascalString(data);
+
+ for (int i = 0; i < NUMBER_OF_ARMOR_TYPES; i++)
+ _armor[i] = NULL;
}
WeaponArray *Chr::getWeapons() {
@@ -202,4 +205,38 @@ WeaponArray *Chr::getWeapons() {
return list;
}
+int Chr::wearObjIfPossible(Obj *obj) {
+ switch (obj->_type) {
+ case Obj::HELMET:
+ if (_armor[HEAD_ARMOR] == NULL) {
+ _armor[HEAD_ARMOR] = obj;
+ return Chr::HEAD_ARMOR;
+ }
+ break;
+ case Obj::CHEST_ARMOR:
+ if (_armor[BODY_ARMOR] == NULL) {
+ _armor[BODY_ARMOR] = obj;
+ return Chr::BODY_ARMOR;
+ }
+ break;
+ case Obj::SHIELD:
+ if (_armor[SHIELD_ARMOR] == NULL) {
+ _armor[SHIELD_ARMOR] = obj;
+ return Chr::SHIELD_ARMOR;
+ }
+ break;
+ case Obj::SPIRITUAL_ARMOR:
+ if (_armor[MAGIC_ARMOR] == NULL) {
+ _armor[MAGIC_ARMOR] = obj;
+ return Chr::MAGIC_ARMOR;
+ }
+ break;
+ default:
+ return -1;
+ }
+
+ return -1;
+}
+
+
} // End of namespace Wage
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index eb3609c7ff..28ce42a365 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -60,7 +60,7 @@ typedef Common::Array<Weapon *> WeaponArray;
class Context {
public:
- enum StatVariables {
+ enum StatVariable {
/** The base physical accuracy of the player. */
PHYS_ACC_BAS = 0,
/** The current physical accuracy of the player. */
@@ -141,7 +141,9 @@ public:
enum ChrArmorType {
HEAD_ARMOR = 0,
BODY_ARMOR = 1,
- SHIELD_ARMOR = 2
+ SHIELD_ARMOR = 2,
+ MAGIC_ARMOR = 3,
+ NUMBER_OF_ARMOR_TYPES = 4
};
Chr(String name, Common::SeekableReadStream *data);
@@ -201,7 +203,7 @@ public:
Scene *_currentScene;
Common::List<Obj> _inventory;
- Obj *_armor[3];
+ Obj *_armor[NUMBER_OF_ARMOR_TYPES];
Context _context;
@@ -276,6 +278,7 @@ public:
bool hasNativeWeapon2() {
return (_nativeWeapon2.size() > 0 && _operativeVerb2.size() > 0);
}
+ int wearObjIfPossible(Obj *obj);
};
class Weapon {
@@ -301,7 +304,7 @@ public:
Obj() : _currentOwner(NULL), _currentScene(NULL) {}
Obj(String name, Common::SeekableReadStream *data);
- enum ObjectTypes {
+ enum ObjectType {
REGULAR_WEAPON = 1,
THROW_WEAPON = 2,
MAGICAL_OBJECT = 3,
@@ -313,7 +316,7 @@ public:
IMMOBILE_OBJECT = 9
};
- enum AttackTypes {
+ enum AttackType {
CAUSES_PHYSICAL_DAMAGE = 0,
CAUSES_SPIRITUAL_DAMAGE = 1,
CAUSES_PHYSICAL_AND_SPIRITUAL_DAMAGE = 2,
@@ -350,7 +353,6 @@ public:
if (currentScene != NULL)
_currentOwner = NULL;
}
-
};
class Scene : public Designed {
diff --git a/engines/wage/script.cpp b/engines/wage/script.cpp
index 5ef1b6e209..dcb993a2a9 100644
--- a/engines/wage/script.cpp
+++ b/engines/wage/script.cpp
@@ -178,16 +178,14 @@ bool Script::execute(World *world, int loopCount, String *inputText, Designed *i
delete weapons;
}
-/*
// TODO: weapons, offer, etc...
- } else if (inputClick instanceof Obj) {
- Obj obj = (Obj) inputClick;
- if (obj.getType() != Obj.IMMOBILE_OBJECT) {
+ } else if (_inputClick->_classType == OBJ) {
+ Obj *obj = (Obj *)_inputClick;
+ if (obj->_type != Obj::IMMOBILE_OBJECT) {
takeObj(obj);
} else {
- appendText(obj.getClickMessage());
+ appendText(obj->_clickMessage);
}
-*/
}
return _handled;
@@ -737,6 +735,27 @@ bool Script::evalClickCondition(Operand *lhs, const char *op, Operand *rhs) {
return false;
}
+void Script::takeObj(Obj *obj) {
+ if (_world->_player->_inventory.size() >= _world->_player->_maximumCarriedObjects) {
+ appendText("Your pack is full, you must drop something.");
+ } else {
+ _world->move(obj, _world->_player);
+ int type = _world->_player->wearObjIfPossible(obj);
+ if (type == Chr::HEAD_ARMOR) {
+ appendText(String("You are now wearing the ") + obj->_name + ".");
+ } else if (type == Chr::BODY_ARMOR) {
+ appendText(String("You are now wearing the ") + obj->_name + ".");
+ } else if (type == Chr::SHIELD_ARMOR) {
+ appendText(String("You are now wearing the ") + obj->_name + ".");
+ } else if (type == Chr::MAGIC_ARMOR) {
+ appendText(String("You are now wearing the ") + obj->_name + ".");
+ } else {
+ appendText(String("You now have the ") + obj->_name + ".");
+ }
+ appendText(obj->_clickMessage);
+ }
+}
+
void Script::processMove() {
warning("STUB: processMove");
}
diff --git a/engines/wage/script.h b/engines/wage/script.h
index b9249c33c6..77b6d7d17e 100644
--- a/engines/wage/script.h
+++ b/engines/wage/script.h
@@ -150,6 +150,7 @@ private:
bool eval(Operand *lhs, const char *op, Operand *rhs);
Operand *convertOperand(Operand *operand, int type);
bool evalClickCondition(Operand *lhs, const char *op, Operand *rhs);
+ void takeObj(Obj *obj);
void processMove();
void processLet();
diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 96f3faf618..b404736d00 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -350,4 +350,8 @@ Common::String *World::loadStringFromDITL(Common::MacResManager *resMan, int res
return NULL;
}
+void World::move(Obj *obj, Chr *chr) {
+ warning("STUB: World::move()");
+}
+
} // End of namespace Wage
diff --git a/engines/wage/world.h b/engines/wage/world.h
index 8e45dcbee5..15a65d8681 100644
--- a/engines/wage/world.h
+++ b/engines/wage/world.h
@@ -60,6 +60,7 @@ public:
bool loadWorld(Common::MacResManager *resMan);
void loadExternalSounds(String fname);
Common::String *loadStringFromDITL(Common::MacResManager *resMan, int resourceId, int itemIndex);
+ void move(Obj *obj, Chr *chr);
String _name;
String _aboutMessage;