some rework
This commit is contained in:
parent
ded2133e7c
commit
88f36b0455
|
@ -45,7 +45,7 @@ public:
|
||||||
void setSkull(uint8 skull) { m_skull = skull; }
|
void setSkull(uint8 skull) { m_skull = skull; }
|
||||||
void setShield(uint8 shield) { m_shield = shield; }
|
void setShield(uint8 shield) { m_shield = shield; }
|
||||||
void setEmblem(uint8 emblem) { m_emblem = emblem; }
|
void setEmblem(uint8 emblem) { m_emblem = emblem; }
|
||||||
void setImpassable(bool impassable) { m_impassable = impassable; }
|
void setPassable(bool passable) { m_passable = passable; }
|
||||||
void setSquareColor(uint8 squareColor) { m_squareColor = squareColor; }
|
void setSquareColor(uint8 squareColor) { m_squareColor = squareColor; }
|
||||||
|
|
||||||
std::string getName() { return m_name; }
|
std::string getName() { return m_name; }
|
||||||
|
@ -57,7 +57,7 @@ public:
|
||||||
uint8 getSkull() { return m_skull; }
|
uint8 getSkull() { return m_skull; }
|
||||||
uint8 getShield() { return m_shield; }
|
uint8 getShield() { return m_shield; }
|
||||||
uint8 getEmblem() { return m_emblem; }
|
uint8 getEmblem() { return m_emblem; }
|
||||||
bool getImpassable() { return m_impassable; }
|
bool getPassable() { return m_passable; }
|
||||||
ThingType *getType();
|
ThingType *getType();
|
||||||
|
|
||||||
virtual void walk(const Position& position, bool inverse = true);
|
virtual void walk(const Position& position, bool inverse = true);
|
||||||
|
@ -82,7 +82,7 @@ protected:
|
||||||
uint8 m_skull;
|
uint8 m_skull;
|
||||||
uint8 m_shield;
|
uint8 m_shield;
|
||||||
uint8 m_emblem;
|
uint8 m_emblem;
|
||||||
bool m_impassable;
|
bool m_passable;
|
||||||
uint8 m_squareColor;
|
uint8 m_squareColor;
|
||||||
bool m_showSquareColor;
|
bool m_showSquareColor;
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ void Effect::start()
|
||||||
|
|
||||||
// schedule removal
|
// schedule removal
|
||||||
g_dispatcher.scheduleEvent([self]() {
|
g_dispatcher.scheduleEvent([self]() {
|
||||||
g_map.getTile(self->getPosition())->removeEffect(self);
|
g_map.removeThing(self);
|
||||||
}, TICKS_PER_FRAME * getAnimationPhases());
|
}, TICKS_PER_FRAME * getAnimationPhases());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,9 +245,6 @@ void Map::addThing(const ThingPtr& thing, const Position& pos, int stackPos)
|
||||||
tile->addThing(thing, stackPos);
|
tile->addThing(thing, stackPos);
|
||||||
m_creatures[creature->getId()] = creature;
|
m_creatures[creature->getId()] = creature;
|
||||||
}
|
}
|
||||||
else if(EffectPtr effect = thing->asEffect()) {
|
|
||||||
tile->addEffect(effect);
|
|
||||||
}
|
|
||||||
else if(MissilePtr shot = thing->asMissile()) {
|
else if(MissilePtr shot = thing->asMissile()) {
|
||||||
m_missilesAtFloor[shot->getPosition().z].push_back(shot);
|
m_missilesAtFloor[shot->getPosition().z].push_back(shot);
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,25 +98,16 @@ void Tile::clean()
|
||||||
m_effects.clear();
|
m_effects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Tile::addEffect(const EffectPtr& effect)
|
|
||||||
{
|
|
||||||
m_effects.push_back(effect);
|
|
||||||
effect->setPosition(m_position);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Tile::removeEffect(const EffectPtr& effect)
|
|
||||||
{
|
|
||||||
auto it = std::find(m_effects.begin(), m_effects.end(), effect);
|
|
||||||
if(it != m_effects.end()) {
|
|
||||||
m_effects.erase(it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
ThingPtr Tile::addThing(const ThingPtr& thing, int stackPos)
|
||||||
{
|
{
|
||||||
if(!thing)
|
if(!thing)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
if(EffectPtr effect = thing->asEffect()) {
|
||||||
|
m_effects.push_back(effect);
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
if(stackPos < 0) {
|
if(stackPos < 0) {
|
||||||
stackPos = 0;
|
stackPos = 0;
|
||||||
int priority = thing->getStackPriority();
|
int priority = thing->getStackPriority();
|
||||||
|
@ -154,6 +145,12 @@ ThingPtr Tile::removeThing(int stackPos)
|
||||||
|
|
||||||
ThingPtr Tile::removeThing(const ThingPtr& thing)
|
ThingPtr Tile::removeThing(const ThingPtr& thing)
|
||||||
{
|
{
|
||||||
|
if(EffectPtr effect = thing->asEffect()) {
|
||||||
|
auto it = std::find(m_effects.begin(), m_effects.end(), effect);
|
||||||
|
if(it != m_effects.end())
|
||||||
|
m_effects.erase(it);
|
||||||
|
return thing;
|
||||||
|
}
|
||||||
ThingPtr oldObject;
|
ThingPtr oldObject;
|
||||||
auto it = std::find(m_things.begin(), m_things.end(), thing);
|
auto it = std::find(m_things.begin(), m_things.end(), thing);
|
||||||
if(it != m_things.end()) {
|
if(it != m_things.end()) {
|
||||||
|
@ -193,6 +190,11 @@ bool Tile::isWalkable()
|
||||||
ThingType *type = thing->getType();
|
ThingType *type = thing->getType();
|
||||||
if(type->properties[ThingType::NotWalkable])
|
if(type->properties[ThingType::NotWalkable])
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if(CreaturePtr creature = thing->asCreature()) {
|
||||||
|
if(!creature->getPassable())
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -229,13 +231,78 @@ bool Tile::isLookPossible()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Tile::hasCreature()
|
||||||
|
{
|
||||||
|
for(const ThingPtr& thing : m_things)
|
||||||
|
if(thing->asCreature())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*bool Tile::canAttack()
|
||||||
|
{
|
||||||
|
return hasCreature();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Tile::canFollow()
|
||||||
|
{
|
||||||
|
return hasCreature();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Tile::canCopyName()
|
||||||
|
{
|
||||||
|
return hasCreature();
|
||||||
|
}*/
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
/*
|
/*
|
||||||
|
|
||||||
|
//Ranges for ID Creatures
|
||||||
|
#define PLAYER_ID_RANGE 0x10000000
|
||||||
|
#define MONSTER_ID_RANGE 0x40000000
|
||||||
|
#define NPC_ID_RANGE 0x80000000
|
||||||
|
|
||||||
Get menu options
|
Get menu options
|
||||||
|
|
||||||
if invited to party
|
|
||||||
if creature, attack and follow
|
if creature:
|
||||||
if item, use or use with
|
Look
|
||||||
|
-----
|
||||||
|
Attack
|
||||||
|
Follow
|
||||||
|
-----
|
||||||
|
Copy Name
|
||||||
|
|
||||||
|
if item:
|
||||||
|
Look
|
||||||
|
Use (if not container)
|
||||||
|
Open (if container)
|
||||||
|
Use with ... (if multiuse?)
|
||||||
|
Rotate (if rotable)
|
||||||
|
-----
|
||||||
|
Trade with ... (if pickupable?)
|
||||||
|
|
||||||
|
if player:
|
||||||
|
Look
|
||||||
|
-----
|
||||||
|
Attack
|
||||||
|
Follow
|
||||||
|
-----
|
||||||
|
Message to NAME
|
||||||
|
Add to VIP list
|
||||||
|
Ignore NAME
|
||||||
|
Invite to Party
|
||||||
|
-----
|
||||||
|
Report Offense
|
||||||
|
-----
|
||||||
|
Copy Name
|
||||||
|
|
||||||
|
if localplayer:
|
||||||
|
Look
|
||||||
|
-----
|
||||||
|
Set Outfit
|
||||||
|
-----
|
||||||
|
Copy Name
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Tile::useItem()
|
void Tile::useItem()
|
||||||
|
|
|
@ -37,8 +37,6 @@ public:
|
||||||
void draw(const Point& p);
|
void draw(const Point& p);
|
||||||
void clean();
|
void clean();
|
||||||
|
|
||||||
void addEffect(const EffectPtr& effect);
|
|
||||||
void removeEffect(const EffectPtr& effect);
|
|
||||||
ThingPtr addThing(const ThingPtr& thing, int stackPos = -1);
|
ThingPtr addThing(const ThingPtr& thing, int stackPos = -1);
|
||||||
ThingPtr getThing(int stackPos);
|
ThingPtr getThing(int stackPos);
|
||||||
ThingPtr removeThing(int stackPos);
|
ThingPtr removeThing(int stackPos);
|
||||||
|
@ -52,13 +50,14 @@ public:
|
||||||
bool isFullGround();
|
bool isFullGround();
|
||||||
bool isFullyOpaque();
|
bool isFullyOpaque();
|
||||||
bool isLookPossible();
|
bool isLookPossible();
|
||||||
|
bool hasCreature();
|
||||||
|
|
||||||
void useItem();
|
void useItem();
|
||||||
|
|
||||||
TilePtr asTile() { return std::static_pointer_cast<Tile>(shared_from_this()); }
|
TilePtr asTile() { return std::static_pointer_cast<Tile>(shared_from_this()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<EffectPtr> m_effects;
|
std::vector<EffectPtr> m_effects; // Leave this outside m_things because it has no stackpos.
|
||||||
std::vector<ThingPtr> m_things;
|
std::vector<ThingPtr> m_things;
|
||||||
Position m_position;
|
Position m_position;
|
||||||
int m_drawElevation;
|
int m_drawElevation;
|
||||||
|
|
|
@ -847,8 +847,6 @@ void ProtocolGame::parseCancelWalk(InputMessage& msg)
|
||||||
|
|
||||||
void ProtocolGame::parseFloorChangeUp(InputMessage& msg)
|
void ProtocolGame::parseFloorChangeUp(InputMessage& msg)
|
||||||
{
|
{
|
||||||
logTraceDebug("this function has never been tested.");
|
|
||||||
|
|
||||||
Position pos = g_map.getCentralPosition();
|
Position pos = g_map.getCentralPosition();
|
||||||
pos.z--;
|
pos.z--;
|
||||||
|
|
||||||
|
@ -866,8 +864,6 @@ void ProtocolGame::parseFloorChangeUp(InputMessage& msg)
|
||||||
|
|
||||||
void ProtocolGame::parseFloorChangeDown(InputMessage& msg)
|
void ProtocolGame::parseFloorChangeDown(InputMessage& msg)
|
||||||
{
|
{
|
||||||
logTraceDebug("this function has never been tested.");
|
|
||||||
|
|
||||||
Position pos = g_map.getCentralPosition();
|
Position pos = g_map.getCentralPosition();
|
||||||
pos.z++;
|
pos.z++;
|
||||||
|
|
||||||
|
@ -1108,7 +1104,7 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg)
|
||||||
if(thingId == 0x0061) // emblem is sent only in packet type 0x61
|
if(thingId == 0x0061) // emblem is sent only in packet type 0x61
|
||||||
emblem = msg.getU8();
|
emblem = msg.getU8();
|
||||||
|
|
||||||
bool impassable = (msg.getU8() == 0); // impassable
|
bool passable = (msg.getU8() == 0);
|
||||||
|
|
||||||
creature->setHealthPercent(healthPercent);
|
creature->setHealthPercent(healthPercent);
|
||||||
creature->setDirection(direction);
|
creature->setDirection(direction);
|
||||||
|
@ -1118,7 +1114,7 @@ ThingPtr ProtocolGame::internalGetThing(InputMessage& msg)
|
||||||
creature->setSkull(skull);
|
creature->setSkull(skull);
|
||||||
creature->setShield(shield);
|
creature->setShield(shield);
|
||||||
creature->setEmblem(emblem);
|
creature->setEmblem(emblem);
|
||||||
creature->setImpassable(impassable);
|
creature->setPassable(passable);
|
||||||
creature->cancelWalk(direction);
|
creature->cancelWalk(direction);
|
||||||
|
|
||||||
thing = creature;
|
thing = creature;
|
||||||
|
|
|
@ -88,9 +88,7 @@ bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
||||||
else if(button == Fw::MouseRightButton) {
|
else if(button == Fw::MouseRightButton) {
|
||||||
EffectPtr effect = EffectPtr(new Effect());
|
EffectPtr effect = EffectPtr(new Effect());
|
||||||
effect->setId(6);
|
effect->setId(6);
|
||||||
effect->start();
|
g_map.addThing(effect, tilePos);
|
||||||
if(tile)
|
|
||||||
tile->addEffect(effect);
|
|
||||||
|
|
||||||
AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
|
AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
|
||||||
animatedText->setPosition(g_map.getCentralPosition());
|
animatedText->setPosition(g_map.getCentralPosition());
|
||||||
|
|
Loading…
Reference in New Issue