ULTIMA1: Implemented Create spell

This commit is contained in:
Paul Gilbert 2020-01-19 19:48:04 -08:00 committed by Paul Gilbert
parent 88df29f4cd
commit 2d3c237857
4 changed files with 33 additions and 2 deletions

View File

@ -86,6 +86,14 @@ public:
return _mapArea->getTileAt(pt, tile, includePlayer);
}
/**
* Sets a tile at a given position
*/
void setTileAt(const Point &pt, uint tileId) {
assert(_mapArea);
return _mapArea->setTileAt(pt, tileId);
}
/**
* Get the viewport position
*/

View File

@ -181,6 +181,10 @@ void MapBase::getTileAt(const Point &pt, MapTile *tile, bool includePlayer) {
}
}
void MapBase::setTileAt(const Point &pt, uint tileId) {
_data[pt.y][pt.x] = tileId;
}
void MapBase::update() {
// Call the update method of each widget, to allow for things like npc movement, etc.
for (uint idx = 0; idx < _widgets.size(); ++idx)

View File

@ -114,6 +114,7 @@ protected:
uint _mapIndex; // Index of map within the group of same maps
uint _mapStyle; // Map style category for towns & castles
ViewportPosition _viewportPos; // Viewport position
Common::Array<MapCellsRow> _data; // Data for the map
protected:
/**
* Set the size of the map
@ -133,7 +134,6 @@ public:
Common::String _name; // Name of map, if applicable
MapWidget *_playerWidget; // Current means of transport, even if on foot
WidgetsArray _widgets; // Party, monsteres, transports, etc.
Common::Array<MapCellsRow> _data; // Data for the map
public:
/**
* Constructor
@ -171,6 +171,11 @@ public:
*/
virtual void getTileAt(const Point &pt, MapTile *tile, bool includePlayer = true);
/**
* Sets a tile at a given position
*/
virtual void setTileAt(const Point &pt, uint tileId);
/**
* Resets the viewport when the viewport changes
*/

View File

@ -23,6 +23,8 @@
#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 {
@ -32,7 +34,19 @@ Create::Create() : Spell(SPELL_CREATE) {
}
void Create::dungeonCast(Maps::MapDungeon *map) {
// TODO
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);
} else {
// Failed
Spell::dungeonCast(map);
}
}
} // End of namespace Spells