mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
- Set fixed boat type for Tavern / Prison
- Move magical boat offset to static function
This commit is contained in:
parent
f1356dd5bf
commit
adec58f5bf
@ -102,17 +102,6 @@ std::string CHero::getSpecialtyTooltipTextID() const
|
|||||||
return TextIdentifier("hero", modScope, identifier, "specialty", "tooltip").get();
|
return TextIdentifier("hero", modScope, identifier, "specialty", "tooltip").get();
|
||||||
}
|
}
|
||||||
|
|
||||||
BoatId CHero::getBoatType() const
|
|
||||||
{
|
|
||||||
switch(heroClass->getAlignment())
|
|
||||||
{
|
|
||||||
case EAlignment::EVIL : return EBoatId::BOAT_EVIL;
|
|
||||||
case EAlignment::GOOD : return EBoatId::BOAT_GOOD;
|
|
||||||
case EAlignment::NEUTRAL : return EBoatId::BOAT_NEUTRAL;
|
|
||||||
default: return EBoatId::NONE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CHero::registerIcons(const IconRegistar & cb) const
|
void CHero::registerIcons(const IconRegistar & cb) const
|
||||||
{
|
{
|
||||||
cb(getIconIndex(), 0, "UN32", iconSpecSmall);
|
cb(getIconIndex(), 0, "UN32", iconSpecSmall);
|
||||||
|
@ -99,8 +99,6 @@ public:
|
|||||||
std::string getSpecialtyDescriptionTextID() const override;
|
std::string getSpecialtyDescriptionTextID() const override;
|
||||||
std::string getSpecialtyTooltipTextID() const override;
|
std::string getSpecialtyTooltipTextID() const override;
|
||||||
|
|
||||||
BoatId getBoatType() const;
|
|
||||||
|
|
||||||
void updateFrom(const JsonNode & data);
|
void updateFrom(const JsonNode & data);
|
||||||
void serializeJson(JsonSerializeFormat & handler);
|
void serializeJson(JsonSerializeFormat & handler);
|
||||||
|
|
||||||
|
@ -1497,7 +1497,7 @@ void NewObject::applyGs(CGameState *gs)
|
|||||||
testObject.pos = pos;
|
testObject.pos = pos;
|
||||||
testObject.appearance = VLC->objtypeh->getHandlerFor(ID, subID)->getTemplates(ETerrainId::WATER).front();
|
testObject.appearance = VLC->objtypeh->getHandlerFor(ID, subID)->getTemplates(ETerrainId::WATER).front();
|
||||||
|
|
||||||
[[maybe_unused]] const int3 previousXAxisTile = int3(pos.x - 1, pos.y, pos.z);
|
[[maybe_unused]] const int3 previousXAxisTile = CGBoat::translatePos(pos, true);
|
||||||
assert(gs->isInTheMap(previousXAxisTile) && (testObject.visitablePos() == previousXAxisTile));
|
assert(gs->isInTheMap(previousXAxisTile) && (testObject.visitablePos() == previousXAxisTile));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -446,19 +446,19 @@ void CGHeroInstance::onHeroVisit(const CGHeroInstance * h) const
|
|||||||
cb->setManaPoints (id, manaLimit());
|
cb->setManaPoints (id, manaLimit());
|
||||||
|
|
||||||
ObjectInstanceID boatId;
|
ObjectInstanceID boatId;
|
||||||
if (cb->gameState()->map->getTile(pos).isWater())
|
const auto boatPos = visitablePos();
|
||||||
|
if (cb->gameState()->map->getTile(boatPos).isWater())
|
||||||
{
|
{
|
||||||
smp.val = maxMovePoints(false);
|
smp.val = maxMovePoints(false);
|
||||||
//Create a new boat for hero
|
//Create a new boat for hero
|
||||||
NewObject no;
|
NewObject no;
|
||||||
no.ID = Obj::BOAT;
|
no.ID = Obj::BOAT;
|
||||||
no.subID = getBoatType().getNum();
|
no.subID = BoatId(EBoatId::BOAT_NEUTRAL);
|
||||||
no.pos = pos + int3(1,0,0); //FIXME: handle this magic offset somehow
|
no.pos = CGBoat::translatePos(boatPos);
|
||||||
|
|
||||||
cb->sendAndApply(&no);
|
cb->sendAndApply(&no);
|
||||||
|
|
||||||
cb->getVisitableObjs(pos);
|
boatId = cb->getTopObj(boatPos)->id;
|
||||||
boatId = cb->getTopObj(pos)->id;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -954,7 +954,13 @@ si32 CGHeroInstance::getManaNewTurn() const
|
|||||||
|
|
||||||
BoatId CGHeroInstance::getBoatType() const
|
BoatId CGHeroInstance::getBoatType() const
|
||||||
{
|
{
|
||||||
return type->getBoatType();
|
switch (type->heroClass->getAlignment())
|
||||||
|
{
|
||||||
|
case EAlignment::EVIL: return EBoatId::BOAT_EVIL;
|
||||||
|
case EAlignment::GOOD: return EBoatId::BOAT_GOOD;
|
||||||
|
case EAlignment::NEUTRAL: return EBoatId::BOAT_NEUTRAL;
|
||||||
|
default: return EBoatId::NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGHeroInstance::getOutOffsets(std::vector<int3> &offsets) const
|
void CGHeroInstance::getOutOffsets(std::vector<int3> &offsets) const
|
||||||
|
@ -1858,6 +1858,22 @@ void CGBoat::initObj(CRandomGenerator & rand)
|
|||||||
hero = nullptr;
|
hero = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int3 CGBoat::translatePos(const int3& pos, bool reverse /* = false */)
|
||||||
|
{
|
||||||
|
//pos - offset we want to place the boat at the map
|
||||||
|
//returned value - actual position as seen by game mechanics
|
||||||
|
|
||||||
|
//If reverse = true, then it's the opposite.
|
||||||
|
if (!reverse)
|
||||||
|
{
|
||||||
|
return pos + int3(1, 0, 0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return pos - int3(1, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CGSirens::initObj(CRandomGenerator & rand)
|
void CGSirens::initObj(CRandomGenerator & rand)
|
||||||
{
|
{
|
||||||
blockVisit = true;
|
blockVisit = true;
|
||||||
|
@ -430,6 +430,7 @@ public:
|
|||||||
std::array<std::string, PlayerColor::PLAYER_LIMIT_I> flagAnimations;
|
std::array<std::string, PlayerColor::PLAYER_LIMIT_I> flagAnimations;
|
||||||
|
|
||||||
void initObj(CRandomGenerator & rand) override;
|
void initObj(CRandomGenerator & rand) override;
|
||||||
|
static int3 translatePos(const int3 &pos, bool reverse = false);
|
||||||
|
|
||||||
CGBoat()
|
CGBoat()
|
||||||
{
|
{
|
||||||
|
@ -201,7 +201,7 @@ ESpellCastResult SummonBoatMechanics::applyAdventureEffects(SpellCastEnvironment
|
|||||||
{
|
{
|
||||||
ChangeObjPos cop;
|
ChangeObjPos cop;
|
||||||
cop.objid = nearest->id;
|
cop.objid = nearest->id;
|
||||||
cop.nPos = summonPos + int3(1,0,0);
|
cop.nPos = CGBoat::translatePos(summonPos);
|
||||||
env->apply(&cop);
|
env->apply(&cop);
|
||||||
}
|
}
|
||||||
else if(schoolLevel < 2) //none or basic level -> cannot create boat :(
|
else if(schoolLevel < 2) //none or basic level -> cannot create boat :(
|
||||||
@ -215,8 +215,8 @@ ESpellCastResult SummonBoatMechanics::applyAdventureEffects(SpellCastEnvironment
|
|||||||
{
|
{
|
||||||
NewObject no;
|
NewObject no;
|
||||||
no.ID = Obj::BOAT;
|
no.ID = Obj::BOAT;
|
||||||
no.subID = parameters.caster->getHeroCaster()->getBoatType().getNum();
|
no.subID = BoatId(EBoatId::BOAT_EVIL);
|
||||||
no.pos = summonPos + int3(1,0,0);
|
no.pos = CGBoat::translatePos(summonPos);
|
||||||
env->apply(&no);
|
env->apply(&no);
|
||||||
}
|
}
|
||||||
return ESpellCastResult::OK;
|
return ESpellCastResult::OK;
|
||||||
|
@ -4421,7 +4421,7 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, PlayerColor pl
|
|||||||
//Create a new boat for hero
|
//Create a new boat for hero
|
||||||
NewObject no;
|
NewObject no;
|
||||||
no.ID = Obj::BOAT;
|
no.ID = Obj::BOAT;
|
||||||
no.subID = VLC->heroh->objects[nh->subID]->getBoatType().getNum();
|
no.subID = BoatId(EBoatId::BOAT_NEUTRAL);
|
||||||
no.pos = hr.tile + int3(1,0,0);
|
no.pos = hr.tile + int3(1,0,0);
|
||||||
sendAndApply(&no);
|
sendAndApply(&no);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user