Initial commit
This commit is contained in:
47
engines/ultima/ultima1/actions/action.cpp
Normal file
47
engines/ultima/ultima1/actions/action.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/shared/gfx/visual_item.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
Ultima1Game *Action::getGame() {
|
||||
return static_cast<Ultima1Game *>(TreeItem::getGame());
|
||||
}
|
||||
|
||||
Maps::Ultima1Map *Action::getMap() {
|
||||
return static_cast<Maps::Ultima1Map *>(getGame()->getMap());
|
||||
}
|
||||
|
||||
GameResources *Action::getRes() {
|
||||
return getGame()->_res;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
70
engines/ultima/ultima1/actions/action.h
Normal file
70
engines/ultima/ultima1/actions/action.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_ACTION_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_ACTION_H
|
||||
|
||||
#include "ultima/shared/actions/action.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
class Ultima1Game;
|
||||
class GameResources;
|
||||
namespace Maps {
|
||||
class Ultima1Map;
|
||||
}
|
||||
|
||||
namespace Actions {
|
||||
|
||||
class Action : public Shared::Actions::Action {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Action(TreeItem *parent) : Shared::Actions::Action(parent) {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Action() override {}
|
||||
|
||||
/**
|
||||
* Jumps up through the parents to find the root game
|
||||
*/
|
||||
Ultima1Game *getGame();
|
||||
|
||||
/**
|
||||
* Return the game's map
|
||||
*/
|
||||
Maps::Ultima1Map *getMap();
|
||||
|
||||
/**
|
||||
* Gets the data resources for the game
|
||||
*/
|
||||
GameResources *getRes();
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
135
engines/ultima/ultima1/actions/attack.cpp
Normal file
135
engines/ultima/ultima1/actions/attack.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/attack.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/widgets/transport.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(AttackFire, Action)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool AttackFire::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
Shared::Maps::Direction dir = Shared::Maps::MapWidget::directionFromKey(msg->_keyState.keycode);
|
||||
|
||||
if (dir == Shared::Maps::DIR_NONE) {
|
||||
addInfoMsg(game->_res->NOTHING);
|
||||
playFX(1);
|
||||
game->endOfTurn();
|
||||
} else {
|
||||
addInfoMsg(game->_res->DIRECTION_NAMES[(int)dir - 1]);
|
||||
doAttack(dir);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
BEGIN_MESSAGE_MAP(Attack, AttackFire)
|
||||
ON_MESSAGE(AttackMsg)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Attack::AttackMsg(CAttackMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
Maps::Ultima1Map *map = static_cast<Maps::Ultima1Map *>(getMap());
|
||||
const Shared::Character &c = *game->_party;
|
||||
const Shared::Weapon &weapon = *c._weapons[c._equippedWeapon];
|
||||
|
||||
addInfoMsg(Common::String::format("%s %s", game->_res->ACTION_NAMES[0], weapon._shortName.c_str()), false);
|
||||
|
||||
if (weapon._distance == 0) {
|
||||
addInfoMsg("?");
|
||||
game->playFX(1);
|
||||
game->endOfTurn();
|
||||
} else if (map->_mapType == Maps::MAP_DUNGEON) {
|
||||
// In the dungeons, attacks always are straight ahead
|
||||
addInfoMsg("");
|
||||
doAttack(Shared::Maps::DIR_UP);
|
||||
} else if (msg->_direction == Shared::Maps::DIR_NONE) {
|
||||
// Prompt user for direction
|
||||
addInfoMsg(": ", false);
|
||||
Shared::CInfoGetKeypress keyMsg(this);
|
||||
keyMsg.execute(getGame());
|
||||
} else {
|
||||
addInfoMsg(": ", false);
|
||||
addInfoMsg(game->_res->DIRECTION_NAMES[(int)msg->_direction - 1]);
|
||||
|
||||
getMap()->attack(msg->_direction, 7);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Attack::doAttack(Shared::Maps::Direction dir) {
|
||||
getMap()->attack(dir, 7);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
BEGIN_MESSAGE_MAP(Fire, AttackFire)
|
||||
ON_MESSAGE(FireMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Fire::FireMsg(CFireMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
Maps::Ultima1Map *map = static_cast<Maps::Ultima1Map *>(getMap());
|
||||
addInfoMsg(game->_res->ACTION_NAMES[5], false);
|
||||
|
||||
if (map->_mapType != Maps::MAP_OVERWORLD) {
|
||||
// Not on the overworld
|
||||
addInfoMsg("?");
|
||||
playFX(1);
|
||||
endOfTurn();
|
||||
} else {
|
||||
Widgets::Transport *transport = dynamic_cast<Widgets::Transport *>(getMap()->getPlayerWidget());
|
||||
if (transport && !transport->getWeaponsName().empty()) {
|
||||
// Prompt user for direction
|
||||
addInfoMsg(Common::String::format(" %s: ", transport->getWeaponsName().c_str()), false);
|
||||
Shared::CInfoGetKeypress keyMsg(this);
|
||||
keyMsg.execute(getGame());
|
||||
} else {
|
||||
// Not in a transport that has weapons
|
||||
addInfoMsg(game->_res->WHAT);
|
||||
playFX(1);
|
||||
endOfTurn();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Fire::doAttack(Shared::Maps::Direction dir) {
|
||||
getMap()->attack(dir, 8);
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
102
engines/ultima/ultima1/actions/attack.h
Normal file
102
engines/ultima/ultima1/actions/attack.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_ATTACK_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_ATTACK_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/maps/map_widget.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CCharacterInputMsg;
|
||||
using Shared::CAttackMsg;
|
||||
using Shared::CFireMsg;
|
||||
|
||||
/**
|
||||
* Common base class for attack and fire actions
|
||||
*/
|
||||
class AttackFire : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg);
|
||||
protected:
|
||||
/**
|
||||
* Do the attack in a given direction
|
||||
*/
|
||||
virtual void doAttack(Shared::Maps::Direction dir) = 0;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
AttackFire(TreeItem *parent) : Action(parent) {}
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Attack action
|
||||
*/
|
||||
class Attack : public AttackFire {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool AttackMsg(CAttackMsg *msg);
|
||||
protected:
|
||||
/**
|
||||
* Do the attack in a given direction
|
||||
*/
|
||||
void doAttack(Shared::Maps::Direction dir) override;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Attack(TreeItem *parent) : AttackFire(parent) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Fire action
|
||||
*/
|
||||
class Fire : public AttackFire {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool FireMsg(CFireMsg *msg);
|
||||
protected:
|
||||
/**
|
||||
* Do the attack in a given direction
|
||||
*/
|
||||
void doAttack(Shared::Maps::Direction dir) override;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Fire(TreeItem *parent) : AttackFire(parent) {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
45
engines/ultima/ultima1/actions/cast.cpp
Normal file
45
engines/ultima/ultima1/actions/cast.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/cast.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/core/character.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Cast, Action)
|
||||
ON_MESSAGE(CastMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Cast::CastMsg(CCastMsg &msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
addInfoMsg(game->_res->ACTION_NAMES[17], false);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
50
engines/ultima/ultima1/actions/cast.h
Normal file
50
engines/ultima/ultima1/actions/cast.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_CAST_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_CAST_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CCastMsg;
|
||||
|
||||
class Cast : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool CastMsg(CCastMsg &msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Cast(TreeItem *parent);
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
58
engines/ultima/ultima1/actions/map_action.h
Normal file
58
engines/ultima/ultima1/actions/map_action.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_MAP_ACTION_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_MAP_ACTION_H
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
#define MAP_ACTION(NAME, ACTION_NUM, MAP_METHOD) \
|
||||
using Shared::C##NAME##Msg; \
|
||||
class NAME : public Action { DECLARE_MESSAGE_MAP; bool NAME##Msg(C##NAME##Msg *msg) { \
|
||||
addInfoMsg(getRes()->ACTION_NAMES[ACTION_NUM], false); \
|
||||
getMap()->MAP_METHOD(); \
|
||||
return true; } \
|
||||
public: \
|
||||
CLASSDEF; \
|
||||
NAME(TreeItem *parent) : Action(parent) {} \
|
||||
}; \
|
||||
BEGIN_MESSAGE_MAP(NAME, Action) ON_MESSAGE(NAME##Msg) END_MESSAGE_MAP()
|
||||
|
||||
#define MAP_ACTION_END_TURN(NAME, ACTION_NUM, MAP_METHOD) \
|
||||
using Shared::C##NAME##Msg; \
|
||||
class NAME : public Action { DECLARE_MESSAGE_MAP; bool NAME##Msg(C##NAME##Msg *msg) { \
|
||||
addInfoMsg(getRes()->ACTION_NAMES[ACTION_NUM], false); \
|
||||
getMap()->MAP_METHOD(); \
|
||||
endOfTurn(); \
|
||||
return true; } \
|
||||
public: \
|
||||
CLASSDEF; \
|
||||
NAME(TreeItem *parent) : Action(parent) {} \
|
||||
}; \
|
||||
BEGIN_MESSAGE_MAP(NAME, Action) ON_MESSAGE(NAME##Msg) END_MESSAGE_MAP()
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
181
engines/ultima/ultima1/actions/move.cpp
Normal file
181
engines/ultima/ultima1/actions/move.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/move.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/widgets/transport.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Move, Action)
|
||||
ON_MESSAGE(MoveMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Move::MoveMsg(CMoveMsg *msg) {
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
|
||||
if (map->_mapType == Maps::MAP_DUNGEON) {
|
||||
switch (msg->_direction) {
|
||||
case Shared::Maps::DIR_LEFT:
|
||||
dungeonTurnLeft();
|
||||
break;
|
||||
case Shared::Maps::DIR_RIGHT:
|
||||
dungeonTurnRight();
|
||||
break;
|
||||
case Shared::Maps::DIR_DOWN:
|
||||
dungeonTurnAround();
|
||||
break;
|
||||
case Shared::Maps::DIR_UP:
|
||||
dungeonMoveForward();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
Shared::Maps::MapWidget *player = map->getPlayerWidget();
|
||||
assert(player);
|
||||
|
||||
// Figure out the new position
|
||||
Point delta;
|
||||
switch (msg->_direction) {
|
||||
case Shared::Maps::DIR_WEST:
|
||||
delta = Point(-1, 0);
|
||||
break;
|
||||
case Shared::Maps::DIR_EAST:
|
||||
delta = Point(1, 0);
|
||||
break;
|
||||
case Shared::Maps::DIR_NORTH:
|
||||
delta = Point(0, -1);
|
||||
break;
|
||||
case Shared::Maps::DIR_SOUTH:
|
||||
delta = Point(0, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
// Check if the player's widget type can move to the new position
|
||||
Point newPos = map->getDeltaPosition(delta);
|
||||
if (player->canMoveTo(newPos) == Shared::Maps::MapWidget::YES) {
|
||||
// Shift the viewport
|
||||
map->shiftViewport(delta);
|
||||
|
||||
// Move to the new position
|
||||
player->moveTo(newPos);
|
||||
addInfoMsg(getRes()->DIRECTION_NAMES[msg->_direction - 1]);
|
||||
} else {
|
||||
// Nope, so show a blocked message
|
||||
addInfoMsg(getRes()->BLOCKED);
|
||||
playFX(1);
|
||||
}
|
||||
}
|
||||
|
||||
endOfTurn();
|
||||
return true;
|
||||
}
|
||||
|
||||
void Move::dungeonTurnLeft() {
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
|
||||
switch (map->getDirection()) {
|
||||
case Shared::Maps::DIR_LEFT:
|
||||
map->setDirection(Shared::Maps::DIR_DOWN);
|
||||
break;
|
||||
case Shared::Maps::DIR_RIGHT:
|
||||
map->setDirection(Shared::Maps::DIR_UP);
|
||||
break;
|
||||
case Shared::Maps::DIR_DOWN:
|
||||
map->setDirection(Shared::Maps::DIR_RIGHT);
|
||||
break;
|
||||
case Shared::Maps::DIR_UP:
|
||||
map->setDirection(Shared::Maps::DIR_LEFT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
addInfoMsg(getGame()->_res->DUNGEON_MOVES[Shared::Maps::DIR_LEFT - 1]);
|
||||
}
|
||||
|
||||
void Move::dungeonTurnRight() {
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
|
||||
switch (map->getDirection()) {
|
||||
case Shared::Maps::DIR_LEFT:
|
||||
map->setDirection(Shared::Maps::DIR_UP);
|
||||
break;
|
||||
case Shared::Maps::DIR_RIGHT:
|
||||
map->setDirection(Shared::Maps::DIR_DOWN);
|
||||
break;
|
||||
case Shared::Maps::DIR_DOWN:
|
||||
map->setDirection(Shared::Maps::DIR_LEFT);
|
||||
break;
|
||||
case Shared::Maps::DIR_UP:
|
||||
map->setDirection(Shared::Maps::DIR_RIGHT);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
addInfoMsg(getGame()->_res->DUNGEON_MOVES[Shared::Maps::DIR_RIGHT - 1]);
|
||||
}
|
||||
|
||||
void Move::dungeonTurnAround() {
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
|
||||
switch (map->getDirection()) {
|
||||
case Shared::Maps::DIR_LEFT:
|
||||
map->setDirection(Shared::Maps::DIR_RIGHT);
|
||||
break;
|
||||
case Shared::Maps::DIR_RIGHT:
|
||||
map->setDirection(Shared::Maps::DIR_LEFT);
|
||||
break;
|
||||
case Shared::Maps::DIR_DOWN:
|
||||
map->setDirection(Shared::Maps::DIR_UP);
|
||||
break;
|
||||
case Shared::Maps::DIR_UP:
|
||||
map->setDirection(Shared::Maps::DIR_DOWN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
addInfoMsg(getGame()->_res->DUNGEON_MOVES[Shared::Maps::DIR_DOWN - 1]);
|
||||
}
|
||||
|
||||
void Move::dungeonMoveForward() {
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
Point delta = map->getDirectionDelta();
|
||||
Shared::Maps::MapWidget *player = map->getPlayerWidget();
|
||||
assert(player);
|
||||
|
||||
if (player->canMoveTo(map->getPosition() + delta) != Shared::Maps::MapWidget::NO) {
|
||||
map->setPosition(map->getPosition() + delta);
|
||||
} else {
|
||||
playFX(0);
|
||||
}
|
||||
|
||||
addInfoMsg(getGame()->_res->DUNGEON_MOVES[Shared::Maps::DIR_UP - 1]);
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
75
engines/ultima/ultima1/actions/move.h
Normal file
75
engines/ultima/ultima1/actions/move.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_MOVE_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_MOVE_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CMoveMsg;
|
||||
|
||||
class Move : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool MoveMsg(CMoveMsg *msg);
|
||||
private:
|
||||
/**
|
||||
* Turn left
|
||||
*/
|
||||
void dungeonTurnLeft();
|
||||
|
||||
/**
|
||||
* Turn right
|
||||
*/
|
||||
void dungeonTurnRight();
|
||||
|
||||
/**
|
||||
* Turn around
|
||||
*/
|
||||
void dungeonTurnAround();
|
||||
|
||||
/**
|
||||
* Move forwards
|
||||
*/
|
||||
void dungeonMoveForward();
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Move(Shared::TreeItem *parent) : Action(parent) {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Move() override {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
46
engines/ultima/ultima1/actions/quit.cpp
Normal file
46
engines/ultima/ultima1/actions/quit.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/quit.h"
|
||||
#include "ultima/ultima1/u1dialogs/stats.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/early/ultima_early.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Quit, Action)
|
||||
ON_MESSAGE(QuitMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Quit::QuitMsg(CQuitMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
addInfoMsg(game->_res->ACTION_NAMES[16]);
|
||||
g_vm->saveGameDialog();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
50
engines/ultima/ultima1/actions/quit.h
Normal file
50
engines/ultima/ultima1/actions/quit.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_QUIT_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_QUIT_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CQuitMsg;
|
||||
|
||||
class Quit : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool QuitMsg(CQuitMsg *msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Quit(TreeItem *parent) : Action(parent) {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
47
engines/ultima/ultima1/actions/ready.cpp
Normal file
47
engines/ultima/ultima1/actions/ready.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/ready.h"
|
||||
#include "ultima/ultima1/u1dialogs/ready.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Ready, Action)
|
||||
ON_MESSAGE(ReadyMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Ready::ReadyMsg(CReadyMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
addInfoMsg(game->_res->ACTION_NAMES[17], false);
|
||||
|
||||
U1Dialogs::Ready *dialog = new U1Dialogs::Ready(game);
|
||||
dialog->show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
50
engines/ultima/ultima1/actions/ready.h
Normal file
50
engines/ultima/ultima1/actions/ready.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_READY_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_READY_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CReadyMsg;
|
||||
|
||||
class Ready : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool ReadyMsg(CReadyMsg *msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Ready(TreeItem *parent) : Action(parent) {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
47
engines/ultima/ultima1/actions/stats.cpp
Normal file
47
engines/ultima/ultima1/actions/stats.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/actions/stats.h"
|
||||
#include "ultima/ultima1/u1dialogs/stats.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Stats, Action)
|
||||
ON_MESSAGE(StatsMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
bool Stats::StatsMsg(CStatsMsg *msg) {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
addInfoMsg(game->_res->ACTION_NAMES[25]);
|
||||
|
||||
U1Dialogs::Stats *dialog = new U1Dialogs::Stats(game);
|
||||
dialog->show();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
50
engines/ultima/ultima1/actions/stats.h
Normal file
50
engines/ultima/ultima1/actions/stats.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ACTIONS_STATS_H
|
||||
#define ULTIMA_ULTIMA1_ACTIONS_STATS_H
|
||||
|
||||
#include "ultima/ultima1/actions/action.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Actions {
|
||||
|
||||
using Shared::CStatsMsg;
|
||||
|
||||
class Stats : public Action {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool StatsMsg(CStatsMsg *msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Stats(TreeItem *parent) : Action(parent) {}
|
||||
};
|
||||
|
||||
} // End of namespace Actions
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
65
engines/ultima/ultima1/core/debugger.cpp
Normal file
65
engines/ultima/ultima1/core/debugger.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/core/debugger.h"
|
||||
#include "ultima/shared/early/game.h"
|
||||
#include "ultima/shared/early/ultima_early.h"
|
||||
#include "ultima/shared/maps/map.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
static int strToInt(const char *s) {
|
||||
if (!*s)
|
||||
// No string at all
|
||||
return 0;
|
||||
else if (toupper(s[strlen(s) - 1]) != 'H')
|
||||
// Standard decimal string
|
||||
return atoi(s);
|
||||
|
||||
// Hexadecimal string
|
||||
uint tmp = 0;
|
||||
int read = sscanf(s, "%xh", &tmp);
|
||||
if (read < 1)
|
||||
error("strToInt failed on string \"%s\"", s);
|
||||
return (int)tmp;
|
||||
}
|
||||
|
||||
Debugger::Debugger() : GUI::Debugger() {
|
||||
registerCmd("spell", WRAP_METHOD(Debugger, cmdSpell));
|
||||
}
|
||||
|
||||
bool Debugger::cmdSpell(int argc, const char **argv) {
|
||||
if (argc != 2) {
|
||||
debugPrintf("spell <spell number>\n");
|
||||
return true;
|
||||
} else {
|
||||
int spellId = strToInt(argv[1]);
|
||||
Shared::Game *game = dynamic_cast<Shared::Game *>(g_vm->_game);
|
||||
assert(game);
|
||||
|
||||
game->_map->castSpell(spellId);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
44
engines/ultima/ultima1/core/debugger.h
Normal file
44
engines/ultima/ultima1/core/debugger.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_ENGINE_DEBUGGER_H
|
||||
#define ULTIMA_ULTIMA1_ENGINE_DEBUGGER_H
|
||||
|
||||
#include "gui/debugger.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
/**
|
||||
* Debugger base class
|
||||
*/
|
||||
class Debugger : public GUI::Debugger {
|
||||
private:
|
||||
bool cmdSpell(int argc, const char **argv);
|
||||
public:
|
||||
Debugger();
|
||||
~Debugger() override {}
|
||||
};
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
53
engines/ultima/ultima1/core/game_state.h
Normal file
53
engines/ultima/ultima1/core/game_state.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_CORE_GAME_STATE_H
|
||||
#define ULTIMA_ULTIMA1_CORE_GAME_STATE_H
|
||||
|
||||
#include "ultima/shared/core/game_state.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
class Ultima1Game;
|
||||
|
||||
class GameState : public Shared::GameState {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
GameState(Ultima1Game *game);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~GameState() {}
|
||||
|
||||
/**
|
||||
* Setup the initial game state
|
||||
*/
|
||||
void setup() override;
|
||||
};
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
37
engines/ultima/ultima1/core/messages.h
Normal file
37
engines/ultima/ultima1/core/messages.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_CORE_MESSAGES_H
|
||||
#define ULTIMA_ULTIMA1_CORE_MESSAGES_H
|
||||
|
||||
#include "ultima/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
typedef Ultima::CMessage CMessage;
|
||||
|
||||
MESSAGE1(CMoveMsg, int, direction, 0);
|
||||
|
||||
} // End of namespace Shared
|
||||
} // End of namespace Xeen
|
||||
|
||||
#endif
|
||||
181
engines/ultima/ultima1/core/party.cpp
Normal file
181
engines/ultima/ultima1/core/party.cpp
Normal file
@@ -0,0 +1,181 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* Foundation, In, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
Party::Party(Ultima1Game *game) {
|
||||
add(new Character(game));
|
||||
}
|
||||
|
||||
void Party::setup() {
|
||||
static_cast<Character *>(_characters.front())->setup();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
Character::Character(Ultima1Game *game) : Shared::Character(),
|
||||
_weaponHands(game, this, WEAPON_HANDS),
|
||||
_weaponDagger(game, this, WEAPON_DAGGER),
|
||||
_weaponMace(game, this, WEAPON_MACE),
|
||||
_weaponAxe(game, this, WEAPON_AXE),
|
||||
_weaponRopeSpikes(game, this, WEAPON_ROPE_SPIKES),
|
||||
_weaponSword(game, this, WEAPON_SWORD),
|
||||
_weaponGreatSword(game, this, WEAPON_GREAT_SWORD),
|
||||
_weaponBowArrows(game, this, WEAPON_BOW_ARROWS),
|
||||
_weaponAmulet(game, this, WEAPON_AMULET),
|
||||
_weaponWand(game, this, WEAPON_WAND),
|
||||
_weaponStaff(game, this, WEAPON_STAFF),
|
||||
_weaponTriangle(game, this, WEAPON_TRIANGLE),
|
||||
_weaponPistol(game, this, WEAPON_PISTOL),
|
||||
_weaponLightSword(game, this, WEAPON_LIGHT_SWORD),
|
||||
_weaponPhazor(game, this, WEAPON_PHAZOR),
|
||||
_weaponBlaster(game, this, WEAPON_BLASTER),
|
||||
|
||||
_armourSkin(game, this, ARMOR_SKIN),
|
||||
_armourLeatherArmor(game, this, ARMOR_LEATHER_armour),
|
||||
_armourChainMail(game, this, ARMOR_CHAIN_MAIL),
|
||||
_armourPlateMail(game, this, ARMOR_PLATE_MAIL),
|
||||
_armourVacuumSuit(game, this, ARMOR_VACUUM_SUIT),
|
||||
_armourReflectSuit(game, this, ARMOR_REFLECT_SUIT),
|
||||
|
||||
_spellBlink(game, this),
|
||||
_spellCreate(game, this),
|
||||
_spellDestroy(game, this),
|
||||
_spellKill(game, this),
|
||||
_spellLadderDown(game, this),
|
||||
_spellLadderUp(game, this),
|
||||
_spellMagicMissile(game, this),
|
||||
_spellOpen(game, this),
|
||||
_spellPrayer(game, this),
|
||||
_spellSteal(game, this),
|
||||
_spellUnlock(game, this) {
|
||||
setup();
|
||||
}
|
||||
|
||||
void Character::setup() {
|
||||
// Weapons setup
|
||||
_weapons.push_back(&_weaponHands);
|
||||
_weapons.push_back(&_weaponDagger);
|
||||
_weapons.push_back(&_weaponMace);
|
||||
_weapons.push_back(&_weaponAxe);
|
||||
_weapons.push_back(&_weaponRopeSpikes);
|
||||
_weapons.push_back(&_weaponSword);
|
||||
_weapons.push_back(&_weaponGreatSword);
|
||||
_weapons.push_back(&_weaponBowArrows);
|
||||
_weapons.push_back(&_weaponAmulet);
|
||||
_weapons.push_back(&_weaponWand);
|
||||
_weapons.push_back(&_weaponStaff);
|
||||
_weapons.push_back(&_weaponTriangle);
|
||||
_weapons.push_back(&_weaponPistol);
|
||||
_weapons.push_back(&_weaponLightSword);
|
||||
_weapons.push_back(&_weaponPhazor);
|
||||
_weapons.push_back(&_weaponBlaster);
|
||||
|
||||
// Armor setup
|
||||
_armour.push_back(&_armourSkin);
|
||||
_armour.push_back(&_armourLeatherArmor);
|
||||
_armour.push_back(&_armourChainMail);
|
||||
_armour.push_back(&_armourPlateMail);
|
||||
_armour.push_back(&_armourVacuumSuit);
|
||||
_armour.push_back(&_armourReflectSuit);
|
||||
|
||||
// Spells setup
|
||||
_spells.push_back(&_spellPrayer);
|
||||
_spells.push_back(&_spellOpen);
|
||||
_spells.push_back(&_spellUnlock);
|
||||
_spells.push_back(&_spellMagicMissile);
|
||||
_spells.push_back(&_spellSteal);
|
||||
_spells.push_back(&_spellLadderDown);
|
||||
_spells.push_back(&_spellLadderUp);
|
||||
_spells.push_back(&_spellBlink);
|
||||
_spells.push_back(&_spellCreate);
|
||||
_spells.push_back(&_spellDestroy);
|
||||
_spells.push_back(&_spellKill);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
Weapon::Weapon(Ultima1Game *game, Character *c, WeaponType weaponType) :
|
||||
_game(game), _character(c), _type(weaponType) {
|
||||
_longName = game->_res->WEAPON_NAMES_UPPERCASE[weaponType];
|
||||
_shortName = game->_res->WEAPON_NAMES_LOWERCASE[weaponType];
|
||||
_distance = game->_res->WEAPON_DISTANCES[weaponType];
|
||||
|
||||
if (weaponType == WEAPON_HANDS)
|
||||
_quantity = 0xffff;
|
||||
}
|
||||
|
||||
|
||||
uint Weapon::getMagicDamage() const {
|
||||
uint damage = _game->getRandomNumber(1, _character->_intelligence);
|
||||
|
||||
switch (_type) {
|
||||
case WEAPON_WAND:
|
||||
damage *= 2;
|
||||
break;
|
||||
case WEAPON_AMULET:
|
||||
damage = (damage * 3) / 2;
|
||||
break;
|
||||
case WEAPON_STAFF:
|
||||
case WEAPON_TRIANGLE:
|
||||
damage *= 3;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
uint Weapon::getBuyCost() const {
|
||||
return ((255 - _character->_intelligence) * _type * _type) / 256 + 5;
|
||||
}
|
||||
|
||||
uint Weapon::getSellCost() const {
|
||||
return ((_character->_intelligence + 40) * _type * _type) / 256 + 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
Armour::Armour(Ultima1Game *game, Character *c, ArmorType armorType) :
|
||||
_character(c), _type(armorType) {
|
||||
_name = game->_res->ARMOR_NAMES[armorType];
|
||||
|
||||
if (armorType == ARMOR_SKIN)
|
||||
_quantity = 0xffff;
|
||||
}
|
||||
|
||||
uint Armour::getBuyCost() const {
|
||||
return (200 - _character->_intelligence) / 4 * _type;
|
||||
}
|
||||
|
||||
uint Armour::getSellCost() const {
|
||||
return (_character->_charisma / 4) * _type;
|
||||
}
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
225
engines/ultima/ultima1/core/party.h
Normal file
225
engines/ultima/ultima1/core/party.h
Normal file
@@ -0,0 +1,225 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_CORE_PARTY_H
|
||||
#define ULTIMA_ULTIMA1_CORE_PARTY_H
|
||||
|
||||
#include "ultima/shared/core/party.h"
|
||||
#include "ultima/ultima1/spells/blink.h"
|
||||
#include "ultima/ultima1/spells/create.h"
|
||||
#include "ultima/ultima1/spells/destroy.h"
|
||||
#include "ultima/ultima1/spells/kill_magic_missile.h"
|
||||
#include "ultima/ultima1/spells/ladder_down.h"
|
||||
#include "ultima/ultima1/spells/ladder_up.h"
|
||||
#include "ultima/ultima1/spells/open_unlock.h"
|
||||
#include "ultima/ultima1/spells/prayer.h"
|
||||
#include "ultima/ultima1/spells/steal.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
enum WeaponType {
|
||||
WEAPON_HANDS = 0, WEAPON_DAGGER = 1, WEAPON_MACE = 2, WEAPON_AXE = 3, WEAPON_ROPE_SPIKES = 4,
|
||||
WEAPON_SWORD = 5, WEAPON_GREAT_SWORD = 6, WEAPON_BOW_ARROWS = 7, WEAPON_AMULET = 8,
|
||||
WEAPON_WAND = 9, WEAPON_STAFF = 10, WEAPON_TRIANGLE = 11, WEAPON_PISTOL = 12,
|
||||
WEAPON_LIGHT_SWORD = 13, WEAPON_PHAZOR = 14, WEAPON_BLASTER = 15
|
||||
};
|
||||
|
||||
enum ArmorType {
|
||||
ARMOR_SKIN = 0, ARMOR_LEATHER_armour = 1, ARMOR_CHAIN_MAIL = 2, ARMOR_PLATE_MAIL = 3,
|
||||
ARMOR_VACUUM_SUIT = 4, ARMOR_REFLECT_SUIT = 5
|
||||
};
|
||||
|
||||
class Ultima1Game;
|
||||
class Character;
|
||||
|
||||
/**
|
||||
* Derived weapon class
|
||||
*/
|
||||
class Weapon : public Shared::Weapon {
|
||||
private:
|
||||
Ultima1Game *_game;
|
||||
Character *_character;
|
||||
WeaponType _type;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Weapon(Ultima1Game *game, Character *c, WeaponType weaponType);
|
||||
|
||||
/**
|
||||
* Change the quantity by a given amount
|
||||
*/
|
||||
void changeQuantity(int delta) override {
|
||||
if (_type != WEAPON_HANDS)
|
||||
_quantity = (uint)CLIP((int)_quantity + delta, 0, 9999);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the magic damage a given weapon does
|
||||
*/
|
||||
uint getMagicDamage() const;
|
||||
|
||||
/**
|
||||
* Gets how much the weapon can be bought for
|
||||
*/
|
||||
uint getBuyCost() const;
|
||||
|
||||
/**
|
||||
* Gets how much the weapon can sell for
|
||||
*/
|
||||
uint getSellCost() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* Derived armor class
|
||||
*/
|
||||
class Armour : public Shared::Armour {
|
||||
private:
|
||||
// Ultima1Game *_game;
|
||||
Character *_character;
|
||||
ArmorType _type;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Armour(Ultima1Game *game, Character *c, ArmorType armorType);
|
||||
|
||||
/**
|
||||
* Change the quantity by a given amount
|
||||
*/
|
||||
void changeQuantity(int delta) override {
|
||||
if (_type != ARMOR_SKIN)
|
||||
_quantity = (uint)CLIP((int)_quantity + delta, 0, 9999);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets how much the weapon can be bought for
|
||||
*/
|
||||
uint getBuyCost() const;
|
||||
|
||||
/**
|
||||
* Gets how much the weapon can sell for
|
||||
*/
|
||||
uint getSellCost() const;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Implements the data for a playable character within the game
|
||||
*/
|
||||
class Character : public Shared::Character {
|
||||
private:
|
||||
// Ultima1Game *_game;
|
||||
|
||||
Weapon _weaponHands;
|
||||
Weapon _weaponDagger;
|
||||
Weapon _weaponMace;
|
||||
Weapon _weaponAxe;
|
||||
Weapon _weaponRopeSpikes;
|
||||
Weapon _weaponSword;
|
||||
Weapon _weaponGreatSword;
|
||||
Weapon _weaponBowArrows;
|
||||
Weapon _weaponAmulet;
|
||||
Weapon _weaponWand;
|
||||
Weapon _weaponStaff;
|
||||
Weapon _weaponTriangle;
|
||||
Weapon _weaponPistol;
|
||||
Weapon _weaponLightSword;
|
||||
Weapon _weaponPhazor;
|
||||
Weapon _weaponBlaster;
|
||||
|
||||
Armour _armourSkin;
|
||||
Armour _armourLeatherArmor;
|
||||
Armour _armourChainMail;
|
||||
Armour _armourPlateMail;
|
||||
Armour _armourVacuumSuit;
|
||||
Armour _armourReflectSuit;
|
||||
|
||||
Spells::Blink _spellBlink;
|
||||
Spells::Create _spellCreate;
|
||||
Spells::Destroy _spellDestroy;
|
||||
Spells::Kill _spellKill;
|
||||
Spells::LadderDown _spellLadderDown;
|
||||
Spells::LadderUp _spellLadderUp;
|
||||
Spells::MagicMissile _spellMagicMissile;
|
||||
Spells::Open _spellOpen;
|
||||
Spells::Prayer _spellPrayer;
|
||||
Spells::Steal _spellSteal;
|
||||
Spells::Unlock _spellUnlock;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Character(Ultima1Game *game);
|
||||
virtual ~Character() {}
|
||||
|
||||
/**
|
||||
* Setup the party
|
||||
*/
|
||||
void setup();
|
||||
|
||||
/**
|
||||
* Return the equipped weapon
|
||||
*/
|
||||
Weapon *equippedWeapon() const { return static_cast<Weapon *>(_weapons[_equippedWeapon]); }
|
||||
|
||||
/**
|
||||
* Return the equipped armor
|
||||
*/
|
||||
Armour *equippedArmour() const { return static_cast<Armour *>(_armour[_equippedArmour]); }
|
||||
|
||||
/**
|
||||
* Return the equipped spell
|
||||
*/
|
||||
Spells::Spell *equippedSpell() const { return static_cast<Spells::Spell *>(_spells[_equippedSpell]); }
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements the party
|
||||
*/
|
||||
class Party : public Shared::Party {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Party(Ultima1Game *game);
|
||||
|
||||
/**
|
||||
* Setup the party
|
||||
*/
|
||||
void setup();
|
||||
|
||||
/**
|
||||
* Operator casting
|
||||
*/
|
||||
operator Character *() const { return static_cast<Character *>(_characters.front()); }
|
||||
|
||||
/**
|
||||
* Operator casting
|
||||
*/
|
||||
operator Character &() const { return *static_cast<Character *>(_characters.front()); }
|
||||
};
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
61
engines/ultima/ultima1/core/quests.cpp
Normal file
61
engines/ultima/ultima1/core/quests.cpp
Normal file
@@ -0,0 +1,61 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* Foundation, In, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/core/quests.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
Quests::Quests(Ultima1Game *game) {
|
||||
for (int idx = 0; idx < FLAGS_COUNT; ++idx)
|
||||
push_back(QuestFlag(game));
|
||||
}
|
||||
|
||||
void Quests::synchronize(Common::Serializer &s) {
|
||||
for (uint idx = 0; idx < size(); ++idx)
|
||||
(*this)[idx].synchronize(s);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
void QuestFlag::synchronize(Common::Serializer &s) {
|
||||
s.syncAsByte(_state);
|
||||
}
|
||||
|
||||
void QuestFlag::start() {
|
||||
_state = IN_PROGRESS;
|
||||
}
|
||||
|
||||
void QuestFlag::complete() {
|
||||
if (isInProgress()) {
|
||||
_state = COMPLETED;
|
||||
|
||||
Shared::CInfoMsg msg(_game->_res->QUEST_COMPLETED, true);
|
||||
msg.execute(_game);
|
||||
_game->playFX(5);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
103
engines/ultima/ultima1/core/quests.h
Normal file
103
engines/ultima/ultima1/core/quests.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_CORE_QUESTS_H
|
||||
#define ULTIMA_ULTIMA1_CORE_QUESTS_H
|
||||
|
||||
#include "common/array.h"
|
||||
#include "common/serializer.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
#define FLAGS_COUNT 9
|
||||
|
||||
class Ultima1Game;
|
||||
|
||||
/**
|
||||
* Quest entry
|
||||
*/
|
||||
class QuestFlag {
|
||||
enum FlagState { UNSTARTED = 0, IN_PROGRESS = -1, COMPLETED = 1 };
|
||||
private:
|
||||
Ultima1Game *_game;
|
||||
FlagState _state;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
QuestFlag() : _game(nullptr), _state(UNSTARTED) {}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
QuestFlag(Ultima1Game *game) : _game(game), _state(UNSTARTED) {}
|
||||
|
||||
/**
|
||||
* Synchronize the data for a single flag
|
||||
*/
|
||||
void synchronize(Common::Serializer &s);
|
||||
|
||||
/**
|
||||
* Returns true if the quest is unstarted
|
||||
*/
|
||||
bool isUnstarted() const { return _state == UNSTARTED; }
|
||||
|
||||
/**
|
||||
* Returns true if the quest is in progress
|
||||
*/
|
||||
bool isInProgress() const { return _state == IN_PROGRESS; }
|
||||
|
||||
/**
|
||||
* Called when a quest is completed
|
||||
*/
|
||||
bool isComplete() const { return _state == COMPLETED; }
|
||||
|
||||
/**
|
||||
* Mark a quest as in progress
|
||||
*/
|
||||
void start();
|
||||
|
||||
/**
|
||||
* Complete an in-progress quest
|
||||
*/
|
||||
void complete();
|
||||
};
|
||||
/**
|
||||
* Manages the list of quest flags
|
||||
*/
|
||||
class Quests : public Common::Array<QuestFlag> {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Quests(Ultima1Game *game);
|
||||
|
||||
/**
|
||||
* Synchronize the data for a single flag
|
||||
*/
|
||||
void synchronize(Common::Serializer &s);
|
||||
};
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
1021
engines/ultima/ultima1/core/resources.cpp
Normal file
1021
engines/ultima/ultima1/core/resources.cpp
Normal file
File diff suppressed because it is too large
Load Diff
186
engines/ultima/ultima1/core/resources.h
Normal file
186
engines/ultima/ultima1/core/resources.h
Normal file
@@ -0,0 +1,186 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_CORE_RESOURCES_H
|
||||
#define ULTIMA_ULTIMA1_CORE_RESOURCES_H
|
||||
|
||||
#include "ultima/shared/engine/resources.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
#define LOCATION_COUNT 84
|
||||
|
||||
class GameResources : public Shared::LocalResourceFile {
|
||||
protected:
|
||||
/**
|
||||
* Synchronize resource data
|
||||
*/
|
||||
void synchronize() override;
|
||||
public:
|
||||
const char *TITLE_MESSAGES[13];
|
||||
const char *MAIN_MENU_TEXT[7];
|
||||
const char *CHAR_GEN_TEXT[14];
|
||||
const char *RACE_NAMES[4];
|
||||
const char *SEX_NAMES[3];
|
||||
const char *CLASS_NAMES[4];
|
||||
const char *TRANSPORT_NAMES[10];
|
||||
const char *STAT_NAMES[10];
|
||||
const char *STATUS_TEXT[4];
|
||||
const char *DIRECTION_NAMES[4];
|
||||
const char *DUNGEON_MOVES[4];
|
||||
const char *LOCATION_NAMES[LOCATION_COUNT];
|
||||
byte LOCATION_X[LOCATION_COUNT];
|
||||
byte LOCATION_Y[LOCATION_COUNT];
|
||||
int LOCATION_PEOPLE[150][4];
|
||||
byte DUNGEON_DRAW_DATA[1964];
|
||||
const char *DUNGEON_ITEM_NAMES[2];
|
||||
const char *WEAPON_NAMES_UPPERCASE[16];
|
||||
const char *WEAPON_NAMES_LOWERCASE[16];
|
||||
const char *WEAPON_NAMES_ARTICLE[16];
|
||||
byte WEAPON_DISTANCES[16];
|
||||
const char *ARMOR_NAMES[6];
|
||||
const char *ARMOR_NAMES_ARTICLE[6];
|
||||
const char *SPELL_NAMES[11];
|
||||
const char *SPELL_PHRASES[14];
|
||||
const char *GEM_NAMES[4];
|
||||
byte OVERWORLD_MONSTER_DAMAGE[15];
|
||||
const char *OVERWORLD_MONSTER_NAMES[15];
|
||||
const char *DUNGEON_MONSTER_NAMES[99];
|
||||
const char *LAND_NAMES[4];
|
||||
const char *BLOCKED;
|
||||
const char *ENTERING;
|
||||
const char *THE_CITY_OF;
|
||||
const char *DUNGEON_LEVEL;
|
||||
const char *ATTACKED_BY;
|
||||
const char *ARMOR_DESTROYED;
|
||||
const char *GREMLIN_STOLE;
|
||||
const char *MENTAL_ATTACK;
|
||||
const char *MISSED;
|
||||
const char *KILLED;
|
||||
const char *DESTROYED;
|
||||
const char *THIEF_STOLE;
|
||||
const char *A, *AN;
|
||||
const char *HIT;
|
||||
const char *HIT_CREATURE;
|
||||
const char *ATTACKS;
|
||||
const char *DAMAGE;
|
||||
const char *BARD_SPEECH1;
|
||||
const char *BARD_SPEECH2;
|
||||
const char *JESTER_SPEECH1;
|
||||
const char *JESTER_SPEECH2;
|
||||
const char *FOUND_KEY;
|
||||
const char *BARD_STOLEN;
|
||||
const char *JESTER_STOLEN;
|
||||
const char *YOU_ARE_AT_SEA;
|
||||
const char *YOU_ARE_IN_WOODS;
|
||||
const char *YOU_ARE_IN_LANDS;
|
||||
const char *FIND;
|
||||
const char *A_SECRET_DOOR;
|
||||
const char *GAIN_HIT_POINTS;
|
||||
const char *OPENED;
|
||||
|
||||
const char *ACTION_NAMES[26];
|
||||
const char *HUH;
|
||||
const char *WHAT;
|
||||
const char *FACE_THE_LADDER;
|
||||
const char *CAUGHT;
|
||||
const char *NONE_WILL_TALK;
|
||||
const char *NOT_BY_COUNTER;
|
||||
const char *BUY_SELL;
|
||||
const char *BUY;
|
||||
const char *SELL;
|
||||
const char *NOTHING;
|
||||
const char *NONE;
|
||||
const char *NOTHING_HERE;
|
||||
const char *NONE_HERE;
|
||||
const char *SOLD;
|
||||
const char *CANT_AFFORD;
|
||||
const char *DONE;
|
||||
const char *DROP_PENCE_WEAPON_armour;
|
||||
const char *DROP_PENCE;
|
||||
const char *DROP_WEAPON;
|
||||
const char *DROP_armour;
|
||||
const char *NOT_THAT_MUCH;
|
||||
const char *OK;
|
||||
const char *SHAZAM;
|
||||
const char *ALAKAZOT;
|
||||
const char *NO_KINGS_PERMISSION;
|
||||
const char *SET_OFF_TRAP;
|
||||
const char *THOU_DOST_FIND;
|
||||
const char *NO_KEY;
|
||||
const char *INCORRECT_KEY;
|
||||
const char *DOOR_IS_OPEN;
|
||||
const char *CANT_LEAVE_IT_HERE;
|
||||
const char *INVENTORY;
|
||||
const char *PLAYER;
|
||||
const char *PLAYER_DESC;
|
||||
const char *PRESS_SPACE_TO_CONTINUE;
|
||||
const char *MORE;
|
||||
const char *READY_WEAPON_armour_SPELL;
|
||||
const char *WEAPON_armour_SPELL[3];
|
||||
const char *TRANSPORT_WEAPONS[2];
|
||||
const char *NO_EFFECT;
|
||||
const char *USED_UP_SPELL;
|
||||
const char *DUNGEON_SPELL_ONLY;
|
||||
const char *MONSTER_REMOVED;
|
||||
const char *FAILED;
|
||||
const char *TELEPORTED;
|
||||
const char *FIELD_CREATED;
|
||||
const char *FIELD_DESTROYED;
|
||||
const char *LADDER_CREATED;
|
||||
const char *QUEST_COMPLETED;
|
||||
const char *EXIT_CRAFT_FIRST;
|
||||
const char *NOTHING_TO_BOARD;
|
||||
const char *CANNOT_OPERATE;
|
||||
|
||||
const char *GROCERY_NAMES[8];
|
||||
const char *GROCERY_SELL;
|
||||
const char *GROCERY_PACKS1;
|
||||
const char *GROCERY_PACKS2;
|
||||
const char *GROCERY_PACKS3;
|
||||
const char *GROCERY_PACKS_FOOD;
|
||||
const char *GROCERY_FIND_PACKS;
|
||||
const char *WEAPONRY_NAMES[8];
|
||||
const char *NO_WEAPONRY_TO_SELL;
|
||||
const char *ARMOURY_NAMES[8];
|
||||
const char *NO_ARMOUR_TO_SELL;
|
||||
const char *MAGIC_NAMES[8];
|
||||
const char *DONT_BUY_SPELLS;
|
||||
const char *TAVERN_NAMES[8];
|
||||
const char *TAVERN_TEXT[4];
|
||||
const char *TAVERN_TIPS[13];
|
||||
const char *TRANSPORTS_NAMES[8];
|
||||
const char *TRANSPORTS_TEXT[2];
|
||||
const char *WITH_KING;
|
||||
const char *HE_IS_NOT_HERE;
|
||||
const char *HE_REJECTS_OFFER;
|
||||
const char *KING_TEXT[12];
|
||||
|
||||
public:
|
||||
GameResources();
|
||||
GameResources(Shared::Resources *resManager);
|
||||
};
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
46
engines/ultima/ultima1/core/widget_player.h
Normal file
46
engines/ultima/ultima1/core/widget_player.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_CORE_WIDGET_PLAYER_H
|
||||
#define ULTIMA_ULTIMA1_CORE_WIDGET_PLAYER_H
|
||||
|
||||
#include "ultima/shared/core/map.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
class WidgetPlayer : public Shared::MapWidget {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
WidgetPlayer(Shared::Game *game, Shared::Map *map) : Shared::MapWidget(game, map) {}
|
||||
|
||||
/**
|
||||
* Get the tile for the widget
|
||||
*/
|
||||
virtual uint getTileNum() const { return 10; }
|
||||
};
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
101
engines/ultima/ultima1/game.cpp
Normal file
101
engines/ultima/ultima1/game.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/u1gfx/view_game.h"
|
||||
#include "ultima/ultima1/u1gfx/view_char_gen.h"
|
||||
#include "ultima/ultima1/u1gfx/view_title.h"
|
||||
#include "ultima/ultima1/u1gfx/text_cursor.h"
|
||||
#include "ultima/ultima1/u6gfx/game_view.h"
|
||||
#include "ultima/ultima1/spells/prayer.h"
|
||||
#include "ultima/shared/early/font_resources.h"
|
||||
#include "ultima/shared/gfx/popup.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
#include "ultima/shared/early/ultima_early.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
EMPTY_MESSAGE_MAP(Ultima1Game, Shared::Game);
|
||||
|
||||
Ultima1Game::Ultima1Game() : Shared::Game(), _quests(this) {
|
||||
_res = new GameResources();
|
||||
_map = new Maps::Ultima1Map(this);
|
||||
|
||||
_textCursor = new U1Gfx::U1TextCursor(_textColor, _bgColor);
|
||||
g_vm->_screen->setCursor(_textCursor);
|
||||
|
||||
if (g_vm->isEnhanced()) {
|
||||
_videoMode = VIDEOMODE_VGA;
|
||||
loadU6Palette();
|
||||
setFont(new Shared::Gfx::Font((const byte *)&_fontResources->_fontU6[0][0]));
|
||||
_gameView = new U6Gfx::GameView(this);
|
||||
_titleView = nullptr;
|
||||
_charGenView = nullptr;
|
||||
} else {
|
||||
setEGAPalette();
|
||||
_gameView = new U1Gfx::ViewGame(this);
|
||||
_titleView = new U1Gfx::ViewTitle(this);
|
||||
_charGenView = new U1Gfx::ViewCharacterGeneration(this);
|
||||
}
|
||||
|
||||
Common::fill(&_gems[0], &_gems[4], 0);
|
||||
}
|
||||
|
||||
Ultima1Game::~Ultima1Game() {
|
||||
Shared::Gfx::Popup *popup = dynamic_cast<Shared::Gfx::Popup *>(_currentView);
|
||||
if (popup)
|
||||
popup->hide();
|
||||
|
||||
delete _map;
|
||||
delete _gameView;
|
||||
delete _party;
|
||||
}
|
||||
|
||||
void Ultima1Game::synchronize(Common::Serializer &s) {
|
||||
Shared::Game::synchronize(s);
|
||||
|
||||
for (int idx = 0; idx < 4; ++idx)
|
||||
s.syncAsUint16LE(_gems[idx]);
|
||||
_quests.synchronize(s);
|
||||
}
|
||||
|
||||
void Ultima1Game::starting(bool isLoading) {
|
||||
Shared::Game::starting(isLoading);
|
||||
|
||||
_res->load();
|
||||
_party = new Party(this);
|
||||
_gameView->setView(isLoading ? "Game" : "Title");
|
||||
}
|
||||
|
||||
bool Ultima1Game::canSaveGameStateCurrently(Common::U32String *msg) {
|
||||
return _currentView->getName() == "Game";
|
||||
}
|
||||
|
||||
void Ultima1Game::giveTreasure(int coins, int v2) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
85
engines/ultima/ultima1/game.h
Normal file
85
engines/ultima/ultima1/game.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_GAME_H
|
||||
#define ULTIMA_ULTIMA1_GAME_H
|
||||
|
||||
#include "ultima/shared/early/game.h"
|
||||
#include "ultima/shared/gfx/visual_container.h"
|
||||
#include "ultima/ultima1/core/quests.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
enum VideoMode {
|
||||
VIDEOMODE_EGA = 0, VIDEOMODE_VGA = 1
|
||||
};
|
||||
|
||||
enum CharacterClass {
|
||||
CLASS_FIGHTER = 0, CLASS_CLERIC = 1, CLASS_WIZARD = 2, CLASS_THIEF = 3
|
||||
};
|
||||
|
||||
class GameResources;
|
||||
|
||||
class Ultima1Game : public Shared::Game {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
public:
|
||||
GameResources *_res;
|
||||
Shared::Gfx::VisualItem *_gameView;
|
||||
Shared::Gfx::VisualItem *_titleView;
|
||||
Shared::Gfx::VisualItem *_charGenView;
|
||||
uint _gems[4];
|
||||
Quests _quests;
|
||||
public:
|
||||
CLASSDEF;
|
||||
Ultima1Game();
|
||||
~Ultima1Game() override;
|
||||
|
||||
/**
|
||||
* Handles loading and saving games
|
||||
*/
|
||||
void synchronize(Common::Serializer &s) override;
|
||||
|
||||
/**
|
||||
* Returns true if the current video mode is VGA
|
||||
*/
|
||||
bool isVGA() const override { return _videoMode == VIDEOMODE_VGA; }
|
||||
|
||||
/**
|
||||
* Called when the game starts
|
||||
*/
|
||||
void starting(bool isLoading) override;
|
||||
|
||||
/**
|
||||
* Returns true if the game can currently be saved
|
||||
*/
|
||||
bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
|
||||
|
||||
/**
|
||||
* Give some treasure
|
||||
*/
|
||||
void giveTreasure(int coins, int v2);
|
||||
};
|
||||
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
101
engines/ultima/ultima1/maps/map.cpp
Normal file
101
engines/ultima/ultima1/maps/map.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/maps/map_city_castle.h"
|
||||
#include "ultima/ultima1/maps/map_dungeon.h"
|
||||
#include "ultima/ultima1/maps/map_overworld.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/core/file.h"
|
||||
#include "ultima/shared/early/ultima_early.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Maps {
|
||||
|
||||
Ultima1Map::Ultima1Map(Ultima1Game *game) : Shared::Maps::Map(),
|
||||
_mapType(MAP_UNKNOWN), _moveCounter(0) {
|
||||
Ultima1Map::clear();
|
||||
_mapCity = new MapCity(game, this);
|
||||
_mapCastle = new MapCastle(game, this);
|
||||
_mapDungeon = new MapDungeon(game, this);
|
||||
_mapOverworld = new MapOverworld(game, this);
|
||||
}
|
||||
|
||||
Ultima1Map::~Ultima1Map() {
|
||||
delete _mapCity;
|
||||
delete _mapCastle;
|
||||
delete _mapDungeon;
|
||||
delete _mapOverworld;
|
||||
}
|
||||
|
||||
void Ultima1Map::clear() {
|
||||
_mapType = MAP_UNKNOWN;
|
||||
}
|
||||
|
||||
void Ultima1Map::load(Shared::Maps::MapId mapId) {
|
||||
// If we're leaving the overworld, update the cached copy of the position in the overworld
|
||||
if (_mapType == MAP_OVERWORLD)
|
||||
_worldPos = _mapArea->getPosition();
|
||||
|
||||
Shared::Maps::Map::load(mapId);
|
||||
|
||||
// Switch to the correct map area
|
||||
if (mapId == MAPID_OVERWORLD) {
|
||||
_mapType = MAP_OVERWORLD;
|
||||
_mapArea = _mapOverworld;
|
||||
} else if (mapId < 33) {
|
||||
_mapType = MAP_CITY;
|
||||
_mapArea = _mapCity;
|
||||
} else if (mapId < 41) {
|
||||
_mapType = MAP_CASTLE;
|
||||
_mapArea = _mapCastle;
|
||||
} else if (mapId < 49) {
|
||||
error("TODO: load Pillar");
|
||||
} else {
|
||||
_mapType = MAP_DUNGEON;
|
||||
_mapArea = _mapDungeon;
|
||||
}
|
||||
|
||||
// Load the map
|
||||
_mapArea->load(mapId);
|
||||
}
|
||||
|
||||
void Ultima1Map::synchronize(Common::Serializer &s) {
|
||||
Shared::Maps::Map::synchronize(s);
|
||||
if (_mapType != MAP_OVERWORLD) {
|
||||
if (s.isLoading())
|
||||
_mapOverworld->load(MAP_OVERWORLD);
|
||||
_mapOverworld->synchronize(s);
|
||||
}
|
||||
|
||||
s.syncAsUint32LE(_moveCounter);
|
||||
}
|
||||
|
||||
void Ultima1Map::dropCoins(uint amount) {
|
||||
static_cast<MapBase *>(_mapArea)->dropCoins(amount);
|
||||
}
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
147
engines/ultima/ultima1/maps/map.h
Normal file
147
engines/ultima/ultima1/maps/map.h
Normal file
@@ -0,0 +1,147 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_MAPS_MAP_H
|
||||
#define ULTIMA_ULTIMA1_MAPS_MAP_H
|
||||
|
||||
#include "ultima/shared/maps/map.h"
|
||||
#include "ultima/shared/maps/map_widget.h"
|
||||
#include "ultima/ultima1/maps/map_base.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
class Ultima1Game;
|
||||
|
||||
namespace Maps {
|
||||
|
||||
enum MapType {
|
||||
MAP_OVERWORLD = 0, MAP_CITY = 1, MAP_CASTLE = 2, MAP_DUNGEON = 3, MAP_UNKNOWN = 4
|
||||
};
|
||||
|
||||
enum MapIdent {
|
||||
MAPID_OVERWORLD = 0
|
||||
};
|
||||
|
||||
class Ultima1Map;
|
||||
class MapCity;
|
||||
class MapCastle;
|
||||
class MapDungeon;
|
||||
class MapOverworld;
|
||||
|
||||
/**
|
||||
* Used to hold the total number of tiles surrounding location entrances
|
||||
*/
|
||||
struct SurroundingTotals {
|
||||
uint _water;
|
||||
uint _grass;
|
||||
uint _woods;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
SurroundingTotals() : _water(0), _grass(0), _woods(0) {}
|
||||
|
||||
/**
|
||||
* Loads the totals from a passed map
|
||||
*/
|
||||
void load(Ultima1Map *map);
|
||||
};
|
||||
|
||||
/**
|
||||
* Ultima 1 map manager
|
||||
*/
|
||||
class Ultima1Map : public Shared::Maps::Map {
|
||||
private:
|
||||
// Ultima1Game *_game;
|
||||
MapCity *_mapCity;
|
||||
MapCastle *_mapCastle;
|
||||
MapDungeon *_mapDungeon;
|
||||
MapOverworld *_mapOverworld;
|
||||
public:
|
||||
MapType _mapType; // Type of map
|
||||
Point _worldPos; // Point in the world map, updated when entering locations
|
||||
uint _moveCounter; // Movement counter
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Ultima1Map(Ultima1Game *game);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Ultima1Map() override;
|
||||
|
||||
/**
|
||||
* Clears all map data
|
||||
*/
|
||||
void clear() override;
|
||||
|
||||
/**
|
||||
* Load a given map
|
||||
*/
|
||||
void load(Shared::Maps::MapId mapId) override;
|
||||
|
||||
/**
|
||||
* Handles loading and saving the map's data
|
||||
*/
|
||||
void synchronize(Common::Serializer &s) override;
|
||||
|
||||
/**
|
||||
* Action pass-throughs
|
||||
*/
|
||||
#define PASS_METHOD(NAME) void NAME() { static_cast<MapBase *>(_mapArea)->NAME(); }
|
||||
PASS_METHOD(board)
|
||||
PASS_METHOD(cast)
|
||||
PASS_METHOD(drop)
|
||||
PASS_METHOD(enter)
|
||||
PASS_METHOD(get)
|
||||
PASS_METHOD(hyperjump)
|
||||
PASS_METHOD(inform)
|
||||
PASS_METHOD(climb)
|
||||
PASS_METHOD(open)
|
||||
PASS_METHOD(steal)
|
||||
PASS_METHOD(talk)
|
||||
PASS_METHOD(unlock)
|
||||
PASS_METHOD(view)
|
||||
PASS_METHOD(disembark)
|
||||
|
||||
void attack(int direction, int effectId) {
|
||||
static_cast<MapBase *>(_mapArea)->attack(direction, effectId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles dropping an amount of coins
|
||||
*/
|
||||
void dropCoins(uint amount);
|
||||
|
||||
/**
|
||||
* Returns the overworld map
|
||||
*/
|
||||
MapOverworld *getOverworldMap() { return _mapOverworld; }
|
||||
};
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
169
engines/ultima/ultima1/maps/map_base.cpp
Normal file
169
engines/ultima/ultima1/maps/map_base.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/maps/map_base.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/maps/map_dungeon.h"
|
||||
#include "ultima/ultima1/maps/map_city_castle.h"
|
||||
#include "ultima/ultima1/maps/map_overworld.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_widget.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_item.h"
|
||||
#include "ultima/ultima1/widgets/merchant_armour.h"
|
||||
#include "ultima/ultima1/widgets/merchant_grocer.h"
|
||||
#include "ultima/ultima1/widgets/merchant_magic.h"
|
||||
#include "ultima/ultima1/widgets/merchant_tavern.h"
|
||||
#include "ultima/ultima1/widgets/merchant_transport.h"
|
||||
#include "ultima/ultima1/widgets/merchant_weapons.h"
|
||||
#include "ultima/ultima1/widgets/overworld_monster.h"
|
||||
#include "ultima/ultima1/widgets/transport.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_monster.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_player.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_chest.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_coffin.h"
|
||||
#include "ultima/ultima1/widgets/bard.h"
|
||||
#include "ultima/ultima1/widgets/guard.h"
|
||||
#include "ultima/ultima1/widgets/king.h"
|
||||
#include "ultima/ultima1/widgets/princess.h"
|
||||
#include "ultima/ultima1/widgets/transport.h"
|
||||
#include "ultima/ultima1/widgets/urban_player.h"
|
||||
#include "ultima/ultima1/widgets/wench.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Maps {
|
||||
|
||||
MapBase::MapBase(Ultima1Game *game, Ultima1Map *map) : Shared::Maps::MapBase(game, map), _game(game) {
|
||||
}
|
||||
|
||||
void MapBase::getTileAt(const Point &pt, Shared::Maps::MapTile *tile, bool includePlayer) {
|
||||
Shared::Maps::MapBase::getTileAt(pt, tile, includePlayer);
|
||||
|
||||
// Extended properties to set if an Ultima 1 map tile structure was passed in
|
||||
U1MapTile *mapTile = dynamic_cast<U1MapTile *>(tile);
|
||||
if (mapTile) {
|
||||
GameResources *res = _game->_res;
|
||||
mapTile->setMap(this);
|
||||
|
||||
// Check for a location at the given position
|
||||
mapTile->_locationNum = -1;
|
||||
if (dynamic_cast<MapOverworld *>(this)) {
|
||||
for (int idx = 0; idx < LOCATION_COUNT; ++idx) {
|
||||
if (pt.x == res->LOCATION_X[idx] && pt.y == res->LOCATION_Y[idx]) {
|
||||
mapTile->_locationNum = idx + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for a dungeon item
|
||||
for (uint idx = 0; idx < _widgets.size() && !mapTile->_item; ++idx) {
|
||||
mapTile->_item = dynamic_cast<Widgets::DungeonItem *>(_widgets[idx].get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MapBase::unknownAction() {
|
||||
addInfoMsg("?");
|
||||
_game->playFX(1);
|
||||
}
|
||||
|
||||
void MapBase::attack(int direction, int effectId) {
|
||||
uint agility, damage, maxDistance;
|
||||
Widgets::Transport *transport = dynamic_cast<Widgets::Transport *>(_playerWidget);
|
||||
|
||||
if (effectId == 7) {
|
||||
Character &c = *static_cast<Party *>(_game->_party);
|
||||
maxDistance = c.equippedWeapon()->_distance;
|
||||
agility = c._agility + 50;
|
||||
damage = _game->getRandomNumber(2, c._strength + c._equippedWeapon * 8);
|
||||
} else {
|
||||
maxDistance = 3;
|
||||
agility = 80;
|
||||
damage = _game->getRandomNumber(1, (transport ? transport->transportId() : 0) * 10);
|
||||
}
|
||||
|
||||
attack(direction, effectId, maxDistance, damage, agility, "PhysicalAttack");
|
||||
}
|
||||
|
||||
void MapBase::board() {
|
||||
unknownAction();
|
||||
_game->endOfTurn();
|
||||
}
|
||||
|
||||
void MapBase::cast() {
|
||||
const Shared::Character &c = *_game->_party;
|
||||
Shared::Spell &spell = *c._spells[c._equippedSpell];
|
||||
addInfoMsg(Common::String::format(" %s", spell._name.c_str()), false);
|
||||
|
||||
if (c._equippedSpell == Spells::SPELL_PRAYER) {
|
||||
castSpell(c._equippedSpell);
|
||||
} else if (spell._quantity == 0) {
|
||||
addInfoMsg("");
|
||||
addInfoMsg(_game->_res->USED_UP_SPELL);
|
||||
_game->playFX(6);
|
||||
} else {
|
||||
spell.decrQuantity();
|
||||
castSpell(c._equippedSpell);
|
||||
}
|
||||
}
|
||||
|
||||
void MapBase::castSpell(uint spellId) {
|
||||
const Shared::Character &c = *_game->_party;
|
||||
static_cast<Spells::Spell *>(c._spells[spellId])->cast(this);
|
||||
}
|
||||
|
||||
Shared::Maps::MapWidget *MapBase::createWidget(const Common::String &name) {
|
||||
REGISTER_WIDGET(Bard);
|
||||
REGISTER_WIDGET(DungeonMonster);
|
||||
REGISTER_WIDGET(DungeonPlayer);
|
||||
REGISTER_WIDGET(DungeonChest);
|
||||
REGISTER_WIDGET(DungeonCoffin);
|
||||
REGISTER_WIDGET(Guard);
|
||||
REGISTER_WIDGET(King);
|
||||
REGISTER_WIDGET(MerchantArmour);
|
||||
REGISTER_WIDGET(MerchantGrocer);
|
||||
REGISTER_WIDGET(MerchantMagic);
|
||||
REGISTER_WIDGET(MerchantTavern);
|
||||
REGISTER_WIDGET(MerchantTransport);
|
||||
REGISTER_WIDGET(MerchantWeapons);
|
||||
REGISTER_WIDGET(OverworldMonster);
|
||||
REGISTER_WIDGET(Princess);
|
||||
REGISTER_WIDGET(TransportOnFoot);
|
||||
REGISTER_WIDGET(UrbanPlayer);
|
||||
REGISTER_WIDGET(Wench);
|
||||
REGISTER_WIDGET(Horse);
|
||||
REGISTER_WIDGET(Cart);
|
||||
REGISTER_WIDGET(Raft);
|
||||
REGISTER_WIDGET(Frigate);
|
||||
REGISTER_WIDGET(Aircar);
|
||||
REGISTER_WIDGET(Shuttle);
|
||||
|
||||
error("Unknown widget type '%s'", name.c_str());
|
||||
}
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
126
engines/ultima/ultima1/maps/map_base.h
Normal file
126
engines/ultima/ultima1/maps/map_base.h
Normal file
@@ -0,0 +1,126 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_MAPS_MAP_BASE_H
|
||||
#define ULTIMA_ULTIMA1_MAPS_MAP_BASE_H
|
||||
|
||||
#include "ultima/shared/maps/map_base.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
class Ultima1Game;
|
||||
|
||||
namespace Maps {
|
||||
|
||||
class Ultima1Map;
|
||||
|
||||
/**
|
||||
* Intermediate base class for Ultima 1 maps
|
||||
*/
|
||||
class MapBase : public Shared::Maps::MapBase {
|
||||
private:
|
||||
/**
|
||||
* Default unknown/question mark display
|
||||
*/
|
||||
void unknownAction();
|
||||
protected:
|
||||
Ultima1Game *_game;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
MapBase(Ultima1Game *game, Ultima1Map *map);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~MapBase() override {}
|
||||
|
||||
/**
|
||||
* Gets a tile at a given position
|
||||
*/
|
||||
void getTileAt(const Point &pt, Shared::Maps::MapTile *tile, bool includePlayer = true) override;
|
||||
|
||||
/**
|
||||
* Instantiates a widget type by name
|
||||
*/
|
||||
Shared::Maps::MapWidget *createWidget(const Common::String &name) override;
|
||||
|
||||
/**
|
||||
* Default implementation for actions
|
||||
*/
|
||||
#define DEFAULT_ACTION(NAME) virtual void NAME() { unknownAction(); }
|
||||
DEFAULT_ACTION(drop)
|
||||
DEFAULT_ACTION(enter)
|
||||
DEFAULT_ACTION(get)
|
||||
DEFAULT_ACTION(hyperjump)
|
||||
DEFAULT_ACTION(inform)
|
||||
DEFAULT_ACTION(climb)
|
||||
DEFAULT_ACTION(open)
|
||||
DEFAULT_ACTION(steal)
|
||||
DEFAULT_ACTION(talk)
|
||||
DEFAULT_ACTION(unlock)
|
||||
DEFAULT_ACTION(view)
|
||||
DEFAULT_ACTION(disembark)
|
||||
|
||||
/**
|
||||
* Perform an attack
|
||||
*/
|
||||
virtual void attack(int direction, int effectId);
|
||||
|
||||
/**
|
||||
* Perform an attack in a direction
|
||||
* @param direction Direction
|
||||
* @param effectId Sound effect to play
|
||||
* @param maxDistance Maximum distance in the given direction
|
||||
* @param amount Damage amount
|
||||
* @param agility Agility threshold
|
||||
* @param widgetNa
|
||||
*/
|
||||
virtual void attack(int direction, int effectId, uint maxDistance, uint amount, uint agility, const Common::String &hitWidget) = 0;
|
||||
|
||||
/**
|
||||
* Board a transport
|
||||
*/
|
||||
virtual void board();
|
||||
|
||||
/**
|
||||
* Cast a spell
|
||||
*/
|
||||
virtual void cast();
|
||||
|
||||
/**
|
||||
* Cast a specific spell
|
||||
*/
|
||||
void castSpell(uint spell) override;
|
||||
|
||||
/**
|
||||
* Handles dropping an amount of coins
|
||||
*/
|
||||
virtual void dropCoins(uint coins) {}
|
||||
};
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
471
engines/ultima/ultima1/maps/map_city_castle.cpp
Normal file
471
engines/ultima/ultima1/maps/map_city_castle.cpp
Normal file
@@ -0,0 +1,471 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/maps/map_city_castle.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
#include "ultima/ultima1/widgets/urban_player.h"
|
||||
#include "ultima/ultima1/widgets/person.h"
|
||||
#include "ultima/ultima1/widgets/bard.h"
|
||||
#include "ultima/ultima1/widgets/guard.h"
|
||||
#include "ultima/ultima1/widgets/king.h"
|
||||
#include "ultima/ultima1/widgets/princess.h"
|
||||
#include "ultima/ultima1/widgets/wench.h"
|
||||
#include "ultima/ultima1/widgets/merchant_armour.h"
|
||||
#include "ultima/ultima1/widgets/merchant_grocer.h"
|
||||
#include "ultima/ultima1/widgets/merchant_magic.h"
|
||||
#include "ultima/ultima1/widgets/merchant_tavern.h"
|
||||
#include "ultima/ultima1/widgets/merchant_transport.h"
|
||||
#include "ultima/ultima1/widgets/merchant_weapons.h"
|
||||
#include "ultima/ultima1/u1dialogs/drop.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Maps {
|
||||
|
||||
void MapCityCastle::load(Shared::Maps::MapId mapId) {
|
||||
clear();
|
||||
Shared::Maps::MapBase::load(mapId);
|
||||
|
||||
setDimensions(Point(38, 18));
|
||||
_tilesPerOrigTile = Point(1, 1);
|
||||
}
|
||||
|
||||
void MapCityCastle::clear() {
|
||||
Shared::Maps::MapBase::clear();
|
||||
_guardsHostile = false;
|
||||
}
|
||||
|
||||
void MapCityCastle::loadWidgets() {
|
||||
// Set up widget for the player
|
||||
_playerWidget = new Widgets::UrbanPlayer(_game, this);
|
||||
addWidget(_playerWidget);
|
||||
|
||||
for (int idx = 0; idx < 15; ++idx) {
|
||||
const int *lp = _game->_res->LOCATION_PEOPLE[_mapStyle * 15 + idx];
|
||||
if (lp[0] == -1)
|
||||
break;
|
||||
|
||||
Widgets::Person *person;
|
||||
switch (lp[0]) {
|
||||
case 17:
|
||||
person = new Widgets::Guard(_game, this, lp[3]);
|
||||
break;
|
||||
case 19:
|
||||
person = new Widgets::Bard(_game, this, lp[3]);
|
||||
break;
|
||||
case 20:
|
||||
person = new Widgets::King(_game, this, lp[3]);
|
||||
break;
|
||||
case 21: {
|
||||
U1MapTile tile;
|
||||
getTileAt(Point(lp[1], lp[2]), &tile);
|
||||
|
||||
switch (tile._tileId) {
|
||||
case 55:
|
||||
person = new Widgets::MerchantArmour(_game, this, lp[3]);
|
||||
break;
|
||||
case 57:
|
||||
person = new Widgets::MerchantGrocer(_game, this, lp[3]);
|
||||
break;
|
||||
case 59:
|
||||
person = new Widgets::MerchantWeapons(_game, this, lp[3]);
|
||||
break;
|
||||
case 60:
|
||||
person = new Widgets::MerchantMagic(_game, this, lp[3]);
|
||||
break;
|
||||
case 61:
|
||||
person = new Widgets::MerchantTavern(_game, this, lp[3]);
|
||||
break;
|
||||
case 62:
|
||||
person = new Widgets::MerchantTransport(_game, this, lp[3]);
|
||||
break;
|
||||
default:
|
||||
error("Invalid merchant");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 22:
|
||||
person = new Widgets::Princess(_game, this, lp[3]);
|
||||
break;
|
||||
case 50:
|
||||
person = new Widgets::Wench(_game, this, lp[3]);
|
||||
break;
|
||||
default:
|
||||
error("Unknown NPC type %d", lp[0]);
|
||||
}
|
||||
|
||||
person->_position = Point(lp[1], lp[2]);
|
||||
addWidget(person);
|
||||
}
|
||||
}
|
||||
|
||||
void MapCityCastle::getTileAt(const Point &pt, Shared::Maps::MapTile *tile, bool includePlayer) {
|
||||
MapBase::getTileAt(pt, tile, includePlayer);
|
||||
|
||||
// Special handling for the cells indicating various merchant talk/steal positions
|
||||
if (tile->_tileDisplayNum >= 51)
|
||||
tile->_tileDisplayNum = 1;
|
||||
}
|
||||
|
||||
Point MapCityCastle::getViewportPosition(const Point &viewportSize) {
|
||||
Point &topLeft = _viewportPos._topLeft;
|
||||
|
||||
if (!_viewportPos.isValid() || _viewportPos._size != viewportSize) {
|
||||
// Calculate the new position
|
||||
topLeft.x = _playerWidget->_position.x - (viewportSize.x - 1) / 2;
|
||||
topLeft.y = _playerWidget->_position.y - (viewportSize.y - 1) / 2;
|
||||
|
||||
// Fixed maps, so constrain top left corner so the map fills the viewport. This will accommodate
|
||||
// future renderings with more tiles, or greater tile size
|
||||
topLeft.x = CLIP((int)topLeft.x, 0, (int)(width() - viewportSize.x));
|
||||
topLeft.y = CLIP((int)topLeft.y, 0, (int)(height() - viewportSize.y));
|
||||
|
||||
_viewportPos._mapId = _mapId;
|
||||
_viewportPos._size = viewportSize;
|
||||
}
|
||||
|
||||
return topLeft;
|
||||
}
|
||||
|
||||
void MapCityCastle::loadTownCastleData() {
|
||||
// Load the contents of the map
|
||||
Shared::File f("tcd.bin");
|
||||
f.seek(_mapStyle * 684);
|
||||
for (int x = 0; x < _size.x; ++x) {
|
||||
for (int y = 0; y < _size.y; ++y)
|
||||
_data[y][x] = f.readByte();
|
||||
}
|
||||
}
|
||||
|
||||
Widgets::Merchant *MapCityCastle::getStealMerchant() {
|
||||
U1MapTile tile;
|
||||
getTileAt(getPosition(), &tile);
|
||||
|
||||
// Scan for the correct merchant depending on the tile player is on
|
||||
switch (tile._tileId) {
|
||||
case 55:
|
||||
return dynamic_cast<Widgets::MerchantArmour *>(_widgets.findByClass(Widgets::MerchantArmour::type()));
|
||||
break;
|
||||
case 57:
|
||||
return dynamic_cast<Widgets::MerchantGrocer *>(_widgets.findByClass(Widgets::MerchantGrocer::type()));
|
||||
break;
|
||||
case 59:
|
||||
return dynamic_cast<Widgets::MerchantWeapons *>(_widgets.findByClass(Widgets::MerchantWeapons::type()));
|
||||
break;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
Widgets::Person *MapCityCastle::getTalkPerson() {
|
||||
U1MapTile tile;
|
||||
getTileAt(getPosition(), &tile);
|
||||
|
||||
switch (tile._tileId) {
|
||||
case 54:
|
||||
case 55:
|
||||
return dynamic_cast<Widgets::Person *>(_widgets.findByClass(Widgets::MerchantArmour::type()));
|
||||
|
||||
case 56:
|
||||
case 57:
|
||||
return dynamic_cast<Widgets::Person *>(_widgets.findByClass(Widgets::MerchantGrocer::type()));
|
||||
|
||||
case 58:
|
||||
case 59:
|
||||
return dynamic_cast<Widgets::Person *>(_widgets.findByClass(Widgets::MerchantWeapons::type()));
|
||||
|
||||
case 60:
|
||||
return dynamic_cast<Widgets::Person *>(_widgets.findByClass(Widgets::MerchantMagic::type()));
|
||||
|
||||
case 61:
|
||||
return dynamic_cast<Widgets::Person *>(_widgets.findByClass(Widgets::MerchantTavern::type()));
|
||||
|
||||
case 62:
|
||||
return dynamic_cast<Widgets::Person *>(_widgets.findByClass(
|
||||
dynamic_cast<MapCity *>(this) ? Widgets::MerchantTransport::type() : Widgets::King::type() ));
|
||||
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MapCityCastle::cast() {
|
||||
addInfoMsg(Common::String::format(" -- %s", _game->_res->NO_EFFECT));
|
||||
_game->playFX(6);
|
||||
}
|
||||
|
||||
void MapCityCastle::drop() {
|
||||
U1Dialogs::Drop *drop = new U1Dialogs::Drop(_game);
|
||||
drop->show();
|
||||
}
|
||||
|
||||
void MapCityCastle::inform() {
|
||||
addInfoMsg("");
|
||||
addInfoMsg(_name);
|
||||
}
|
||||
|
||||
void MapCityCastle::steal() {
|
||||
Widgets::Merchant *merchant = getStealMerchant();
|
||||
|
||||
if (merchant) {
|
||||
// Found a merchant, so call their steal handler
|
||||
merchant->steal();
|
||||
} else {
|
||||
addInfoMsg(_game->_res->NOTHING_HERE);
|
||||
_game->playFX(1);
|
||||
}
|
||||
}
|
||||
|
||||
void MapCityCastle::attack(int direction, int effectId, uint maxDistance, uint amount, uint agility, const Common::String &hitWidget) {
|
||||
_game->playFX(effectId);
|
||||
Point delta = getDirectionDelta();
|
||||
U1MapTile tile;
|
||||
Widgets::Person *person;
|
||||
//int currTile;
|
||||
|
||||
// Scan in the given direction for a person to attack
|
||||
uint distance = 1;
|
||||
do {
|
||||
Point pt = getPosition() + Point(delta.x * distance, delta.y * distance);
|
||||
getTileAt(pt, &tile);
|
||||
//currTile = tile._tileId == CTILE_63 ? -1 : tile._tileId;
|
||||
person = dynamic_cast<Widgets::Person *>(tile._widget);
|
||||
|
||||
} while (++distance <= maxDistance && !person && (tile._tileId == CTILE_GROUND || tile._tileId >= CTILE_POND_EDGE1));
|
||||
|
||||
if (person && _game->getRandomNumber(1, 100) <= agility) {
|
||||
addInfoMsg(Common::String::format(_game->_res->HIT_CREATURE, person->_name.c_str()), false);
|
||||
|
||||
// Damage the person
|
||||
if (person->subtractHitPoints(amount)) {
|
||||
// Killed them
|
||||
addInfoMsg(_game->_res->KILLED);
|
||||
} else {
|
||||
// Still alive
|
||||
addInfoMsg(Common::String::format("%u %s!", amount, _game->_res->DAMAGE));
|
||||
}
|
||||
} else {
|
||||
addInfoMsg(_game->_res->MISSED);
|
||||
}
|
||||
|
||||
_game->endOfTurn();
|
||||
}
|
||||
|
||||
bool MapCityCastle::isWenchNearby() const {
|
||||
Shared::Maps::MapWidget *widget = _widgets.findByClass(Widgets::Wench::type());
|
||||
if (!widget)
|
||||
return false;
|
||||
|
||||
const Point &playerPos = _playerWidget->_position;
|
||||
const Point &wenchPos = widget->_position;
|
||||
int distance = MAX(ABS(playerPos.x - wenchPos.x), ABS(playerPos.y - wenchPos.y));
|
||||
return distance == 1;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
void MapCity::load(Shared::Maps::MapId mapId) {
|
||||
MapCityCastle::load(mapId);
|
||||
|
||||
_mapStyle = ((_mapId - 1) % 8) + 2;
|
||||
_mapIndex = _mapId;
|
||||
_name = Common::String::format("%s %s", _game->_res->THE_CITY_OF, _game->_res->LOCATION_NAMES[_mapId - 1]);
|
||||
|
||||
loadTownCastleData();
|
||||
|
||||
// Load up the widgets for the given map
|
||||
loadWidgets();
|
||||
setPosition(Common::Point(width() / 2, height() - 1)); // Start at bottom center edge of map
|
||||
}
|
||||
|
||||
void MapCity::dropCoins(uint coins) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
U1MapTile tile;
|
||||
getTileAt(getPosition(), &tile);
|
||||
|
||||
if (tile._tileId == CTILE_POND_EDGE1 || tile._tileId == CTILE_POND_EDGE2 || tile._tileId == CTILE_POND_EDGE3) {
|
||||
addInfoMsg(_game->_res->SHAZAM);
|
||||
_game->playFX(5);
|
||||
|
||||
switch (tile._tileId) {
|
||||
case CTILE_POND_EDGE1: {
|
||||
// Increase one of the attributes randomly
|
||||
uint *attrList[6] = { &c._strength, &c._agility, &c._stamina, &c._charisma, &c._wisdom, &c._intelligence };
|
||||
uint &attr = *attrList[_game->getRandomNumber(0, 5)];
|
||||
|
||||
attr = MIN(attr + coins / 10, 99U);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTILE_POND_EDGE2: {
|
||||
// Increase the quantity of a random weapon
|
||||
uint weaponNum = _game->getRandomNumber(1, 15);
|
||||
Shared::Weapon &weapon = *c._weapons[weaponNum];
|
||||
weapon._quantity = MIN(weapon._quantity + 1, 255U);
|
||||
break;
|
||||
}
|
||||
|
||||
case CTILE_POND_EDGE3:
|
||||
// Increase food
|
||||
c._food += coins;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
addInfoMsg(_game->_res->OK);
|
||||
}
|
||||
}
|
||||
|
||||
void MapCity::get() {
|
||||
addInfoMsg(_game->_res->WHAT);
|
||||
_game->playFX(1);
|
||||
}
|
||||
|
||||
void MapCity::talk() {
|
||||
if (_guardsHostile) {
|
||||
addInfoMsg(_game->_res->NONE_WILL_TALK);
|
||||
} else {
|
||||
Widgets::Person *person = getTalkPerson();
|
||||
|
||||
if (person) {
|
||||
person->talk();
|
||||
} else {
|
||||
addInfoMsg("");
|
||||
addInfoMsg(_game->_res->NOT_BY_COUNTER);
|
||||
_game->endOfTurn();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MapCity::unlock() {
|
||||
addInfoMsg(_game->_res->WHAT);
|
||||
_game->playFX(1);
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
void MapCastle::load(Shared::Maps::MapId mapId) {
|
||||
MapCityCastle::load(mapId);
|
||||
|
||||
_mapIndex = _mapId - 33;
|
||||
_mapStyle = _mapIndex % 2;
|
||||
_name = _game->_res->LOCATION_NAMES[_mapId - 1];
|
||||
_castleKey = _game->getRandomNumber(255) & 1 ? 61 : 60;
|
||||
_getCounter = 0;
|
||||
|
||||
loadTownCastleData();
|
||||
|
||||
// Set up door locks
|
||||
_data[_mapStyle ? 4 : 14][35] = CTILE_GATE;
|
||||
_data[_mapStyle ? 4 : 14][31] = CTILE_GATE;
|
||||
|
||||
// Load up the widgets for the given map
|
||||
loadWidgets();
|
||||
setPosition(Common::Point(0, height() / 2)); // Start at center left edge of map
|
||||
}
|
||||
|
||||
void MapCastle::synchronize(Common::Serializer &s) {
|
||||
MapCityCastle::synchronize(s);
|
||||
s.syncAsByte(_castleKey);
|
||||
s.syncAsByte(_getCounter);
|
||||
s.syncAsByte(_freeingPrincess);
|
||||
}
|
||||
|
||||
void MapCastle::dropCoins(uint coins) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
U1MapTile tile;
|
||||
getTileAt(getPosition(), &tile);
|
||||
|
||||
if (tile._tileId == CTILE_POND_EDGE1) {
|
||||
uint hp = coins * 3 / 2;
|
||||
c._hitPoints = MIN(c._hitPoints + hp, 9999U);
|
||||
|
||||
if (_game->getRandomNumber(1, 255) > 16) {
|
||||
addInfoMsg(_game->_res->SHAZAM);
|
||||
} else {
|
||||
uint spellNum = _game->getRandomNumber(1, 7);
|
||||
if (spellNum == Spells::SPELL_MAGIC_MISSILE)
|
||||
spellNum = Spells::SPELL_STEAL;
|
||||
|
||||
c._spells[spellNum]->incrQuantity();
|
||||
addInfoMsg(_game->_res->ALAKAZOT);
|
||||
}
|
||||
} else {
|
||||
addInfoMsg(_game->_res->OK);
|
||||
}
|
||||
}
|
||||
|
||||
void MapCastle::get() {
|
||||
Widgets::Merchant *merchant = getStealMerchant();
|
||||
|
||||
if (merchant) {
|
||||
// Found a merchant, so call their get handler
|
||||
merchant->get();
|
||||
} else {
|
||||
addInfoMsg(_game->_res->NOTHING_HERE);
|
||||
_game->playFX(1);
|
||||
}
|
||||
}
|
||||
|
||||
void MapCastle::talk() {
|
||||
addInfoMsg(_game->_res->WITH_KING);
|
||||
Widgets::Person *person = getTalkPerson();
|
||||
|
||||
if (person) {
|
||||
person->talk();
|
||||
} else {
|
||||
addInfoMsg(_game->_res->HE_IS_NOT_HERE);
|
||||
_game->endOfTurn();
|
||||
}
|
||||
}
|
||||
|
||||
void MapCastle::unlock() {
|
||||
U1MapTile tile;
|
||||
Point pt = getPosition();
|
||||
getTileAt(pt, &tile);
|
||||
|
||||
if (tile._tileId != CTILE_LOCK1 && tile._tileId != CTILE_LOCK2) {
|
||||
addInfoMsg(_game->_res->WHAT);
|
||||
_game->playFX(1);
|
||||
} else if (!_castleKey) {
|
||||
addInfoMsg(_game->_res->NO_KEY);
|
||||
} else if (tile._tileId != (int)_castleKey) {
|
||||
addInfoMsg(_game->_res->INCORRECT_KEY);
|
||||
} else {
|
||||
addInfoMsg(_game->_res->DOOR_IS_OPEN);
|
||||
_data[pt.y][pt.x] = CTILE_GROUND;
|
||||
_freeingPrincess = true;
|
||||
}
|
||||
}
|
||||
|
||||
bool MapCastle::isLordBritishCastle() const {
|
||||
return getMapIndex() == 0;
|
||||
}
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
229
engines/ultima/ultima1/maps/map_city_castle.h
Normal file
229
engines/ultima/ultima1/maps/map_city_castle.h
Normal file
@@ -0,0 +1,229 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_MAP_MAP_CITY_CASTLE_H
|
||||
#define ULTIMA_ULTIMA1_MAP_MAP_CITY_CASTLE_H
|
||||
|
||||
#include "ultima/ultima1/maps/map_base.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Widgets {
|
||||
class Person;
|
||||
class Merchant;
|
||||
}
|
||||
|
||||
namespace Maps {
|
||||
|
||||
enum CityTile {
|
||||
CTILE_GROUND = 1, CTILE_POND_EDGE1 = 51, CTILE_POND_EDGE2 = 52, CTILE_POND_EDGE3 = 53,
|
||||
CTILE_GATE = 11, CTILE_LOCK1 = 60, CTILE_LOCK2 = 61, CTILE_63 = 63
|
||||
};
|
||||
|
||||
/**
|
||||
* Common base class for city and castle maps
|
||||
*/
|
||||
class MapCityCastle : public MapBase {
|
||||
protected:
|
||||
/**
|
||||
* Load widget list for the map
|
||||
*/
|
||||
void loadWidgets();
|
||||
|
||||
/**
|
||||
* Load the base map for towns and castles
|
||||
*/
|
||||
void loadTownCastleData();
|
||||
|
||||
/**
|
||||
* Get a merchant for a given steal-type tile
|
||||
*/
|
||||
Widgets::Merchant *getStealMerchant();
|
||||
|
||||
/**
|
||||
* Get a person to talk to based on the tile the player is on
|
||||
*/
|
||||
Widgets::Person *getTalkPerson();
|
||||
public:
|
||||
bool _guardsHostile; // Flag for whether guards are hostile
|
||||
uint _tipCounter; // Tip counter for taverns
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
MapCityCastle(Ultima1Game *game, Ultima1Map *map) : MapBase(game, map),
|
||||
_guardsHostile(false), _tipCounter(0) {}
|
||||
|
||||
/**
|
||||
* Load the map
|
||||
*/
|
||||
void load(Shared::Maps::MapId mapId) override;
|
||||
|
||||
/**
|
||||
* Gets a tile at a given position
|
||||
*/
|
||||
void getTileAt(const Point &pt, Shared::Maps::MapTile *tile, bool includePlayer = true) override;
|
||||
|
||||
/**
|
||||
* Clears all map data
|
||||
*/
|
||||
void clear() override;
|
||||
|
||||
/**
|
||||
* Get the viewport position
|
||||
*/
|
||||
Point getViewportPosition(const Point &viewportSize) override;
|
||||
|
||||
/**
|
||||
* Cast a spell
|
||||
*/
|
||||
void cast() override;
|
||||
|
||||
/**
|
||||
* Do a drop action
|
||||
*/
|
||||
void drop() override;
|
||||
|
||||
/**
|
||||
* Do an inform action
|
||||
*/
|
||||
void inform() override;
|
||||
|
||||
/**
|
||||
* Do a steal action
|
||||
*/
|
||||
void steal() override;
|
||||
|
||||
/**
|
||||
* Perform an attack in a direction
|
||||
* @param direction Direction
|
||||
* @param effectId Sound effect to play
|
||||
* @param maxDistance Maximum distance in the given direction
|
||||
* @param amount Damage amount
|
||||
* @param agility Agility threshold
|
||||
* @param widgetNa
|
||||
*/
|
||||
void attack(int direction, int effectId, uint maxDistance, uint amount, uint agility, const Common::String &hitWidget) override;
|
||||
|
||||
/**
|
||||
* Returns true if a wench is on an adjacent tile to the player
|
||||
*/
|
||||
bool isWenchNearby() const;
|
||||
};
|
||||
|
||||
/**
|
||||
* City map
|
||||
*/
|
||||
class MapCity : public MapCityCastle {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
MapCity(Ultima1Game *game, Ultima1Map *map) : MapCityCastle(game, map) {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~MapCity() override {}
|
||||
|
||||
/**
|
||||
* Load the map
|
||||
*/
|
||||
void load(Shared::Maps::MapId mapId) override;
|
||||
|
||||
/**
|
||||
* Handles dropping an amount of coins
|
||||
*/
|
||||
void dropCoins(uint coins) override;
|
||||
|
||||
/**
|
||||
* Do a get action
|
||||
*/
|
||||
void get() override;
|
||||
|
||||
/**
|
||||
* Do a talk action
|
||||
*/
|
||||
void talk() override;
|
||||
|
||||
/**
|
||||
* Do an unlock action
|
||||
*/
|
||||
void unlock() override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Castle map
|
||||
*/
|
||||
class MapCastle : public MapCityCastle {
|
||||
public:
|
||||
uint _castleKey; // Key for castle map lock
|
||||
int _getCounter; // Counter for allowed gets without stealing check
|
||||
bool _freeingPrincess; // Set when freeing the princess is in progress
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
MapCastle(Ultima1Game *game, Ultima1Map *map) : MapCityCastle(game, map), _castleKey(0),
|
||||
_getCounter(0), _freeingPrincess(false) {}
|
||||
|
||||
/**
|
||||
* Load the map
|
||||
*/
|
||||
void load(Shared::Maps::MapId mapId) override;
|
||||
|
||||
/**
|
||||
* Handles loading and saving the map's data
|
||||
*/
|
||||
void synchronize(Common::Serializer &s) override;
|
||||
|
||||
/**
|
||||
* Handles dropping an amount of coins
|
||||
*/
|
||||
void dropCoins(uint coins) override;
|
||||
|
||||
/**
|
||||
* Do a get action
|
||||
*/
|
||||
void get() override;
|
||||
|
||||
/**
|
||||
* Do a talk action
|
||||
*/
|
||||
void talk() override;
|
||||
|
||||
/**
|
||||
* Do an unlock action
|
||||
*/
|
||||
void unlock() override;
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if Lord British's castle is the currently active map
|
||||
*/
|
||||
bool isLordBritishCastle() const;
|
||||
};
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
349
engines/ultima/ultima1/maps/map_dungeon.cpp
Normal file
349
engines/ultima/ultima1/maps/map_dungeon.cpp
Normal file
@@ -0,0 +1,349 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/maps/map_dungeon.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_chest.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_coffin.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_monster.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_player.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Maps {
|
||||
|
||||
void MapDungeon::load(Shared::Maps::MapId mapId) {
|
||||
Shared::Maps::MapBase::load(mapId);
|
||||
|
||||
_tilesPerOrigTile = Point(1, 1);
|
||||
_dungeonLevel = 1;
|
||||
_dungeonExitHitPoints = 0;
|
||||
_name = _game->_res->LOCATION_NAMES[mapId - 1];
|
||||
|
||||
changeLevel(0);
|
||||
_playerWidget->moveTo(Point(1, 1), Shared::Maps::DIR_SOUTH);
|
||||
}
|
||||
|
||||
void MapDungeon::synchronize(Common::Serializer &s) {
|
||||
MapBase::synchronize(s);
|
||||
s.syncAsUint16LE(_dungeonLevel);
|
||||
s.syncAsUint16LE(_dungeonExitHitPoints);
|
||||
}
|
||||
|
||||
void MapDungeon::getTileAt(const Point &pt, Shared::Maps::MapTile *tile, bool includePlayer) {
|
||||
MapBase::MapBase::getTileAt(pt, tile, includePlayer);
|
||||
|
||||
tile->_isHallway = tile->_tileId == DTILE_HALLWAY;
|
||||
tile->_isDoor = tile->_tileId == DTILE_DOOR;
|
||||
tile->_isSecretDoor = tile->_tileId == DTILE_SECRET_DOOR;
|
||||
tile->_isWall = tile->_tileId == DTILE_WALL;
|
||||
tile->_isLadderUp = tile->_tileId == DTILE_LADDER_UP;
|
||||
tile->_isLadderDown = tile->_tileId == DTILE_LADDER_DOWN;
|
||||
tile->_isBeams = tile->_tileId == DTILE_BEAMS;
|
||||
}
|
||||
|
||||
bool MapDungeon::changeLevel(int delta) {
|
||||
_dungeonLevel += delta;
|
||||
if (_dungeonLevel <= 0) {
|
||||
leavingDungeon();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set seed for generating a deterministic resulting dungoen level
|
||||
setRandomSeed();
|
||||
|
||||
// Reset dungeon area
|
||||
setDimensions(Point(DUNGEON_WIDTH, DUNGEON_HEIGHT));
|
||||
|
||||
if (_widgets.empty()) {
|
||||
// Set up widget for the player
|
||||
_playerWidget = new Widgets::DungeonPlayer(_game, this);
|
||||
addWidget(_playerWidget);
|
||||
} else {
|
||||
_widgets.resize(1);
|
||||
}
|
||||
|
||||
// Place walls around the edge of the map
|
||||
for (int y = 0; y < DUNGEON_HEIGHT; ++y) {
|
||||
_data[y][0] = DTILE_WALL;
|
||||
_data[y][DUNGEON_WIDTH - 1] = DTILE_WALL;
|
||||
}
|
||||
for (int x = 0; x < DUNGEON_WIDTH; ++x) {
|
||||
_data[0][x] = DTILE_WALL;
|
||||
_data[DUNGEON_HEIGHT - 1][x] = DTILE_WALL;
|
||||
}
|
||||
|
||||
// Set up walls vertically across the dungeon
|
||||
for (int x = 2; x < (DUNGEON_WIDTH - 1); x += 2)
|
||||
for (int y = 2; y < (DUNGEON_HEIGHT - 1); y += 2)
|
||||
_data[y][x] = DTILE_WALL;
|
||||
|
||||
// Randomly set up random tiles for all alternate positions in wall columns
|
||||
for (int x = 2; x < (DUNGEON_WIDTH - 1); x += 2)
|
||||
for (int y = 1; y < DUNGEON_HEIGHT; y += 2)
|
||||
_data[y][x] = getDeterministicRandomNumber(DTILE_HALLWAY, DTILE_DOOR);
|
||||
|
||||
// Set up wall and beams randomly to subdivide the blank columns
|
||||
const byte DATA1[15] = { 8, 5, 2, 8, 1, 5, 4, 6, 1, 3, 7, 3, 9, 2, 6 };
|
||||
const byte DATA2[15] = { 1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 6, 8, 8, 9, 9 };
|
||||
for (uint ctr = 0; ctr < (_dungeonLevel * 2); ++ctr) {
|
||||
byte newTile = (getDeterministicRandomNumber(0, 255) <= 160) ? DTILE_WALL : DTILE_BEAMS;
|
||||
uint idx = getDeterministicRandomNumber(0, 14);
|
||||
|
||||
if (_dungeonLevel & 1) {
|
||||
_data[DATA2[idx]][DATA1[idx]] = newTile;
|
||||
}
|
||||
else {
|
||||
_data[DATA1[idx]][DATA2[idx]] = newTile;
|
||||
}
|
||||
}
|
||||
|
||||
// Place chests and/or coffins randomly throughout the level
|
||||
_random.setSeed(_random.getSeed() + 1777);
|
||||
for (uint ctr = 0; ctr <= _dungeonLevel; ++ctr) {
|
||||
Point pt(getDeterministicRandomNumber(10, 99) / 10, getDeterministicRandomNumber(10, 99) / 10);
|
||||
byte currTile = _data[pt.y][pt.x];
|
||||
|
||||
if (currTile != DTILE_WALL && currTile != DTILE_SECRET_DOOR && currTile != DTILE_BEAMS) {
|
||||
_widgets.push_back(Shared::Maps::MapWidgetPtr((getDeterministicRandomNumber(1, 100) & 1) ?
|
||||
(Widgets::DungeonItem *)new Widgets::DungeonChest(_game, this, pt) :
|
||||
(Widgets::DungeonItem *)new Widgets::DungeonCoffin(_game, this, pt)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// Set up ladders
|
||||
_data[2][1] = DTILE_HALLWAY;
|
||||
if (_dungeonLevel & 1) {
|
||||
_data[3][7] = DTILE_LADDER_UP;
|
||||
_data[6][3] = DTILE_LADDER_DOWN;
|
||||
} else {
|
||||
_data[3][7] = DTILE_LADDER_DOWN;
|
||||
_data[6][3] = DTILE_LADDER_UP;
|
||||
}
|
||||
|
||||
if (_dungeonLevel == 10)
|
||||
_data[3][7] = DTILE_HALLWAY;
|
||||
if (_dungeonLevel == 1) {
|
||||
_data[1][1] = DTILE_LADDER_UP;
|
||||
_data[3][7] = DTILE_HALLWAY;
|
||||
}
|
||||
|
||||
for (int ctr = 0; ctr < 3; ++ctr)
|
||||
spawnMonster();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void MapDungeon::setRandomSeed() {
|
||||
Ultima1Map *map = static_cast<Ultima1Map *>(_game->getMap());
|
||||
uint32 seed = _game->_randomSeed + map->_worldPos.x * 5 + map->_worldPos.y * 3 + _dungeonLevel * 17;
|
||||
_random.setSeed(seed);
|
||||
}
|
||||
|
||||
void MapDungeon::spawnMonster() {
|
||||
U1MapTile tile;
|
||||
|
||||
// Pick a random position for the monster, trying again up to 500 times
|
||||
// if the chosen position isn't a valid place for the monster
|
||||
for (int tryNum = 0; tryNum < 500; ++tryNum) {
|
||||
Point newPos(_game->getRandomNumber(242) % 9 + 1, _game->getRandomNumber(242) % 9 + 1);
|
||||
getTileAt(newPos, &tile);
|
||||
|
||||
if (tile._tileId == DTILE_HALLWAY && tile._widgetNum == -1) {
|
||||
// Found a free spot
|
||||
spawnMonsterAt(newPos);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MapDungeon::spawnMonsterAt(const Point &pt) {
|
||||
// Try up 50 times to randomly pick a monster not already present in the dungeon map
|
||||
for (int tryNum = 0; tryNum < 50; ++tryNum) {
|
||||
Widgets::DungeonWidgetId monsterId = (Widgets::DungeonWidgetId)((_dungeonLevel - 1) / 2 * 5 + _game->getRandomNumber(4));
|
||||
|
||||
// Only allow one of every type of monster on the map at the same time
|
||||
uint monsIdx;
|
||||
for (monsIdx = 0; monsIdx < _widgets.size(); ++monsIdx) {
|
||||
Widgets::DungeonMonster *mons = dynamic_cast<Widgets::DungeonMonster *>(_widgets[monsIdx].get());
|
||||
if (mons && mons->id() == monsterId)
|
||||
break;
|
||||
}
|
||||
|
||||
if (monsIdx == _widgets.size()) {
|
||||
// Monster not present, so can be added
|
||||
uint hp = _game->getRandomNumber(1, _dungeonLevel * _dungeonLevel + 1) +
|
||||
(int)monsterId + 10;
|
||||
Widgets::DungeonMonster *monster = new Widgets::DungeonMonster(_game, this, monsterId, hp, pt);
|
||||
addWidget(monster);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widgets::DungeonMonster *MapDungeon::findCreatureInCurrentDirection(uint maxDistance) {
|
||||
U1MapTile tile;
|
||||
Point delta = getDirectionDelta();
|
||||
|
||||
for (uint idx = 1; idx <= maxDistance; ++idx) {
|
||||
Point pt = getPosition() + Point(delta.x * idx, delta.y * idx);
|
||||
getTileAt(pt, &tile);
|
||||
|
||||
// If a monster found, return it
|
||||
Widgets::DungeonMonster *monster = dynamic_cast<Widgets::DungeonMonster *>(tile._widget);
|
||||
if (monster)
|
||||
return monster;
|
||||
|
||||
// If a blocking tile reached, then abort the loop
|
||||
if (tile._isWall || tile._isSecretDoor || tile._isBeams || tile._isDoor)
|
||||
break;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void MapDungeon::update() {
|
||||
U1MapTile tile;
|
||||
Point pt;
|
||||
|
||||
// Widgets in the dungeon are updated by row
|
||||
for (pt.y = 1; pt.y < ((int)height() - 1) && !_game->_party->isFoodless(); pt.y++) {
|
||||
for (pt.x = 1; pt.x < ((int)width() - 1); pt.x++) {
|
||||
// Check for a widget at the given position
|
||||
getTileAt(pt, &tile);
|
||||
|
||||
Shared::Maps::Creature *creature = dynamic_cast<Shared::Maps::Creature *>(tile._widget);
|
||||
if (creature)
|
||||
creature->update(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MapDungeon::inform() {
|
||||
U1MapTile currTile, destTile;
|
||||
Point pt = getPosition();
|
||||
getTileAt(pt, &currTile);
|
||||
getTileAt(pt + getDirectionDelta(), &destTile);
|
||||
|
||||
if (destTile._isSecretDoor && !currTile._isDoor) {
|
||||
addInfoMsg(Common::String::format("%s %s", _game->_res->FIND, _game->_res->A_SECRET_DOOR));
|
||||
_data[pt.y][pt.x] = DTILE_DOOR;
|
||||
} else {
|
||||
addInfoMsg(Common::String::format("%s %s", _game->_res->FIND, _game->_res->NOTHING));
|
||||
}
|
||||
}
|
||||
|
||||
void MapDungeon::open() {
|
||||
U1MapTile tile;
|
||||
getTileAt(getPosition(), &tile);
|
||||
addInfoMsg(Common::String::format(" %s", _game->_res->DUNGEON_ITEM_NAMES[1]), false);
|
||||
|
||||
// If there's an item on the cell, try and open it
|
||||
if (tile._item) {
|
||||
addInfoMsg(Common::String::format("%s ", tile._item->_name.c_str()));
|
||||
if (!tile._item->open()) {
|
||||
MapBase::open();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
addInfoMsg(_game->_res->NONE_HERE);
|
||||
_game->playFX(1);
|
||||
}
|
||||
}
|
||||
|
||||
void MapDungeon::climb() {
|
||||
Maps::U1MapTile tile;
|
||||
getTileAt(getPosition(), &tile);
|
||||
|
||||
if (!tile._isLadderUp && !tile._isLadderDown) {
|
||||
addInfoMsg(_game->_res->WHAT);
|
||||
_game->playFX(1);
|
||||
} else if (getDirection() == Shared::Maps::DIR_LEFT || getDirection() == Shared::Maps::DIR_RIGHT) {
|
||||
addInfoMsg("");
|
||||
addInfoMsg(_game->_res->FACE_THE_LADDER);
|
||||
_game->playFX(1);
|
||||
} else if (tile._isLadderUp) {
|
||||
if (!changeLevel(-1))
|
||||
_game->getMap()->load(MAPID_OVERWORLD);
|
||||
} else {
|
||||
changeLevel(1);
|
||||
}
|
||||
}
|
||||
|
||||
void MapDungeon::castSpell(uint spellId) {
|
||||
const Shared::Character &c = *_game->_party;
|
||||
static_cast<Spells::Spell *>(c._spells[spellId])->dungeonCast(this);
|
||||
}
|
||||
|
||||
void MapDungeon::leavingDungeon() {
|
||||
Shared::Character &c = *_game->_party;
|
||||
|
||||
// Don't allow the hit points addition to push the hit point total beyond 9999
|
||||
if (c._hitPoints + _dungeonExitHitPoints > 9999)
|
||||
_dungeonExitHitPoints = 9999 - c._hitPoints;
|
||||
|
||||
if (_dungeonExitHitPoints) {
|
||||
addInfoMsg(Common::String::format(_game->_res->GAIN_HIT_POINTS, _dungeonExitHitPoints));
|
||||
c._hitPoints += _dungeonExitHitPoints;
|
||||
}
|
||||
}
|
||||
|
||||
void MapDungeon::attack(int direction, int effectId) {
|
||||
const Character &c = *static_cast<Party *>(_game->_party);
|
||||
Widgets::DungeonMonster *monster = findCreatureInCurrentDirection(
|
||||
c.equippedWeapon()->_distance);
|
||||
_game->playFX(7);
|
||||
|
||||
if (monster) {
|
||||
uint agility = c._agility + 50;
|
||||
uint damage = _game->getRandomNumber(2, agility + c._equippedWeapon * 8 + c._strength);
|
||||
monster->attackMonster(2, agility, damage);
|
||||
} else {
|
||||
addInfoMsg(_game->_res->NOTHING);
|
||||
}
|
||||
|
||||
_game->endOfTurn();
|
||||
}
|
||||
|
||||
void MapDungeon::attack(int direction, int effectId, uint maxDistance, uint amount, uint agility, const Common::String &hitWidget) {
|
||||
//const Character &c = *static_cast<Party *>(_game->_party);
|
||||
Widgets::DungeonMonster *monster = findCreatureInCurrentDirection(maxDistance);
|
||||
_game->playFX(effectId);
|
||||
|
||||
if (monster) {
|
||||
monster->attackMonster(2, agility, amount);
|
||||
} else {
|
||||
addInfoMsg(_game->_res->NOTHING);
|
||||
}
|
||||
|
||||
_game->endOfTurn();
|
||||
}
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
170
engines/ultima/ultima1/maps/map_dungeon.h
Normal file
170
engines/ultima/ultima1/maps/map_dungeon.h
Normal file
@@ -0,0 +1,170 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_MAP_MAP_DUNGEON_H
|
||||
#define ULTIMA_ULTIMA1_MAP_MAP_DUNGEON_H
|
||||
|
||||
#include "ultima/ultima1/maps/map_base.h"
|
||||
#include "ultima/shared/core/rect.h"
|
||||
#include "common/random.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Widgets {
|
||||
class DungeonMonster;
|
||||
}
|
||||
|
||||
namespace Maps {
|
||||
|
||||
#define DUNGEON_WIDTH 11
|
||||
#define DUNGEON_HEIGHT 11
|
||||
|
||||
enum DungeonTile {
|
||||
DTILE_HALLWAY = 0, DTILE_WALL = 1, DTILE_SECRET_DOOR = 2, DTILE_DOOR = 3, DTILE_LADDER_DOWN = 6,
|
||||
DTILE_LADDER_UP = 7, DTILE_BEAMS = 8
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements the dungeon map
|
||||
*/
|
||||
class MapDungeon : public MapBase {
|
||||
private:
|
||||
Common::RandomSource _random;
|
||||
uint _dungeonLevel; // Dungeon level number
|
||||
private:
|
||||
/**
|
||||
* Sets up a deterministic random seed for generating dungeon data
|
||||
*/
|
||||
void setRandomSeed();
|
||||
|
||||
/**
|
||||
* Gets a deterministic random number based on a given seed. Used in dungeon generation
|
||||
* so that a given dungeon and level will always be built the same
|
||||
*/
|
||||
uint getDeterministicRandomNumber(uint min, uint max) { return min + _random.getRandomNumber(max - min); }
|
||||
|
||||
/**
|
||||
* Called when the dungeon is being left
|
||||
*/
|
||||
void leavingDungeon();
|
||||
public:
|
||||
uint _dungeonExitHitPoints;
|
||||
public:
|
||||
MapDungeon(Ultima1Game *game, Ultima1Map *map) : MapBase(game, map), _random("UltimaDungeons"),
|
||||
_dungeonLevel(0), _dungeonExitHitPoints(0) {}
|
||||
~MapDungeon() override {}
|
||||
|
||||
/**
|
||||
* Handles loading and saving viewport
|
||||
*/
|
||||
void synchronize(Common::Serializer &s) override;
|
||||
|
||||
/**
|
||||
* Load the map
|
||||
*/
|
||||
void load(Shared::Maps::MapId mapId) override;
|
||||
|
||||
/**
|
||||
* Gets a tile at a given position
|
||||
*/
|
||||
void getTileAt(const Point &pt, Shared::Maps::MapTile *tile, bool includePlayer = true) override;
|
||||
|
||||
/**
|
||||
* Changes the dungeon level by a given delta amount, and generates a new map
|
||||
* @param delta Delta to change dungeon level by
|
||||
* @returns False if dungeon left, true if still within dungeon
|
||||
*/
|
||||
bool changeLevel(int delta) override;
|
||||
|
||||
/**
|
||||
* Get the current map level
|
||||
*/
|
||||
uint getLevel() const override { return _dungeonLevel; }
|
||||
|
||||
/**
|
||||
* Updates the map at the end of a turn
|
||||
*/
|
||||
void update() override;
|
||||
|
||||
/**
|
||||
* Spawns a monster within dungeons
|
||||
*/
|
||||
void spawnMonster();
|
||||
|
||||
/**
|
||||
* Spawns a monster at a given position in the dungeon map
|
||||
*/
|
||||
void spawnMonsterAt(const Point &pt);
|
||||
|
||||
/**
|
||||
* Find a monster in the current direction being faced
|
||||
*/
|
||||
Widgets::DungeonMonster *findCreatureInCurrentDirection(uint maxDistance = 5);
|
||||
|
||||
/**
|
||||
* Perform an attack in a direction
|
||||
* @param direction Direction
|
||||
* @param effectId Sound effect to play
|
||||
*/
|
||||
void attack(int direction, int effectId) override;
|
||||
|
||||
/**
|
||||
* Perform an attack in a direction
|
||||
* @param direction Direction
|
||||
* @param effectId Sound effect to play
|
||||
* @param maxDistance Maximum distance in the given direction
|
||||
* @param amount Damage amount
|
||||
* @param agility Agility threshold
|
||||
* @param widgetNa
|
||||
*/
|
||||
void attack(int direction, int effectId, uint maxDistance, uint amount, uint agility, const Common::String &hitWidget) override;
|
||||
|
||||
/**
|
||||
* Do an inform action
|
||||
*/
|
||||
void inform() override;
|
||||
|
||||
/**
|
||||
* Do a climb action
|
||||
*/
|
||||
void climb() override;
|
||||
|
||||
/**
|
||||
* Do an open action
|
||||
*/
|
||||
void open() override;
|
||||
|
||||
/**
|
||||
* Do an unlock action
|
||||
*/
|
||||
void unlock() override { open(); }
|
||||
|
||||
/**
|
||||
* Cast a specific spell
|
||||
*/
|
||||
void castSpell(uint spell) override;
|
||||
};
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
213
engines/ultima/ultima1/maps/map_overworld.cpp
Normal file
213
engines/ultima/ultima1/maps/map_overworld.cpp
Normal file
@@ -0,0 +1,213 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/maps/map_overworld.h"
|
||||
#include "ultima/ultima1/widgets/transport.h"
|
||||
#include "ultima/ultima1/widgets/overworld_monster.h"
|
||||
#include "ultima/ultima1/widgets/transport.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Maps {
|
||||
|
||||
void MapOverworld::load(Shared::Maps::MapId mapId) {
|
||||
Shared::Maps::MapBase::load(mapId);
|
||||
setDimensions(Point(168, 156));
|
||||
_tilesPerOrigTile = Point(1, 1);
|
||||
|
||||
Shared::File f("map.bin");
|
||||
byte b;
|
||||
for (int y = 0; y < _size.y; ++y) {
|
||||
for (int x = 0; x < _size.x; x += 2) {
|
||||
b = f.readByte();
|
||||
_data[y][x] = b >> 4;
|
||||
_data[y][x + 1] = b & 0xf;
|
||||
}
|
||||
}
|
||||
|
||||
// Load widgets
|
||||
loadWidgets();
|
||||
}
|
||||
|
||||
void MapOverworld::loadWidgets() {
|
||||
// Note: the overworld player, transports, and monsters are persistent, so we only have to set up
|
||||
// the initial "on foot" transport the first time
|
||||
if (_widgets.empty()) {
|
||||
// Set up widget for the player
|
||||
_playerWidget = new Widgets::TransportOnFoot(_game, this);
|
||||
addWidget(_playerWidget);
|
||||
}
|
||||
}
|
||||
|
||||
Point MapOverworld::getDeltaPosition(const Point &delta) {
|
||||
Point pt = _playerWidget->_position + delta;
|
||||
|
||||
if (pt.x < 0)
|
||||
pt.x += _size.x;
|
||||
else if (pt.x >= _size.x)
|
||||
pt.x -= _size.x;
|
||||
if (pt.y < 0)
|
||||
pt.y += _size.y;
|
||||
else if (pt.y >= _size.y)
|
||||
pt.y -= _size.y;
|
||||
|
||||
return pt;
|
||||
}
|
||||
|
||||
Point MapOverworld::getViewportPosition(const Point &viewportSize) {
|
||||
Point &topLeft = _viewportPos._topLeft;
|
||||
|
||||
if (!_viewportPos.isValid() || _viewportPos._size != viewportSize) {
|
||||
// Calculate the new position
|
||||
topLeft.x = _playerWidget->_position.x - (viewportSize.x - 1) / 2;
|
||||
topLeft.y = _playerWidget->_position.y - (viewportSize.y - 1) / 2;
|
||||
|
||||
// Non-fixed map, so it wraps around the edges if necessary
|
||||
if (topLeft.x < 0)
|
||||
topLeft.x += width();
|
||||
else if (topLeft.x >= (int)width())
|
||||
topLeft.x -= width();
|
||||
|
||||
if (topLeft.y < 0)
|
||||
topLeft.y += height();
|
||||
else if (topLeft.y >= (int)height())
|
||||
topLeft.y -= height();
|
||||
|
||||
_viewportPos._mapId = _mapId;
|
||||
_viewportPos._size = viewportSize;
|
||||
}
|
||||
|
||||
return topLeft;
|
||||
}
|
||||
|
||||
void MapOverworld::shiftViewport(const Point &delta) {
|
||||
Point &topLeft = _viewportPos._topLeft;
|
||||
topLeft += delta;
|
||||
|
||||
if (topLeft.x < 0)
|
||||
topLeft.x += width();
|
||||
else if (topLeft.x >= (int16)width())
|
||||
topLeft.x -= width();
|
||||
if (topLeft.y < 0)
|
||||
topLeft.y += height();
|
||||
else if (topLeft.y >= (int16)height())
|
||||
topLeft.y -= height();
|
||||
}
|
||||
|
||||
void MapOverworld::board() {
|
||||
Maps::U1MapTile tile;
|
||||
getTileAt(getPosition(), &tile);
|
||||
Widgets::Transport *transport = dynamic_cast<Widgets::Transport *>(tile._widget);
|
||||
|
||||
if (!dynamic_cast<Widgets::TransportOnFoot *>(_playerWidget)) {
|
||||
addInfoMsg(_game->_res->EXIT_CRAFT_FIRST, true, true);
|
||||
_game->playFX(1);
|
||||
_game->endOfTurn();
|
||||
} else if (!transport) {
|
||||
addInfoMsg(_game->_res->NOTHING_TO_BOARD, true, true);
|
||||
_game->playFX(1);
|
||||
_game->endOfTurn();
|
||||
} else {
|
||||
transport->board();
|
||||
}
|
||||
}
|
||||
|
||||
void MapOverworld::enter() {
|
||||
Maps::U1MapTile tile;
|
||||
getTileAt(getPosition(), &tile);
|
||||
|
||||
if (tile._locationNum == -1) {
|
||||
// Fall back to base unknown action
|
||||
MapBase::enter();
|
||||
} else {
|
||||
// Load the location
|
||||
Shared::Maps::Map *map = _game->getMap();
|
||||
map->load(tile._locationNum);
|
||||
|
||||
// Add message for location having been entered
|
||||
addInfoMsg(_game->_res->ENTERING);
|
||||
addInfoMsg(map->getName());
|
||||
}
|
||||
}
|
||||
|
||||
void MapOverworld::inform() {
|
||||
Maps::U1MapTile tile;
|
||||
getTileAt(getPosition(), &tile, false);
|
||||
|
||||
addInfoMsg("");
|
||||
if (tile._locationNum != -1) {
|
||||
if (tile._locationNum < 33)
|
||||
addInfoMsg(Common::String::format("%s %s", _game->_res->THE_CITY_OF, _game->_res->LOCATION_NAMES[tile._locationNum - 1]));
|
||||
else
|
||||
addInfoMsg(_game->_res->LOCATION_NAMES[tile._locationNum - 1]);
|
||||
} else if (tile.isOriginalWater()) {
|
||||
addInfoMsg(_game->_res->YOU_ARE_AT_SEA);
|
||||
} else if (tile.isOriginalWoods()) {
|
||||
addInfoMsg(_game->_res->YOU_ARE_IN_WOODS);
|
||||
} else {
|
||||
addInfoMsg(_game->_res->YOU_ARE_IN_LANDS);
|
||||
addInfoMsg(_game->_res->LAND_NAMES[getLandsNumber()]);
|
||||
}
|
||||
}
|
||||
|
||||
void MapOverworld::disembark() {
|
||||
Widgets::Transport *transport = dynamic_cast<Widgets::Transport *>(_playerWidget);
|
||||
|
||||
if (transport) {
|
||||
addInfoMsg("");
|
||||
transport->disembark();
|
||||
} else {
|
||||
addInfoMsg(_game->_res->WHAT);
|
||||
}
|
||||
}
|
||||
|
||||
uint MapOverworld::getLandsNumber() const {
|
||||
Point pt = getPosition();
|
||||
return (pt.y > 77 ? 2 : 0) + (pt.x > 83 ? 1 : 0);
|
||||
}
|
||||
|
||||
void MapOverworld::addOnFoot() {
|
||||
_widgets.insert_at(0, Shared::Maps::MapWidgetPtr(new Widgets::TransportOnFoot(_game, this)));
|
||||
_playerWidget = _widgets[0].get();
|
||||
}
|
||||
|
||||
uint MapOverworld::getEnemyVesselCount() const {
|
||||
uint total = 0;
|
||||
for (uint idx = 0; idx < _widgets.size(); ++idx) {
|
||||
if (dynamic_cast<Widgets::EnemyVessel *>(_widgets[idx].get()))
|
||||
++total;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
void MapOverworld::attack(int direction, int effectId, uint maxDistance, uint amount, uint agility, const Common::String &hitWidget) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
121
engines/ultima/ultima1/maps/map_overworld.h
Normal file
121
engines/ultima/ultima1/maps/map_overworld.h
Normal file
@@ -0,0 +1,121 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_MAP_MAP_OVERWORLD_H
|
||||
#define ULTIMA_ULTIMA1_MAP_MAP_OVERWORLD_H
|
||||
|
||||
#include "ultima/ultima1/maps/map_base.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Maps {
|
||||
|
||||
enum OverworldTile {
|
||||
OTILE_OCEAN = 0, OTILE_GRASS = 1, OTILE_WOODS = 2
|
||||
};
|
||||
|
||||
class MapOverworld : public MapBase {
|
||||
private:
|
||||
/**
|
||||
* Load widget list for the map
|
||||
*/
|
||||
void loadWidgets();
|
||||
public:
|
||||
MapOverworld(Ultima1Game *game, Ultima1Map *map) : MapBase(game, map) {}
|
||||
~MapOverworld() override {}
|
||||
|
||||
/**
|
||||
* Load the map
|
||||
*/
|
||||
void load(Shared::Maps::MapId mapId) override;
|
||||
|
||||
/**
|
||||
* Returns whether the map wraps around to the other side at it's edges (i.e. the overworld)
|
||||
*/
|
||||
bool isMapWrapped() const override { return true; }
|
||||
|
||||
/**
|
||||
* Shifts the viewport by a given delta
|
||||
*/
|
||||
void shiftViewport(const Point &delta) override;
|
||||
|
||||
/**
|
||||
* Get the viewport position
|
||||
*/
|
||||
Point getViewportPosition(const Point &viewportSize) override;
|
||||
|
||||
/**
|
||||
* Gets a point relative to the current position
|
||||
*/
|
||||
Point getDeltaPosition(const Point &delta) override;
|
||||
|
||||
/**
|
||||
* Perform an attack in a direction
|
||||
* @param direction Direction
|
||||
* @param effectId Sound effect to play
|
||||
* @param maxDistance Maximum distance in the given direction
|
||||
* @param amount Damage amount
|
||||
* @param agility Agility threshold
|
||||
* @param widgetNa
|
||||
*/
|
||||
void attack(int direction, int effectId, uint maxDistance, uint amount, uint agility, const Common::String &hitWidget) override;
|
||||
|
||||
/**
|
||||
* Board a transport
|
||||
*/
|
||||
void board() override;
|
||||
|
||||
/**
|
||||
* Do an enter action
|
||||
*/
|
||||
void enter() override;
|
||||
|
||||
/**
|
||||
* Do an inform action
|
||||
*/
|
||||
void inform() override;
|
||||
|
||||
/**
|
||||
* Do an exit transport action
|
||||
*/
|
||||
void disembark() override;
|
||||
|
||||
/**
|
||||
* Get the lands number the player is currently within
|
||||
*/
|
||||
uint getLandsNumber() const;
|
||||
|
||||
/**
|
||||
* Adds a widget for the player being on foot, and sets it to the active player widget
|
||||
*/
|
||||
void addOnFoot();
|
||||
|
||||
/**
|
||||
* Get the number of active enemy vessels
|
||||
*/
|
||||
uint getEnemyVesselCount() const;
|
||||
};
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
70
engines/ultima/ultima1/maps/map_tile.cpp
Normal file
70
engines/ultima/ultima1/maps/map_tile.cpp
Normal file
@@ -0,0 +1,70 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/maps/map_overworld.h"
|
||||
#include "ultima/ultima1/maps/map_city_castle.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Maps {
|
||||
|
||||
void U1MapTile::clear() {
|
||||
_map = nullptr;
|
||||
_locationNum = -1;
|
||||
}
|
||||
|
||||
bool U1MapTile::isWater() const {
|
||||
return dynamic_cast<MapOverworld *>(_map) && _tileId == TILE_WATER;
|
||||
}
|
||||
|
||||
bool U1MapTile::isGrass() const {
|
||||
return dynamic_cast<MapOverworld *>(_map) && _tileId == TILE_GRASS;
|
||||
}
|
||||
|
||||
bool U1MapTile::isWoods() const {
|
||||
return dynamic_cast<MapOverworld *>(_map) && _tileId == TILE_WOODS;
|
||||
}
|
||||
|
||||
bool U1MapTile::isOriginalWater() const {
|
||||
return dynamic_cast<MapOverworld *>(_map) && _tileId == TILE_WATER;
|
||||
}
|
||||
|
||||
bool U1MapTile::isOriginalGrass() const {
|
||||
return dynamic_cast<MapOverworld *>(_map) && _tileId == TILE_GRASS;
|
||||
}
|
||||
|
||||
bool U1MapTile::isOriginalWoods() const {
|
||||
return dynamic_cast<MapOverworld *>(_map) && _tileId == TILE_WOODS;
|
||||
}
|
||||
|
||||
bool U1MapTile::isGround() const {
|
||||
if (dynamic_cast<MapCityCastle *>(_map) && (_tileId == 1 || _tileId >= 51))
|
||||
return true;
|
||||
else if (dynamic_cast<MapOverworld *>(_map))
|
||||
// Not water or mountains
|
||||
return _tileId != TILE_WATER && _tileId != TILE_MOUNTAINS;
|
||||
return false;
|
||||
}
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
107
engines/ultima/ultima1/maps/map_tile.h
Normal file
107
engines/ultima/ultima1/maps/map_tile.h
Normal file
@@ -0,0 +1,107 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_MAPS_MAP_TILE_H
|
||||
#define ULTIMA_ULTIMA1_MAPS_MAP_TILE_H
|
||||
|
||||
#include "ultima/shared/maps/map_tile.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Widgets {
|
||||
class DungeonItem;
|
||||
}
|
||||
|
||||
namespace Maps {
|
||||
|
||||
enum TileId {
|
||||
TILE_WATER = 0, TILE_GRASS = 1, TILE_WOODS = 2, TILE_MOUNTAINS = 3
|
||||
};
|
||||
|
||||
class MapBase;
|
||||
class Ultima1Map;
|
||||
|
||||
/**
|
||||
* Derived map tile class for Ultima 1 that adds extra properties
|
||||
*/
|
||||
class U1MapTile : public Shared::Maps::MapTile {
|
||||
private:
|
||||
MapBase *_map;
|
||||
public:
|
||||
int _locationNum;
|
||||
Widgets::DungeonItem *_item;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
U1MapTile() : Shared::Maps::MapTile(), _item(0), _locationNum(-1), _map(nullptr) {}
|
||||
|
||||
/**
|
||||
* Set the active map
|
||||
*/
|
||||
void setMap(MapBase *map) { _map = map; }
|
||||
|
||||
/**
|
||||
* Clears tile data
|
||||
*/
|
||||
void clear() override;
|
||||
|
||||
/**
|
||||
* Return true if the tile base is water
|
||||
*/
|
||||
bool isWater() const;
|
||||
|
||||
/**
|
||||
* Return true if the tile base is grass
|
||||
*/
|
||||
bool isGrass() const;
|
||||
|
||||
/**
|
||||
* Return true if the tile base is woods
|
||||
*/
|
||||
bool isWoods() const;
|
||||
|
||||
/**
|
||||
* Return true if the tile base in the original map is water
|
||||
*/
|
||||
bool isOriginalWater() const;
|
||||
|
||||
/**
|
||||
* Return true if the tile base in the original map is grass
|
||||
*/
|
||||
bool isOriginalGrass() const;
|
||||
|
||||
/**
|
||||
* Return true if the tile base in the original map is woods
|
||||
*/
|
||||
bool isOriginalWoods() const;
|
||||
|
||||
/**
|
||||
* Returns true if the tile is a ground type tool
|
||||
*/
|
||||
bool isGround() const;
|
||||
};
|
||||
|
||||
} // End of namespace Maps
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
53
engines/ultima/ultima1/spells/blink.cpp
Normal file
53
engines/ultima/ultima1/spells/blink.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/spells/blink.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
Blink::Blink(Ultima1Game *game, Character *c) : Spell(game, c, SPELL_BLINK) {
|
||||
}
|
||||
|
||||
void Blink::dungeonCast(Maps::MapDungeon *map) {
|
||||
Point newPos;
|
||||
Maps::U1MapTile tile;
|
||||
|
||||
// Choose a random new location to teleport to
|
||||
do {
|
||||
newPos = Point(_game->getRandomNumber(1, 9), _game->getRandomNumber(1, 9));
|
||||
map->getTileAt(newPos, &tile);
|
||||
} while (newPos != map->getPosition() && tile._widget &&
|
||||
!tile._isBeams && !tile._isWall && !tile._isSecretDoor);
|
||||
|
||||
// And teleport there
|
||||
addInfoMsg(_game->_res->TELEPORTED);
|
||||
map->setPosition(newPos);
|
||||
_game->endOfTurn();
|
||||
}
|
||||
|
||||
} // End of namespace Spells
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
51
engines/ultima/ultima1/spells/blink.h
Normal file
51
engines/ultima/ultima1/spells/blink.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_BLINK_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_BLINK_H
|
||||
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
/**
|
||||
* Blink spell
|
||||
*/
|
||||
class Blink : public Spell {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Blink(Ultima1Game *game, Character *c);
|
||||
|
||||
/**
|
||||
* Cast the spell within dungeons
|
||||
*/
|
||||
void dungeonCast(Maps::MapDungeon *map) override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
55
engines/ultima/ultima1/spells/create.cpp
Normal file
55
engines/ultima/ultima1/spells/create.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/spells/create.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/maps/map_dungeon.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
Create::Create(Ultima1Game *game, Character *c) : Spell(game, c, SPELL_CREATE) {
|
||||
}
|
||||
|
||||
void Create::dungeonCast(Maps::MapDungeon *map) {
|
||||
Point newPos;
|
||||
Maps::U1MapTile tile;
|
||||
|
||||
newPos = map->getPosition() + map->getDirectionDelta();
|
||||
map->getTileAt(newPos, &tile);
|
||||
|
||||
if (tile._isHallway && !tile._widget) {
|
||||
// Create beams on the tile in front of the player
|
||||
map->setTileAt(newPos, Maps::DTILE_BEAMS);
|
||||
addInfoMsg(_game->_res->FIELD_CREATED);
|
||||
_game->endOfTurn();
|
||||
} else {
|
||||
// Failed
|
||||
Spell::dungeonCast(map);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Spells
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
51
engines/ultima/ultima1/spells/create.h
Normal file
51
engines/ultima/ultima1/spells/create.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_CREATE_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_CREATE_H
|
||||
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
/**
|
||||
* Create spell
|
||||
*/
|
||||
class Create : public Spell {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Create(Ultima1Game *game, Character *c);
|
||||
|
||||
/**
|
||||
* Cast the spell within dungeons
|
||||
*/
|
||||
void dungeonCast(Maps::MapDungeon *map) override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
55
engines/ultima/ultima1/spells/destroy.cpp
Normal file
55
engines/ultima/ultima1/spells/destroy.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/spells/destroy.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/maps/map_dungeon.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
Destroy::Destroy(Ultima1Game *game, Character *c) : Spell(game, c, SPELL_DESTROY) {
|
||||
}
|
||||
|
||||
void Destroy::dungeonCast(Maps::MapDungeon *map) {
|
||||
Point newPos;
|
||||
Maps::U1MapTile tile;
|
||||
|
||||
newPos = map->getPosition() + map->getDirectionDelta();
|
||||
map->getTileAt(newPos, &tile);
|
||||
|
||||
if (tile._isBeams && !tile._widget) {
|
||||
// Destroy the beams in front of the player
|
||||
map->setTileAt(newPos, Maps::DTILE_HALLWAY);
|
||||
addInfoMsg(_game->_res->FIELD_DESTROYED);
|
||||
_game->endOfTurn();
|
||||
} else {
|
||||
// Failed
|
||||
Spell::dungeonCast(map);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Spells
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
51
engines/ultima/ultima1/spells/destroy.h
Normal file
51
engines/ultima/ultima1/spells/destroy.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_DESTROY_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_DESTROY_H
|
||||
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
/**
|
||||
* Destroy spell
|
||||
*/
|
||||
class Destroy : public Spell {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Destroy(Ultima1Game *game, Character *c);
|
||||
|
||||
/**
|
||||
* Cast the spell within dungeons
|
||||
*/
|
||||
void dungeonCast(Maps::MapDungeon *map) override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
115
engines/ultima/ultima1/spells/kill_magic_missile.cpp
Normal file
115
engines/ultima/ultima1/spells/kill_magic_missile.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/spells/kill_magic_missile.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_monster.h"
|
||||
#include "ultima/shared/maps/map_widget.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
BEGIN_MESSAGE_MAP(KillMagicMIssile, Spell)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
void KillMagicMIssile::cast(Maps::MapBase *map) {
|
||||
// Prompt for a direction
|
||||
addInfoMsg(": ", false);
|
||||
Shared::CInfoGetKeypress keyMsg(this);
|
||||
keyMsg.execute(_game);
|
||||
}
|
||||
|
||||
bool KillMagicMIssile::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
Shared::Maps::Direction dir = Shared::Maps::MapWidget::directionFromKey(msg->_keyState.keycode);
|
||||
Character &c = *static_cast<Party *>(_game->_party);
|
||||
|
||||
if (dir == Shared::Maps::DIR_NONE) {
|
||||
addInfoMsg(_game->_res->NONE);
|
||||
_game->endOfTurn();
|
||||
} else {
|
||||
addInfoMsg(_game->_res->DIRECTION_NAMES[(int)dir - 1]);
|
||||
addInfoMsg(_game->_res->SPELL_PHRASES[_spellId == SPELL_MAGIC_MISSILE ? 12 : 13], false);
|
||||
//uint damage = _spellId == SPELL_MAGIC_MISSILE ?
|
||||
// c.equippedWeapon()->getMagicDamage() : 9999;
|
||||
|
||||
if (c._class == CLASS_CLERIC || _game->getRandomNumber(1, 100) < c._wisdom) {
|
||||
_game->playFX(5);
|
||||
addInfoMsg("");
|
||||
|
||||
// TODO: Non-dungeon damage
|
||||
// damage(dir, 7, 3, damage, 101, "SpellEffect");
|
||||
} else {
|
||||
addInfoMsg(_game->_res->FAILED);
|
||||
_game->playFX(6);
|
||||
_game->endOfTurn();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
Kill::Kill(Ultima1Game *game, Character *c) : KillMagicMIssile(game, c, SPELL_KILL) {
|
||||
}
|
||||
|
||||
void Kill::dungeonCast(Maps::MapDungeon *map) {
|
||||
Point newPos;
|
||||
Maps::U1MapTile tile;
|
||||
|
||||
newPos = map->getPosition() + map->getDirectionDelta();
|
||||
map->getTileAt(newPos, &tile);
|
||||
|
||||
Widgets::DungeonMonster *monster = dynamic_cast<Widgets::DungeonMonster *>(tile._widget);
|
||||
if (monster) {
|
||||
monster->attackMonster(5, 101, Widgets::ITS_OVER_9000);
|
||||
_game->endOfTurn();
|
||||
} else {
|
||||
// Failed
|
||||
KillMagicMIssile::dungeonCast(map);
|
||||
}
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------*/
|
||||
|
||||
MagicMissile::MagicMissile(Ultima1Game *game, Character *c) : KillMagicMIssile(game, c, SPELL_MAGIC_MISSILE) {
|
||||
}
|
||||
|
||||
void MagicMissile::dungeonCast(Maps::MapDungeon *map) {
|
||||
Widgets::DungeonMonster *monster = map->findCreatureInCurrentDirection();
|
||||
|
||||
if (monster) {
|
||||
Character *c = *static_cast<Party *>(_game->_party);
|
||||
uint damage = c->equippedWeapon()->getMagicDamage();
|
||||
monster->attackMonster(5, 101, damage);
|
||||
} else {
|
||||
KillMagicMIssile::dungeonCast(map);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Spells
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
90
engines/ultima/ultima1/spells/kill_magic_missile.h
Normal file
90
engines/ultima/ultima1/spells/kill_magic_missile.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_KILL_MAGIC_MISSILE_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_KILL_MAGIC_MISSILE_H
|
||||
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
using Shared::CCharacterInputMsg;
|
||||
|
||||
/**
|
||||
* Common intermediate base class for both the Kill and Magic Missile spells
|
||||
*/
|
||||
class KillMagicMIssile : public Spell {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
KillMagicMIssile(Ultima1Game *game, Character *c, SpellId spellId) : Spell(game, c, spellId) {}
|
||||
|
||||
/**
|
||||
* Cast the spell outside a dungeon
|
||||
*/
|
||||
void cast(Maps::MapBase *map) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Kill spell
|
||||
*/
|
||||
class Kill : public KillMagicMIssile {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Kill(Ultima1Game *game, Character *c);
|
||||
|
||||
/**
|
||||
* Cast the spell within dungeons
|
||||
*/
|
||||
void dungeonCast(Maps::MapDungeon *map) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Magic Missile spell
|
||||
*/
|
||||
class MagicMissile : public KillMagicMIssile {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
MagicMissile(Ultima1Game *game, Character *c);
|
||||
|
||||
/**
|
||||
* Cast the spell within dungeons
|
||||
*/
|
||||
void dungeonCast(Maps::MapDungeon *map) override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
51
engines/ultima/ultima1/spells/ladder_down.cpp
Normal file
51
engines/ultima/ultima1/spells/ladder_down.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/spells/ladder_down.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
LadderDown::LadderDown(Ultima1Game *game, Character *c) : Spell(game, c, SPELL_LADDER_DOWN) {
|
||||
}
|
||||
|
||||
void LadderDown::dungeonCast(Maps::MapDungeon *map) {
|
||||
Point pt = map->getPosition();
|
||||
Maps::U1MapTile tile;
|
||||
map->getTileAt(pt, &tile);
|
||||
|
||||
if (map->getLevel() < 10 && !tile._isBeams && ((pt.x & 1) || (pt.y & 1))) {
|
||||
map->setTileAt(pt, Maps::DTILE_LADDER_DOWN);
|
||||
addInfoMsg(_game->_res->LADDER_CREATED);
|
||||
_game->endOfTurn();
|
||||
} else {
|
||||
// Failed
|
||||
Spell::dungeonCast(map);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Spells
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
51
engines/ultima/ultima1/spells/ladder_down.h
Normal file
51
engines/ultima/ultima1/spells/ladder_down.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_LADDER_DOWN_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_LADDER_DOWN_H
|
||||
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
/**
|
||||
* Ladder Down spell
|
||||
*/
|
||||
class LadderDown : public Spell {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
LadderDown(Ultima1Game *game, Character *c);
|
||||
|
||||
/**
|
||||
* Cast the spell within dungeons
|
||||
*/
|
||||
void dungeonCast(Maps::MapDungeon *map) override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
51
engines/ultima/ultima1/spells/ladder_up.cpp
Normal file
51
engines/ultima/ultima1/spells/ladder_up.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/spells/ladder_up.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
LadderUp::LadderUp(Ultima1Game *game, Character *c) : Spell(game, c, SPELL_LADDER_UP) {
|
||||
}
|
||||
|
||||
void LadderUp::dungeonCast(Maps::MapDungeon *map) {
|
||||
Point pt = map->getPosition();
|
||||
Maps::U1MapTile tile;
|
||||
map->getTileAt(pt, &tile);
|
||||
|
||||
if (!tile._isBeams && ((pt.x & 1) || (pt.y & 1))) {
|
||||
map->setTileAt(pt, Maps::DTILE_LADDER_UP);
|
||||
addInfoMsg(_game->_res->LADDER_CREATED);
|
||||
_game->endOfTurn();
|
||||
} else {
|
||||
// Failed
|
||||
Spell::dungeonCast(map);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Spells
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
51
engines/ultima/ultima1/spells/ladder_up.h
Normal file
51
engines/ultima/ultima1/spells/ladder_up.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_LADDER_UP_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_LADDER_UP_H
|
||||
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
/**
|
||||
* Ladder Up spell
|
||||
*/
|
||||
class LadderUp : public Spell {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
LadderUp(Ultima1Game *game, Character *c);
|
||||
|
||||
/**
|
||||
* Cast the spell within dungeons
|
||||
*/
|
||||
void dungeonCast(Maps::MapDungeon *map) override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
58
engines/ultima/ultima1/spells/open_unlock.cpp
Normal file
58
engines/ultima/ultima1/spells/open_unlock.cpp
Normal file
@@ -0,0 +1,58 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/spells/open_unlock.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_item.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
void OpenUnlock::dungeonCast(Maps::MapDungeon *map) {
|
||||
Maps::U1MapTile tile;
|
||||
map->getTileAt(map->getPosition(), &tile);
|
||||
|
||||
Widgets::DungeonItem *item = dynamic_cast<Widgets::DungeonItem *>(tile._widget);
|
||||
if (item) {
|
||||
addInfoMsg(item->_name, false);
|
||||
openItem(map, item);
|
||||
_game->endOfTurn();
|
||||
} else {
|
||||
Spell::dungeonCast(map);
|
||||
}
|
||||
}
|
||||
|
||||
void OpenUnlock::openItem(Maps::MapDungeon *map, Widgets::DungeonItem *item) {
|
||||
// Say opened, and remove the coffin/chest
|
||||
map->removeWidget(item);
|
||||
addInfoMsg(Common::String::format(" %s", _game->_res->OPENED));
|
||||
addInfoMsg(_game->_res->THOU_DOST_FIND, false);
|
||||
|
||||
uint coins = _game->getRandomNumber(3, map->getLevel() * map->getLevel() + 9);
|
||||
_game->giveTreasure(coins, 0);
|
||||
}
|
||||
|
||||
} // End of namespace Spells
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
79
engines/ultima/ultima1/spells/open_unlock.h
Normal file
79
engines/ultima/ultima1/spells/open_unlock.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_OPEN_UNLOCK_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_OPEN_UNLOCK_H
|
||||
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
#include "ultima/ultima1/widgets/dungeon_item.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
/**
|
||||
* Open/unlock common spell base class
|
||||
*/
|
||||
class OpenUnlock : public Spell {
|
||||
private:
|
||||
/**
|
||||
* Open a given widget
|
||||
*/
|
||||
void openItem(Maps::MapDungeon *map, Widgets::DungeonItem *item);
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
OpenUnlock(Ultima1Game *game, Character *c, SpellId spellId) : Spell(game, c, spellId) {}
|
||||
|
||||
/**
|
||||
* Cast the spell within dungeons
|
||||
*/
|
||||
void dungeonCast(Maps::MapDungeon *map) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Open spell
|
||||
*/
|
||||
class Open : public OpenUnlock {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Open(Ultima1Game *game, Character *c) : OpenUnlock(game, c, SPELL_OPEN) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Open spell
|
||||
*/
|
||||
class Unlock : public OpenUnlock {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Unlock(Ultima1Game *game, Character *c) : OpenUnlock(game, c, SPELL_UNLOCK) {}
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
88
engines/ultima/ultima1/spells/prayer.cpp
Normal file
88
engines/ultima/ultima1/spells/prayer.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/spells/prayer.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/widgets/overworld_monster.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
Prayer::Prayer(Ultima1Game *game, Character *c) : Spell(game, c, SPELL_PRAYER) {
|
||||
_quantity = 0xffff; // Prayer has unlimited uses
|
||||
}
|
||||
|
||||
void Prayer::cast(Maps::MapBase *map) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
addInfoMsg("");
|
||||
addInfoMsg(_game->_res->SPELL_PHRASES[0], false);
|
||||
|
||||
bool flag = false;
|
||||
if (c._hitPoints < 15) {
|
||||
// Add hit points
|
||||
c._hitPoints = 15;
|
||||
addInfoMsg(Common::String::format(" %s", _game->_res->SPELL_PHRASES[11]));
|
||||
_game->playFX(5);
|
||||
flag = true;
|
||||
} else if (c._food < 15) {
|
||||
// Add food
|
||||
c._food = 15;
|
||||
addInfoMsg(Common::String::format(" %s", _game->_res->SPELL_PHRASES[11]));
|
||||
_game->playFX(5);
|
||||
flag = true;
|
||||
} else if (_game->getRandomNumber(1, 100) < 25) {
|
||||
for (uint idx = 0; idx < map->_widgets.size(); ++idx) {
|
||||
Widgets::OverworldMonster *monster = dynamic_cast<Widgets::OverworldMonster *>(map->_widgets[idx].get());
|
||||
if (monster && monster->attackDistance() != 0) {
|
||||
map->removeWidget(monster);
|
||||
addInfoMsg(_game->_res->MONSTER_REMOVED);
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
addInfoMsg(_game->_res->NO_EFFECT);
|
||||
_game->playFX(6);
|
||||
}
|
||||
|
||||
_game->endOfTurn();
|
||||
}
|
||||
|
||||
void Prayer::dungeonCast(Maps::MapDungeon *map) {
|
||||
addInfoMsg("");
|
||||
addInfoMsg(_game->_res->SPELL_PHRASES[0]);
|
||||
|
||||
// When cast within the dungeon, cast a random spell without cost
|
||||
SpellId spellId = (SpellId)_game->getRandomNumber(SPELL_OPEN, SPELL_KILL);
|
||||
if (spellId == SPELL_STEAL)
|
||||
spellId = SPELL_LADDER_DOWN;
|
||||
|
||||
const Shared::Character &c = *_game->_party;
|
||||
static_cast<Spell *>(c._spells[spellId])->dungeonCast(map);
|
||||
}
|
||||
|
||||
} // End of namespace Spells
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
56
engines/ultima/ultima1/spells/prayer.h
Normal file
56
engines/ultima/ultima1/spells/prayer.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_PRAYER_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_PRAYER_H
|
||||
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
/**
|
||||
* Prayer spell
|
||||
*/
|
||||
class Prayer : public Spell {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Prayer(Ultima1Game *game, Character *c);
|
||||
|
||||
/**
|
||||
* Cast the spell outside a dungeon
|
||||
*/
|
||||
void cast(Maps::MapBase *map) override;
|
||||
|
||||
/**
|
||||
* Cast the spell within dungeons
|
||||
*/
|
||||
void dungeonCast(Maps::MapDungeon *map) override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
62
engines/ultima/ultima1/spells/spell.cpp
Normal file
62
engines/ultima/ultima1/spells/spell.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
Spell::Spell(Ultima1Game *game, Character *c, SpellId spellId) : _game(game),
|
||||
_character(c), _spellId(spellId) {
|
||||
_name = _game->_res->SPELL_NAMES[spellId];
|
||||
}
|
||||
|
||||
void Spell::addInfoMsg(const Common::String &text, bool newLine, bool replaceLine) {
|
||||
Shared::CInfoMsg msg(text, newLine, replaceLine);
|
||||
msg.execute("Game");
|
||||
}
|
||||
|
||||
void Spell::cast(Maps::MapBase *map) {
|
||||
// Most spells can't be used outside of dungeons
|
||||
addInfoMsg("");
|
||||
addInfoMsg(_game->_res->DUNGEON_SPELL_ONLY);
|
||||
_game->playFX(6);
|
||||
_game->endOfTurn();
|
||||
}
|
||||
|
||||
void Spell::dungeonCast(Maps::MapDungeon *map) {
|
||||
// This is the fallback the spells call if it fails
|
||||
addInfoMsg(_game->_res->FAILED);
|
||||
_game->playFX(6);
|
||||
_game->endOfTurn();
|
||||
}
|
||||
|
||||
uint Spell::getBuyCost() const {
|
||||
return (200 - _character->_wisdom) / 32 * _spellId;
|
||||
}
|
||||
|
||||
} // End of namespace Spells
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
91
engines/ultima/ultima1/spells/spell.h
Normal file
91
engines/ultima/ultima1/spells/spell.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_SPELL_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_SPELL_H
|
||||
|
||||
#include "ultima/shared/core/party.h"
|
||||
#include "ultima/ultima1/maps/map_base.h"
|
||||
#include "ultima/ultima1/maps/map_dungeon.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
class Ultima1Game;
|
||||
class Character;
|
||||
|
||||
namespace Spells {
|
||||
|
||||
enum SpellId {
|
||||
SPELL_PRAYER = 0, SPELL_OPEN = 1, SPELL_UNLOCK = 2, SPELL_MAGIC_MISSILE = 3, SPELL_STEAL = 4,
|
||||
SPELL_LADDER_DOWN = 5, SPELL_LADDER_UP = 6, SPELL_BLINK = 7, SPELL_CREATE = 8,
|
||||
SPELL_DESTROY = 9, SPELL_KILL = 10
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for Ultima 1 spells
|
||||
*/
|
||||
class Spell : public Shared::Spell {
|
||||
protected:
|
||||
Ultima1Game *_game;
|
||||
Character *_character;
|
||||
SpellId _spellId;
|
||||
protected:
|
||||
/**
|
||||
* Adds a text string to the info area
|
||||
* @param text Text to add
|
||||
* @param newLine Whether to apply a newline at the end
|
||||
*/
|
||||
void addInfoMsg(const Common::String &text, bool newLine = true, bool replaceLine = false);
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Spell(Ultima1Game *game, Character *c, SpellId spellId);
|
||||
public:
|
||||
/**
|
||||
* Change the quantity by a given amount
|
||||
*/
|
||||
void changeQuantity(int delta) override {
|
||||
_quantity = (uint)CLIP((int)_quantity + delta, 0, 255);
|
||||
}
|
||||
|
||||
/**
|
||||
* Cast the spell outside of dungeons
|
||||
*/
|
||||
virtual void cast(Maps::MapBase *map);
|
||||
|
||||
/**
|
||||
* Cast the spell in dungeons
|
||||
*/
|
||||
virtual void dungeonCast(Maps::MapDungeon *map);
|
||||
|
||||
/**
|
||||
* Gets how much the weapon can be bought for
|
||||
*/
|
||||
uint getBuyCost() const;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
39
engines/ultima/ultima1/spells/steal.cpp
Normal file
39
engines/ultima/ultima1/spells/steal.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/spells/steal.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
Steal::Steal(Ultima1Game *game, Character *c) : Spell(game, c, SPELL_STEAL) {
|
||||
}
|
||||
|
||||
void Steal::dungeonCast(Maps::MapDungeon *map) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
} // End of namespace Spells
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
51
engines/ultima/ultima1/spells/steal.h
Normal file
51
engines/ultima/ultima1/spells/steal.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_STEAL_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_STEAL_H
|
||||
|
||||
#include "ultima/ultima1/spells/spell.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Spells {
|
||||
|
||||
/**
|
||||
* Steal spell
|
||||
*/
|
||||
class Steal : public Spell {
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Steal(Ultima1Game *game, Character *c);
|
||||
|
||||
/**
|
||||
* Cast the spell within dungeons
|
||||
*/
|
||||
void dungeonCast(Maps::MapDungeon *map) override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
186
engines/ultima/ultima1/u1dialogs/armoury.cpp
Normal file
186
engines/ultima/ultima1/u1dialogs/armoury.cpp
Normal file
@@ -0,0 +1,186 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/armoury.h"
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
#include "ultima/shared/core/str.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
EMPTY_MESSAGE_MAP(Armoury, BuySellDialog);
|
||||
|
||||
Armoury::Armoury(Ultima1Game *game, int armouryNum) : BuySellDialog(game, game->_res->ARMOURY_NAMES[armouryNum]) {
|
||||
Maps::Ultima1Map *map = static_cast<Maps::Ultima1Map *>(game->_map);
|
||||
|
||||
_startIndex = 1;
|
||||
_endIndex = (map->_moveCounter > 3000) ? 5 : 3;
|
||||
}
|
||||
|
||||
void Armoury::setMode(BuySell mode) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
|
||||
switch (mode) {
|
||||
case BUY: {
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->BUY), false, true);
|
||||
|
||||
_mode = BUY;
|
||||
setDirty();
|
||||
getKeypress();
|
||||
break;
|
||||
}
|
||||
|
||||
case SELL:
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->SELL), false, true);
|
||||
|
||||
if (c._armour.hasNothing()) {
|
||||
addInfoMsg(_game->_res->NOTHING);
|
||||
closeShortly();
|
||||
} else {
|
||||
getKeypress();
|
||||
}
|
||||
|
||||
_mode = SELL;
|
||||
setDirty();
|
||||
break;
|
||||
|
||||
default:
|
||||
BuySellDialog::setMode(mode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Armoury::draw() {
|
||||
BuySellDialog::draw();
|
||||
|
||||
switch (_mode) {
|
||||
case BUY:
|
||||
drawBuy();
|
||||
break;
|
||||
|
||||
case SELL:
|
||||
drawSell();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Armoury::drawBuy() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int titleLines = String(_title).split("\r\n").size();
|
||||
Common::String line;
|
||||
|
||||
for (uint idx = _startIndex, yp = titleLines + 2; idx <= _endIndex; ++idx, ++yp) {
|
||||
const Armour &armour = *static_cast<Armour *>(c._armour[idx]);
|
||||
|
||||
line = Common::String::format("%c) %s", 'a' + idx, armour._name.c_str());
|
||||
s.writeString(line, TextPoint(5, yp));
|
||||
line = Common::String::format("-%4u", armour.getBuyCost());
|
||||
s.writeString(line, TextPoint(22, yp));
|
||||
}
|
||||
}
|
||||
|
||||
void Armoury::drawSell() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int lineCount = c._armour.itemsCount();
|
||||
int titleLines = String(_title).split("\r\n").size();
|
||||
Common::String line;
|
||||
|
||||
if (lineCount == 0) {
|
||||
centerText(_game->_res->NO_ARMOUR_TO_SELL, titleLines + 2);
|
||||
} else {
|
||||
for (uint idx = 1; idx < c._armour.size(); ++idx) {
|
||||
const Armour &armour = *static_cast<Armour *>(c._armour[idx]);
|
||||
if (!armour.empty()) {
|
||||
line = Common::String::format("%c) %s", 'a' + idx, armour._name.c_str());
|
||||
s.writeString(line, TextPoint(5, idx + titleLines + 1));
|
||||
line = Common::String::format("-%4u", armour.getSellCost());
|
||||
s.writeString(line, TextPoint(22, idx + titleLines + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Armoury::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
|
||||
if (_mode == BUY) {
|
||||
if (msg->_keyState.keycode >= (int)(Common::KEYCODE_a + _startIndex) &&
|
||||
msg->_keyState.keycode <= (int)(Common::KEYCODE_a + _endIndex)) {
|
||||
uint armourNum = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
Armour &armour = *static_cast<Armour *>(c._armour[armourNum]);
|
||||
|
||||
if (armour.getBuyCost() <= c._coins) {
|
||||
// Display the sold armour in the info area
|
||||
addInfoMsg(armour._name);
|
||||
|
||||
// Remove coins for armour and add it to the inventory
|
||||
c._coins -= armour.getBuyCost();
|
||||
armour.incrQuantity();
|
||||
|
||||
// Show sold and close the dialog
|
||||
setMode(SOLD);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
nothing();
|
||||
return true;
|
||||
} else if (_mode == SELL && !c._armour.hasNothing()) {
|
||||
if (msg->_keyState.keycode >= Common::KEYCODE_b &&
|
||||
msg->_keyState.keycode < (Common::KEYCODE_a + (int)c._armour.size())) {
|
||||
uint armourNum = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
Armour &armour = *static_cast<Armour *>(c._armour[armourNum]);
|
||||
|
||||
if (!armour.empty()) {
|
||||
// Display the sold armour in the info area
|
||||
addInfoMsg(armour._name);
|
||||
|
||||
// Give coins for armour and remove it from the inventory
|
||||
c._coins += armour.getSellCost();
|
||||
if (armour.decrQuantity() && (int)armourNum == c._equippedArmour)
|
||||
c.removeArmour();
|
||||
|
||||
// Close the dialog
|
||||
setMode(DONE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
nothing();
|
||||
return true;
|
||||
} else {
|
||||
return BuySellDialog::CharacterInputMsg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
73
engines/ultima/ultima1/u1dialogs/armoury.h
Normal file
73
engines/ultima/ultima1/u1dialogs/armoury.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_ARMOURY_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_ARMOURY_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/buy_sell_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
/**
|
||||
* Implements the buy/sell dialog for the armory
|
||||
*/
|
||||
class Armoury : public BuySellDialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg) override;
|
||||
private:
|
||||
// uint _armouryNum;
|
||||
uint _startIndex, _endIndex;
|
||||
private:
|
||||
/**
|
||||
* Draws the Buy dialog content
|
||||
*/
|
||||
void drawBuy();
|
||||
|
||||
/**
|
||||
* Draws the Sell dialog content
|
||||
*/
|
||||
void drawSell();
|
||||
protected:
|
||||
/**
|
||||
* Set the mode
|
||||
*/
|
||||
void setMode(BuySell mode) override;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Armoury(Ultima1Game *game, int armouryNum);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
149
engines/ultima/ultima1/u1dialogs/buy_sell_dialog.cpp
Normal file
149
engines/ultima/ultima1/u1dialogs/buy_sell_dialog.cpp
Normal file
@@ -0,0 +1,149 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/buy_sell_dialog.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/shared/core/str.h"
|
||||
#include "ultima/shared/gfx/visual_surface.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
BEGIN_MESSAGE_MAP(BuySellDialog, Dialog)
|
||||
ON_MESSAGE(ShowMsg)
|
||||
ON_MESSAGE(FrameMsg)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
BuySellDialog::BuySellDialog(Ultima1Game *game, const Common::String &title) :
|
||||
Dialog(game), _mode(SELECT), _title(title), _charInput(game), _closeCounter(0) {
|
||||
_bounds = Rect(31, 23, 287, 127);
|
||||
}
|
||||
|
||||
bool BuySellDialog::ShowMsg(CShowMsg *msg) {
|
||||
addInfoMsg(_game->_res->BUY_SELL, false);
|
||||
getKeypress();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuySellDialog::FrameMsg(CFrameMsg *msg) {
|
||||
if (_closeCounter > 0 && --_closeCounter == 0) {
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BuySellDialog::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
switch (_mode) {
|
||||
case SELECT:
|
||||
if (msg->_keyState.keycode == Common::KEYCODE_b)
|
||||
setMode(BUY);
|
||||
else if (msg->_keyState.keycode == Common::KEYCODE_s)
|
||||
setMode(SELL);
|
||||
else
|
||||
nothing();
|
||||
break;
|
||||
|
||||
case CANT_AFFORD:
|
||||
addInfoMsg("", true, true);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BuySellDialog::draw() {
|
||||
Dialog::draw();
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
|
||||
if (_mode != SELECT) {
|
||||
// Draw the background and frame
|
||||
s.clear();
|
||||
s.frameRect(Rect(3, 3, _bounds.width() - 3, _bounds.height() - 3), getGame()->_borderColor);
|
||||
|
||||
// Draw the title
|
||||
centerText(String(_title).split('\n'), 1);
|
||||
}
|
||||
|
||||
switch (_mode) {
|
||||
case SOLD:
|
||||
centerText(getGame()->_res->SOLD, 5);
|
||||
break;
|
||||
|
||||
case CANT_AFFORD:
|
||||
centerText(getGame()->_res->CANT_AFFORD, 5);
|
||||
break;
|
||||
|
||||
case DONE:
|
||||
centerText(getGame()->_res->DONE, 5);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void BuySellDialog::setMode(BuySell mode) {
|
||||
_mode = mode;
|
||||
setDirty();
|
||||
|
||||
switch (_mode) {
|
||||
case BUY:
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->BUY), false, true);
|
||||
getKeypress();
|
||||
break;
|
||||
|
||||
case SELL:
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->SELL), false, true);
|
||||
getKeypress();
|
||||
break;
|
||||
|
||||
case CANT_AFFORD:
|
||||
addInfoMsg(_game->_res->NOTHING);
|
||||
_game->playFX(1);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (_mode == SOLD || _mode == CANT_AFFORD || _mode == DONE)
|
||||
// Start dialog close countdown
|
||||
closeShortly();
|
||||
}
|
||||
|
||||
void BuySellDialog::nothing() {
|
||||
addInfoMsg(_game->_res->NOTHING);
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Gfx
|
||||
} // End of namespace Ultima
|
||||
97
engines/ultima/ultima1/u1dialogs/buy_sell_dialog.h
Normal file
97
engines/ultima/ultima1/u1dialogs/buy_sell_dialog.h
Normal file
@@ -0,0 +1,97 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_BUY_SELL_DIALOG_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_BUY_SELL_DIALOG_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/dialog.h"
|
||||
#include "ultima/shared/gfx/character_input.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
#define DIALOG_CLOSE_DELAY 50
|
||||
|
||||
enum BuySell { SELECT, BUY, SELL, SOLD, CANT_AFFORD, DONE };
|
||||
|
||||
using Shared::CShowMsg;
|
||||
using Shared::CFrameMsg;
|
||||
using Shared::CCharacterInputMsg;
|
||||
|
||||
/**
|
||||
* Secondary base class for dialogs that have display for buying and selling
|
||||
*/
|
||||
class BuySellDialog : public Dialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool ShowMsg(CShowMsg *msg);
|
||||
bool FrameMsg(CFrameMsg *msg);
|
||||
virtual bool CharacterInputMsg(CCharacterInputMsg *msg);
|
||||
private:
|
||||
Shared::Gfx::CharacterInput _charInput;
|
||||
protected:
|
||||
BuySell _mode;
|
||||
Common::String _title;
|
||||
uint _closeCounter;
|
||||
protected:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
BuySellDialog(Ultima1Game *game, const Common::String &title);
|
||||
|
||||
/**
|
||||
* Nothing selected
|
||||
*/
|
||||
void nothing();
|
||||
|
||||
/**
|
||||
* Set the mode
|
||||
*/
|
||||
virtual void setMode(BuySell mode);
|
||||
|
||||
/**
|
||||
* Switches the dialog to displaying sold
|
||||
*/
|
||||
void showSold() { setMode(SOLD); }
|
||||
|
||||
/**
|
||||
* Switches the dialog to displaying a can't afford message
|
||||
*/
|
||||
void cantAfford() { setMode(CANT_AFFORD); }
|
||||
|
||||
/**
|
||||
* Sets the dialog to close after a brief pause
|
||||
*/
|
||||
void closeShortly() { _closeCounter = 3 * DIALOG_CLOSE_DELAY; }
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
87
engines/ultima/ultima1/u1dialogs/combat.cpp
Normal file
87
engines/ultima/ultima1/u1dialogs/combat.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/combat.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/shared/gfx/text_cursor.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Combat, Dialog)
|
||||
ON_MESSAGE(KeypressMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
Combat::Combat(Ultima1Game *game, Shared::Maps::Direction direction, int weaponType,
|
||||
const Common::String &weaponName) : FullScreenDialog(game), _direction(direction) {
|
||||
}
|
||||
|
||||
bool Combat::KeypressMsg(CKeypressMsg *msg) {
|
||||
if (_direction == Shared::Maps::DIR_NONE) {
|
||||
switch (msg->_keyState.keycode) {
|
||||
case Common::KEYCODE_LEFT:
|
||||
case Common::KEYCODE_KP4:
|
||||
_direction = Shared::Maps::DIR_LEFT;
|
||||
break;
|
||||
case Common::KEYCODE_RIGHT:
|
||||
case Common::KEYCODE_KP6:
|
||||
_direction = Shared::Maps::DIR_RIGHT;
|
||||
break;
|
||||
case Common::KEYCODE_UP:
|
||||
case Common::KEYCODE_KP8:
|
||||
_direction = Shared::Maps::DIR_UP;
|
||||
break;
|
||||
case Common::KEYCODE_DOWN:
|
||||
case Common::KEYCODE_KP2:
|
||||
_direction = Shared::Maps::DIR_DOWN;
|
||||
break;
|
||||
default:
|
||||
nothing();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
setDirty(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void Combat::draw() {
|
||||
if (_direction == Shared::Maps::DIR_NONE)
|
||||
drawSelection();
|
||||
}
|
||||
|
||||
void Combat::drawSelection() {
|
||||
|
||||
}
|
||||
|
||||
void Combat::nothing() {
|
||||
addInfoMsg(Common::String::format(" %s", _game->_res->NOTHING));
|
||||
hide();
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
71
engines/ultima/ultima1/u1dialogs/combat.h
Normal file
71
engines/ultima/ultima1/u1dialogs/combat.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_COMBAT_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_COMBAT_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/full_screen_dialog.h"
|
||||
#include "ultima/shared/maps/map_widget.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
using Shared::CKeypressMsg;
|
||||
|
||||
/**
|
||||
* Implements player combat attacks
|
||||
*/
|
||||
class Combat : public FullScreenDialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool KeypressMsg(CKeypressMsg *msg);
|
||||
private:
|
||||
Common::String _weaponName;
|
||||
int _direction;
|
||||
private:
|
||||
/**
|
||||
* Nothing selected
|
||||
*/
|
||||
void nothing();
|
||||
|
||||
/**
|
||||
* Draw the selection prompt
|
||||
*/
|
||||
void drawSelection();
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Combat(Ultima1Game *game, Shared::Maps::Direction direction, int weaponType, const Common::String &weaponName);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
86
engines/ultima/ultima1/u1dialogs/dialog.cpp
Normal file
86
engines/ultima/ultima1/u1dialogs/dialog.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/dialog.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/u1gfx/info.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
Dialog::Dialog(Ultima1Game *game) : Popup(game), _game(game) {
|
||||
}
|
||||
|
||||
Maps::Ultima1Map *Dialog::getMap() {
|
||||
return static_cast<Maps::Ultima1Map *>(_game->getMap());
|
||||
}
|
||||
|
||||
void Dialog::addInfoMsg(const Common::String &text, bool newLine, bool replaceLine) {
|
||||
Shared::TreeItem *infoArea = _game->findByName("Info");
|
||||
|
||||
Shared::CInfoMsg msg(text, newLine, replaceLine);
|
||||
msg.execute(infoArea);
|
||||
}
|
||||
|
||||
void Dialog::getKeypress() {
|
||||
Shared::TreeItem *infoArea = _game->findByName("Info");
|
||||
|
||||
Shared::CInfoGetKeypress msg(this);
|
||||
msg.execute(infoArea);
|
||||
}
|
||||
|
||||
void Dialog::getInput(bool isNumeric, size_t maxCharacters) {
|
||||
TreeItem *infoArea = _game->findByName("Info");
|
||||
|
||||
Shared::CInfoGetInput msg(this, isNumeric, maxCharacters);
|
||||
msg.execute(infoArea);
|
||||
}
|
||||
|
||||
void Dialog::draw() {
|
||||
// Redraw the game's info area
|
||||
U1Gfx::Info *infoArea = dynamic_cast<U1Gfx::Info *>(_game->findByName("Info"));
|
||||
assert(infoArea);
|
||||
infoArea->draw();
|
||||
}
|
||||
|
||||
void Dialog::centerText(const Common::String &line, int yp) {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
s.writeString(line, TextPoint((_bounds.width() / 8 - line.size() + 1) / 2, yp));
|
||||
}
|
||||
|
||||
void Dialog::centerText(const Shared::StringArray &lines, int yp) {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
for (uint idx = 0; idx < lines.size(); ++idx)
|
||||
s.writeString(lines[idx], TextPoint((_bounds.width() / 8 - lines[idx].size() + 1) / 2, yp + idx));
|
||||
}
|
||||
|
||||
void Dialog::hide() {
|
||||
Popup::hide();
|
||||
|
||||
// Delete the dialog when hidden
|
||||
delete this;
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Gfx
|
||||
} // End of namespace Ultima
|
||||
105
engines/ultima/ultima1/u1dialogs/dialog.h
Normal file
105
engines/ultima/ultima1/u1dialogs/dialog.h
Normal file
@@ -0,0 +1,105 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_DIALOG_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_DIALOG_H
|
||||
|
||||
#include "ultima/shared/gfx/popup.h"
|
||||
#include "ultima/shared/gfx/character_input.h"
|
||||
#include "ultima/shared/core/str.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
class Ultima1Game;
|
||||
namespace Maps {
|
||||
class Ultima1Map;
|
||||
}
|
||||
|
||||
namespace U1Dialogs {
|
||||
|
||||
/**
|
||||
* Base class for Ultima 1 popup dialogs
|
||||
*/
|
||||
class Dialog : public Shared::Gfx::Popup {
|
||||
protected:
|
||||
Ultima1Game *_game;
|
||||
Common::String _prompt;
|
||||
protected:
|
||||
/**
|
||||
* Jumps up through the parents to find the root game
|
||||
*/
|
||||
Ultima1Game *getGame() { return _game; }
|
||||
|
||||
/**
|
||||
* Return the game's map
|
||||
*/
|
||||
Maps::Ultima1Map *getMap();
|
||||
|
||||
/**
|
||||
* Adds a text string to the info area
|
||||
* @param text Text to add
|
||||
* @param newLine Whether to apply a newline at the end
|
||||
* @param replaceLine If true, replaces the current last line
|
||||
*/
|
||||
void addInfoMsg(const Common::String &text, bool newLine = true, bool replaceLine = false);
|
||||
|
||||
/**
|
||||
* Prompts for a keypress
|
||||
*/
|
||||
void getKeypress();
|
||||
|
||||
/**
|
||||
* Prompts for an input
|
||||
*/
|
||||
void getInput(bool isNumeric = true, size_t maxCharacters = 4);
|
||||
|
||||
/**
|
||||
* Write a text line to the dialog
|
||||
*/
|
||||
void centerText(const Common::String &line, int yp);
|
||||
|
||||
/**
|
||||
* Write a text line to the dialog
|
||||
*/
|
||||
void centerText(const Shared::StringArray &lines, int yp);
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Dialog(Ultima1Game *game);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
|
||||
/**
|
||||
* Hide the dialog
|
||||
*/
|
||||
void hide() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
245
engines/ultima/ultima1/u1dialogs/drop.cpp
Normal file
245
engines/ultima/ultima1/u1dialogs/drop.cpp
Normal file
@@ -0,0 +1,245 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/drop.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Drop, Dialog)
|
||||
ON_MESSAGE(ShowMsg)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
ON_MESSAGE(TextInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
Drop::Drop(Ultima1Game *game) : FullScreenDialog(game), _mode(SELECT) {
|
||||
}
|
||||
|
||||
bool Drop::ShowMsg(CShowMsg *msg) {
|
||||
addInfoMsg(_game->_res->DROP_PENCE_WEAPON_armour, false);
|
||||
getKeypress();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Drop::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
|
||||
switch (_mode) {
|
||||
case SELECT:
|
||||
switch (msg->_keyState.keycode) {
|
||||
case Common::KEYCODE_p:
|
||||
setMode(DROP_PENCE);
|
||||
break;
|
||||
case Common::KEYCODE_w:
|
||||
setMode(DROP_WEAPON);
|
||||
break;
|
||||
case Common::KEYCODE_a:
|
||||
setMode(DROP_armour);
|
||||
break;
|
||||
default:
|
||||
nothing();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case DROP_WEAPON:
|
||||
if (msg->_keyState.keycode >= Common::KEYCODE_b && msg->_keyState.keycode < (Common::KEYCODE_b + (int)c._weapons.size())
|
||||
&& !c._weapons[msg->_keyState.keycode - Common::KEYCODE_a]->empty()) {
|
||||
// Drop the weapon
|
||||
int weaponNum = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
if (c._weapons[weaponNum]->decrQuantity() && c._equippedWeapon == weaponNum)
|
||||
c.removeWeapon();
|
||||
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->DROP_WEAPON,
|
||||
_game->_res->WEAPON_NAMES_UPPERCASE[weaponNum]), true, true);
|
||||
hide();
|
||||
} else {
|
||||
none();
|
||||
}
|
||||
break;
|
||||
|
||||
case DROP_armour:
|
||||
if (msg->_keyState.keycode >= Common::KEYCODE_b && msg->_keyState.keycode < (Common::KEYCODE_b + (int)c._armour.size())
|
||||
&& c._armour[msg->_keyState.keycode - Common::KEYCODE_a]->_quantity > 0) {
|
||||
// Drop the armor
|
||||
int armorNum = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
if (c._armour[armorNum]->decrQuantity() && c._equippedArmour == armorNum)
|
||||
c.removeArmour();
|
||||
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->DROP_armour,
|
||||
_game->_res->ARMOR_NAMES[armorNum]), true, true);
|
||||
hide();
|
||||
} else {
|
||||
none();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Drop::TextInputMsg(CTextInputMsg *msg) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
assert(_mode == DROP_PENCE);
|
||||
Ultima1Game *game = _game;
|
||||
Maps::Ultima1Map *map = getMap();
|
||||
|
||||
uint amount = atoi(msg->_text.c_str());
|
||||
|
||||
if (msg->_escaped || !amount) {
|
||||
none();
|
||||
|
||||
} else {
|
||||
addInfoMsg(Common::String::format(" %u", amount));
|
||||
|
||||
if (amount > c._coins) {
|
||||
addInfoMsg(game->_res->NOT_THAT_MUCH);
|
||||
game->playFX(1);
|
||||
} else {
|
||||
c._coins -= amount;
|
||||
hide();
|
||||
|
||||
map->dropCoins(amount);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Drop::setMode(Mode mode) {
|
||||
setDirty();
|
||||
_mode = mode;
|
||||
|
||||
const Shared::Character &c = *_game->_party;
|
||||
switch (mode) {
|
||||
case DROP_PENCE:
|
||||
addInfoMsg(_game->_res->DROP_PENCE, false, true);
|
||||
getInput();
|
||||
break;
|
||||
|
||||
case DROP_WEAPON:
|
||||
if (c._weapons.hasNothing()) {
|
||||
nothing();
|
||||
} else {
|
||||
addInfoMsg(_game->_res->DROP_WEAPON, false, true);
|
||||
getKeypress();
|
||||
}
|
||||
break;
|
||||
|
||||
case DROP_armour:
|
||||
if (c._armour.hasNothing()) {
|
||||
nothing();
|
||||
} else {
|
||||
addInfoMsg(_game->_res->DROP_armour, false, true);
|
||||
getKeypress();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Drop::nothing() {
|
||||
addInfoMsg(Common::String::format("%s %s", _game->_res->ACTION_NAMES[3],
|
||||
_game->_res->NOTHING), true, true);
|
||||
hide();
|
||||
}
|
||||
|
||||
void Drop::none() {
|
||||
const char *DROPS[4] = { nullptr, _game->_res->DROP_PENCE, _game->_res->DROP_WEAPON, _game->_res->DROP_armour };
|
||||
|
||||
addInfoMsg(Common::String::format("%s%s", DROPS[_mode], _game->_res->NONE), true, true);
|
||||
hide();
|
||||
}
|
||||
|
||||
void Drop::draw() {
|
||||
Dialog::draw();
|
||||
|
||||
switch (_mode) {
|
||||
case DROP_WEAPON:
|
||||
drawDropWeapon();
|
||||
break;
|
||||
case DROP_armour:
|
||||
drawDropArmor();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Drop::drawDropWeapon() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
drawFrame(_game->_res->ACTION_NAMES[3]);
|
||||
|
||||
// Count the number of different types of weapons
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int numLines = 0;
|
||||
for (uint idx = 1; idx < c._weapons.size(); ++idx) {
|
||||
if (c._weapons[idx]->_quantity)
|
||||
++numLines;
|
||||
}
|
||||
|
||||
// Draw lines for weapons the player has
|
||||
int yp = 10 - (numLines / 2);
|
||||
for (uint idx = 1; idx < c._weapons.size(); ++idx) {
|
||||
if (c._weapons[idx]->_quantity) {
|
||||
Common::String text = Common::String::format("%c) %s", 'a' + idx,
|
||||
_game->_res->WEAPON_NAMES_UPPERCASE[idx]);
|
||||
s.writeString(text, TextPoint(15, yp++));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Drop::drawDropArmor() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
drawFrame(_game->_res->ACTION_NAMES[3]);
|
||||
|
||||
// Count the number of different types of armor
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int numLines = 0;
|
||||
for (uint idx = 1; idx < c._armour.size(); ++idx) {
|
||||
if (c._armour[idx]->_quantity)
|
||||
++numLines;
|
||||
}
|
||||
|
||||
// Draw lines for armor the player has
|
||||
int yp = 10 - (numLines / 2);
|
||||
for (uint idx = 1; idx < c._armour.size(); ++idx) {
|
||||
if (c._armour[idx]->_quantity) {
|
||||
Common::String text = Common::String::format("%c) %s", 'a' + idx,
|
||||
_game->_res->ARMOR_NAMES[idx]);
|
||||
s.writeString(text, TextPoint(13, yp++));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
91
engines/ultima/ultima1/u1dialogs/drop.h
Normal file
91
engines/ultima/ultima1/u1dialogs/drop.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_DROP_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_DROP_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/full_screen_dialog.h"
|
||||
#include "ultima/shared/gfx/text_input.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
using Shared::CShowMsg;
|
||||
using Shared::CCharacterInputMsg;
|
||||
using Shared::CTextInputMsg;
|
||||
|
||||
/**
|
||||
* Implements the drop dialog
|
||||
*/
|
||||
class Drop : public FullScreenDialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool ShowMsg(CShowMsg *msg);
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg);
|
||||
bool TextInputMsg(CTextInputMsg *msg);
|
||||
|
||||
enum Mode { SELECT, DROP_PENCE, DROP_WEAPON, DROP_armour };
|
||||
private:
|
||||
Mode _mode;
|
||||
private:
|
||||
/**
|
||||
* Sets the mode
|
||||
*/
|
||||
void setMode(Mode mode);
|
||||
|
||||
/**
|
||||
* Nothing selected
|
||||
*/
|
||||
void nothing();
|
||||
|
||||
/**
|
||||
* None response
|
||||
*/
|
||||
void none();
|
||||
|
||||
/**
|
||||
* Draw the drop weapon display
|
||||
*/
|
||||
void drawDropWeapon();
|
||||
|
||||
/**
|
||||
* Draw the drop armor display
|
||||
*/
|
||||
void drawDropArmor();
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Drop(Ultima1Game *game);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
57
engines/ultima/ultima1/u1dialogs/full_screen_dialog.cpp
Normal file
57
engines/ultima/ultima1/u1dialogs/full_screen_dialog.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/full_screen_dialog.h"
|
||||
#include "ultima/ultima1/u1gfx/drawing_support.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
FullScreenDialog::FullScreenDialog(Ultima1Game *game) : Dialog(game) {
|
||||
_bounds = Common::Rect(0, 0, 320, 200);
|
||||
}
|
||||
|
||||
void FullScreenDialog::drawFrame(const Common::String &title) {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
U1Gfx::DrawingSupport ds(s);
|
||||
s.fillRect(TextRect(0, 0, 40, 20), _game->_bgColor);
|
||||
ds.drawGameFrame();
|
||||
|
||||
size_t titleLen = title.size() + 2;
|
||||
size_t xStart = 20 - titleLen / 2;
|
||||
ds.drawRightArrow(TextPoint(xStart - 1, 0));
|
||||
s.fillRect(TextRect(xStart, 0, xStart + titleLen, 0), 0);
|
||||
s.writeString(title, TextPoint(xStart + 1, 0));
|
||||
ds.drawLeftArrow(TextPoint(xStart + titleLen, 0));
|
||||
}
|
||||
|
||||
void FullScreenDialog::hide() {
|
||||
Ultima1Game *game = _game;
|
||||
Dialog::hide();
|
||||
|
||||
game->endOfTurn();
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Gfx
|
||||
} // End of namespace Ultima
|
||||
57
engines/ultima/ultima1/u1dialogs/full_screen_dialog.h
Normal file
57
engines/ultima/ultima1/u1dialogs/full_screen_dialog.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_FULL_SCREEN_DIALOG_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_FULL_SCREEN_DIALOG_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
/**
|
||||
* Base class for dialogs that cover the entire game area, with the exception of the
|
||||
* info & status areas at the bottom of the screen
|
||||
*/
|
||||
class FullScreenDialog : public Dialog {
|
||||
protected:
|
||||
/**
|
||||
* Draw the frame
|
||||
*/
|
||||
void drawFrame(const Common::String &title);
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
FullScreenDialog(Ultima1Game *game);
|
||||
|
||||
/**
|
||||
* Hide the popup
|
||||
*/
|
||||
void hide() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
111
engines/ultima/ultima1/u1dialogs/grocery.cpp
Normal file
111
engines/ultima/ultima1/u1dialogs/grocery.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/grocery.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/core/str.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Grocery, BuySellDialog)
|
||||
ON_MESSAGE(TextInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
Grocery::Grocery(Ultima1Game *game, int groceryNum) : BuySellDialog(game, game->_res->GROCERY_NAMES[groceryNum - 1]) {
|
||||
Shared::Character &c = *game->_party;
|
||||
_costPerPack = 5 - c._intelligence / 20;
|
||||
}
|
||||
|
||||
void Grocery::setMode(BuySell mode) {
|
||||
switch (mode) {
|
||||
case BUY:
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->BUY), false, true);
|
||||
_mode = BUY;
|
||||
setDirty();
|
||||
|
||||
getInput(true, 3);
|
||||
break;
|
||||
|
||||
case SELL:
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->SELL), false, true);
|
||||
|
||||
_mode = SELL;
|
||||
closeShortly();
|
||||
setDirty();
|
||||
break;
|
||||
|
||||
default:
|
||||
BuySellDialog::setMode(mode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Grocery::draw() {
|
||||
BuySellDialog::draw();
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
Ultima1Game *game = getGame();
|
||||
|
||||
switch (_mode) {
|
||||
case BUY:
|
||||
centerText(Common::String::format(game->_res->GROCERY_PACKS1, _costPerPack), 4);
|
||||
centerText(game->_res->GROCERY_PACKS2, 5);
|
||||
centerText(game->_res->GROCERY_PACKS3, 6);
|
||||
break;
|
||||
|
||||
case SELL:
|
||||
centerText(game->_res->GROCERY_SELL, String(_title).split('\n').size() + 2);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool Grocery::TextInputMsg(CTextInputMsg *msg) {
|
||||
assert(_mode == BUY);
|
||||
Shared::Character &c = *_game->_party;
|
||||
uint amount = atoi(msg->_text.c_str());
|
||||
uint cost = amount * _costPerPack;
|
||||
|
||||
if (msg->_escaped || !amount) {
|
||||
nothing();
|
||||
} else if (cost > c._coins) {
|
||||
cantAfford();
|
||||
} else {
|
||||
addInfoMsg(msg->_text);
|
||||
|
||||
c._coins -= cost;
|
||||
c._food += amount * 10;
|
||||
addInfoMsg(Common::String::format(_game->_res->GROCERY_PACKS_FOOD, amount));
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
65
engines/ultima/ultima1/u1dialogs/grocery.h
Normal file
65
engines/ultima/ultima1/u1dialogs/grocery.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_GROCERY_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_GROCERY_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/buy_sell_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
using Shared::CFrameMsg;
|
||||
using Shared::CTextInputMsg;
|
||||
|
||||
/**
|
||||
* Implements the buy/sell dialog for grocers
|
||||
*/
|
||||
class Grocery : public BuySellDialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool TextInputMsg(CTextInputMsg *msg);
|
||||
private:
|
||||
uint _costPerPack;
|
||||
protected:
|
||||
/**
|
||||
* Set the mode
|
||||
*/
|
||||
void setMode(BuySell mode) override;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Grocery(Ultima1Game *game, int groceryNum);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
219
engines/ultima/ultima1/u1dialogs/king.cpp
Normal file
219
engines/ultima/ultima1/u1dialogs/king.cpp
Normal file
@@ -0,0 +1,219 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/king.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/shared/gfx/visual_surface.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
BEGIN_MESSAGE_MAP(King, Dialog)
|
||||
ON_MESSAGE(ShowMsg)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
ON_MESSAGE(TextInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
King::King(Ultima1Game *game, uint kingIndex) : Dialog(game), _kingIndex(kingIndex), _mode(SELECT) {
|
||||
_bounds = Rect(31, 23, 287, 127);
|
||||
}
|
||||
|
||||
bool King::ShowMsg(CShowMsg *msg) {
|
||||
addInfoMsg(_game->_res->KING_TEXT[0], false);
|
||||
getKeypress();
|
||||
return true;
|
||||
}
|
||||
|
||||
void King::draw() {
|
||||
Dialog::draw();
|
||||
|
||||
if (_mode != SERVICE)
|
||||
return;
|
||||
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
|
||||
// Draw the background and frame
|
||||
s.clear();
|
||||
s.frameRect(Rect(3, 3, _bounds.width() - 3, _bounds.height() - 3), getGame()->_borderColor);
|
||||
|
||||
if (_kingIndex % 1) {
|
||||
// Kill a monster
|
||||
centerText(_game->_res->KING_TEXT[8], 2);
|
||||
|
||||
Common::String name;
|
||||
switch ((_kingIndex - 1) / 2) {
|
||||
case 0:
|
||||
// Gelatinous Cube
|
||||
name = _game->_res->DUNGEON_MONSTER_NAMES[9];
|
||||
break;
|
||||
case 1:
|
||||
// Carrion Creeper
|
||||
name = _game->_res->DUNGEON_MONSTER_NAMES[14];
|
||||
break;
|
||||
case 2:
|
||||
// Lich
|
||||
name = _game->_res->DUNGEON_MONSTER_NAMES[18];
|
||||
break;
|
||||
case 3:
|
||||
// Balron
|
||||
name = _game->_res->DUNGEON_MONSTER_NAMES[23];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
centerText(name, 4);
|
||||
} else {
|
||||
// Find a location
|
||||
centerText(_game->_res->KING_TEXT[9], 2);
|
||||
|
||||
switch (_kingIndex / 2) {
|
||||
case 0:
|
||||
centerText(_game->_res->LOCATION_NAMES[47], 4);
|
||||
break;
|
||||
case 1:
|
||||
centerText(_game->_res->LOCATION_NAMES[45], 4);
|
||||
break;
|
||||
case 2:
|
||||
centerText(_game->_res->LOCATION_NAMES[43], 4);
|
||||
break;
|
||||
case 3:
|
||||
centerText(_game->_res->LOCATION_NAMES[41], 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
centerText(_game->_res->KING_TEXT[10], 6);
|
||||
centerText(_game->_res->KING_TEXT[11], 7);
|
||||
}
|
||||
|
||||
void King::setMode(KingMode mode) {
|
||||
_mode = mode;
|
||||
|
||||
switch (_mode) {
|
||||
case PENCE:
|
||||
addInfoMsg(_game->_res->KING_TEXT[2]); // Pence
|
||||
addInfoMsg(_game->_res->KING_TEXT[4], false); // How much?
|
||||
getInput();
|
||||
break;
|
||||
|
||||
case SERVICE:
|
||||
addInfoMsg(_game->_res->KING_TEXT[3]);
|
||||
|
||||
if (_game->_quests[_kingIndex].isInProgress()) {
|
||||
alreadyOnQuest();
|
||||
return;
|
||||
} else {
|
||||
_game->_quests[_kingIndex].start();
|
||||
addInfoMsg(_game->_res->PRESS_SPACE_TO_CONTINUE, false);
|
||||
getKeypress();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
setDirty();
|
||||
}
|
||||
|
||||
bool King::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
switch (_mode) {
|
||||
case SELECT:
|
||||
if (msg->_keyState.keycode == Common::KEYCODE_p)
|
||||
setMode(PENCE);
|
||||
else if (msg->_keyState.keycode == Common::KEYCODE_s)
|
||||
setMode(SERVICE);
|
||||
else
|
||||
neither();
|
||||
break;
|
||||
|
||||
case SERVICE:
|
||||
addInfoMsg("");
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool King::TextInputMsg(CTextInputMsg *msg) {
|
||||
assert(_mode == PENCE);
|
||||
const Shared::Character &c = *_game->_party;
|
||||
uint amount = atoi(msg->_text.c_str());
|
||||
|
||||
if (msg->_escaped || !amount) {
|
||||
none();
|
||||
} else if (amount > c._coins) {
|
||||
notThatMuch();
|
||||
} else {
|
||||
addInfoMsg(Common::String::format("%u", amount));
|
||||
giveHitPoints(amount * 3 / 2);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void King::neither() {
|
||||
addInfoMsg(_game->_res->KING_TEXT[1]);
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
void King::none() {
|
||||
addInfoMsg(_game->_res->NONE);
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
void King::notThatMuch() {
|
||||
addInfoMsg(_game->_res->KING_TEXT[5]);
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
void King::alreadyOnQuest() {
|
||||
addInfoMsg(_game->_res->KING_TEXT[7]);
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
void King::giveHitPoints(uint amount) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
assert(amount <= c._coins);
|
||||
c._coins -= amount;
|
||||
c._hitPoints += amount;
|
||||
|
||||
addInfoMsg(Common::String::format(_game->_res->KING_TEXT[6], amount));
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Gfx
|
||||
} // End of namespace Ultima
|
||||
96
engines/ultima/ultima1/u1dialogs/king.h
Normal file
96
engines/ultima/ultima1/u1dialogs/king.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_KING_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_KING_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/dialog.h"
|
||||
#include "ultima/shared/gfx/character_input.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
using Shared::CShowMsg;
|
||||
using Shared::CCharacterInputMsg;
|
||||
using Shared::CTextInputMsg;
|
||||
|
||||
/**
|
||||
* Dialog for talking to kings
|
||||
*/
|
||||
class King : public Dialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool ShowMsg(CShowMsg *msg);
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg);
|
||||
bool TextInputMsg(CTextInputMsg *msg);
|
||||
enum KingMode { SELECT, PENCE, SERVICE };
|
||||
private:
|
||||
KingMode _mode;
|
||||
uint _kingIndex;
|
||||
private:
|
||||
/**
|
||||
* Set the mode
|
||||
*/
|
||||
void setMode(KingMode mode);
|
||||
|
||||
/**
|
||||
* Neither option (buy, service) selected
|
||||
*/
|
||||
void neither();
|
||||
|
||||
/**
|
||||
* No pence entered
|
||||
*/
|
||||
void none();
|
||||
|
||||
/**
|
||||
* Not that much
|
||||
*/
|
||||
void notThatMuch();
|
||||
|
||||
/**
|
||||
* Already on a quest
|
||||
*/
|
||||
void alreadyOnQuest();
|
||||
|
||||
/**
|
||||
* Give hit points
|
||||
*/
|
||||
void giveHitPoints(uint amount);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
King(Ultima1Game *game, uint kingIndex);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
135
engines/ultima/ultima1/u1dialogs/magic.cpp
Normal file
135
engines/ultima/ultima1/u1dialogs/magic.cpp
Normal file
@@ -0,0 +1,135 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/magic.h"
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
#include "ultima/shared/core/str.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
EMPTY_MESSAGE_MAP(Magic, BuySellDialog);
|
||||
|
||||
Magic::Magic(Ultima1Game *game, int magicNum) : BuySellDialog(game, game->_res->MAGIC_NAMES[magicNum]) {
|
||||
const Shared::Character &c = *game->_party;
|
||||
_startIndex = 1 + (magicNum & 1);
|
||||
_endIndex = (c._class == CLASS_WIZARD) ? c._spells.size() - 1 : 5;
|
||||
}
|
||||
|
||||
void Magic::setMode(BuySell mode) {
|
||||
switch (mode) {
|
||||
case BUY: {
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->BUY), false, true);
|
||||
|
||||
_mode = BUY;
|
||||
setDirty();
|
||||
getKeypress();
|
||||
break;
|
||||
}
|
||||
|
||||
case SELL:
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->SELL), false, true);
|
||||
|
||||
_mode = SELL;
|
||||
closeShortly();
|
||||
setDirty();
|
||||
break;
|
||||
|
||||
default:
|
||||
BuySellDialog::setMode(mode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Magic::draw() {
|
||||
BuySellDialog::draw();
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
Ultima1Game *game = getGame();
|
||||
|
||||
switch (_mode) {
|
||||
case BUY:
|
||||
drawBuy();
|
||||
break;
|
||||
|
||||
case SELL:
|
||||
centerText(game->_res->DONT_BUY_SPELLS, String(_title).split('\n').size() + 2);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Magic::drawBuy() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int titleLines = String(_title).split("\r\n").size();
|
||||
Common::String line;
|
||||
|
||||
for (uint idx = _startIndex, yp = titleLines + 2; idx <= _endIndex; idx += 2, ++yp) {
|
||||
const Spells::Spell &spell = *static_cast<Spells::Spell *>(c._spells[idx]);
|
||||
|
||||
line = Common::String::format("%c) %s", 'a' + idx, spell._name.c_str());
|
||||
s.writeString(line, TextPoint(5, yp));
|
||||
line = Common::String::format("-%4u", spell.getBuyCost());
|
||||
s.writeString(line, TextPoint(22, yp));
|
||||
}
|
||||
}
|
||||
|
||||
bool Magic::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
|
||||
if (_mode == BUY) {
|
||||
if (msg->_keyState.keycode >= (int)(Common::KEYCODE_a + _startIndex) &&
|
||||
msg->_keyState.keycode <= (int)(Common::KEYCODE_a + _endIndex) &&
|
||||
(int)(msg->_keyState.keycode - Common::KEYCODE_a - _startIndex) % 2 == 0) {
|
||||
uint magicNum = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
Spells::Spell &spell = *static_cast<Spells::Spell *>(c._spells[magicNum]);
|
||||
|
||||
if (spell.getBuyCost() <= c._coins) {
|
||||
// Display the sold spell in the info area
|
||||
addInfoMsg(spell._name);
|
||||
|
||||
// Remove coins for spell and add it to the inventory
|
||||
c._coins -= spell.getBuyCost();
|
||||
spell.incrQuantity();
|
||||
|
||||
// Show sold and close the dialog
|
||||
setMode(SOLD);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
nothing();
|
||||
return true;
|
||||
} else {
|
||||
return BuySellDialog::CharacterInputMsg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
70
engines/ultima/ultima1/u1dialogs/magic.h
Normal file
70
engines/ultima/ultima1/u1dialogs/magic.h
Normal file
@@ -0,0 +1,70 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_MAGIC_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_MAGIC_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/buy_sell_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
using Shared::CCharacterInputMsg;
|
||||
|
||||
/**
|
||||
* Implements the buy/sell dialog for magic
|
||||
*/
|
||||
class Magic : public BuySellDialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg) override;
|
||||
private:
|
||||
// uint _magicNum;
|
||||
uint _startIndex, _endIndex;
|
||||
private:
|
||||
/**
|
||||
* Draws the Buy dialog content
|
||||
*/
|
||||
void drawBuy();
|
||||
protected:
|
||||
/**
|
||||
* Set the mode
|
||||
*/
|
||||
void setMode(BuySell mode) override;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Magic(Ultima1Game *game, int magicNum);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
248
engines/ultima/ultima1/u1dialogs/ready.cpp
Normal file
248
engines/ultima/ultima1/u1dialogs/ready.cpp
Normal file
@@ -0,0 +1,248 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/ready.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/shared/gfx/text_cursor.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Ready, Dialog)
|
||||
ON_MESSAGE(ShowMsg)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
Ready::Ready(Ultima1Game *game) : FullScreenDialog(game), _mode(SELECT) {
|
||||
}
|
||||
|
||||
bool Ready::ShowMsg(CShowMsg *msg) {
|
||||
addInfoMsg(_game->_res->READY_WEAPON_armour_SPELL, false);
|
||||
getKeypress();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Ready::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
|
||||
switch (_mode) {
|
||||
case SELECT:
|
||||
switch (msg->_keyState.keycode) {
|
||||
case Common::KEYCODE_w:
|
||||
setMode(READY_WEAPON);
|
||||
break;
|
||||
case Common::KEYCODE_a:
|
||||
setMode(READY_armour);
|
||||
break;
|
||||
case Common::KEYCODE_s:
|
||||
setMode(READY_SPELL);
|
||||
break;
|
||||
default:
|
||||
addInfoMsg(Common::String::format("%s ", _game->_res->ACTION_NAMES[17]), false, true);
|
||||
nothing();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case READY_WEAPON:
|
||||
if (msg->_keyState.keycode >= Common::KEYCODE_a && msg->_keyState.keycode < (Common::KEYCODE_a + (int)c._weapons.size())) {
|
||||
int index = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
if (!c._weapons[index]->empty())
|
||||
c._equippedWeapon = index;
|
||||
}
|
||||
|
||||
addInfoMsg(Common::String::format("%s %s: %s", _game->_res->ACTION_NAMES[17],
|
||||
_game->_res->WEAPON_armour_SPELL[0], c.equippedWeapon()->_longName.c_str()),
|
||||
true, true);
|
||||
hide();
|
||||
break;
|
||||
|
||||
case READY_armour:
|
||||
if (msg->_keyState.keycode >= Common::KEYCODE_a && msg->_keyState.keycode < (Common::KEYCODE_a + (int)c._armour.size())) {
|
||||
int index = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
if (!c._armour[index]->empty())
|
||||
c._equippedArmour = index;
|
||||
}
|
||||
|
||||
addInfoMsg(Common::String::format("%s %s: %s", _game->_res->ACTION_NAMES[17],
|
||||
_game->_res->WEAPON_armour_SPELL[1], c.equippedArmour()->_name.c_str()),
|
||||
true, true);
|
||||
hide();
|
||||
break;
|
||||
|
||||
case READY_SPELL:
|
||||
if (msg->_keyState.keycode >= Common::KEYCODE_a && msg->_keyState.keycode < (Common::KEYCODE_a + (int)c._spells.size())) {
|
||||
int index = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
if (!c._spells[index]->empty())
|
||||
c._equippedSpell = index;
|
||||
}
|
||||
|
||||
addInfoMsg(Common::String::format("%s %s: %s", _game->_res->ACTION_NAMES[17],
|
||||
_game->_res->WEAPON_armour_SPELL[2], c._spells[c._equippedSpell]->_name.c_str()),
|
||||
true, true);
|
||||
hide();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Ready::setMode(Mode mode) {
|
||||
setDirty();
|
||||
_mode = mode;
|
||||
|
||||
const Shared::Character &c = *_game->_party;
|
||||
switch (mode) {
|
||||
case READY_WEAPON:
|
||||
if (c._weapons.hasNothing()) {
|
||||
nothing();
|
||||
} else {
|
||||
addInfoMsg(Common::String::format("%s %s: ", _game->_res->ACTION_NAMES[17],
|
||||
_game->_res->WEAPON_armour_SPELL[0]), false, true);
|
||||
getKeypress();
|
||||
}
|
||||
break;
|
||||
|
||||
case READY_armour:
|
||||
if (c._armour.hasNothing()) {
|
||||
nothing();
|
||||
} else {
|
||||
addInfoMsg(Common::String::format("%s %s: ", _game->_res->ACTION_NAMES[17],
|
||||
_game->_res->WEAPON_armour_SPELL[1]), false, true);
|
||||
getKeypress();
|
||||
}
|
||||
break;
|
||||
|
||||
case READY_SPELL:
|
||||
addInfoMsg(Common::String::format("%s %s: ", _game->_res->ACTION_NAMES[17],
|
||||
_game->_res->WEAPON_armour_SPELL[2]), false, true);
|
||||
getKeypress();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Ready::nothing() {
|
||||
addInfoMsg(_game->_res->NOTHING);
|
||||
hide();
|
||||
}
|
||||
|
||||
void Ready::none() {
|
||||
addInfoMsg(Common::String::format(" %s", _game->_res->NONE));
|
||||
hide();
|
||||
}
|
||||
|
||||
void Ready::draw() {
|
||||
Dialog::draw();
|
||||
|
||||
switch (_mode) {
|
||||
case READY_WEAPON:
|
||||
drawReadyWeapon();
|
||||
break;
|
||||
case READY_armour:
|
||||
drawReadyArmor();
|
||||
break;
|
||||
case READY_SPELL:
|
||||
drawReadySpell();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Ready::drawReadyWeapon() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
drawFrame(_game->_res->ACTION_NAMES[17]);
|
||||
|
||||
// Count the number of different types of weapons
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int numLines = 0;
|
||||
for (uint idx = 0; idx < c._weapons.size(); ++idx) {
|
||||
if (!c._weapons[idx]->empty())
|
||||
++numLines;
|
||||
}
|
||||
|
||||
// Draw lines for weapons the player has
|
||||
int yp = 10 - (numLines / 2);
|
||||
for (uint idx = 0; idx < c._weapons.size(); ++idx) {
|
||||
if (!c._weapons[idx]->empty()) {
|
||||
Common::String text = Common::String::format("%c) %s", 'a' + idx, c._weapons[idx]->_longName.c_str());
|
||||
s.writeString(text, TextPoint(15, yp++), (int)idx == c._equippedWeapon ? _game->_highlightColor : _game->_textColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ready::drawReadyArmor() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
drawFrame(_game->_res->ACTION_NAMES[17]);
|
||||
|
||||
// Count the number of different types of weapons
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int numLines = 0;
|
||||
for (uint idx = 0; idx < c._armour.size(); ++idx) {
|
||||
if (!c._armour[idx]->empty())
|
||||
++numLines;
|
||||
}
|
||||
|
||||
// Draw lines for armor the player has
|
||||
int yp = 10 - (numLines / 2);
|
||||
for (uint idx = 0; idx < c._armour.size(); ++idx) {
|
||||
if (!c._armour[idx]->empty()) {
|
||||
Common::String text = Common::String::format("%c) %s", 'a' + idx, c._armour[idx]->_name.c_str());
|
||||
s.writeString(text, TextPoint(15, yp++), (int)idx == c._equippedArmour ? _game->_highlightColor : _game->_textColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Ready::drawReadySpell() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
drawFrame(_game->_res->ACTION_NAMES[17]);
|
||||
|
||||
// Count the number of different types of spells
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int numLines = 0;
|
||||
for (uint idx = 0; idx < c._spells.size(); ++idx) {
|
||||
if (c._spells[idx]->_quantity)
|
||||
++numLines;
|
||||
}
|
||||
|
||||
// Draw lines for weapons the player has
|
||||
int yp = 10 - (numLines / 2);
|
||||
for (uint idx = 0; idx < c._spells.size(); ++idx) {
|
||||
if (c._spells[idx]->_quantity) {
|
||||
Common::String text = Common::String::format("%c) %s", 'a' + idx, c._spells[idx]->_name.c_str());
|
||||
s.writeString(text, TextPoint(15, yp++), (int)idx == c._equippedSpell ? _game->_highlightColor : _game->_textColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
93
engines/ultima/ultima1/u1dialogs/ready.h
Normal file
93
engines/ultima/ultima1/u1dialogs/ready.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_READY_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_READY_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/full_screen_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
using Shared::CShowMsg;
|
||||
using Shared::CCharacterInputMsg;
|
||||
|
||||
/**
|
||||
* Implements the Ready dialog
|
||||
*/
|
||||
class Ready : public FullScreenDialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool ShowMsg(CShowMsg *msg);
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg);
|
||||
|
||||
enum Mode { SELECT, READY_WEAPON, READY_armour, READY_SPELL };
|
||||
private:
|
||||
Mode _mode;
|
||||
private:
|
||||
/**
|
||||
* Sets the mode
|
||||
*/
|
||||
void setMode(Mode mode);
|
||||
|
||||
/**
|
||||
* Nothing selected
|
||||
*/
|
||||
void nothing();
|
||||
|
||||
/**
|
||||
* None response
|
||||
*/
|
||||
void none();
|
||||
|
||||
/**
|
||||
* Draw the ready weapon display
|
||||
*/
|
||||
void drawReadyWeapon();
|
||||
|
||||
/**
|
||||
* Draw the ready armor display
|
||||
*/
|
||||
void drawReadyArmor();
|
||||
|
||||
/**
|
||||
* Draw the ready spell display
|
||||
*/
|
||||
void drawReadySpell();
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Ready(Ultima1Game *game);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
175
engines/ultima/ultima1/u1dialogs/stats.cpp
Normal file
175
engines/ultima/ultima1/u1dialogs/stats.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/stats.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map_overworld.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/widgets/transport.h"
|
||||
#include "ultima/ultima1/u1gfx/drawing_support.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Stats, FullScreenDialog)
|
||||
ON_MESSAGE(ShowMsg)
|
||||
ON_MESSAGE(CharacterInputMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
|
||||
bool Stats::ShowMsg(CShowMsg *msg) {
|
||||
addInfoMsg(_game->_res->PRESS_SPACE_TO_CONTINUE, false);
|
||||
getKeypress();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Stats::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
if ((_startingIndex + 26U) < _stats.size()) {
|
||||
_startingIndex += 26U;
|
||||
setDirty();
|
||||
getKeypress();
|
||||
} else {
|
||||
addInfoMsg("", false, true);
|
||||
hide();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Counts the number of a given transport type
|
||||
*/
|
||||
template<class T>
|
||||
void countTransport(Maps::MapOverworld *overworldMap, Common::Array<Stats::StatEntry> &stats, const char *name, byte textColor) {
|
||||
// Count the number of transports that are of the given type
|
||||
uint total = 0;
|
||||
for (uint idx = 0; idx < overworldMap->_widgets.size(); ++idx) {
|
||||
if (dynamic_cast<T *>(overworldMap->_widgets[idx].get()))
|
||||
++total;
|
||||
}
|
||||
|
||||
if (total > 0)
|
||||
stats.push_back(Stats::StatEntry(Stats::formatStat(name, total), textColor));
|
||||
}
|
||||
|
||||
void Stats::load() {
|
||||
const Shared::Character &c = *_game->_party;
|
||||
Maps::MapOverworld *overworld = getMap()->getOverworldMap();
|
||||
|
||||
// Basic attributes
|
||||
const uint basicAttributes[7] = { c._hitPoints,c._strength, c._agility, c._stamina, c._charisma,c._wisdom, c._intelligence };
|
||||
addStats(_game->_res->STAT_NAMES, basicAttributes, 0, 6);
|
||||
|
||||
// Money line(s)
|
||||
if (c._coins % 10)
|
||||
_stats.push_back(StatEntry(formatStat(_game->_res->STAT_NAMES[7], c._coins % 10), _game->_textColor));
|
||||
if ((c._coins % 100) >= 10)
|
||||
_stats.push_back(StatEntry(formatStat(_game->_res->STAT_NAMES[8], (c._coins / 10) % 10), _game->_textColor));
|
||||
if (c._coins >= 100)
|
||||
_stats.push_back(StatEntry(formatStat(_game->_res->STAT_NAMES[9], c._coins / 100), _game->_textColor));
|
||||
|
||||
// Enemy vessels
|
||||
uint enemyVessels = overworld->getEnemyVesselCount();
|
||||
if (enemyVessels != 0)
|
||||
_stats.push_back(StatEntry(_game->_res->STAT_NAMES[9], enemyVessels));
|
||||
|
||||
// Armor, weapons, & spells
|
||||
for (uint idx = 1; idx < c._armour.size(); ++idx) {
|
||||
if (!c._armour[idx]->empty())
|
||||
_stats.push_back(StatEntry(formatStat(c._armour[idx]->_name.c_str(), c._armour[idx]->_quantity),
|
||||
(int)idx == c._equippedArmour ? _game->_highlightColor : _game->_textColor));
|
||||
}
|
||||
for (uint idx = 1; idx < c._weapons.size(); ++idx) {
|
||||
if (!c._weapons[idx]->empty())
|
||||
_stats.push_back(StatEntry(formatStat(c._weapons[idx]->_longName.c_str(), c._weapons[idx]->_quantity),
|
||||
(int)idx == c._equippedWeapon ? _game->_highlightColor : _game->_textColor));
|
||||
}
|
||||
for (uint idx = 1; idx < c._spells.size(); ++idx) {
|
||||
if (!c._spells[idx]->empty())
|
||||
_stats.push_back(StatEntry(formatStat(c._spells[idx]->_name.c_str(), c._spells[idx]->_quantity),
|
||||
(int)idx == c._equippedSpell ? _game->_highlightColor : _game->_textColor));
|
||||
}
|
||||
|
||||
// Counts of transport types
|
||||
countTransport<Widgets::Horse>(overworld, _stats, _game->_res->TRANSPORT_NAMES[1], _game->_textColor);
|
||||
countTransport<Widgets::Cart>(overworld, _stats, _game->_res->TRANSPORT_NAMES[2], _game->_textColor);
|
||||
countTransport<Widgets::Raft>(overworld, _stats, _game->_res->TRANSPORT_NAMES[3], _game->_textColor);
|
||||
countTransport<Widgets::Frigate>(overworld, _stats, _game->_res->TRANSPORT_NAMES[4], _game->_textColor);
|
||||
countTransport<Widgets::Aircar>(overworld, _stats, _game->_res->TRANSPORT_NAMES[5], _game->_textColor);
|
||||
countTransport<Widgets::Shuttle>(overworld, _stats, _game->_res->TRANSPORT_NAMES[6], _game->_textColor);
|
||||
countTransport<Widgets::TimeMachine>(overworld, _stats, _game->_res->TRANSPORT_NAMES[7], _game->_textColor);
|
||||
|
||||
// Add entries for any gems
|
||||
addStats(_game->_res->GEM_NAMES, _game->_gems, 0, 3);
|
||||
}
|
||||
|
||||
void Stats::addStats(const char *const *names, const uint *values, int start, int end, int equippedIndex) {
|
||||
for (int idx = start; idx <= end; ++idx) {
|
||||
if (values[idx]) {
|
||||
Common::String line = formatStat(names[idx], values[idx]);
|
||||
_stats.push_back(StatEntry(line, (idx == equippedIndex) ? _game->_highlightColor : _game->_textColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Common::String Stats::formatStat(const char *name, uint value) {
|
||||
Common::String line(name);
|
||||
Common::String val = Common::String::format("%u", value);
|
||||
while ((line.size() + val.size()) < 17)
|
||||
line += '.';
|
||||
|
||||
return line + val;
|
||||
}
|
||||
|
||||
void Stats::draw() {
|
||||
Dialog::draw();
|
||||
|
||||
drawFrame(_game->_res->INVENTORY);
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
const Shared::Character &c = *_game->_party;
|
||||
|
||||
// Player name and description
|
||||
s.writeString(Common::String::format(_game->_res->PLAYER, c._name.c_str()),
|
||||
TextPoint(2, 2), _game->_edgeColor);
|
||||
s.writeString(Common::String::format(_game->_res->PLAYER_DESC, c.getLevel(),
|
||||
_game->_res->SEX_NAMES[c._sex], _game->_res->RACE_NAMES[c._race], _game->_res->CLASS_NAMES[c._class]),
|
||||
TextPoint(2, 3), _game->_edgeColor);
|
||||
|
||||
// Display stats
|
||||
for (uint idx = 0; idx < MIN(26U, _stats.size() - _startingIndex); ++idx) {
|
||||
s.writeString(_stats[_startingIndex + idx]._line, TextPoint(idx >= 13 ? 21 : 2, (idx % 13) + 5), _stats[_startingIndex + idx]._color);
|
||||
}
|
||||
|
||||
// Display a more sign if thare more than 26 remaining entries being displayed
|
||||
if ((_startingIndex + 26) < _stats.size()) {
|
||||
U1Gfx::DrawingSupport ds(s);
|
||||
ds.drawRightArrow(TextPoint(16, 19));
|
||||
s.writeString(_game->_res->MORE, TextPoint(17, 19));
|
||||
ds.drawLeftArrow(TextPoint(23, 19));
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
101
engines/ultima/ultima1/u1dialogs/stats.h
Normal file
101
engines/ultima/ultima1/u1dialogs/stats.h
Normal file
@@ -0,0 +1,101 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_STATS_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_STATS_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/full_screen_dialog.h"
|
||||
#include "common/array.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
using Shared::CShowMsg;
|
||||
using Shared::CCharacterInputMsg;
|
||||
|
||||
/**
|
||||
* Implements the stats/inventory dialog
|
||||
*/
|
||||
class Stats : public FullScreenDialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool ShowMsg(CShowMsg *msg);
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg);
|
||||
public:
|
||||
/**
|
||||
* Contains the data for a single stat entry to display
|
||||
*/
|
||||
struct StatEntry {
|
||||
Common::String _line;
|
||||
byte _color;
|
||||
|
||||
StatEntry() : _color(0) {}
|
||||
StatEntry(const Common::String &line, byte color) : _line(line), _color(color) {}
|
||||
};
|
||||
|
||||
/**
|
||||
* Format a name/value text with dots between them
|
||||
* @param name Stat/item name
|
||||
* @param value The value/quantity
|
||||
* @returns The formatted display of name dots value
|
||||
*/
|
||||
static Common::String formatStat(const char *name, uint value);
|
||||
private:
|
||||
Common::Array<StatEntry> _stats;
|
||||
uint _startingIndex;
|
||||
private:
|
||||
/**
|
||||
* Loads the list of stats to display into an array
|
||||
*/
|
||||
void load();
|
||||
|
||||
/**
|
||||
* Add a range of values into the stats list
|
||||
* @param names Stat names
|
||||
* @param values Values
|
||||
* @param start Starting index
|
||||
* @param end Ending index
|
||||
* @param equippedIndex Equipped item index, if applicable
|
||||
* @param row Starting text row
|
||||
* @returns Ending text row
|
||||
*/
|
||||
void addStats(const char *const *names, const uint *values, int start, int end, int equippedIndex = -1);
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Stats(Ultima1Game *game) : FullScreenDialog(game), _startingIndex(0) {
|
||||
load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
203
engines/ultima/ultima1/u1dialogs/tavern.cpp
Normal file
203
engines/ultima/ultima1/u1dialogs/tavern.cpp
Normal file
@@ -0,0 +1,203 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/tavern.h"
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/maps/map_city_castle.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
#include "ultima/shared/core/str.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Tavern, BuySellDialog)
|
||||
ON_MESSAGE(FrameMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
Tavern::Tavern(Ultima1Game *game, Maps::MapCityCastle *map, int tavernNum) :
|
||||
BuySellDialog(game, game->_res->TAVERN_NAMES[tavernNum]), _map(map),
|
||||
_countdown(0), _tipNumber(0), _buyDisplay(INITIAL) {
|
||||
}
|
||||
|
||||
void Tavern::setMode(BuySell mode) {
|
||||
switch (mode) {
|
||||
case BUY:
|
||||
_mode = BUY;
|
||||
addInfoMsg(Common::String::format("%s%s%s", _game->_res->ACTION_NAMES[19], _game->_res->BUY, _game->_res->TAVERN_TEXT[3]), false, true);
|
||||
setDirty();
|
||||
delay(DIALOG_CLOSE_DELAY * 2);
|
||||
break;
|
||||
|
||||
case SELL:
|
||||
_mode = SELL;
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->SELL), false, true);
|
||||
|
||||
delay(DIALOG_CLOSE_DELAY * 2);
|
||||
setDirty();
|
||||
break;
|
||||
|
||||
default:
|
||||
BuySellDialog::setMode(mode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool Tavern::FrameMsg(CFrameMsg *msg) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
|
||||
if (_countdown > 0 && --_countdown == 0) {
|
||||
switch (_mode) {
|
||||
case BUY:
|
||||
switch (_buyDisplay) {
|
||||
case INITIAL:
|
||||
if (c._coins == 0) {
|
||||
close();
|
||||
break;
|
||||
}
|
||||
|
||||
if (++_map->_tipCounter > (c._stamina / 4) && _map->isWenchNearby()) {
|
||||
_buyDisplay = TIP0;
|
||||
_tipNumber = 0;
|
||||
c._coins /= 2;
|
||||
c._wisdom = MAX(c._wisdom - 1, 5U);
|
||||
|
||||
delay();
|
||||
break;
|
||||
}
|
||||
// fall through
|
||||
|
||||
case TIP0:
|
||||
if (_game->getRandomNumber(255) < 75) {
|
||||
_buyDisplay = TIP_PAGE1;
|
||||
_tipNumber = _game->getRandomNumber(11, 89) / 10;
|
||||
delay((_tipNumber == 8) ? 7 * DIALOG_CLOSE_DELAY : 4 * DIALOG_CLOSE_DELAY);
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
break;
|
||||
|
||||
case TIP_PAGE1:
|
||||
if (_tipNumber == 8) {
|
||||
_buyDisplay = TIP_PAGE2;
|
||||
delay();
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
break;
|
||||
|
||||
case TIP_PAGE2:
|
||||
close();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SELL:
|
||||
addInfoMsg(_game->_res->NOTHING);
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Tavern::close() {
|
||||
addInfoMsg("");
|
||||
_game->endOfTurn();
|
||||
hide();
|
||||
}
|
||||
|
||||
void Tavern::draw() {
|
||||
BuySellDialog::draw();
|
||||
|
||||
switch (_mode) {
|
||||
case BUY:
|
||||
drawBuy();
|
||||
break;
|
||||
|
||||
case SELL:
|
||||
drawSell();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Tavern::drawBuy() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int titleLines = String(_title).split("\r\n").size();
|
||||
|
||||
switch (_buyDisplay) {
|
||||
case INITIAL:
|
||||
if (c._coins == 0) {
|
||||
// Broke
|
||||
centerText(String(_game->_res->TAVERN_TEXT[0]).split("\r\n"), titleLines + 2);
|
||||
} else {
|
||||
// Initial ale give
|
||||
centerText(String(_game->_res->TAVERN_TEXT[2]).split("\r\n"), titleLines + 2);
|
||||
}
|
||||
break;
|
||||
|
||||
case TIP0:
|
||||
case TIP_PAGE1:
|
||||
case TIP_PAGE2: {
|
||||
if (_tipNumber != 0)
|
||||
centerText(_game->_res->TAVERN_TIPS[0], 3);
|
||||
switch (_tipNumber) {
|
||||
case 2:
|
||||
centerText(Common::String::format(_game->_res->TAVERN_TIPS[3],
|
||||
_game->_res->TAVERN_TIPS[c._sex == Shared::SEX_MALE ? 11 : 12]), 4);
|
||||
break;
|
||||
case 8:
|
||||
centerText(String(_game->_res->TAVERN_TIPS[_buyDisplay == TIP_PAGE1 ? 9 : 10]).split("\r\n"), 4);
|
||||
break;
|
||||
default:
|
||||
centerText(String(_game->_res->TAVERN_TIPS[_tipNumber + 1]).split("\r\n"), 4);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Tavern::drawSell() {
|
||||
int titleLines = String(_title).split("\r\n").size();
|
||||
|
||||
centerText(String(_game->_res->TAVERN_TEXT[1]).split("\r\n"), titleLines + 2);
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
93
engines/ultima/ultima1/u1dialogs/tavern.h
Normal file
93
engines/ultima/ultima1/u1dialogs/tavern.h
Normal file
@@ -0,0 +1,93 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_TAVERN_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_TAVERN_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/buy_sell_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace Maps {
|
||||
class MapCityCastle;
|
||||
}
|
||||
|
||||
namespace U1Dialogs {
|
||||
|
||||
/**
|
||||
* Implements the buy/sell dialog for taverns
|
||||
*/
|
||||
class Tavern : public BuySellDialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool FrameMsg(CFrameMsg *msg);
|
||||
private:
|
||||
Maps::MapCityCastle *_map;
|
||||
//uint _tavernNum;
|
||||
uint _tipNumber;
|
||||
uint _countdown;
|
||||
enum { INITIAL, TIP0, TIP_PAGE1, TIP_PAGE2 } _buyDisplay;
|
||||
private:
|
||||
/**
|
||||
* Delay be a specified amount
|
||||
*/
|
||||
void delay(uint amount = 4 * DIALOG_CLOSE_DELAY) {
|
||||
_countdown = amount;
|
||||
setDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the dialog
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Draws the Buy dialog content
|
||||
*/
|
||||
void drawBuy();
|
||||
|
||||
/**
|
||||
* Draws the Sell dialog content
|
||||
*/
|
||||
void drawSell();
|
||||
protected:
|
||||
/**
|
||||
* Set the mode
|
||||
*/
|
||||
void setMode(BuySell mode) override;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Tavern(Ultima1Game *game, Maps::MapCityCastle *map, int tavernNum);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
229
engines/ultima/ultima1/u1dialogs/transports.cpp
Normal file
229
engines/ultima/ultima1/u1dialogs/transports.cpp
Normal file
@@ -0,0 +1,229 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/transports.h"
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/maps/map_city_castle.h"
|
||||
#include "ultima/ultima1/maps/map_overworld.h"
|
||||
#include "ultima/ultima1/maps/map_tile.h"
|
||||
#include "ultima/ultima1/widgets/transport.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
#include "ultima/shared/core/str.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
EMPTY_MESSAGE_MAP(Transports, BuySellDialog);
|
||||
|
||||
Transports::Transports(Ultima1Game *game, int transportsNum) : BuySellDialog(game, game->_res->WEAPONRY_NAMES[transportsNum]) {
|
||||
loadOverworldFreeTiles();
|
||||
}
|
||||
|
||||
void Transports::loadOverworldFreeTiles() {
|
||||
Maps::MapOverworld *map = static_cast<Maps::Ultima1Map *>(_game->_map)->getOverworldMap();
|
||||
Maps::Ultima1Map *currMap = static_cast<Maps::Ultima1Map *>(_game->_map);
|
||||
|
||||
Point delta;
|
||||
|
||||
Maps::U1MapTile mapTile;
|
||||
_water = _woods = _grass = 0;
|
||||
|
||||
// Iterate through the tiles surrounding the city/castle
|
||||
for (delta.y = -1; delta.y <= 1; ++delta.y) {
|
||||
for (delta.x = -1; delta.x <= 1; ++delta.x) {
|
||||
if (delta.x != 0 || delta.y != 0) {
|
||||
map->getTileAt(map->getPosition() + delta, &mapTile);
|
||||
|
||||
if (!mapTile._widget) {
|
||||
if (mapTile.isOriginalWater())
|
||||
++_water;
|
||||
else if (mapTile.isOriginalGrass())
|
||||
++_grass;
|
||||
else if (mapTile.isOriginalWoods())
|
||||
++_woods;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Count the number of transports
|
||||
_transportCount = 0;
|
||||
_hasShuttle = false;
|
||||
for (uint idx = 0; idx < map->_widgets.size(); ++idx) {
|
||||
if (dynamic_cast<Widgets::Transport *>(map->_widgets[idx].get()))
|
||||
++_transportCount;
|
||||
if (dynamic_cast<Widgets::Shuttle *>(map->_widgets[idx].get()))
|
||||
_hasShuttle = true;
|
||||
}
|
||||
|
||||
_hasFreeTiles = _water != 0 || _woods != 0 || _grass != 0;
|
||||
_isClosed = !_hasFreeTiles || (_hasShuttle && _transportCount == 15)
|
||||
|| (!_grass && _transportCount == 15);
|
||||
|
||||
bool flag = !_hasShuttle && _transportCount == 15;
|
||||
_transports[0] = _transports[1] = (_woods || _grass) && !flag;
|
||||
_transports[2] = _transports[3] = _water && !flag;
|
||||
_transports[4] = currMap->_moveCounter > 3000 && _grass && !flag;
|
||||
_transports[5] = currMap->_moveCounter > 3000 && _grass && !_hasShuttle;
|
||||
}
|
||||
|
||||
void Transports::setMode(BuySell mode) {
|
||||
_mode = mode;
|
||||
setDirty();
|
||||
|
||||
switch (mode) {
|
||||
case BUY: {
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->BUY), false, true);
|
||||
|
||||
if (_isClosed) {
|
||||
addInfoMsg(_game->_res->NOTHING, false);
|
||||
closeShortly();
|
||||
} else {
|
||||
getKeypress();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case SELL:
|
||||
addInfoMsg(Common::String::format("%s%s%s", _game->_res->ACTION_NAMES[19], _game->_res->SELL, _game->_res->NOTHING), false, true);
|
||||
closeShortly();
|
||||
break;
|
||||
|
||||
default:
|
||||
BuySellDialog::setMode(mode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint Transports::getBuyCost(int transportIndex) const {
|
||||
const Shared::Character &c = *_game->_party;
|
||||
return (200 - c._intelligence) / 5 * transportIndex * transportIndex;
|
||||
}
|
||||
|
||||
|
||||
void Transports::draw() {
|
||||
BuySellDialog::draw();
|
||||
|
||||
switch (_mode) {
|
||||
case BUY:
|
||||
drawBuy();
|
||||
break;
|
||||
|
||||
case SELL:
|
||||
drawSell();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Transports::drawBuy() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
int titleLines = String(_title).split("\r\n").size();
|
||||
Common::String line;
|
||||
|
||||
if (_hasFreeTiles) {
|
||||
for (int idx = 0, yp = titleLines + 2; idx < 6; ++idx) {
|
||||
if (_transports[idx]) {
|
||||
line = Common::String::format("%c) %s", 'a' + idx, _game->_res->TRANSPORT_NAMES[idx + 1]);
|
||||
s.writeString(line, TextPoint(8, yp));
|
||||
line = Common::String::format("- %u", getBuyCost(idx + 1));
|
||||
s.writeString(line, TextPoint(19, yp));
|
||||
++yp;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
centerText(_game->_res->TRANSPORTS_TEXT[1], titleLines + 2);
|
||||
}
|
||||
}
|
||||
|
||||
void Transports::drawSell() {
|
||||
int titleLines = String(_title).split("\r\n").size();
|
||||
centerText(String(_game->_res->TRANSPORTS_TEXT[0]).split("\r\n"), titleLines + 2);
|
||||
}
|
||||
|
||||
bool Transports::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
int transportIndex = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
|
||||
if (_mode == BUY) {
|
||||
if (msg->_keyState.keycode >= Common::KEYCODE_a &&
|
||||
msg->_keyState.keycode <= Common::KEYCODE_f &&
|
||||
_transports[transportIndex]) {
|
||||
uint cost = getBuyCost(transportIndex + 1);
|
||||
if (cost <= c._coins) {
|
||||
// Display the bought transport name in the info area
|
||||
addInfoMsg(_game->_res->TRANSPORT_NAMES[transportIndex + 1]);
|
||||
|
||||
// Remove the cost, and add in the new transport
|
||||
c._coins -= cost;
|
||||
addTransport(transportIndex);
|
||||
|
||||
// Show sold and close the dialog
|
||||
setMode(SOLD);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
nothing();
|
||||
return true;
|
||||
} else {
|
||||
return BuySellDialog::CharacterInputMsg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
void Transports::addTransport(int transportIndex) {
|
||||
Maps::MapOverworld *map = static_cast<Maps::Ultima1Map *>(_game->_map)->getOverworldMap();
|
||||
Point delta;
|
||||
Maps::U1MapTile mapTile;
|
||||
const char *const WIDGET_NAMES[6] = {
|
||||
"Horse", "Cart", "Raft", "Frigate", "Aircar", "Shuttle"
|
||||
};
|
||||
|
||||
// Iterate through the tiles surrounding the city/castle
|
||||
for (delta.y = -1; delta.y <= 1; ++delta.y) {
|
||||
for (delta.x = -1; delta.x <= 1; ++delta.x) {
|
||||
map->getTileAt(map->getPosition() + delta, &mapTile);
|
||||
|
||||
if (!mapTile._widget && mapTile._locationNum == -1) {
|
||||
if ((transportIndex <= 1 && (mapTile.isOriginalWoods() || (!_woods && mapTile.isOriginalGrass())))
|
||||
|| (transportIndex >= 2 && transportIndex <= 3 && mapTile.isOriginalWater())
|
||||
|| (transportIndex >= 4 && mapTile.isOriginalGrass())) {
|
||||
// Add the transport onto the designated tile around the location
|
||||
Shared::Maps::MapWidget *widget = map->createWidget(WIDGET_NAMES[transportIndex]);
|
||||
assert(widget);
|
||||
widget->_position = map->getPosition() + delta;
|
||||
map->addWidget(widget);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
92
engines/ultima/ultima1/u1dialogs/transports.h
Normal file
92
engines/ultima/ultima1/u1dialogs/transports.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_TRANSPORTS_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_TRANSPORTS_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/buy_sell_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
using Shared::CCharacterInputMsg;
|
||||
|
||||
/**
|
||||
* Implements the dialog for the transport merchant
|
||||
*/
|
||||
class Transports : public BuySellDialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg) override;
|
||||
private:
|
||||
uint _water, _woods, _grass;
|
||||
bool _hasFreeTiles, _hasShuttle, _isClosed;
|
||||
uint _transportCount;
|
||||
bool _transports[6];
|
||||
private:
|
||||
/**
|
||||
* Calculates the number of free tiles in the overworld
|
||||
*/
|
||||
void loadOverworldFreeTiles();
|
||||
|
||||
/**
|
||||
* Draws the Buy dialog content
|
||||
*/
|
||||
void drawBuy();
|
||||
|
||||
/**
|
||||
* Draws the Sell dialog content
|
||||
*/
|
||||
void drawSell();
|
||||
|
||||
/**
|
||||
* Gets the cost for buying a given transport
|
||||
*/
|
||||
uint getBuyCost(int transportIndex) const;
|
||||
|
||||
/**
|
||||
* Add a transport to the overworld map
|
||||
*/
|
||||
void addTransport(int transportIndex);
|
||||
protected:
|
||||
/**
|
||||
* Set the mode
|
||||
*/
|
||||
void setMode(BuySell mode) override;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Transports(Ultima1Game *game, int transportNum);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
193
engines/ultima/ultima1/u1dialogs/weaponry.cpp
Normal file
193
engines/ultima/ultima1/u1dialogs/weaponry.cpp
Normal file
@@ -0,0 +1,193 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/weaponry.h"
|
||||
#include "ultima/ultima1/core/party.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
#include "ultima/ultima1/maps/map.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
#include "ultima/shared/core/str.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
EMPTY_MESSAGE_MAP(Weaponry, BuySellDialog);
|
||||
|
||||
Weaponry::Weaponry(Ultima1Game *game, int weaponryNum) : BuySellDialog(game, game->_res->WEAPONRY_NAMES[weaponryNum]) {
|
||||
//, _weaponryNum(weaponryNum) {
|
||||
Maps::Ultima1Map *map = static_cast<Maps::Ultima1Map *>(game->_map);
|
||||
|
||||
int offset = (weaponryNum + 1) % 2 + 1;
|
||||
int index = (map->_moveCounter % 0x7fff) / 1500;
|
||||
if (index > 3 || map->_moveCounter > 3000)
|
||||
index = 3;
|
||||
|
||||
_startIndex = offset;
|
||||
_endIndex = offset + (index + 1) * 2;
|
||||
}
|
||||
|
||||
void Weaponry::setMode(BuySell mode) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
|
||||
switch (mode) {
|
||||
case BUY: {
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->BUY), false, true);
|
||||
|
||||
_mode = BUY;
|
||||
setDirty();
|
||||
getKeypress();
|
||||
break;
|
||||
}
|
||||
|
||||
case SELL:
|
||||
addInfoMsg(Common::String::format("%s%s", _game->_res->ACTION_NAMES[19], _game->_res->SELL), false, true);
|
||||
|
||||
if (c._weapons.hasNothing()) {
|
||||
addInfoMsg(_game->_res->NOTHING);
|
||||
closeShortly();
|
||||
} else {
|
||||
getKeypress();
|
||||
}
|
||||
|
||||
_mode = SELL;
|
||||
setDirty();
|
||||
break;
|
||||
|
||||
default:
|
||||
BuySellDialog::setMode(mode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Weaponry::draw() {
|
||||
BuySellDialog::draw();
|
||||
|
||||
switch (_mode) {
|
||||
case BUY:
|
||||
drawBuy();
|
||||
break;
|
||||
|
||||
case SELL:
|
||||
drawSell();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Weaponry::drawBuy() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int titleLines = String(_title).split("\r\n").size();
|
||||
Common::String line;
|
||||
|
||||
for (uint idx = _startIndex, yp = titleLines + 2; idx <= _endIndex; idx += 2, ++yp) {
|
||||
const Weapon &weapon = *static_cast<Weapon *>(c._weapons[idx]);
|
||||
|
||||
line = Common::String::format("%c) %s", 'a' + idx, weapon._longName.c_str());
|
||||
s.writeString(line, TextPoint(5, yp));
|
||||
line = Common::String::format("-%4u", weapon.getBuyCost());
|
||||
s.writeString(line, TextPoint(22, yp));
|
||||
}
|
||||
}
|
||||
|
||||
void Weaponry::drawSell() {
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
const Shared::Character &c = *_game->_party;
|
||||
int lineCount = c._weapons.itemsCount();
|
||||
int titleLines = String(_title).split("\r\n").size();
|
||||
Common::String line;
|
||||
|
||||
if (lineCount == 0) {
|
||||
centerText(_game->_res->NO_WEAPONRY_TO_SELL, titleLines + 2);
|
||||
} else {
|
||||
for (uint idx = 1; idx < c._weapons.size(); ++idx) {
|
||||
const Weapon &weapon = *static_cast<Weapon *>(c._weapons[idx]);
|
||||
if (!weapon.empty()) {
|
||||
line = Common::String::format("%c) %s", 'a' + idx, weapon._longName.c_str());
|
||||
s.writeString(line, TextPoint(5, idx + titleLines + 1));
|
||||
line = Common::String::format("-%4u", weapon.getSellCost());
|
||||
s.writeString(line, TextPoint(22, idx + titleLines + 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Weaponry::CharacterInputMsg(CCharacterInputMsg *msg) {
|
||||
Shared::Character &c = *_game->_party;
|
||||
|
||||
if (_mode == BUY) {
|
||||
if (msg->_keyState.keycode >= (int)(Common::KEYCODE_a + _startIndex) &&
|
||||
msg->_keyState.keycode <= (int)(Common::KEYCODE_a + _endIndex) &&
|
||||
(int)(msg->_keyState.keycode - Common::KEYCODE_a - _startIndex) % 2 == 0) {
|
||||
uint weaponNum = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
Weapon &weapon = *static_cast<Weapon *>(c._weapons[weaponNum]);
|
||||
|
||||
if (weapon.getBuyCost() <= c._coins) {
|
||||
// Display the sold weapon in the info area
|
||||
addInfoMsg(weapon._longName);
|
||||
|
||||
// Remove coins for weapon and add it to the inventory
|
||||
c._coins -= weapon.getBuyCost();
|
||||
weapon.incrQuantity();
|
||||
|
||||
// Show sold and close the dialog
|
||||
setMode(SOLD);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
nothing();
|
||||
return true;
|
||||
} else if (_mode == SELL && !c._weapons.hasNothing()) {
|
||||
if (msg->_keyState.keycode >= Common::KEYCODE_b &&
|
||||
msg->_keyState.keycode < (Common::KEYCODE_a + (int)c._weapons.size())) {
|
||||
uint weaponNum = msg->_keyState.keycode - Common::KEYCODE_a;
|
||||
Weapon &weapon = *static_cast<Weapon *>(c._weapons[weaponNum]);
|
||||
|
||||
if (!weapon.empty()) {
|
||||
// Display the sold weapon in the info area
|
||||
addInfoMsg(weapon._longName);
|
||||
|
||||
// Give coins for weapon and remove it from the inventory
|
||||
c._coins += weapon.getSellCost();
|
||||
if (weapon.decrQuantity() && (int)weaponNum == c._equippedWeapon)
|
||||
c.removeWeapon();
|
||||
|
||||
// Close the dialog
|
||||
setMode(DONE);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
nothing();
|
||||
return true;
|
||||
} else {
|
||||
return BuySellDialog::CharacterInputMsg(msg);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
73
engines/ultima/ultima1/u1dialogs/weaponry.h
Normal file
73
engines/ultima/ultima1/u1dialogs/weaponry.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1DIALOGS_WEAPONRY_H
|
||||
#define ULTIMA_ULTIMA1_U1DIALOGS_WEAPONRY_H
|
||||
|
||||
#include "ultima/ultima1/u1dialogs/buy_sell_dialog.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Dialogs {
|
||||
|
||||
/**
|
||||
* Implements the buy/sell dialog for grocers
|
||||
*/
|
||||
class Weaponry : public BuySellDialog {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool CharacterInputMsg(CCharacterInputMsg *msg) override;
|
||||
private:
|
||||
// uint _weaponryNum;
|
||||
uint _startIndex, _endIndex;
|
||||
private:
|
||||
/**
|
||||
* Draws the Buy dialog content
|
||||
*/
|
||||
void drawBuy();
|
||||
|
||||
/**
|
||||
* Draws the Sell dialog content
|
||||
*/
|
||||
void drawSell();
|
||||
protected:
|
||||
/**
|
||||
* Set the mode
|
||||
*/
|
||||
void setMode(BuySell mode) override;
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Weaponry(Ultima1Game *game, int weaponryNum);
|
||||
|
||||
/**
|
||||
* Draws the visual item on the screen
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Dialogs
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
115
engines/ultima/ultima1/u1gfx/drawing_support.cpp
Normal file
115
engines/ultima/ultima1/u1gfx/drawing_support.cpp
Normal file
@@ -0,0 +1,115 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more detail_surface.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1gfx/drawing_support.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/shared/early/ultima_early.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
DrawingSupport::DrawingSupport(const Shared::Gfx::VisualSurface &s) : _surface(s, s.getBounds()) {
|
||||
_game = static_cast<Ultima1Game *>(g_vm->_game);
|
||||
}
|
||||
|
||||
void DrawingSupport::drawFrame() {
|
||||
// Big border around the screen
|
||||
_surface.fillRect(Rect(0, 0, 317, 7), _game->_borderColor);
|
||||
_surface.fillRect(Rect(0, 6, 7, 200), _game->_borderColor);
|
||||
_surface.fillRect(Rect(313, 7, 320, 200), _game->_borderColor);
|
||||
_surface.fillRect(Rect(0, 193, 320, 200), _game->_borderColor);
|
||||
|
||||
// Thin line on edge of big border
|
||||
_surface.vLine(7, 7, 192, _game->_edgeColor);
|
||||
_surface.vLine(312, 7, 192, _game->_edgeColor);
|
||||
_surface.hLine(7, 7, 312, _game->_edgeColor);
|
||||
_surface.hLine(7, 192, 312, _game->_edgeColor);
|
||||
|
||||
}
|
||||
|
||||
void DrawingSupport::drawGameFrame() {
|
||||
// Big border around the screen
|
||||
_surface.fillRect(Rect(0, 0, 317, 7), _game->_borderColor);
|
||||
_surface.fillRect(Rect(0, 153, 320, 159), _game->_borderColor);
|
||||
_surface.fillRect(Rect(0, 6, 7, 159), _game->_borderColor);
|
||||
_surface.fillRect(Rect(313, 7, 320, 159), _game->_borderColor);
|
||||
|
||||
// Thin line on edge of big border
|
||||
_surface.vLine(7, 7, 152, _game->_edgeColor);
|
||||
_surface.vLine(312, 7, 152, _game->_edgeColor);
|
||||
_surface.hLine(7, 7, 312, _game->_edgeColor);
|
||||
_surface.hLine(7, 152, 312, _game->_edgeColor);
|
||||
|
||||
// Draw separator at bottom of screen
|
||||
_surface.fillRect(Rect(241, 153, 247, 200), _game->_borderColor);
|
||||
_surface.hLine(0, 159, 240, _game->_edgeColor);
|
||||
_surface.hLine(247, 159, 320, _game->_edgeColor);
|
||||
_surface.vLine(240, 159, 200, _game->_edgeColor);
|
||||
_surface.vLine(247, 159, 200, _game->_edgeColor);
|
||||
}
|
||||
|
||||
void DrawingSupport::roundFrameCorners(bool skipBottom) {
|
||||
// Round the edges of the big outer border
|
||||
for (int idx = 1; idx <= 4; ++idx) {
|
||||
_surface.drawLine(0, idx, idx, 0, 0);
|
||||
_surface.drawLine(319 - idx, 0, 319, idx, 0);
|
||||
|
||||
if (!skipBottom) {
|
||||
_surface.drawLine(0, 199 - idx, idx, 199, 0);
|
||||
_surface.drawLine(319, 199 - idx, 319 - idx, 199, 0);
|
||||
}
|
||||
}
|
||||
|
||||
_surface.drawPoint(Point(0, 0), 0);
|
||||
_surface.drawPoint(Point(0, 5), 0);
|
||||
_surface.drawPoint(Point(5, 0), 0);
|
||||
_surface.drawPoint(Point(319, 0), 0);
|
||||
_surface.drawPoint(Point(314, 0), 0);
|
||||
_surface.drawPoint(Point(319, 5), 0);
|
||||
|
||||
if (!skipBottom) {
|
||||
_surface.drawPoint(Point(0, 199), 0);
|
||||
_surface.drawPoint(Point(0, 194), 0);
|
||||
_surface.drawPoint(Point(5, 199), 0);
|
||||
_surface.drawPoint(Point(319, 199), 0);
|
||||
_surface.drawPoint(Point(319, 194), 0);
|
||||
_surface.drawPoint(Point(314, 199), 0);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawingSupport::drawRightArrow(const Point &pt) {
|
||||
_surface.writeChar(16, pt, _game->_borderColor);
|
||||
_surface.drawLine(pt.x, pt.y, pt.x + 7, pt.y + 3, _game->_edgeColor);
|
||||
_surface.drawLine(pt.x + 7, pt.y + 3, pt.x, pt.y + 7, _game->_edgeColor);
|
||||
_surface.drawLine(pt.x, pt.y + 1, pt.x, pt.y + 6, _game->_borderColor);
|
||||
}
|
||||
|
||||
void DrawingSupport::drawLeftArrow(const Point &pt) {
|
||||
_surface.writeChar(17, pt, _game->_borderColor);
|
||||
_surface.drawLine(pt.x + 7, pt.y, pt.x, pt.y + 3, _game->_edgeColor);
|
||||
_surface.drawLine(pt.x, pt.y + 3, pt.x + 7, pt.y + 7, _game->_edgeColor);
|
||||
_surface.drawLine(pt.x + 7, pt.y + 1, pt.x + 7, pt.y + 6, _game->_borderColor);
|
||||
}
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
78
engines/ultima/ultima1/u1gfx/drawing_support.h
Normal file
78
engines/ultima/ultima1/u1gfx/drawing_support.h
Normal file
@@ -0,0 +1,78 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1GFX_DRAWING_SUPPORT_H
|
||||
#define ULTIMA_ULTIMA1_U1GFX_DRAWING_SUPPORT_H
|
||||
|
||||
#include "ultima/shared/gfx/visual_surface.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
|
||||
class Ultima1Game;
|
||||
|
||||
namespace U1Gfx {
|
||||
|
||||
/**
|
||||
* Implements various support methods for drawing onto visual surfaces
|
||||
*/
|
||||
class DrawingSupport {
|
||||
private:
|
||||
Shared::Gfx::VisualSurface _surface;
|
||||
Ultima1Game *_game;
|
||||
private:
|
||||
/**
|
||||
* Tweaks the edges of a drawn border to give it a rounded effect
|
||||
*/
|
||||
void roundFrameCorners(bool skipBottom = false);
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
DrawingSupport(const Shared::Gfx::VisualSurface &s);
|
||||
|
||||
/**
|
||||
* Draws a frame around the entire screen
|
||||
*/
|
||||
void drawFrame();
|
||||
|
||||
/**
|
||||
* Draw a frame around the viewport area of the screen, and a vertical separator line
|
||||
* to the bottom of the screen to separate the status and info areas
|
||||
*/
|
||||
void drawGameFrame();
|
||||
|
||||
/**
|
||||
* Draw a right arrow glyph
|
||||
*/
|
||||
void drawRightArrow(const Point &pt);
|
||||
|
||||
/**
|
||||
* Draw a left arrow glyph
|
||||
*/
|
||||
void drawLeftArrow(const Point &pt);
|
||||
};
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Shared
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
5
engines/ultima/ultima1/u1gfx/flags.xbm
Normal file
5
engines/ultima/ultima1/u1gfx/flags.xbm
Normal file
@@ -0,0 +1,5 @@
|
||||
#define flags_width 24
|
||||
#define flags_height 8
|
||||
static const unsigned char flags_bits[] = {
|
||||
0x00,0x00,0x18,0x00,0x00,0x0c,0x00,0x03,0x07,0x01,0x3f,0x01,0x07,0x03,0x00,
|
||||
0x0c,0x00,0x00,0x18,0x00,0x00,0x00,0x00,0x00};
|
||||
37
engines/ultima/ultima1/u1gfx/info.cpp
Normal file
37
engines/ultima/ultima1/u1gfx/info.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1gfx/info.h"
|
||||
#include "ultima/ultima1/u1gfx/drawing_support.h"
|
||||
#include "ultima/shared/early/game.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
void Info::drawPrompt(Shared::Gfx::VisualSurface &surf, const Point &pt) {
|
||||
DrawingSupport ds(surf);
|
||||
ds.drawRightArrow(pt);
|
||||
}
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
56
engines/ultima/ultima1/u1gfx/info.h
Normal file
56
engines/ultima/ultima1/u1gfx/info.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_GFX_INFO_H
|
||||
#define ULTIMA_ULTIMA1_GFX_INFO_H
|
||||
|
||||
#include "ultima/shared/gfx/info.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
/**
|
||||
* Textual info area, showing what commands area done, and any responses to them
|
||||
*/
|
||||
class Info : public Shared::Info {
|
||||
protected:
|
||||
/**
|
||||
* Draws a prompt character
|
||||
*/
|
||||
void drawPrompt(Shared::Gfx::VisualSurface &surf, const Point &pt) override;
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Info(TreeItem *parent) : Shared::Info(parent, TextRect(0, 21, 29, 24)) {}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Info() override {}
|
||||
};
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
153
engines/ultima/ultima1/u1gfx/logo.xbm
Normal file
153
engines/ultima/ultima1/u1gfx/logo.xbm
Normal file
@@ -0,0 +1,153 @@
|
||||
#define logo_width 275
|
||||
#define logo_height 64
|
||||
static const unsigned char logo_bits[] = {
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0x07,0xff,0xff,0xff,0x3f,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xff,0xff,0xff,0x3f,0xff,
|
||||
0xf3,0x3f,0xff,0xf3,0x3f,0xff,0xf3,0x3f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0x06,
|
||||
0xff,0xff,0xff,0x9f,0xff,0xf9,0x9f,0xff,0xf1,0x9f,0xff,0xf9,0x9f,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0x7f,0x06,0xff,0xff,0xff,0x9f,0xff,0xf9,0x9f,0xff,0xe0,0x9f,
|
||||
0xff,0xf9,0x9f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x07,0xff,0xff,0xff,0xcf,0xff,
|
||||
0xfc,0xcf,0x3f,0xe0,0xcf,0xff,0xfc,0xcf,0xff,0x00,0x00,0xff,0xff,0x03,0x00,
|
||||
0xfc,0xff,0xff,0xff,0x03,0x00,0xfc,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x07,
|
||||
0xff,0xff,0xff,0xcf,0xff,0xfc,0xcf,0x1f,0xc0,0xcf,0xff,0xfc,0xcf,0x0f,0x00,
|
||||
0x00,0xfc,0x3f,0x00,0x00,0xf0,0xff,0xf0,0x3f,0x00,0x00,0xf0,0x3f,0xfc,0x0f,
|
||||
0xff,0x7f,0xf8,0x9f,0x07,0xff,0xff,0xff,0xe7,0x7f,0xfe,0xe7,0x07,0xc0,0xe7,
|
||||
0x7f,0xfe,0xe7,0x07,0x00,0x00,0xf0,0x0f,0x00,0x00,0xc0,0x7f,0xf8,0x0f,0x00,
|
||||
0x00,0xc0,0x3f,0xfc,0x0f,0xff,0x7f,0xf8,0x9f,0x07,0xff,0xff,0xff,0xe7,0x7f,
|
||||
0xfe,0xe7,0x03,0x80,0xe7,0x7f,0xfe,0xe7,0x83,0xff,0x7f,0xf0,0x0f,0xfe,0xff,
|
||||
0xc1,0x7f,0xf8,0x07,0xff,0xff,0xc1,0x1f,0xfe,0x07,0xfe,0x3f,0xfc,0xcf,0x07,
|
||||
0xff,0xff,0xff,0xf3,0x3f,0xff,0xf3,0x00,0x80,0xf3,0x3f,0xff,0xf3,0xe1,0xff,
|
||||
0x7f,0xf8,0x87,0xff,0xff,0xe1,0x3f,0xfc,0x87,0xff,0xff,0xe1,0x1f,0xfe,0x07,
|
||||
0xfe,0x3f,0xfc,0xcf,0x07,0xff,0xff,0xff,0xf3,0x3f,0xff,0x73,0x00,0x00,0xf3,
|
||||
0x3f,0xff,0xf3,0xe1,0xff,0x7f,0xf8,0x87,0xff,0xff,0xe1,0x3f,0xfc,0xc3,0xff,
|
||||
0xff,0xe1,0x0f,0xff,0x03,0xfe,0x1f,0xfe,0xe7,0x07,0xff,0xff,0xff,0x01,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xf8,0xf0,0xff,0x3f,0xfc,0xc3,0xff,0xff,
|
||||
0xf0,0x1f,0xfe,0xc3,0xff,0xff,0xff,0x0f,0xff,0x03,0xfc,0x1f,0xfe,0xe7,0x07,
|
||||
0xff,0xff,0xff,0xf9,0x9f,0xff,0xf9,0x87,0xff,0xf9,0x9f,0xff,0xf9,0xf0,0xff,
|
||||
0x3f,0xfc,0xc3,0xff,0xff,0xf0,0x1f,0xfe,0xe1,0xff,0xff,0xff,0x87,0xff,0x01,
|
||||
0xfc,0x0f,0xff,0xf3,0x07,0xff,0xff,0xff,0xfc,0xcf,0xff,0xfc,0xc3,0xff,0xfc,
|
||||
0xcf,0xff,0x7c,0xf8,0xff,0x1f,0xfe,0xe1,0xff,0x7f,0xf8,0x0f,0xff,0xe1,0xff,
|
||||
0xff,0xff,0x87,0xff,0x21,0xfc,0x0f,0xff,0xf3,0x07,0xff,0xff,0xff,0xfc,0xcf,
|
||||
0xff,0xfc,0xc3,0xff,0xfc,0xcf,0xff,0x7c,0xf8,0xff,0x1f,0xfe,0xe1,0xff,0x3f,
|
||||
0xf8,0x0f,0xff,0xf0,0xff,0xff,0xff,0xc3,0xff,0x70,0xf8,0x87,0xff,0xf9,0x07,
|
||||
0xff,0xff,0x7f,0xfe,0xe7,0x7f,0xfe,0xe1,0x7f,0xfe,0xe7,0x7f,0x3e,0xfc,0xff,
|
||||
0x0f,0xff,0xf0,0xff,0x03,0xfc,0x87,0xff,0xf0,0xff,0xff,0xff,0xc3,0xff,0x70,
|
||||
0xf8,0x87,0xff,0xf9,0x07,0xff,0xff,0x7f,0xfe,0xe7,0x7f,0xfe,0xe1,0x7f,0xfe,
|
||||
0xe7,0x7f,0x3e,0xfc,0xff,0x0f,0xff,0xf0,0x0f,0x00,0xff,0x87,0x7f,0xf8,0xff,
|
||||
0xff,0xff,0xe1,0x7f,0x78,0xf8,0xc3,0xff,0xfc,0x07,0xff,0xff,0x3f,0xff,0xf3,
|
||||
0x3f,0xff,0xf0,0x3f,0xff,0xf3,0x3f,0x1f,0xfe,0xff,0x87,0x7f,0xf8,0x03,0xf0,
|
||||
0xff,0xc3,0x7f,0xf8,0xff,0xff,0xff,0xe1,0x7f,0xf8,0xf0,0xc3,0xff,0xfc,0x07,
|
||||
0xff,0xff,0x3f,0xff,0xf3,0x3f,0xff,0xf0,0x3f,0xff,0xf3,0x3f,0x1f,0xfe,0xff,
|
||||
0x87,0x7f,0xf8,0x81,0xff,0xff,0xc3,0x3f,0xfc,0x0f,0x80,0xff,0xf0,0x3f,0xfc,
|
||||
0xf0,0xe1,0x7f,0xfe,0x07,0xff,0xff,0x9f,0xff,0xf9,0x9f,0x7f,0xf8,0x9f,0xff,
|
||||
0xf9,0x9f,0x0f,0xff,0xff,0xc3,0x3f,0xfc,0xe1,0xff,0xff,0xe1,0x3f,0xfc,0x0f,
|
||||
0x00,0xff,0xf0,0x3f,0xfc,0xf0,0xe1,0x7f,0xfe,0x07,0xff,0xff,0x9f,0xff,0xf9,
|
||||
0x9f,0x7f,0xf8,0x9f,0xff,0xf9,0x9f,0x0f,0xff,0xff,0xc3,0x3f,0xfc,0xc3,0xff,
|
||||
0xff,0xe1,0x1f,0xfe,0x0f,0x00,0x7f,0xf8,0x1f,0xfe,0xe1,0xf0,0x3f,0xff,0x07,
|
||||
0xff,0xff,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x87,0xff,0xff,
|
||||
0xe1,0x1f,0xfe,0x87,0xff,0xff,0xf0,0x1f,0xfe,0xff,0x83,0x7f,0xf8,0x1f,0xfe,
|
||||
0xe1,0xf0,0x3f,0xff,0x07,0xff,0xff,0xcf,0xff,0xfc,0xcf,0x3f,0xfc,0xcf,0xff,
|
||||
0xfc,0xcf,0x87,0xff,0xff,0xe1,0x1f,0xfe,0x0f,0xff,0xff,0xf0,0x0f,0xff,0xff,
|
||||
0x87,0x3f,0xfc,0x0f,0xff,0x61,0xf8,0x9f,0xff,0x07,0xff,0xff,0xe7,0x7f,0xfe,
|
||||
0xe7,0x1f,0xfe,0xe7,0x7f,0xfe,0xe7,0xc3,0xff,0xff,0xf0,0x0f,0xff,0x1f,0xfe,
|
||||
0x7f,0xf8,0x0f,0xff,0xff,0xc3,0x3f,0xfc,0x0f,0xff,0x43,0xf8,0x9f,0xff,0x07,
|
||||
0xff,0xff,0xe7,0x3f,0xfe,0xe7,0x1f,0xfe,0xe7,0x7f,0xfc,0xe7,0xc3,0xff,0xff,
|
||||
0xf0,0x0f,0xff,0x3f,0xfc,0x7f,0xf8,0x87,0xff,0xff,0xc3,0x1f,0xfe,0x87,0xff,
|
||||
0x03,0xfc,0xcf,0xff,0x07,0xff,0xff,0xf3,0x0f,0xff,0xf3,0x0f,0xff,0xf3,0x3f,
|
||||
0xf8,0xf3,0xe1,0xff,0x7f,0xf8,0x87,0xff,0x7f,0xf8,0x3f,0xfc,0x87,0xff,0xff,
|
||||
0xe1,0x1f,0xfe,0x87,0xff,0x03,0xfc,0xcf,0xff,0x07,0xff,0xff,0xf3,0x03,0xff,
|
||||
0xf3,0x0f,0xff,0xf3,0x3f,0xf0,0xf3,0xe1,0xff,0x7f,0xf8,0x87,0xff,0xff,0xf0,
|
||||
0x3f,0xfc,0xc3,0xff,0xff,0xe1,0x0f,0xff,0xc3,0xff,0x07,0xfe,0xe7,0xff,0x07,
|
||||
0xff,0xff,0x79,0x80,0xff,0xf9,0x87,0xff,0xf9,0x1f,0xe0,0xf9,0xc0,0xff,0x1f,
|
||||
0xfc,0xc3,0xff,0xff,0xf0,0x1f,0xfe,0x03,0xff,0x7f,0xf0,0x0f,0xff,0xc3,0xff,
|
||||
0x07,0xfe,0xe7,0xff,0x07,0xff,0xff,0x19,0x80,0xff,0xf9,0x87,0xff,0xf9,0x1f,
|
||||
0xc0,0xf9,0x00,0x00,0x00,0xfc,0xc3,0xff,0xff,0xf0,0x1f,0xfe,0x03,0x00,0x00,
|
||||
0xf8,0x87,0xff,0xe1,0xff,0x07,0xff,0xf3,0xff,0x07,0xff,0xff,0x06,0xc0,0xff,
|
||||
0xfc,0xc3,0xff,0xfc,0x0f,0x80,0xfd,0x03,0x00,0x00,0xff,0xe1,0xff,0xff,0xf0,
|
||||
0x0f,0xff,0x0f,0x00,0x00,0xfc,0x87,0xff,0xe1,0xff,0x07,0xff,0xf3,0xff,0x07,
|
||||
0xff,0xff,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x0f,0x00,0xf0,
|
||||
0xff,0xe1,0xff,0x7f,0xf8,0x0f,0xff,0x3f,0x00,0xc0,0xff,0xc3,0xff,0xf0,0xff,
|
||||
0x87,0xff,0xf9,0xff,0x07,0xff,0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0xfe,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xf9,0xff,0x07,0xff,0xff,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xfc,0xff,0x07,
|
||||
0xff,0xbf,0x03,0xf0,0x3f,0xff,0xf0,0x3f,0xff,0x03,0x60,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xfc,0xff,0x07,0xff,0x3f,0x0f,0xf0,0x3f,0xff,0xf0,0x3f,0xff,0x03,
|
||||
0x38,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfe,0xff,0x07,0xff,0x9f,0x1f,0xf8,0x9f,
|
||||
0x7f,0xf8,0x9f,0xff,0x01,0x9f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x7f,0xfe,0xff,0x07,
|
||||
0xff,0x9f,0x3f,0xf8,0x9f,0x7f,0xf8,0x9f,0xff,0xc1,0x9f,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0x3f,0xff,0xff,0x07,0xff,0xcf,0x7f,0xfc,0xcf,0x3f,0xfc,0xcf,0xff,0xf8,
|
||||
0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xff,0xff,0x07,0xff,0xcf,0xff,0xfc,0xcf,
|
||||
0x3f,0xfc,0xcf,0xff,0xfc,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x9f,0xff,0xff,0x07,
|
||||
0xff,0xe7,0x7f,0xfe,0xe7,0x1f,0xfe,0xe7,0x7f,0xfe,0xe7,0x1f,0xe0,0xe1,0xe1,
|
||||
0x07,0xf8,0x00,0xe0,0x01,0x78,0xf8,0x87,0x0f,0xf0,0x3f,0x3c,0x1c,0x7e,0xe0,
|
||||
0xff,0x9f,0xff,0xff,0x07,0xff,0xe7,0x7f,0xfe,0xe7,0x1f,0xfe,0xe7,0x7f,0xfe,
|
||||
0xe7,0x03,0xe0,0xe1,0xe1,0x00,0xf8,0x00,0xe0,0x01,0x78,0xf8,0x87,0x01,0xf0,
|
||||
0x3f,0x3c,0x1c,0x1e,0xe0,0xff,0xcf,0xff,0xff,0x07,0xff,0x03,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0xf0,0xe1,0xff,0xf0,0x70,0xf8,0xff,0x0f,0xff,0xf0,
|
||||
0x3f,0xf0,0xc0,0xf0,0xff,0x1f,0x1e,0x0c,0x0f,0xff,0xff,0xcf,0xff,0xff,0x07,
|
||||
0xff,0xf3,0x3f,0xff,0xf3,0x0f,0xff,0xf3,0x3f,0xff,0xf3,0xf0,0xff,0xf0,0x30,
|
||||
0xfc,0xff,0x0f,0xff,0xf0,0x3f,0x30,0x40,0xf8,0xff,0x1f,0x1e,0x0c,0x87,0xff,
|
||||
0xff,0xe7,0xff,0xff,0x07,0xff,0xf9,0x9f,0xff,0xf9,0x87,0xff,0xf9,0x9f,0xff,
|
||||
0x79,0xf8,0x7f,0x78,0x18,0xfe,0xff,0x87,0x7f,0xf8,0x1f,0x00,0x20,0xfc,0xff,
|
||||
0x0f,0x0f,0x84,0xc3,0xff,0xff,0xe7,0xff,0xff,0x07,0xff,0xf9,0x9f,0xff,0xf9,
|
||||
0x87,0xff,0xf9,0x9f,0xff,0xf9,0xf0,0x7f,0x78,0x38,0xfc,0xff,0x87,0x7f,0xf8,
|
||||
0x1f,0x06,0x20,0xfc,0xff,0x0f,0x0f,0x84,0xc3,0xff,0xff,0xf3,0xff,0xff,0x07,
|
||||
0xff,0xfc,0xcf,0xff,0xfc,0xc3,0xff,0xfc,0xcf,0xff,0xfc,0x01,0x7e,0x00,0x7c,
|
||||
0x80,0xff,0xc3,0x3f,0x80,0x0f,0xc7,0x70,0x00,0xff,0x87,0x07,0xc0,0xe1,0xff,
|
||||
0xff,0xf3,0xff,0xff,0x07,0xff,0xfc,0xcf,0xff,0xfc,0xc3,0xff,0xfc,0xcf,0xff,
|
||||
0xfc,0x0f,0x78,0x00,0xff,0x03,0xfe,0xc3,0x3f,0x80,0x0f,0xff,0xf0,0x03,0xfc,
|
||||
0x87,0x07,0xc0,0xe1,0xff,0xff,0xf9,0xff,0xff,0x07,0x7f,0xfe,0xe7,0x7f,0xfe,
|
||||
0xe1,0x7f,0xfe,0xe7,0x7f,0xfe,0xff,0xf0,0xe1,0xff,0x3f,0xfc,0xe1,0x1f,0xfe,
|
||||
0x87,0x7f,0xf8,0x7f,0xf8,0xc3,0x03,0xe0,0xf0,0xff,0xff,0xf9,0xff,0xff,0x07,
|
||||
0x7f,0xfe,0xe7,0x7f,0xfe,0xe1,0x7f,0xfe,0xe7,0x7f,0xfe,0xff,0xf0,0xe1,0xff,
|
||||
0x3f,0xfc,0xe1,0x1f,0xfe,0x87,0x7f,0xf8,0x7f,0xf8,0xc3,0x43,0xe0,0xf0,0xff,
|
||||
0xff,0xfc,0xff,0xff,0x07,0x3f,0xff,0xf3,0x3f,0xff,0xf0,0x3f,0xff,0xf3,0x3f,
|
||||
0xff,0x7f,0xf8,0xf0,0xff,0x1f,0xfe,0xf0,0x0f,0xff,0xc3,0x3f,0xfc,0x3f,0xfc,
|
||||
0xe1,0x61,0x70,0xf8,0xff,0xff,0xfc,0xff,0xff,0x07,0x3f,0xff,0xf3,0x3f,0xff,
|
||||
0xf0,0x3f,0xff,0xf3,0x3f,0xff,0x3f,0xfc,0xf0,0xff,0x0f,0xff,0xf0,0x0f,0xff,
|
||||
0xc3,0x3f,0xfc,0x1f,0xfe,0xe1,0x61,0x70,0xf8,0xff,0x7f,0xfe,0xff,0xff,0x07,
|
||||
0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x7f,0x00,0x7e,0xf8,0x1f,
|
||||
0x80,0x7f,0xf8,0x07,0xe0,0xe1,0x1f,0x3e,0x00,0xff,0xf0,0x70,0xf8,0x80,0xe7,
|
||||
0x7f,0xfe,0xff,0xff,0x07,0x9f,0xff,0xf9,0x9f,0x01,0x00,0x9c,0xff,0xf9,0x9f,
|
||||
0x7f,0xc0,0x7f,0xf8,0x1f,0xe0,0x7f,0xf8,0x07,0xe0,0xe1,0x1f,0x3e,0xc0,0xff,
|
||||
0xf0,0x70,0xf8,0x81,0xe7,0x3f,0xff,0xff,0xff,0x07,0xcf,0xff,0xfc,0xcf,0x03,
|
||||
0x00,0xce,0xff,0xfc,0xcf,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0xff,0xff,0xff,0x07,
|
||||
0xcf,0xff,0xfc,0xcf,0x03,0x80,0xcf,0xff,0xfc,0xcf,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0x9f,0xff,0xff,0xff,0x07,0xe7,0x7f,0xfe,0xe7,0x07,0xc0,0xe7,0x7f,0xfe,0xe7,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0x9f,0xff,0xff,0xff,0x07,0xe7,0x7f,0xfe,0xe7,0x07,
|
||||
0xf0,0xe7,0x7f,0xfe,0xe7,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xcf,0xff,0xff,0xff,0x07,
|
||||
0xf3,0x3f,0xff,0xf3,0x07,0xf8,0xf3,0x3f,0xff,0xf3,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xcf,0xff,0xff,0xff,0x07,0xf3,0x3f,0xff,0xf3,0x0f,0xfe,0xf3,0x3f,0xff,0xf3,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff,0x07,0xf9,0x9f,0xff,0xf9,0x8f,
|
||||
0xff,0xf9,0x9f,0xff,0xf9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff,0x07,
|
||||
0xf9,0x9f,0xff,0xf9,0xcf,0xff,0xf9,0x9f,0xff,0xf9,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xf3,0xff,0xff,0xff,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0xf0,0xff,0xff,0xff,0x07,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x07,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
|
||||
0xff,0xff,0xff,0xff,0x07};
|
||||
98
engines/ultima/ultima1/u1gfx/sprites.cpp
Normal file
98
engines/ultima/ultima1/u1gfx/sprites.cpp
Normal file
@@ -0,0 +1,98 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1gfx/sprites.h"
|
||||
#include "ultima/shared/early/ultima_early.h"
|
||||
#include "ultima/shared/early/game.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Sprites, Shared::TreeItem)
|
||||
ON_MESSAGE(FrameMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
#define ANIMATE_FRAME_DELAY 200
|
||||
|
||||
void Sprites::load(bool isOverworld) {
|
||||
_isOverworld = isOverworld;
|
||||
|
||||
if (isOverworld)
|
||||
Shared::Gfx::Sprites::load("t1ktiles.bin", 4);
|
||||
else
|
||||
Shared::Gfx::Sprites::load("t1ktown.bin", 4, 8, 8);
|
||||
}
|
||||
|
||||
bool Sprites::FrameMsg(CFrameMsg *msg) {
|
||||
if (!empty() && _isOverworld) {
|
||||
animateWater();
|
||||
}
|
||||
|
||||
++_frameCtr;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Sprites::animateWater() {
|
||||
byte lineBuffer[16];
|
||||
Shared::Gfx::Sprite &sprite = (*this)[0];
|
||||
|
||||
Common::copy(sprite.getBasePtr(0, 15), sprite.getBasePtr(0, 16), lineBuffer);
|
||||
Common::copy_backward(sprite.getBasePtr(0, 0), sprite.getBasePtr(0, 15), sprite.getBasePtr(0, 16));
|
||||
Common::copy(lineBuffer, lineBuffer + 16, sprite.getBasePtr(0, 0));
|
||||
}
|
||||
|
||||
Shared::Gfx::Sprite &Sprites::operator[](uint idx) {
|
||||
int offset = 2;
|
||||
if ((_frameCtr % 6) == 0)
|
||||
offset = 0;
|
||||
else if ((_frameCtr % 3) == 0)
|
||||
offset = 1;
|
||||
|
||||
if (!_isOverworld) {
|
||||
// Don't do overworld tile animations within the cities and castles
|
||||
return Shared::Gfx::Sprites::operator[](idx);
|
||||
} else if (idx == 4 && offset != 2) {
|
||||
// Castle flag waving
|
||||
return Shared::Gfx::Sprites::operator[](4 + offset);
|
||||
} else if (idx == 6) {
|
||||
// City flag waving
|
||||
return Shared::Gfx::Sprites::operator[](7 + ((_frameCtr & 3) ? 1 : 0));
|
||||
} else {
|
||||
if (idx >= 7 && idx < 50)
|
||||
idx += 2;
|
||||
|
||||
if (idx == 14 || idx == 25) {
|
||||
// Transports
|
||||
return Shared::Gfx::Sprites::operator[](idx + (_frameCtr & 1));
|
||||
} else if (idx >= 19 && idx <= 47) {
|
||||
// Random monster animation
|
||||
return Shared::Gfx::Sprites::operator[](idx + (g_vm->getRandomNumber(1, 100) & 1));
|
||||
} else {
|
||||
return Shared::Gfx::Sprites::operator[](idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
80
engines/ultima/ultima1/u1gfx/sprites.h
Normal file
80
engines/ultima/ultima1/u1gfx/sprites.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1GFX_SPRITES_H
|
||||
#define ULTIMA_ULTIMA1_U1GFX_SPRITES_H
|
||||
|
||||
#include "ultima/shared/gfx/sprites.h"
|
||||
#include "ultima/shared/core/tree_item.h"
|
||||
#include "ultima/shared/early/ultima_early.h"
|
||||
#include "ultima/shared/engine/messages.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
using Shared::CFrameMsg;
|
||||
|
||||
/**
|
||||
* Displays the total hits, food, experience, and coins you have
|
||||
*/
|
||||
class Sprites : public Shared::Gfx::Sprites, public Shared::TreeItem {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool FrameMsg(CFrameMsg *msg);
|
||||
private:
|
||||
bool _isOverworld;
|
||||
uint _frameCtr;
|
||||
private:
|
||||
/**
|
||||
* Animates the water sprite by rotating it's lines vertically
|
||||
*/
|
||||
void animateWater();
|
||||
public:
|
||||
CLASSDEF;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Sprites(TreeItem *parent) : Shared::Gfx::Sprites(), TreeItem(), _isOverworld(false), _frameCtr(0) {
|
||||
addUnder(parent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~Sprites() override {}
|
||||
|
||||
/**
|
||||
* Return a specific sprite
|
||||
*/
|
||||
Shared::Gfx::Sprite &operator[](uint idx) override;
|
||||
|
||||
/**
|
||||
* Loads the Ultima 1 sprites
|
||||
*/
|
||||
void load(bool isOverworld);
|
||||
};
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
80
engines/ultima/ultima1/u1gfx/status.cpp
Normal file
80
engines/ultima/ultima1/u1gfx/status.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1gfx/status.h"
|
||||
#include "ultima/ultima1/game.h"
|
||||
#include "ultima/ultima1/core/resources.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
BEGIN_MESSAGE_MAP(Status, Shared::Gfx::VisualItem)
|
||||
ON_MESSAGE(FrameMsg)
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
Status::Status(Shared::TreeItem *parent) : Shared::Gfx::VisualItem("Status", TextRect(31, 21, 39, 24), parent),
|
||||
_hitPoints(0), _food(0), _experience(0), _coins(0) {
|
||||
}
|
||||
|
||||
bool Status::FrameMsg(CFrameMsg *msg) {
|
||||
// If any of the figures have changed, mark the display as dirty
|
||||
const Ultima1Game *game = static_cast<const Ultima1Game *>(getGame());
|
||||
const Shared::Character &c = *game->_party;
|
||||
|
||||
if (c._hitPoints != _hitPoints || c._food != _food || c._experience != _experience || c._coins != _coins)
|
||||
setDirty(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Status::draw() {
|
||||
Ultima1Game *game = static_cast<Ultima1Game *>(getGame());
|
||||
const Shared::Character &c = *game->_party;
|
||||
|
||||
// Update the local copy of the fields
|
||||
_hitPoints = c._hitPoints;
|
||||
_food = c._food;
|
||||
_experience = c._experience;
|
||||
_coins = c._coins;
|
||||
|
||||
// Clear the status area
|
||||
Shared::Gfx::VisualSurface s = getSurface();
|
||||
s.clear();
|
||||
|
||||
// Iterate through displaying the values
|
||||
const uint *vals[4] = { &_hitPoints, &_food, &_experience, &_coins };
|
||||
int count = game->isVGA() ? 3 : 4;
|
||||
|
||||
for (int idx = 0; idx < count; ++idx) {
|
||||
// Write header
|
||||
s.writeString(game->_res->STATUS_TEXT[idx], TextPoint(0, idx));
|
||||
|
||||
uint value = MIN(*vals[idx], (uint)9999);
|
||||
s.writeString(Common::String::format("%4u", value), TextPoint(5, idx));
|
||||
}
|
||||
|
||||
_isDirty = false;
|
||||
}
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
57
engines/ultima/ultima1/u1gfx/status.h
Normal file
57
engines/ultima/ultima1/u1gfx/status.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1GFX_STATUS_H
|
||||
#define ULTIMA_ULTIMA1_U1GFX_STATUS_H
|
||||
|
||||
#include "ultima/shared/gfx/visual_item.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
using Shared::CFrameMsg;
|
||||
|
||||
/**
|
||||
* Displays the total hits, food, experience, and coins you have
|
||||
*/
|
||||
class Status : public Shared::Gfx::VisualItem {
|
||||
DECLARE_MESSAGE_MAP;
|
||||
bool FrameMsg(CFrameMsg *msg);
|
||||
private:
|
||||
uint _hitPoints, _food, _experience, _coins;
|
||||
private:
|
||||
public:
|
||||
CLASSDEF;
|
||||
Status(TreeItem *parent);
|
||||
~Status() override {}
|
||||
|
||||
/**
|
||||
* Draw the contents
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
86
engines/ultima/ultima1/u1gfx/text_cursor.cpp
Normal file
86
engines/ultima/ultima1/u1gfx/text_cursor.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ultima/ultima1/u1gfx/text_cursor.h"
|
||||
#include "ultima/shared/early/ultima_early.h"
|
||||
#include "ultima/shared/gfx/screen.h"
|
||||
#include "common/system.h"
|
||||
#include "graphics/managed_surface.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
#define CURSOR_ANIM_FRAME_TIME 100
|
||||
#define CURSOR_W 8
|
||||
#define CURSOR_H 8
|
||||
|
||||
static const byte TEXT_CURSOR_FRAMES[4][8] = {
|
||||
{ 0x66, 0x3C, 0x18, 0x66, 0x66, 0x18, 0x3C, 0x66 },
|
||||
{ 0x3C, 0x18, 0x66, 0x24, 0x24, 0x66, 0x18, 0x3C },
|
||||
{ 0x18, 0x66, 0x24, 0x3C, 0x3C, 0x24, 0x66, 0x18 },
|
||||
{ 0x66, 0x24, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x66 }
|
||||
};
|
||||
|
||||
U1TextCursor::U1TextCursor(const byte &fgColor, const byte &bgColor) : _fgColor(fgColor),
|
||||
_bgColor(bgColor), _frameNum(0), _lastFrameFrame(0) {
|
||||
_bounds = Common::Rect(0, 0, 8, 8);
|
||||
}
|
||||
|
||||
void U1TextCursor::update() {
|
||||
uint32 time = getTime();
|
||||
if (!_visible || !_fgColor || (time - _lastFrameFrame) < CURSOR_ANIM_FRAME_TIME)
|
||||
return;
|
||||
|
||||
// Increment to next frame
|
||||
_lastFrameFrame = time;
|
||||
_frameNum = (_frameNum + 1) % 3;
|
||||
|
||||
markAsDirty();
|
||||
}
|
||||
|
||||
void U1TextCursor::draw() {
|
||||
if (!_visible)
|
||||
return;
|
||||
|
||||
// Get the surface area to draw the cursor on
|
||||
Graphics::ManagedSurface s(8, 8);
|
||||
|
||||
// Loop to draw the cursor
|
||||
for (int y = 0; y < CURSOR_H; ++y) {
|
||||
byte *lineP = (byte *)s.getBasePtr(0, y);
|
||||
byte bits = TEXT_CURSOR_FRAMES[_frameNum][y];
|
||||
|
||||
for (int x = 0; x < CURSOR_W; ++x, ++lineP, bits >>= 1) {
|
||||
*lineP = (bits & 1) ? _fgColor : _bgColor;
|
||||
}
|
||||
}
|
||||
|
||||
g_system->copyRectToScreen(s.getPixels(), s.pitch, _bounds.left, _bounds.top, _bounds.width(), _bounds.height());
|
||||
}
|
||||
|
||||
uint32 U1TextCursor::getTime() {
|
||||
return g_system->getMillis();
|
||||
}
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
67
engines/ultima/ultima1/u1gfx/text_cursor.h
Normal file
67
engines/ultima/ultima1/u1gfx/text_cursor.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* ScummVM - Graphic Adventure Engine
|
||||
*
|
||||
* ScummVM is the legal property of its developers, whose names
|
||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
||||
* file distributed with this source distribution.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ULTIMA_ULTIMA1_U1GFX_TEXT_CURSOR_H
|
||||
#define ULTIMA_ULTIMA1_U1GFX_TEXT_CURSOR_H
|
||||
|
||||
#include "ultima/shared/gfx/text_cursor.h"
|
||||
|
||||
namespace Ultima {
|
||||
namespace Ultima1 {
|
||||
namespace U1Gfx {
|
||||
|
||||
class U1TextCursor : public Shared::Gfx::TextCursor {
|
||||
private:
|
||||
const byte &_fgColor, &_bgColor;
|
||||
int _frameNum;
|
||||
uint32 _lastFrameFrame;
|
||||
private:
|
||||
/**
|
||||
* Get the current game milliseconds
|
||||
*/
|
||||
uint32 getTime();
|
||||
public:
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
U1TextCursor(const byte &fgColor, const byte &bgColor);
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
~U1TextCursor() override {}
|
||||
|
||||
/**
|
||||
* Update the cursor
|
||||
*/
|
||||
void update() override;
|
||||
|
||||
/**
|
||||
* Draw the cursor
|
||||
*/
|
||||
void draw() override;
|
||||
};
|
||||
|
||||
} // End of namespace U1Gfx
|
||||
} // End of namespace Ultima1
|
||||
} // End of namespace Ultima
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user