mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
Mod system improvement Part I : Special buildings should work in the modders towns
This commit is contained in:
@@ -2361,9 +2361,14 @@ bool CGameHandler::teleportHero(ObjectInstanceID hid, ObjectInstanceID dstid, ui
|
||||
const CGTownInstance *from = h->visitedTown;
|
||||
if (((h->getOwner() != t->getOwner())
|
||||
&& complain("Cannot teleport hero to another player"))
|
||||
|| ((!from || !from->hasBuilt(BuildingID::CASTLE_GATE, ETownType::INFERNO))
|
||||
|
||||
|| (from->town->faction->index != t->town->faction->index
|
||||
&& complain("Source town and destination town should belong to the same faction"))
|
||||
|
||||
|| ((!from || !from->hasBuilt(BuildingSubID::CASTLE_GATE))
|
||||
&& complain("Hero must be in town with Castle gate for teleporting"))
|
||||
|| (!t->hasBuilt(BuildingID::CASTLE_GATE, ETownType::INFERNO)
|
||||
|
||||
|| (!t->hasBuilt(BuildingSubID::CASTLE_GATE)
|
||||
&& complain("Cannot teleport hero to town without Castle gate in it")))
|
||||
return false;
|
||||
int3 pos = t->visitablePos();
|
||||
@@ -2511,7 +2516,6 @@ void CGameHandler::heroVisitCastle(const CGTownInstance * obj, const CGHeroInsta
|
||||
sendAndApply(&vc);
|
||||
visitCastleObjects(obj, hero);
|
||||
giveSpells(obj, hero);
|
||||
|
||||
checkVictoryLossConditionsForPlayer(hero->tempOwner); //transported artifact?
|
||||
}
|
||||
|
||||
@@ -3082,9 +3086,11 @@ bool CGameHandler::buildStructure(ObjectInstanceID tid, BuildingID requestedID,
|
||||
//Performs stuff that has to be done after new building is built
|
||||
auto processAfterBuiltStructure = [t, this](const BuildingID buildingID)
|
||||
{
|
||||
if (buildingID <= BuildingID::MAGES_GUILD_5 || //it's mage guild
|
||||
(t->subID == ETownType::TOWER && buildingID == BuildingID::LIBRARY) ||
|
||||
(t->subID == ETownType::CONFLUX && buildingID == BuildingID::GRAIL))
|
||||
auto isMageGuild = (buildingID <= BuildingID::MAGES_GUILD_5 && buildingID >= BuildingID::MAGES_GUILD_1);
|
||||
auto isLibrary = isMageGuild ? false
|
||||
: t->town->buildings.at(buildingID)->subId == BuildingSubID::EBuildingSubID::LIBRARY;
|
||||
|
||||
if(isMageGuild || isLibrary || (t->subID == ETownType::CONFLUX && buildingID == BuildingID::GRAIL))
|
||||
{
|
||||
if (t->visitingHero)
|
||||
giveSpells(t,t->visitingHero);
|
||||
@@ -3830,7 +3836,7 @@ bool CGameHandler::hireHero(const CGObjectInstance *obj, ui8 hid, PlayerColor pl
|
||||
if (t)
|
||||
{
|
||||
visitCastleObjects(t, nh);
|
||||
giveSpells (t,nh);
|
||||
giveSpells(t,nh);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user