mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Basic support for configurable flaggable objects
Converted CGLighthouse class into FlaggableMapObject Bonus provided by Lighthouse/Flaggable is now defined in config and is accessible to mods.
This commit is contained in:
@@ -1311,75 +1311,6 @@ void CGObelisk::setPropertyDer(ObjProperty what, ObjPropertyID identifier)
|
||||
}
|
||||
}
|
||||
|
||||
const IOwnableObject * CGLighthouse::asOwnable() const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
ResourceSet CGLighthouse::dailyIncome() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
std::vector<CreatureID> CGLighthouse::providedCreatures() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void CGLighthouse::onHeroVisit( const CGHeroInstance * h ) const
|
||||
{
|
||||
if(h->tempOwner != tempOwner)
|
||||
{
|
||||
PlayerColor oldOwner = tempOwner;
|
||||
cb->setOwner(this,h->tempOwner); //not ours? flag it!
|
||||
h->showInfoDialog(69);
|
||||
giveBonusTo(h->tempOwner);
|
||||
|
||||
if(oldOwner.isValidPlayer()) //remove bonus from old owner
|
||||
{
|
||||
RemoveBonus rb(GiveBonus::ETarget::PLAYER);
|
||||
rb.whoID = oldOwner;
|
||||
rb.source = BonusSource::OBJECT_INSTANCE;
|
||||
rb.id = BonusSourceID(id);
|
||||
cb->sendAndApply(rb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CGLighthouse::initObj(vstd::RNG & rand)
|
||||
{
|
||||
if(tempOwner.isValidPlayer())
|
||||
{
|
||||
// FIXME: This is dirty hack
|
||||
giveBonusTo(tempOwner, true);
|
||||
}
|
||||
}
|
||||
|
||||
void CGLighthouse::giveBonusTo(const PlayerColor & player, bool onInit) const
|
||||
{
|
||||
GiveBonus gb(GiveBonus::ETarget::PLAYER);
|
||||
gb.bonus.type = BonusType::MOVEMENT;
|
||||
gb.bonus.val = 500;
|
||||
gb.id = player;
|
||||
gb.bonus.duration = BonusDuration::PERMANENT;
|
||||
gb.bonus.source = BonusSource::OBJECT_INSTANCE;
|
||||
gb.bonus.sid = BonusSourceID(id);
|
||||
gb.bonus.subtype = BonusCustomSubtype::heroMovementSea;
|
||||
|
||||
// FIXME: This is really dirty hack
|
||||
// Proper fix would be to make CGLighthouse into bonus system node
|
||||
// Unfortunately this will cause saves breakage
|
||||
if(onInit)
|
||||
gb.applyGs(cb->gameState());
|
||||
else
|
||||
cb->sendAndApply(gb);
|
||||
}
|
||||
|
||||
void CGLighthouse::serializeJsonOptions(JsonSerializeFormat& handler)
|
||||
{
|
||||
serializeJsonOwner(handler);
|
||||
}
|
||||
|
||||
void HillFort::onHeroVisit(const CGHeroInstance * h) const
|
||||
{
|
||||
cb->showObjectWindow(this, EOpenWindowMode::HILL_FORT_WINDOW, h, false);
|
||||
|
||||
Reference in New Issue
Block a user