2017-07-13 10:26:03 +02:00
|
|
|
/*
|
|
|
|
* NetPacksLib.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2011-12-14 00:23:17 +03:00
|
|
|
#include "StdInc.h"
|
2023-05-17 15:52:16 +02:00
|
|
|
#include "ArtifactUtils.h"
|
2009-05-20 13:08:56 +03:00
|
|
|
#include "NetPacks.h"
|
2023-02-12 09:23:39 +02:00
|
|
|
#include "NetPackVisitor.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CGeneralTextHandler.h"
|
|
|
|
#include "CArtHandler.h"
|
|
|
|
#include "CHeroHandler.h"
|
2009-05-20 13:08:56 +03:00
|
|
|
#include "VCMI_Lib.h"
|
2013-04-07 13:48:07 +03:00
|
|
|
#include "mapping/CMap.h"
|
2015-03-10 22:14:58 +02:00
|
|
|
#include "spells/CSpellHandler.h"
|
2010-12-20 23:22:53 +02:00
|
|
|
#include "CCreatureHandler.h"
|
2023-06-23 17:02:48 +02:00
|
|
|
#include "gameState/CGameState.h"
|
2023-07-11 14:16:02 +02:00
|
|
|
#include "gameState/TavernHeroesPool.h"
|
2017-03-17 17:48:44 +02:00
|
|
|
#include "CStack.h"
|
2017-06-24 16:42:05 +02:00
|
|
|
#include "battle/BattleInfo.h"
|
2013-09-27 18:20:42 +03:00
|
|
|
#include "CTownHandler.h"
|
2014-06-25 17:11:07 +03:00
|
|
|
#include "mapping/CMapInfo.h"
|
|
|
|
#include "StartInfo.h"
|
2015-12-02 21:39:53 +02:00
|
|
|
#include "CPlayerState.h"
|
2023-01-09 01:17:37 +02:00
|
|
|
#include "TerrainHandler.h"
|
2023-06-17 14:21:42 +02:00
|
|
|
#include "mapObjects/CGCreature.h"
|
2023-06-02 20:47:37 +02:00
|
|
|
#include "mapObjects/CGMarket.h"
|
|
|
|
#include "mapObjectConstructors/AObjectTypeHandler.h"
|
|
|
|
#include "mapObjectConstructors/CObjectClassesHandler.h"
|
2023-06-25 21:28:24 +02:00
|
|
|
#include "campaign/CampaignState.h"
|
2023-03-15 21:34:29 +02:00
|
|
|
#include "GameSettings.h"
|
2023-02-24 22:38:12 +02:00
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void CPack::visit(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitBasic(visitor);
|
|
|
|
|
|
|
|
// visitBasic may destroy this and in such cases we do not want to call visitTyped
|
|
|
|
if(visitor.callTyped())
|
|
|
|
{
|
|
|
|
visitTyped(visitor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPack::visitBasic(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPack::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPackForClient::visitBasic(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitForClient(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPackForServer::visitBasic(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitForServer(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPackForLobby::visitBasic(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitForLobby(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CPackForLobby::isForServer() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CLobbyPackToServer::isForServer() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PackageApplied::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitPackageApplied(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemMessage::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSystemMessage(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayerBlocked::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitPlayerBlocked(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayerCheated::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitPlayerCheated(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void YourTurn::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitYourTurn(*this);
|
|
|
|
}
|
|
|
|
|
2023-08-24 20:35:01 +02:00
|
|
|
void DaysWithoutTown::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
2023-08-24 22:34:28 +02:00
|
|
|
visitor.visitDaysWithoutTown(*this);
|
2023-08-24 20:35:01 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void EntitiesChanged::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitEntitiesChanged(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetResources::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetResources(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetPrimSkill::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetPrimSkill(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetSecSkill::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetSecSkill(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HeroVisitCastle::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitHeroVisitCastle(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChangeSpells::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitChangeSpells(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMana::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetMana(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetMovePoints::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetMovePoints(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void FoWChange::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitFoWChange(*this);
|
|
|
|
}
|
|
|
|
|
2023-07-11 14:16:02 +02:00
|
|
|
void SetAvailableHero::visitTyped(ICPackVisitor & visitor)
|
2023-02-12 09:23:39 +02:00
|
|
|
{
|
|
|
|
visitor.visitSetAvailableHeroes(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GiveBonus::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitGiveBonus(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChangeObjPos::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitChangeObjPos(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayerEndsGame::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitPlayerEndsGame(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayerReinitInterface::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitPlayerReinitInterface(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemoveBonus::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitRemoveBonus(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetCommanderProperty::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetCommanderProperty(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AddQuest::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitAddQuest(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateArtHandlerLists::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitUpdateArtHandlerLists(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateMapEvents::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitUpdateMapEvents(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateCastleEvents::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitUpdateCastleEvents(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChangeFormation::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitChangeFormation(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RemoveObject::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitRemoveObject(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TryMoveHero::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitTryMoveHero(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewStructures::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitNewStructures(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RazeStructures::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitRazeStructures(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetAvailableCreatures::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetAvailableCreatures(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetHeroesInTown::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetHeroesInTown(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HeroRecruited::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitHeroRecruited(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GiveHero::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitGiveHero(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenWindow::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitOpenWindow(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewObject::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitNewObject(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetAvailableArtifacts::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetAvailableArtifacts(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewArtifact::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitNewArtifact(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChangeStackCount::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitChangeStackCount(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetStackType::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetStackType(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EraseStack::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitEraseStack(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SwapStacks::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSwapStacks(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InsertNewStack::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitInsertNewStack(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RebalanceStacks::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitRebalanceStacks(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BulkRebalanceStacks::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBulkRebalanceStacks(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BulkSmartRebalanceStacks::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBulkSmartRebalanceStacks(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PutArtifact::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitPutArtifact(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EraseArtifact::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitEraseArtifact(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoveArtifact::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitMoveArtifact(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BulkMoveArtifacts::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBulkMoveArtifacts(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AssembledArtifact::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitAssembledArtifact(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisassembledArtifact::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitDisassembledArtifact(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HeroVisit::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitHeroVisit(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewTurn::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitNewTurn(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InfoWindow::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitInfoWindow(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetObjectProperty::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetObjectProperty(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ChangeObjectVisitors::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitChangeObjectVisitors(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PrepareHeroLevelUp::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitPrepareHeroLevelUp(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HeroLevelUp::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitHeroLevelUp(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CommanderLevelUp::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitCommanderLevelUp(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlockingDialog::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBlockingDialog(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GarrisonDialog::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitGarrisonDialog(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ExchangeDialog::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitExchangeDialog(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TeleportDialog::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitTeleportDialog(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MapObjectSelectDialog::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitMapObjectSelectDialog(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleStart::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleStart(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleNextRound::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleNextRound(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleSetActiveStack::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleSetActiveStack(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleResult::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleResult(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleLogMessage::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleLogMessage(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleStackMoved::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleStackMoved(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleUnitsChanged::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleUnitsChanged(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleAttack::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleAttack(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StartAction::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitStartAction(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EndAction::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitEndAction(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleSpellCast::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleSpellCast(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetStackEffect::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetStackEffect(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StacksInjured::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitStacksInjured(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleResultsApplied::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleResultsApplied(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleObstaclesChanged::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleObstaclesChanged(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleSetStackProperty::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleSetStackProperty(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleTriggerEffect::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleTriggerEffect(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BattleUpdateGateState::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBattleUpdateGateState(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AdvmapSpellCast::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitAdvmapSpellCast(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ShowWorldViewEx::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitShowWorldViewEx(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EndTurn::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitEndTurn(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DismissHero::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitDismissHero(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MoveHero::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitMoveHero(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CastleTeleportHero::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitCastleTeleportHero(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArrangeStacks::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitArrangeStacks(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BulkMoveArmy::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBulkMoveArmy(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BulkSplitStack::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBulkSplitStack(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BulkMergeStacks::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBulkMergeStacks(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BulkSmartSplitStack::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBulkSmartSplitStack(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DisbandCreature::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitDisbandCreature(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BuildStructure::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBuildStructure(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RazeStructure::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitRazeStructure(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RecruitCreatures::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitRecruitCreatures(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UpgradeCreature::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitUpgradeCreature(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GarrisonHeroSwap::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitGarrisonHeroSwap(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ExchangeArtifacts::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitExchangeArtifacts(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BulkExchangeArtifacts::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBulkExchangeArtifacts(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AssembleArtifacts::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitAssembleArtifacts(*this);
|
|
|
|
}
|
|
|
|
|
2023-04-07 23:41:55 +02:00
|
|
|
void EraseArtifactByClient::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitEraseArtifactByClient(*this);
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BuyArtifact::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBuyArtifact(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TradeOnMarketplace::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitTradeOnMarketplace(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetFormation::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSetFormation(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void HireHero::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitHireHero(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BuildBoat::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitBuildBoat(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QueryReply::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitQueryReply(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void MakeAction::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitMakeAction(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DigWithHero::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitDigWithHero(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CastAdvSpell::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitCastAdvSpell(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SaveGame::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitSaveGame(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayerMessage::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitPlayerMessage(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlayerMessageClient::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitPlayerMessageClient(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CenterView::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitCenterView(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyClientConnected::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyClientConnected(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyClientDisconnected::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyClientDisconnected(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyChatMessage::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyChatMessage(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyGuiAction::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyGuiAction(*this);
|
|
|
|
}
|
|
|
|
|
2023-08-21 03:06:58 +02:00
|
|
|
void LobbyLoadProgress::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyLoadProgress(*this);
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void LobbyEndGame::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyEndGame(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyStartGame::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyStartGame(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyChangeHost::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyChangeHost(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyUpdateState::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyUpdateState(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbySetMap::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbySetMap(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbySetCampaign::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbySetCampaign(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbySetCampaignMap::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbySetCampaignMap(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbySetCampaignBonus::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbySetCampaignBonus(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyChangePlayerOption::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyChangePlayerOption(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbySetPlayer::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbySetPlayer(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbySetTurnTime::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbySetTurnTime(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbySetDifficulty::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbySetDifficulty(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyForceSetPlayer::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyForceSetPlayer(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LobbyShowMessage::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitLobbyShowMessage(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetResources::applyGs(CGameState * gs) const
|
2011-07-05 09:14:07 +03:00
|
|
|
{
|
2023-08-27 00:35:38 +02:00
|
|
|
assert(player.isValidPlayer());
|
2016-11-26 14:14:43 +02:00
|
|
|
if(abs)
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
gs->getPlayerState(player)->resources = res;
|
2016-11-26 14:14:43 +02:00
|
|
|
else
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
gs->getPlayerState(player)->resources += res;
|
2016-11-26 14:14:43 +02:00
|
|
|
|
|
|
|
//just ensure that player resources are not negative
|
|
|
|
//server is responsible to check if player can afford deal
|
|
|
|
//but events on server side are allowed to take more than player have
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
gs->getPlayerState(player)->resources.positive();
|
2011-07-05 09:14:07 +03:00
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetPrimSkill::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2014-04-10 20:11:09 +03:00
|
|
|
CGHeroInstance * hero = gs->getHero(id);
|
2010-05-02 21:20:26 +03:00
|
|
|
assert(hero);
|
2014-04-10 20:11:09 +03:00
|
|
|
hero->setPrimarySkill(which, val, abs);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetSecSkill::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
|
|
|
CGHeroInstance *hero = gs->getHero(id);
|
2013-02-04 22:43:16 +03:00
|
|
|
hero->setSecSkillLevel(which, val, abs);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetCommanderProperty::applyGs(CGameState *gs)
|
2012-05-18 17:02:27 +03:00
|
|
|
{
|
|
|
|
CCommanderInstance * commander = gs->getHero(heroid)->commander;
|
|
|
|
assert (commander);
|
|
|
|
|
|
|
|
switch (which)
|
|
|
|
{
|
|
|
|
case BONUS:
|
2016-09-19 23:36:35 +02:00
|
|
|
commander->accumulateBonus (std::make_shared<Bonus>(accumulatedBonus));
|
2012-05-18 17:02:27 +03:00
|
|
|
break;
|
2012-05-18 22:44:15 +03:00
|
|
|
case SPECIAL_SKILL:
|
2016-09-19 23:36:35 +02:00
|
|
|
commander->accumulateBonus (std::make_shared<Bonus>(accumulatedBonus));
|
2012-05-18 22:44:15 +03:00
|
|
|
commander->specialSKills.insert (additionalInfo);
|
|
|
|
break;
|
2012-05-18 17:02:27 +03:00
|
|
|
case SECONDARY_SKILL:
|
2020-10-01 10:38:06 +02:00
|
|
|
commander->secondarySkills[additionalInfo] = static_cast<ui8>(amount);
|
2012-05-18 17:02:27 +03:00
|
|
|
break;
|
|
|
|
case ALIVE:
|
|
|
|
if (amount)
|
|
|
|
commander->setAlive(true);
|
|
|
|
else
|
|
|
|
commander->setAlive(false);
|
|
|
|
break;
|
2012-05-18 22:44:15 +03:00
|
|
|
case EXPERIENCE:
|
2016-10-29 17:00:12 +02:00
|
|
|
commander->giveStackExp(amount); //TODO: allow setting exp for stacks via netpacks
|
2012-05-18 22:44:15 +03:00
|
|
|
break;
|
2012-05-18 17:02:27 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void AddQuest::applyGs(CGameState * gs) const
|
2012-07-06 22:12:04 +03:00
|
|
|
{
|
|
|
|
assert (vstd::contains(gs->players, player));
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * vec = &gs->players[player].quests;
|
2012-07-08 19:36:20 +03:00
|
|
|
if (!vstd::contains(*vec, quest))
|
|
|
|
vec->push_back (quest);
|
|
|
|
else
|
2017-08-10 18:39:27 +02:00
|
|
|
logNetwork->warn("Warning! Attempt to add duplicated quest");
|
2012-07-06 22:12:04 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void UpdateArtHandlerLists::applyGs(CGameState * gs) const
|
2013-02-19 01:37:22 +03:00
|
|
|
{
|
|
|
|
VLC->arth->minors = minors;
|
|
|
|
VLC->arth->majors = majors;
|
|
|
|
VLC->arth->treasures = treasures;
|
|
|
|
VLC->arth->relics = relics;
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void UpdateMapEvents::applyGs(CGameState * gs) const
|
2013-02-19 01:37:22 +03:00
|
|
|
{
|
|
|
|
gs->map->events = events;
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void UpdateCastleEvents::applyGs(CGameState * gs) const
|
2013-02-19 01:37:22 +03:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * t = gs->getTown(town);
|
2013-02-19 01:37:22 +03:00
|
|
|
t->events = events;
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void ChangeFormation::applyGs(CGameState * gs) const
|
2016-09-08 18:29:15 +02:00
|
|
|
{
|
|
|
|
gs->getHero(hid)->setFormation(formation);
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void HeroVisitCastle::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
|
|
|
CGHeroInstance *h = gs->getHero(hid);
|
|
|
|
CGTownInstance *t = gs->getTown(tid);
|
2011-02-04 16:58:14 +02:00
|
|
|
|
2014-06-05 18:19:11 +03:00
|
|
|
assert(h);
|
|
|
|
assert(t);
|
2014-07-01 08:07:40 +03:00
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
if(start())
|
2011-02-04 16:58:14 +02:00
|
|
|
t->setVisitingHero(h);
|
2009-03-07 17:55:56 +02:00
|
|
|
else
|
2013-06-26 14:18:27 +03:00
|
|
|
t->setVisitingHero(nullptr);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void ChangeSpells::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
|
|
|
CGHeroInstance *hero = gs->getHero(hid);
|
|
|
|
|
|
|
|
if(learn)
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const auto & sid : spells)
|
2018-12-20 23:42:31 +02:00
|
|
|
hero->addSpellToSpellbook(sid);
|
2009-03-07 17:55:56 +02:00
|
|
|
else
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const auto & sid : spells)
|
2018-12-20 23:42:31 +02:00
|
|
|
hero->removeSpellFromSpellbook(sid);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetMana::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2014-11-26 12:30:55 +02:00
|
|
|
CGHeroInstance * hero = gs->getHero(hid);
|
2015-03-10 22:14:58 +02:00
|
|
|
|
2014-11-26 12:30:55 +02:00
|
|
|
assert(hero);
|
2015-03-10 22:14:58 +02:00
|
|
|
|
2014-11-26 12:30:55 +02:00
|
|
|
if(absolute)
|
2015-03-10 22:14:58 +02:00
|
|
|
hero->mana = val;
|
2014-11-26 12:30:55 +02:00
|
|
|
else
|
|
|
|
hero->mana += val;
|
|
|
|
|
|
|
|
vstd::amax(hero->mana, 0); //not less than 0
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetMovePoints::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
|
|
|
CGHeroInstance *hero = gs->getHero(hid);
|
2017-05-11 20:52:10 +02:00
|
|
|
|
|
|
|
assert(hero);
|
|
|
|
|
|
|
|
if(absolute)
|
2023-06-21 19:38:26 +02:00
|
|
|
hero->setMovementPoints(val);
|
2017-05-11 20:52:10 +02:00
|
|
|
else
|
2023-06-21 19:38:26 +02:00
|
|
|
hero->setMovementPoints(hero->movementPointsRemaining() + val);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void FoWChange::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2010-08-03 15:34:06 +03:00
|
|
|
TeamState * team = gs->getPlayerTeam(player);
|
2022-09-18 16:39:10 +02:00
|
|
|
auto fogOfWarMap = team->fogOfWarMap;
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const int3 & t : tiles)
|
2022-09-18 16:39:10 +02:00
|
|
|
(*fogOfWarMap)[t.z][t.x][t.y] = mode;
|
2010-06-06 09:05:39 +03:00
|
|
|
if (mode == 0) //do not hide too much
|
|
|
|
{
|
2023-04-16 00:48:49 +02:00
|
|
|
std::unordered_set<int3> tilesRevealed;
|
2013-06-29 16:05:48 +03:00
|
|
|
for (auto & elem : gs->map->objects)
|
2010-06-06 09:05:39 +03:00
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
const CGObjectInstance *o = elem;
|
2013-01-12 21:08:33 +03:00
|
|
|
if (o)
|
2010-06-06 09:05:39 +03:00
|
|
|
{
|
2013-01-12 21:08:33 +03:00
|
|
|
switch(o->ID)
|
2010-06-06 09:05:39 +03:00
|
|
|
{
|
2013-01-12 21:08:33 +03:00
|
|
|
case Obj::HERO:
|
|
|
|
case Obj::MINE:
|
|
|
|
case Obj::TOWN:
|
|
|
|
case Obj::ABANDONED_MINE:
|
|
|
|
if(vstd::contains(team->players, o->tempOwner)) //check owned observators
|
2016-01-31 17:01:58 +02:00
|
|
|
gs->getTilesInRange(tilesRevealed, o->getSightCenter(), o->getSightRadius(), o->tempOwner, 1);
|
2010-06-06 09:05:39 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const int3 & t : tilesRevealed) //probably not the most optimal solution ever
|
2022-09-18 16:39:10 +02:00
|
|
|
(*fogOfWarMap)[t.z][t.x][t.y] = 1;
|
2010-06-06 09:05:39 +03:00
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
2016-11-18 16:45:59 +02:00
|
|
|
|
2023-07-11 14:16:02 +02:00
|
|
|
void SetAvailableHero::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-07-12 11:29:05 +02:00
|
|
|
gs->heroesPool->setHeroForPlayer(player, slotID, hid, army, roleID);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void GiveBonus::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2013-06-26 14:18:27 +03:00
|
|
|
CBonusSystemNode *cbsn = nullptr;
|
2010-02-10 04:56:00 +02:00
|
|
|
switch(who)
|
|
|
|
{
|
2023-03-28 13:46:53 +02:00
|
|
|
case ETarget::HERO:
|
2013-02-14 02:55:42 +03:00
|
|
|
cbsn = gs->getHero(ObjectInstanceID(id));
|
2010-02-10 04:56:00 +02:00
|
|
|
break;
|
2023-03-28 13:46:53 +02:00
|
|
|
case ETarget::PLAYER:
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
cbsn = gs->getPlayerState(PlayerColor(id));
|
2010-02-10 04:56:00 +02:00
|
|
|
break;
|
2023-03-28 13:46:53 +02:00
|
|
|
case ETarget::TOWN:
|
2013-02-14 02:55:42 +03:00
|
|
|
cbsn = gs->getTown(ObjectInstanceID(id));
|
2010-11-19 00:06:56 +02:00
|
|
|
break;
|
2023-03-28 13:57:44 +02:00
|
|
|
case ETarget::BATTLE:
|
|
|
|
assert(Bonus::OneBattle(&bonus));
|
2023-08-25 17:23:15 +02:00
|
|
|
cbsn = dynamic_cast<CBonusSystemNode*>(gs->getBattle(BattleID(id)));
|
2023-03-28 13:57:44 +02:00
|
|
|
break;
|
2010-02-10 04:56:00 +02:00
|
|
|
}
|
2009-04-21 01:57:07 +03:00
|
|
|
|
2010-11-19 00:06:56 +02:00
|
|
|
assert(cbsn);
|
|
|
|
|
2015-11-20 11:11:35 +02:00
|
|
|
if(Bonus::OneWeek(&bonus))
|
|
|
|
bonus.turnsRemain = 8 - gs->getDate(Date::DAY_OF_WEEK); // set correct number of days before adding bonus
|
|
|
|
|
2016-09-19 23:36:35 +02:00
|
|
|
auto b = std::make_shared<Bonus>(bonus);
|
2010-11-19 00:06:56 +02:00
|
|
|
cbsn->addNewBonus(b);
|
|
|
|
|
|
|
|
std::string &descr = b->description;
|
2009-04-21 01:57:07 +03:00
|
|
|
|
2023-06-18 11:18:25 +02:00
|
|
|
if(bdescr.empty() && (bonus.type == BonusType::LUCK || bonus.type == BonusType::MORALE))
|
2009-04-21 01:57:07 +03:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
if (bonus.source == BonusSource::OBJECT)
|
2021-01-14 00:02:13 +02:00
|
|
|
{
|
|
|
|
descr = VLC->generaltexth->arraytxt[bonus.val > 0 ? 110 : 109]; //+/-%d Temporary until next battle"
|
|
|
|
}
|
2023-05-01 00:20:01 +02:00
|
|
|
else if(bonus.source == BonusSource::TOWN_STRUCTURE)
|
2021-01-14 00:02:13 +02:00
|
|
|
{
|
|
|
|
descr = bonus.description;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-18 11:18:25 +02:00
|
|
|
descr = bdescr.toString();
|
2021-01-14 00:02:13 +02:00
|
|
|
}
|
2009-04-21 01:57:07 +03:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-06-18 11:18:25 +02:00
|
|
|
descr = bdescr.toString();
|
2009-04-21 01:57:07 +03:00
|
|
|
}
|
2014-04-07 20:32:15 +03:00
|
|
|
// Some of(?) versions of H3 use %s here instead of %d. Try to replace both of them
|
2023-02-09 18:06:02 +02:00
|
|
|
boost::replace_first(descr, "%d", std::to_string(std::abs(bonus.val)));
|
|
|
|
boost::replace_first(descr, "%s", std::to_string(std::abs(bonus.val)));
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void ChangeObjPos::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2013-02-14 02:55:42 +03:00
|
|
|
CGObjectInstance *obj = gs->getObjInstance(objid);
|
2009-03-07 17:55:56 +02:00
|
|
|
if(!obj)
|
|
|
|
{
|
2017-08-12 13:36:04 +02:00
|
|
|
logNetwork->error("Wrong ChangeObjPos: object %d doesn't exist!", objid.getNum());
|
2009-03-07 17:55:56 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
gs->map->removeBlockVisTiles(obj);
|
2023-06-20 22:09:11 +02:00
|
|
|
obj->pos = nPos + obj->getVisitableOffset();
|
2009-03-07 17:55:56 +02:00
|
|
|
gs->map->addBlockVisTiles(obj);
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void ChangeObjectVisitors::applyGs(CGameState * gs) const
|
2014-04-07 20:32:15 +03:00
|
|
|
{
|
|
|
|
switch (mode) {
|
|
|
|
case VISITOR_ADD:
|
|
|
|
gs->getHero(hero)->visitedObjects.insert(object);
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
gs->getPlayerState(gs->getHero(hero)->tempOwner)->visitedObjects.insert(object);
|
2014-04-07 20:32:15 +03:00
|
|
|
break;
|
2016-09-20 22:05:44 +02:00
|
|
|
case VISITOR_ADD_TEAM:
|
|
|
|
{
|
|
|
|
TeamState *ts = gs->getPlayerTeam(gs->getHero(hero)->tempOwner);
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const auto & color : ts->players)
|
2016-09-20 22:05:44 +02:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
gs->getPlayerState(color)->visitedObjects.insert(object);
|
2016-09-20 22:05:44 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2014-04-07 20:32:15 +03:00
|
|
|
case VISITOR_CLEAR:
|
|
|
|
for (CGHeroInstance * hero : gs->map->allHeroes)
|
2016-09-28 19:07:48 +02:00
|
|
|
{
|
|
|
|
if (hero)
|
|
|
|
{
|
|
|
|
hero->visitedObjects.erase(object); // remove visit info from all heroes, including those that are not present on map
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for(auto &elem : gs->players)
|
|
|
|
{
|
|
|
|
elem.second.visitedObjects.erase(object);
|
|
|
|
}
|
|
|
|
|
2014-04-07 20:32:15 +03:00
|
|
|
break;
|
|
|
|
case VISITOR_REMOVE:
|
|
|
|
gs->getHero(hero)->visitedObjects.erase(object);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void PlayerEndsGame::applyGs(CGameState * gs) const
|
2010-01-29 22:52:45 +02:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
PlayerState *p = gs->getPlayerState(player);
|
2018-01-05 19:21:07 +02:00
|
|
|
if(victoryLossCheckResult.victory())
|
|
|
|
{
|
|
|
|
p->status = EPlayerStatus::WINNER;
|
|
|
|
|
|
|
|
// TODO: Campaign-specific code might as well go somewhere else
|
2023-06-26 15:25:34 +02:00
|
|
|
// keep all heroes from the winning player
|
2018-01-05 19:21:07 +02:00
|
|
|
if(p->human && gs->scenarioOps->campState)
|
|
|
|
{
|
|
|
|
std::vector<CGHeroInstance *> crossoverHeroes;
|
|
|
|
for (CGHeroInstance * hero : gs->map->heroesOnMap)
|
|
|
|
if (hero->tempOwner == player)
|
|
|
|
crossoverHeroes.push_back(hero);
|
|
|
|
|
|
|
|
gs->scenarioOps->campState->setCurrentMapAsConquered(crossoverHeroes);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p->status = EPlayerStatus::LOSER;
|
|
|
|
}
|
2010-01-29 22:52:45 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void PlayerReinitInterface::applyGs(CGameState *gs)
|
2022-09-30 21:08:37 +02:00
|
|
|
{
|
|
|
|
if(!gs || !gs->scenarioOps)
|
|
|
|
return;
|
2022-10-04 00:25:22 +02:00
|
|
|
|
2022-09-30 21:08:37 +02:00
|
|
|
//TODO: what does mean if more that one player connected?
|
2022-10-04 16:11:12 +02:00
|
|
|
if(playerConnectionId == PlayerSettings::PLAYER_AI)
|
2022-10-04 23:54:31 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const auto & player : players)
|
2022-10-04 23:54:31 +02:00
|
|
|
gs->scenarioOps->getIthPlayersSettings(player).connectedPlayerIDs.clear();
|
|
|
|
}
|
2022-09-30 21:08:37 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void RemoveBonus::applyGs(CGameState *gs)
|
2010-02-10 04:56:00 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
CBonusSystemNode * node = nullptr;
|
2023-03-28 13:46:53 +02:00
|
|
|
if (who == GiveBonus::ETarget::HERO)
|
2013-02-14 02:55:42 +03:00
|
|
|
node = gs->getHero(ObjectInstanceID(whoID));
|
2011-07-13 21:39:02 +03:00
|
|
|
else
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
node = gs->getPlayerState(PlayerColor(whoID));
|
2010-02-10 04:56:00 +02:00
|
|
|
|
2015-04-13 08:04:43 +02:00
|
|
|
BonusList &bonuses = node->getExportedBonusList();
|
2013-01-12 21:08:33 +03:00
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const auto & b : bonuses)
|
2010-02-10 04:56:00 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
if(vstd::to_underlying(b->source) == source && b->sid == id)
|
2010-02-10 04:56:00 +02:00
|
|
|
{
|
2011-07-13 21:39:02 +03:00
|
|
|
bonus = *b; //backup bonus (to show to interfaces later)
|
2016-01-22 11:53:01 +02:00
|
|
|
node->removeBonus(b);
|
2010-02-10 04:56:00 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void RemoveObject::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2013-04-21 15:11:13 +03:00
|
|
|
|
2013-02-14 02:55:42 +03:00
|
|
|
CGObjectInstance *obj = gs->getObjInstance(id);
|
2017-08-11 19:03:05 +02:00
|
|
|
logGlobal->debug("removing object id=%d; address=%x; name=%s", id, (intptr_t)obj, obj->getObjectName());
|
2010-02-11 17:51:26 +02:00
|
|
|
//unblock tiles
|
2014-01-03 02:48:38 +03:00
|
|
|
gs->map->removeBlockVisTiles(obj);
|
2010-02-11 17:51:26 +02:00
|
|
|
|
2021-03-23 16:47:07 +02:00
|
|
|
if(obj->ID == Obj::HERO) //remove beaten hero
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * beatenHero = dynamic_cast<CGHeroInstance *>(obj);
|
|
|
|
assert(beatenHero);
|
2021-03-23 16:47:07 +02:00
|
|
|
PlayerState * p = gs->getPlayerState(beatenHero->tempOwner);
|
|
|
|
gs->map->heroesOnMap -= beatenHero;
|
|
|
|
p->heroes -= beatenHero;
|
2023-07-15 15:04:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
auto * siegeNode = beatenHero->whereShouldBeAttachedOnSiege(gs);
|
|
|
|
|
|
|
|
// FIXME: workaround:
|
|
|
|
// hero should be attached to siegeNode after battle
|
|
|
|
// however this code might also be called on dismissing hero while in town
|
|
|
|
if (siegeNode && vstd::contains(beatenHero->getParentNodes(), siegeNode))
|
|
|
|
beatenHero->detachFrom(*siegeNode);
|
|
|
|
|
2021-03-23 16:47:07 +02:00
|
|
|
beatenHero->tempOwner = PlayerColor::NEUTRAL; //no one owns beaten hero
|
|
|
|
vstd::erase_if(beatenHero->artifactsInBackpack, [](const ArtSlotInfo& asi)
|
2016-01-20 13:22:12 +02:00
|
|
|
{
|
2023-01-02 15:58:56 +02:00
|
|
|
return asi.artifact->artType->getId() == ArtifactID::GRAIL;
|
2016-01-20 13:22:12 +02:00
|
|
|
});
|
2010-01-29 22:52:45 +02:00
|
|
|
|
2021-03-23 16:47:07 +02:00
|
|
|
if(beatenHero->visitedTown)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2021-03-23 16:47:07 +02:00
|
|
|
if(beatenHero->visitedTown->garrisonHero == beatenHero)
|
|
|
|
beatenHero->visitedTown->garrisonHero = nullptr;
|
2009-03-07 17:55:56 +02:00
|
|
|
else
|
2021-03-23 16:47:07 +02:00
|
|
|
beatenHero->visitedTown->visitingHero = nullptr;
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2021-03-23 16:47:07 +02:00
|
|
|
beatenHero->visitedTown = nullptr;
|
|
|
|
beatenHero->inTownGarrison = false;
|
|
|
|
}
|
2010-07-08 08:52:11 +03:00
|
|
|
//return hero to the pool, so he may reappear in tavern
|
2011-01-18 20:56:14 +02:00
|
|
|
|
2023-07-12 11:29:05 +02:00
|
|
|
gs->heroesPool->addHeroToPool(beatenHero);
|
2013-06-26 14:18:27 +03:00
|
|
|
gs->map->objects[id.getNum()] = nullptr;
|
2013-01-12 21:08:33 +03:00
|
|
|
|
2013-09-09 00:50:49 +03:00
|
|
|
//If hero on Boat is removed, the Boat disappears
|
2021-03-23 16:47:07 +02:00
|
|
|
if(beatenHero->boat)
|
2013-09-09 00:50:49 +03:00
|
|
|
{
|
2023-04-18 23:11:51 +02:00
|
|
|
beatenHero->detachFrom(const_cast<CGBoat&>(*beatenHero->boat));
|
2021-03-23 16:47:07 +02:00
|
|
|
gs->map->instanceNames.erase(beatenHero->boat->instanceName);
|
|
|
|
gs->map->objects[beatenHero->boat->id.getNum()].dellNull();
|
|
|
|
beatenHero->boat = nullptr;
|
2013-09-09 00:50:49 +03:00
|
|
|
}
|
2011-01-18 20:56:14 +02:00
|
|
|
return;
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
2012-07-19 12:10:55 +03:00
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
const auto * quest = dynamic_cast<const IQuestObject *>(obj);
|
2012-07-19 12:10:55 +03:00
|
|
|
if (quest)
|
|
|
|
{
|
2013-07-23 18:03:01 +03:00
|
|
|
gs->map->quests[quest->quest->qid] = nullptr;
|
2013-06-29 16:05:48 +03:00
|
|
|
for (auto &player : gs->players)
|
2012-07-19 12:10:55 +03:00
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
for (auto &q : player.second.quests)
|
2012-07-19 12:10:55 +03:00
|
|
|
{
|
|
|
|
if (q.obj == obj)
|
|
|
|
{
|
2013-06-26 14:18:27 +03:00
|
|
|
q.obj = nullptr;
|
2012-07-19 12:10:55 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-09 15:10:02 +03:00
|
|
|
for (TriggeredEvent & event : gs->map->triggeredEvents)
|
|
|
|
{
|
2014-08-07 19:40:22 +03:00
|
|
|
auto patcher = [&](EventCondition cond) -> EventExpression::Variant
|
2014-02-09 15:10:02 +03:00
|
|
|
{
|
|
|
|
if (cond.object == obj)
|
|
|
|
{
|
2016-11-13 12:38:42 +02:00
|
|
|
if (cond.condition == EventCondition::DESTROY || cond.condition == EventCondition::DESTROY_0)
|
2014-02-09 15:10:02 +03:00
|
|
|
{
|
|
|
|
cond.condition = EventCondition::CONST_VALUE;
|
|
|
|
cond.value = 1; // destroyed object, from now on always fulfilled
|
|
|
|
}
|
2016-11-13 12:38:42 +02:00
|
|
|
else if (cond.condition == EventCondition::CONTROL || cond.condition == EventCondition::HAVE_0)
|
2014-02-09 15:10:02 +03:00
|
|
|
{
|
|
|
|
cond.condition = EventCondition::CONST_VALUE;
|
|
|
|
cond.value = 0; // destroyed object, from now on can not be fulfilled
|
|
|
|
}
|
|
|
|
}
|
2014-08-07 19:40:22 +03:00
|
|
|
return cond;
|
2014-02-09 15:10:02 +03:00
|
|
|
};
|
2014-08-07 19:40:22 +03:00
|
|
|
event.trigger = event.trigger.morph(patcher);
|
2014-02-09 15:10:02 +03:00
|
|
|
}
|
2016-02-22 18:26:42 +02:00
|
|
|
gs->map->instanceNames.erase(obj->instanceName);
|
2013-02-14 02:55:42 +03:00
|
|
|
gs->map->objects[id.getNum()].dellNull();
|
2014-04-01 14:53:28 +03:00
|
|
|
gs->map->calculateGuardingGreaturePositions();
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
static int getDir(const int3 & src, const int3 & dst)
|
2009-07-18 06:13:13 +03:00
|
|
|
{
|
|
|
|
int ret = -1;
|
|
|
|
if(dst.x+1 == src.x && dst.y+1 == src.y) //tl
|
|
|
|
{
|
|
|
|
ret = 1;
|
|
|
|
}
|
|
|
|
else if(dst.x == src.x && dst.y+1 == src.y) //t
|
|
|
|
{
|
|
|
|
ret = 2;
|
|
|
|
}
|
|
|
|
else if(dst.x-1 == src.x && dst.y+1 == src.y) //tr
|
|
|
|
{
|
|
|
|
ret = 3;
|
|
|
|
}
|
|
|
|
else if(dst.x-1 == src.x && dst.y == src.y) //r
|
|
|
|
{
|
|
|
|
ret = 4;
|
|
|
|
}
|
|
|
|
else if(dst.x-1 == src.x && dst.y-1 == src.y) //br
|
|
|
|
{
|
|
|
|
ret = 5;
|
|
|
|
}
|
|
|
|
else if(dst.x == src.x && dst.y-1 == src.y) //b
|
|
|
|
{
|
|
|
|
ret = 6;
|
|
|
|
}
|
|
|
|
else if(dst.x+1 == src.x && dst.y-1 == src.y) //bl
|
|
|
|
{
|
|
|
|
ret = 7;
|
|
|
|
}
|
|
|
|
else if(dst.x+1 == src.x && dst.y == src.y) //l
|
|
|
|
{
|
|
|
|
ret = 8;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2016-10-12 17:16:26 +02:00
|
|
|
void TryMoveHero::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
|
|
|
CGHeroInstance *h = gs->getHero(id);
|
2015-10-24 15:09:46 +02:00
|
|
|
if (!h)
|
|
|
|
{
|
2017-08-11 19:03:05 +02:00
|
|
|
logGlobal->error("Attempt ot move unavailable hero %d", id.getNum());
|
2015-10-24 15:09:46 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-06-21 19:38:26 +02:00
|
|
|
h->setMovementPoints(movePoints);
|
2009-07-19 04:00:19 +03:00
|
|
|
|
2014-02-15 12:40:33 +03:00
|
|
|
if((result == SUCCESS || result == BLOCKING_VISIT || result == EMBARK || result == DISEMBARK) && start != end)
|
2013-10-13 23:05:34 +03:00
|
|
|
{
|
|
|
|
auto dir = getDir(start,end);
|
|
|
|
if(dir > 0 && dir <= 8)
|
|
|
|
h->moveDir = dir;
|
2014-05-21 12:02:20 +03:00
|
|
|
//else don`t change move direction - hero might have traversed the subterranean gate, direction should be kept
|
2010-05-06 15:13:31 +03:00
|
|
|
}
|
2009-07-19 06:10:24 +03:00
|
|
|
|
2014-05-21 12:02:20 +03:00
|
|
|
if(result == EMBARK) //hero enters boat at destination tile
|
2009-07-19 04:00:19 +03:00
|
|
|
{
|
2022-12-09 14:42:47 +02:00
|
|
|
const TerrainTile &tt = gs->map->getTile(h->convertToVisitablePos(end));
|
2023-04-20 19:20:51 +02:00
|
|
|
assert(tt.visitableObjects.size() >= 1 && tt.visitableObjects.back()->ID == Obj::BOAT); //the only visitable object at destination is Boat
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * boat = dynamic_cast<CGBoat *>(tt.visitableObjects.back());
|
|
|
|
assert(boat);
|
2009-07-19 04:00:19 +03:00
|
|
|
|
|
|
|
gs->map->removeBlockVisTiles(boat); //hero blockvis mask will be used, we don't need to duplicate it with boat
|
|
|
|
h->boat = boat;
|
2023-04-18 23:11:51 +02:00
|
|
|
h->attachTo(*boat);
|
2009-07-19 04:00:19 +03:00
|
|
|
boat->hero = h;
|
|
|
|
}
|
2014-05-21 12:02:20 +03:00
|
|
|
else if(result == DISEMBARK) //hero leaves boat to destination tile
|
2009-07-19 06:10:24 +03:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * b = const_cast<CGBoat *>(h->boat);
|
2010-07-20 21:34:32 +03:00
|
|
|
b->direction = h->moveDir;
|
|
|
|
b->pos = start;
|
2013-06-26 14:18:27 +03:00
|
|
|
b->hero = nullptr;
|
2010-07-20 21:34:32 +03:00
|
|
|
gs->map->addBlockVisTiles(b);
|
2023-04-18 23:11:51 +02:00
|
|
|
h->detachFrom(*b);
|
2013-06-26 14:18:27 +03:00
|
|
|
h->boat = nullptr;
|
2009-07-19 06:10:24 +03:00
|
|
|
}
|
2009-07-19 04:00:19 +03:00
|
|
|
|
2009-07-19 06:10:24 +03:00
|
|
|
if(start!=end && (result == SUCCESS || result == TELEPORTATION || result == EMBARK || result == DISEMBARK))
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
|
|
|
gs->map->removeBlockVisTiles(h);
|
|
|
|
h->pos = end;
|
2023-02-09 18:06:02 +02:00
|
|
|
if(auto * b = const_cast<CGBoat *>(h->boat))
|
2010-07-20 21:34:32 +03:00
|
|
|
b->pos = end;
|
2009-03-07 17:55:56 +02:00
|
|
|
gs->map->addBlockVisTiles(h);
|
|
|
|
}
|
2009-07-18 06:13:13 +03:00
|
|
|
|
2022-09-18 16:39:10 +02:00
|
|
|
auto fogOfWarMap = gs->getPlayerTeam(h->getOwner())->fogOfWarMap;
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const int3 & t : fowRevealed)
|
2022-09-18 16:39:10 +02:00
|
|
|
(*fogOfWarMap)[t.z][t.x][t.y] = 1;
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void NewStructures::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2009-08-23 18:02:21 +03:00
|
|
|
CGTownInstance *t = gs->getTown(tid);
|
2021-01-14 00:02:13 +02:00
|
|
|
|
2013-06-29 16:05:48 +03:00
|
|
|
for(const auto & id : bid)
|
2009-08-23 18:02:21 +03:00
|
|
|
{
|
2013-11-12 13:45:42 +03:00
|
|
|
assert(t->town->buildings.at(id) != nullptr);
|
2009-03-07 17:55:56 +02:00
|
|
|
t->builtBuildings.insert(id);
|
2016-08-24 04:15:04 +02:00
|
|
|
t->updateAppearance();
|
2021-01-14 00:02:13 +02:00
|
|
|
auto currentBuilding = t->town->buildings.at(id);
|
|
|
|
|
|
|
|
if(currentBuilding->overrideBids.empty())
|
|
|
|
continue;
|
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const auto & overrideBid : currentBuilding->overrideBids)
|
2021-01-14 00:02:13 +02:00
|
|
|
{
|
|
|
|
t->overriddenBuildings.insert(overrideBid);
|
|
|
|
t->deleteTownBonus(overrideBid);
|
|
|
|
}
|
2009-08-23 18:02:21 +03:00
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
t->builded = builded;
|
2011-02-04 16:58:14 +02:00
|
|
|
t->recreateBuildingsBonuses();
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
2021-01-14 00:02:13 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void RazeStructures::applyGs(CGameState *gs)
|
2009-09-22 17:27:46 +03:00
|
|
|
{
|
|
|
|
CGTownInstance *t = gs->getTown(tid);
|
2013-06-29 16:05:48 +03:00
|
|
|
for(const auto & id : bid)
|
2009-09-22 17:27:46 +03:00
|
|
|
{
|
|
|
|
t->builtBuildings.erase(id);
|
2016-08-24 04:15:04 +02:00
|
|
|
|
|
|
|
t->updateAppearance();
|
2009-09-22 17:27:46 +03:00
|
|
|
}
|
2009-09-24 20:54:02 +03:00
|
|
|
t->destroyed = destroyed; //yeaha
|
2011-02-04 16:58:14 +02:00
|
|
|
t->recreateBuildingsBonuses();
|
2009-09-22 17:27:46 +03:00
|
|
|
}
|
2011-02-04 16:58:14 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetAvailableCreatures::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * dw = dynamic_cast<CGDwelling *>(gs->getObjInstance(tid));
|
2009-07-26 13:43:22 +03:00
|
|
|
assert(dw);
|
|
|
|
dw->creatures = creatures;
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetHeroesInTown::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
|
|
|
CGTownInstance *t = gs->getTown(tid);
|
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
CGHeroInstance * v = gs->getHero(visiting);
|
|
|
|
CGHeroInstance * g = gs->getHero(garrison);
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2011-02-04 16:58:14 +02:00
|
|
|
bool newVisitorComesFromGarrison = v && v == t->garrisonHero;
|
|
|
|
bool newGarrisonComesFromVisiting = g && g == t->visitingHero;
|
|
|
|
|
|
|
|
if(newVisitorComesFromGarrison)
|
2013-06-26 14:18:27 +03:00
|
|
|
t->setGarrisonedHero(nullptr);
|
2011-02-04 16:58:14 +02:00
|
|
|
if(newGarrisonComesFromVisiting)
|
2013-06-26 14:18:27 +03:00
|
|
|
t->setVisitingHero(nullptr);
|
2011-02-04 16:58:14 +02:00
|
|
|
if(!newGarrisonComesFromVisiting || v)
|
|
|
|
t->setVisitingHero(v);
|
|
|
|
if(!newVisitorComesFromGarrison || g)
|
|
|
|
t->setGarrisonedHero(g);
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
if(v)
|
|
|
|
{
|
|
|
|
gs->map->addBlockVisTiles(v);
|
|
|
|
}
|
|
|
|
if(g)
|
|
|
|
{
|
|
|
|
gs->map->removeBlockVisTiles(g);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void HeroRecruited::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-07-12 11:29:05 +02:00
|
|
|
CGHeroInstance *h = gs->heroesPool->takeHeroFromPool(hid);
|
2009-03-07 17:55:56 +02:00
|
|
|
CGTownInstance *t = gs->getTown(tid);
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
PlayerState *p = gs->getPlayerState(player);
|
2013-09-09 00:50:49 +03:00
|
|
|
|
2023-08-19 23:22:31 +02:00
|
|
|
if (boatId != ObjectInstanceID::NONE)
|
2023-06-08 09:17:08 +02:00
|
|
|
{
|
|
|
|
CGObjectInstance *obj = gs->getObjInstance(boatId);
|
|
|
|
auto * boat = dynamic_cast<CGBoat *>(obj);
|
|
|
|
if (boat)
|
|
|
|
{
|
2023-08-01 18:51:33 +02:00
|
|
|
gs->map->removeBlockVisTiles(boat);
|
|
|
|
h->attachToBoat(boat);
|
2023-06-08 09:17:08 +02:00
|
|
|
}
|
|
|
|
}
|
2013-09-09 00:50:49 +03:00
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
h->setOwner(player);
|
|
|
|
h->pos = tile;
|
2023-07-22 21:04:32 +02:00
|
|
|
h->initObj(gs->getRandomGenerator());
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2013-02-14 02:55:42 +03:00
|
|
|
if(h->id == ObjectInstanceID())
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
h->id = ObjectInstanceID(static_cast<si32>(gs->map->objects.size()));
|
|
|
|
gs->map->objects.emplace_back(h);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
else
|
2013-02-14 02:55:42 +03:00
|
|
|
gs->map->objects[h->id.getNum()] = h;
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
gs->map->heroesOnMap.emplace_back(h);
|
|
|
|
p->heroes.emplace_back(h);
|
2022-11-06 01:26:13 +02:00
|
|
|
h->attachTo(*p);
|
2009-03-07 17:55:56 +02:00
|
|
|
gs->map->addBlockVisTiles(h);
|
2010-07-09 02:03:27 +03:00
|
|
|
|
|
|
|
if(t)
|
2011-02-04 16:58:14 +02:00
|
|
|
t->setVisitingHero(h);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void GiveHero::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
|
|
|
CGHeroInstance *h = gs->getHero(id);
|
2012-01-03 04:55:26 +03:00
|
|
|
|
2023-08-19 23:22:31 +02:00
|
|
|
if (boatId != ObjectInstanceID::NONE)
|
2023-06-08 09:17:08 +02:00
|
|
|
{
|
|
|
|
CGObjectInstance *obj = gs->getObjInstance(boatId);
|
|
|
|
auto * boat = dynamic_cast<CGBoat *>(obj);
|
|
|
|
if (boat)
|
|
|
|
{
|
2023-08-01 18:51:33 +02:00
|
|
|
gs->map->removeBlockVisTiles(boat);
|
|
|
|
h->attachToBoat(boat);
|
2023-06-08 09:17:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-03 04:55:26 +03:00
|
|
|
//bonus system
|
2022-11-06 01:26:13 +02:00
|
|
|
h->detachFrom(gs->globalEffects);
|
|
|
|
h->attachTo(*gs->getPlayerState(player));
|
2012-01-03 04:55:26 +03:00
|
|
|
|
2022-12-09 14:42:47 +02:00
|
|
|
auto oldVisitablePos = h->visitablePos();
|
2009-03-07 17:55:56 +02:00
|
|
|
gs->map->removeBlockVisTiles(h,true);
|
2022-12-04 22:00:33 +02:00
|
|
|
h->appearance = VLC->objtypeh->getHandlerFor(Obj::HERO, h->type->heroClass->getIndex())->getTemplates().front();
|
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
h->setOwner(player);
|
2023-06-21 19:38:26 +02:00
|
|
|
h->setMovementPoints(h->movementPointsLimit(true));
|
2022-12-09 14:42:47 +02:00
|
|
|
h->pos = h->convertFromVisitablePos(oldVisitablePos);
|
2023-02-09 18:06:02 +02:00
|
|
|
gs->map->heroesOnMap.emplace_back(h);
|
|
|
|
gs->getPlayerState(h->getOwner())->heroes.emplace_back(h);
|
2022-12-04 22:00:33 +02:00
|
|
|
|
2009-03-07 17:55:56 +02:00
|
|
|
gs->map->addBlockVisTiles(h);
|
|
|
|
h->inTownGarrison = false;
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void NewObject::applyGs(CGameState *gs)
|
2009-07-26 06:33:13 +03:00
|
|
|
{
|
2023-01-10 20:09:09 +02:00
|
|
|
TerrainId terrainType = ETerrainId::NONE;
|
2019-05-18 19:39:36 +02:00
|
|
|
|
2023-06-20 21:06:45 +02:00
|
|
|
if (!gs->isInTheMap(targetPos))
|
2019-05-18 19:39:36 +02:00
|
|
|
{
|
2023-06-20 21:06:45 +02:00
|
|
|
logGlobal->error("Attempt to create object outside map at %s!", targetPos.toString());
|
|
|
|
return;
|
2019-05-18 19:39:36 +02:00
|
|
|
}
|
2013-01-12 21:08:33 +03:00
|
|
|
|
2023-06-20 21:06:45 +02:00
|
|
|
const TerrainTile & t = gs->map->getTile(targetPos);
|
|
|
|
terrainType = t.terType->getId();
|
|
|
|
|
2023-04-24 22:46:29 +02:00
|
|
|
auto handler = VLC->objtypeh->getHandlerFor(ID, subID);
|
2023-07-17 21:19:25 +02:00
|
|
|
|
2023-04-24 22:46:29 +02:00
|
|
|
CGObjectInstance * o = handler->create();
|
|
|
|
handler->configureObject(o, gs->getRandomGenerator());
|
|
|
|
|
2023-06-20 21:06:45 +02:00
|
|
|
if (ID == Obj::MONSTER) //probably more options will be needed
|
2009-07-26 06:33:13 +03:00
|
|
|
{
|
2023-06-20 21:06:45 +02:00
|
|
|
//CStackInstance hlp;
|
|
|
|
auto * cre = dynamic_cast<CGCreature *>(o);
|
|
|
|
//cre->slots[0] = hlp;
|
|
|
|
assert(cre);
|
|
|
|
cre->notGrowingTeam = cre->neverFlees = false;
|
|
|
|
cre->character = 2;
|
|
|
|
cre->gainedArtifact = ArtifactID::NONE;
|
|
|
|
cre->identifier = -1;
|
|
|
|
cre->addToSlot(SlotID(0), new CStackInstance(CreatureID(subID), -1)); //add placeholder stack
|
2009-07-26 06:33:13 +03:00
|
|
|
}
|
2023-06-20 21:06:45 +02:00
|
|
|
|
|
|
|
assert(!handler->getTemplates(terrainType).empty());
|
2023-07-17 21:19:25 +02:00
|
|
|
if (handler->getTemplates().empty())
|
|
|
|
{
|
|
|
|
logGlobal->error("Attempt to create object (%d %d) with no templates!", ID, subID);
|
|
|
|
return;
|
|
|
|
}
|
2023-06-20 21:06:45 +02:00
|
|
|
|
|
|
|
if (!handler->getTemplates(terrainType).empty())
|
|
|
|
o->appearance = handler->getTemplates(terrainType).front();
|
|
|
|
else
|
|
|
|
o->appearance = handler->getTemplates().front();
|
|
|
|
|
|
|
|
o->id = ObjectInstanceID(static_cast<si32>(gs->map->objects.size()));
|
2009-07-26 06:33:13 +03:00
|
|
|
o->ID = ID;
|
|
|
|
o->subID = subID;
|
2023-06-20 22:09:11 +02:00
|
|
|
o->pos = targetPos + o->getVisitableOffset();
|
2009-07-26 06:33:13 +03:00
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
gs->map->objects.emplace_back(o);
|
2009-07-26 06:33:13 +03:00
|
|
|
gs->map->addBlockVisTiles(o);
|
2016-09-09 19:30:36 +02:00
|
|
|
o->initObj(gs->getRandomGenerator());
|
2014-04-01 14:53:28 +03:00
|
|
|
gs->map->calculateGuardingGreaturePositions();
|
2013-08-18 18:46:28 +03:00
|
|
|
|
2023-06-20 21:06:45 +02:00
|
|
|
createdObjectID = o->id;
|
|
|
|
|
|
|
|
logGlobal->debug("Added object id=%d; address=%x; name=%s", o->id, (intptr_t)o, o->getObjectName());
|
2009-07-26 06:33:13 +03:00
|
|
|
}
|
2013-08-18 18:46:28 +03:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void NewArtifact::applyGs(CGameState *gs)
|
2010-11-10 02:06:25 +02:00
|
|
|
{
|
2010-12-26 16:34:11 +02:00
|
|
|
assert(!vstd::contains(gs->map->artInstances, art));
|
2011-07-13 21:39:02 +03:00
|
|
|
assert(!art->getParentNodes().size());
|
2023-06-18 14:21:35 +02:00
|
|
|
assert(art->artType);
|
|
|
|
|
2011-01-18 20:56:14 +02:00
|
|
|
art->setType(art->artType);
|
2023-06-29 17:34:07 +02:00
|
|
|
if(art->isCombined())
|
2023-06-18 14:21:35 +02:00
|
|
|
{
|
2023-07-03 18:15:40 +02:00
|
|
|
for(const auto & part : art->artType->getConstituents())
|
|
|
|
art->addPart(ArtifactUtils::createNewArtifactInstance(part), ArtifactPosition::PRE_FIRST);
|
2023-06-18 14:21:35 +02:00
|
|
|
}
|
|
|
|
gs->map->addNewArtifactInstance(art);
|
2010-11-10 02:06:25 +02:00
|
|
|
}
|
2009-07-26 06:33:13 +03:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
const CStackInstance * StackLocation::getStack()
|
2010-12-14 23:55:23 +02:00
|
|
|
{
|
|
|
|
if(!army->hasStackAtSlot(slot))
|
|
|
|
{
|
2017-08-11 19:03:05 +02:00
|
|
|
logNetwork->warn("%s don't have a stack at slot %d", army->nodeName(), slot.getNum());
|
2013-06-26 14:18:27 +03:00
|
|
|
return nullptr;
|
2010-12-14 23:55:23 +02:00
|
|
|
}
|
|
|
|
return &army->getStack(slot);
|
|
|
|
}
|
|
|
|
|
2023-04-16 23:24:11 +02:00
|
|
|
struct ObjectRetriever
|
2012-04-14 05:20:22 +03:00
|
|
|
{
|
|
|
|
const CArmedInstance * operator()(const ConstTransitivePtr<CGHeroInstance> &h) const
|
|
|
|
{
|
|
|
|
return h;
|
|
|
|
}
|
|
|
|
const CArmedInstance * operator()(const ConstTransitivePtr<CStackInstance> &s) const
|
|
|
|
{
|
|
|
|
return s->armyObj;
|
|
|
|
}
|
|
|
|
};
|
2023-04-16 23:24:11 +02:00
|
|
|
template<typename T>
|
|
|
|
struct GetBase
|
2012-04-14 05:20:22 +03:00
|
|
|
{
|
|
|
|
template <typename TArg>
|
|
|
|
T * operator()(TArg &arg) const
|
|
|
|
{
|
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-02-09 02:07:33 +03:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void ArtifactLocation::removeArtifact()
|
2014-02-09 02:07:33 +03:00
|
|
|
{
|
|
|
|
CArtifactInstance *a = getArt();
|
|
|
|
assert(a);
|
|
|
|
a->removeFrom(*this);
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
const CArmedInstance * ArtifactLocation::relatedObj() const
|
2012-04-14 05:20:22 +03:00
|
|
|
{
|
2023-04-15 03:33:00 +02:00
|
|
|
return std::visit(ObjectRetriever(), artHolder);
|
2012-04-14 05:20:22 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
PlayerColor ArtifactLocation::owningPlayer() const
|
2012-04-14 05:20:22 +03:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
const auto * obj = relatedObj();
|
2013-03-03 20:06:03 +03:00
|
|
|
return obj ? obj->tempOwner : PlayerColor::NEUTRAL;
|
2012-04-14 05:20:22 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
CArtifactSet *ArtifactLocation::getHolderArtSet()
|
2012-04-14 05:20:22 +03:00
|
|
|
{
|
2023-04-15 03:33:00 +02:00
|
|
|
return std::visit(GetBase<CArtifactSet>(), artHolder);
|
2012-04-14 05:20:22 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
CBonusSystemNode *ArtifactLocation::getHolderNode()
|
2012-04-14 05:20:22 +03:00
|
|
|
{
|
2023-04-15 03:33:00 +02:00
|
|
|
return std::visit(GetBase<CBonusSystemNode>(), artHolder);
|
2012-04-14 05:20:22 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
const CArtifactInstance *ArtifactLocation::getArt() const
|
2010-12-26 16:34:11 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
const auto * s = getSlot();
|
2022-11-10 18:29:39 +02:00
|
|
|
if(s)
|
2022-11-06 23:54:50 +02:00
|
|
|
return s->getArt();
|
|
|
|
else
|
|
|
|
return nullptr;
|
2010-12-26 16:34:11 +02:00
|
|
|
}
|
|
|
|
|
2023-06-24 17:14:56 +02:00
|
|
|
CArtifactSet * ArtifactLocation::getHolderArtSet() const
|
2012-04-14 05:20:22 +03:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * t = const_cast<ArtifactLocation *>(this);
|
2012-04-14 05:20:22 +03:00
|
|
|
return t->getHolderArtSet();
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
const CBonusSystemNode * ArtifactLocation::getHolderNode() const
|
2012-04-14 05:20:22 +03:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * t = const_cast<ArtifactLocation *>(this);
|
2012-04-14 05:20:22 +03:00
|
|
|
return t->getHolderNode();
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
CArtifactInstance *ArtifactLocation::getArt()
|
2010-12-26 16:34:11 +02:00
|
|
|
{
|
|
|
|
const ArtifactLocation *t = this;
|
|
|
|
return const_cast<CArtifactInstance*>(t->getArt());
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
const ArtSlotInfo *ArtifactLocation::getSlot() const
|
2010-12-26 16:34:11 +02:00
|
|
|
{
|
2012-04-14 05:20:22 +03:00
|
|
|
return getHolderArtSet()->getSlot(slot);
|
2010-12-26 16:34:11 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void ChangeStackCount::applyGs(CGameState * gs)
|
2010-11-27 03:46:19 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * srcObj = gs->getArmyInstance(army);
|
2018-03-10 23:19:36 +02:00
|
|
|
if(!srcObj)
|
|
|
|
logNetwork->error("[CRITICAL] ChangeStackCount: invalid army object %d, possible game state corruption.", army.getNum());
|
|
|
|
|
2010-11-27 03:46:19 +02:00
|
|
|
if(absoluteValue)
|
2018-03-10 23:19:36 +02:00
|
|
|
srcObj->setStackCount(slot, count);
|
2010-11-27 03:46:19 +02:00
|
|
|
else
|
2018-03-10 23:19:36 +02:00
|
|
|
srcObj->changeStackCount(slot, count);
|
2010-11-27 03:46:19 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetStackType::applyGs(CGameState * gs)
|
2010-11-27 03:46:19 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * srcObj = gs->getArmyInstance(army);
|
2018-03-10 23:19:36 +02:00
|
|
|
if(!srcObj)
|
|
|
|
logNetwork->error("[CRITICAL] SetStackType: invalid army object %d, possible game state corruption.", army.getNum());
|
|
|
|
|
|
|
|
srcObj->setStackType(slot, type);
|
2010-11-27 03:46:19 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void EraseStack::applyGs(CGameState * gs)
|
2010-11-27 03:46:19 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * srcObj = gs->getArmyInstance(army);
|
2018-03-10 23:19:36 +02:00
|
|
|
if(!srcObj)
|
|
|
|
logNetwork->error("[CRITICAL] EraseStack: invalid army object %d, possible game state corruption.", army.getNum());
|
|
|
|
|
|
|
|
srcObj->eraseStack(slot);
|
2010-11-27 03:46:19 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SwapStacks::applyGs(CGameState * gs)
|
2010-11-27 03:46:19 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * srcObj = gs->getArmyInstance(srcArmy);
|
2018-03-10 23:19:36 +02:00
|
|
|
if(!srcObj)
|
|
|
|
logNetwork->error("[CRITICAL] SwapStacks: invalid army object %d, possible game state corruption.", srcArmy.getNum());
|
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * dstObj = gs->getArmyInstance(dstArmy);
|
2018-03-10 23:19:36 +02:00
|
|
|
if(!dstObj)
|
|
|
|
logNetwork->error("[CRITICAL] SwapStacks: invalid army object %d, possible game state corruption.", dstArmy.getNum());
|
|
|
|
|
|
|
|
CStackInstance * s1 = srcObj->detachStack(srcSlot);
|
|
|
|
CStackInstance * s2 = dstObj->detachStack(dstSlot);
|
2010-11-27 03:46:19 +02:00
|
|
|
|
2018-03-10 23:19:36 +02:00
|
|
|
srcObj->putStack(srcSlot, s2);
|
|
|
|
dstObj->putStack(dstSlot, s1);
|
2010-11-27 03:46:19 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void InsertNewStack::applyGs(CGameState *gs)
|
2010-11-27 03:46:19 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
if(auto * obj = gs->getArmyInstance(army))
|
2022-09-24 16:29:39 +02:00
|
|
|
obj->putStack(slot, new CStackInstance(type, count));
|
2018-03-10 23:19:36 +02:00
|
|
|
else
|
|
|
|
logNetwork->error("[CRITICAL] InsertNewStack: invalid army object %d, possible game state corruption.", army.getNum());
|
2010-11-27 03:46:19 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void RebalanceStacks::applyGs(CGameState * gs)
|
2010-11-27 03:46:19 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * srcObj = gs->getArmyInstance(srcArmy);
|
2018-03-10 23:19:36 +02:00
|
|
|
if(!srcObj)
|
|
|
|
logNetwork->error("[CRITICAL] RebalanceStacks: invalid army object %d, possible game state corruption.", srcArmy.getNum());
|
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * dstObj = gs->getArmyInstance(dstArmy);
|
2018-03-10 23:19:36 +02:00
|
|
|
if(!dstObj)
|
|
|
|
logNetwork->error("[CRITICAL] RebalanceStacks: invalid army object %d, possible game state corruption.", dstArmy.getNum());
|
|
|
|
|
|
|
|
StackLocation src(srcObj, srcSlot);
|
|
|
|
StackLocation dst(dstObj, dstSlot);
|
|
|
|
|
|
|
|
const CCreature * srcType = src.army->getCreature(src.slot);
|
2010-12-06 01:10:02 +02:00
|
|
|
TQuantity srcCount = src.army->getStackCount(src.slot);
|
2023-03-15 21:34:29 +02:00
|
|
|
bool stackExp = VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE);
|
2010-12-06 01:10:02 +02:00
|
|
|
|
|
|
|
if(srcCount == count) //moving whole stack
|
|
|
|
{
|
2023-04-11 00:00:46 +02:00
|
|
|
[[maybe_unused]] const CCreature *c = dst.army->getCreature(dst.slot);
|
|
|
|
|
|
|
|
if(c) //stack at dest -> merge
|
2010-12-06 01:10:02 +02:00
|
|
|
{
|
|
|
|
assert(c == srcType);
|
2013-03-05 10:34:52 +03:00
|
|
|
auto alHere = ArtifactLocation (src.getStack(), ArtifactPosition::CREATURE_SLOT);
|
|
|
|
auto alDest = ArtifactLocation (dst.getStack(), ArtifactPosition::CREATURE_SLOT);
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * artHere = alHere.getArt();
|
|
|
|
auto * artDest = alDest.getArt();
|
2013-03-05 10:34:52 +03:00
|
|
|
if (artHere)
|
|
|
|
{
|
|
|
|
if (alDest.getArt())
|
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * hero = dynamic_cast<CGHeroInstance *>(src.army.get());
|
2023-03-21 12:13:53 +02:00
|
|
|
auto dstSlot = ArtifactUtils::getArtBackpackPosition(hero, alDest.getArt()->getTypeId());
|
|
|
|
if(hero && dstSlot != ArtifactPosition::PRE_FIRST)
|
2013-03-05 10:34:52 +03:00
|
|
|
{
|
2023-03-21 12:13:53 +02:00
|
|
|
artDest->move (alDest, ArtifactLocation (hero, dstSlot));
|
2013-03-05 10:34:52 +03:00
|
|
|
}
|
|
|
|
//else - artifact cna be lost :/
|
|
|
|
else
|
|
|
|
{
|
2023-03-21 12:13:53 +02:00
|
|
|
EraseArtifact ea;
|
|
|
|
ea.al = alDest;
|
|
|
|
ea.applyGs(gs);
|
|
|
|
logNetwork->warn("Cannot move artifact! No free slots");
|
2013-03-05 10:34:52 +03:00
|
|
|
}
|
|
|
|
artHere->move (alHere, alDest);
|
|
|
|
//TODO: choose from dialog
|
|
|
|
}
|
|
|
|
else //just move to the other slot before stack gets erased
|
|
|
|
{
|
|
|
|
artHere->move (alHere, alDest);
|
|
|
|
}
|
|
|
|
}
|
2012-08-24 12:37:52 +03:00
|
|
|
if (stackExp)
|
2011-03-27 12:31:14 +03:00
|
|
|
{
|
|
|
|
ui64 totalExp = srcCount * src.army->getStackExperience(src.slot) + dst.army->getStackCount(dst.slot) * dst.army->getStackExperience(dst.slot);
|
|
|
|
src.army->eraseStack(src.slot);
|
|
|
|
dst.army->changeStackCount(dst.slot, count);
|
|
|
|
dst.army->setStackExp(dst.slot, totalExp /(dst.army->getStackCount(dst.slot))); //mean
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
src.army->eraseStack(src.slot);
|
|
|
|
dst.army->changeStackCount(dst.slot, count);
|
|
|
|
}
|
2010-12-06 01:10:02 +02:00
|
|
|
}
|
2011-03-27 12:31:14 +03:00
|
|
|
else //move stack to an empty slot, no exp change needed
|
2010-12-06 01:10:02 +02:00
|
|
|
{
|
|
|
|
CStackInstance *stackDetached = src.army->detachStack(src.slot);
|
|
|
|
dst.army->putStack(dst.slot, stackDetached);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-04-11 00:00:46 +02:00
|
|
|
[[maybe_unused]] const CCreature *c = dst.army->getCreature(dst.slot);
|
|
|
|
if(c) //stack at dest -> rebalance
|
2010-12-06 01:10:02 +02:00
|
|
|
{
|
|
|
|
assert(c == srcType);
|
2012-08-24 12:37:52 +03:00
|
|
|
if (stackExp)
|
2011-03-27 12:31:14 +03:00
|
|
|
{
|
|
|
|
ui64 totalExp = srcCount * src.army->getStackExperience(src.slot) + dst.army->getStackCount(dst.slot) * dst.army->getStackExperience(dst.slot);
|
|
|
|
src.army->changeStackCount(src.slot, -count);
|
|
|
|
dst.army->changeStackCount(dst.slot, count);
|
|
|
|
dst.army->setStackExp(dst.slot, totalExp /(src.army->getStackCount(src.slot) + dst.army->getStackCount(dst.slot))); //mean
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
src.army->changeStackCount(src.slot, -count);
|
|
|
|
dst.army->changeStackCount(dst.slot, count);
|
|
|
|
}
|
2010-12-06 01:10:02 +02:00
|
|
|
}
|
|
|
|
else //split stack to an empty slot
|
|
|
|
{
|
|
|
|
src.army->changeStackCount(src.slot, -count);
|
2023-04-05 02:26:29 +02:00
|
|
|
dst.army->addToSlot(dst.slot, srcType->getId(), count, false);
|
2012-08-24 12:37:52 +03:00
|
|
|
if (stackExp)
|
2011-03-27 12:31:14 +03:00
|
|
|
dst.army->setStackExp(dst.slot, src.army->getStackExperience(src.slot));
|
2010-12-06 01:10:02 +02:00
|
|
|
}
|
|
|
|
}
|
2012-03-06 19:59:55 +03:00
|
|
|
|
|
|
|
CBonusSystemNode::treeHasChanged();
|
2010-11-27 03:46:19 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BulkRebalanceStacks::applyGs(CGameState * gs)
|
2021-11-28 14:57:38 +02:00
|
|
|
{
|
|
|
|
for(auto & move : moves)
|
|
|
|
move.applyGs(gs);
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BulkSmartRebalanceStacks::applyGs(CGameState * gs)
|
2021-11-28 14:57:38 +02:00
|
|
|
{
|
|
|
|
for(auto & move : moves)
|
|
|
|
move.applyGs(gs);
|
|
|
|
|
|
|
|
for(auto & change : changes)
|
|
|
|
change.applyGs(gs);
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void PutArtifact::applyGs(CGameState *gs)
|
2010-12-26 16:34:11 +02:00
|
|
|
{
|
|
|
|
assert(art->canBePutAt(al));
|
2023-05-09 15:48:52 +02:00
|
|
|
// Ensure that artifact has been correctly added via NewArtifact pack
|
|
|
|
assert(vstd::contains(gs->map->artInstances, art));
|
|
|
|
assert(!art->getParentNodes().empty());
|
2012-04-14 05:20:22 +03:00
|
|
|
art->putAt(al);
|
2010-12-26 16:34:11 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void EraseArtifact::applyGs(CGameState *gs)
|
2010-12-26 16:34:11 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
const auto * slot = al.getSlot();
|
2016-01-22 11:53:01 +02:00
|
|
|
if(slot->locked)
|
|
|
|
{
|
2023-01-02 15:58:56 +02:00
|
|
|
logGlobal->debug("Erasing locked artifact: %s", slot->artifact->artType->getNameTranslated());
|
2016-01-22 11:53:01 +02:00
|
|
|
DisassembledArtifact dis;
|
|
|
|
dis.al.artHolder = al.artHolder;
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * aset = al.getHolderArtSet();
|
2016-10-27 19:22:29 +02:00
|
|
|
#ifndef NDEBUG
|
2016-01-22 11:53:01 +02:00
|
|
|
bool found = false;
|
2023-02-12 09:23:39 +02:00
|
|
|
#endif
|
2016-01-22 11:53:01 +02:00
|
|
|
for(auto& p : aset->artifactsWorn)
|
|
|
|
{
|
|
|
|
auto art = p.second.artifact;
|
2023-06-29 17:34:07 +02:00
|
|
|
if(art->isCombined() && art->isPart(slot->artifact))
|
2016-01-22 11:53:01 +02:00
|
|
|
{
|
|
|
|
dis.al.slot = aset->getArtPos(art);
|
2016-10-27 19:22:29 +02:00
|
|
|
#ifndef NDEBUG
|
2016-01-22 11:53:01 +02:00
|
|
|
found = true;
|
2023-02-12 09:23:39 +02:00
|
|
|
#endif
|
2016-01-22 11:53:01 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(found && "Failed to determine the assembly this locked artifact belongs to");
|
2023-01-02 15:58:56 +02:00
|
|
|
logGlobal->debug("Found the corresponding assembly: %s", dis.al.getSlot()->artifact->artType->getNameTranslated());
|
2016-01-22 11:53:01 +02:00
|
|
|
dis.applyGs(gs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-01-02 15:58:56 +02:00
|
|
|
logGlobal->debug("Erasing artifact %s", slot->artifact->artType->getNameTranslated());
|
2016-01-22 11:53:01 +02:00
|
|
|
}
|
2014-02-09 02:07:33 +03:00
|
|
|
al.removeArtifact();
|
2010-12-26 16:34:11 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void MoveArtifact::applyGs(CGameState * gs)
|
2010-12-26 16:34:11 +02:00
|
|
|
{
|
2022-11-06 23:54:50 +02:00
|
|
|
CArtifactInstance * art = src.getArt();
|
2023-05-06 23:59:44 +02:00
|
|
|
assert(!ArtifactUtils::isSlotEquipment(dst.slot) || !dst.getArt());
|
2022-11-06 23:54:50 +02:00
|
|
|
art->move(src, dst);
|
2010-12-26 16:34:11 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BulkMoveArtifacts::applyGs(CGameState * gs)
|
2022-11-06 23:54:50 +02:00
|
|
|
{
|
2022-11-12 19:30:24 +02:00
|
|
|
enum class EBulkArtsOp
|
2022-11-06 23:54:50 +02:00
|
|
|
{
|
2022-11-12 19:30:24 +02:00
|
|
|
BULK_MOVE,
|
|
|
|
BULK_REMOVE,
|
|
|
|
BULK_PUT
|
|
|
|
};
|
2012-02-17 22:30:40 +03:00
|
|
|
|
2022-11-12 19:30:24 +02:00
|
|
|
auto bulkArtsOperation = [this](std::vector<LinkedSlots> & artsPack,
|
|
|
|
CArtifactSet * artSet, EBulkArtsOp operation) -> void
|
2012-04-14 05:20:22 +03:00
|
|
|
{
|
2022-11-12 19:30:24 +02:00
|
|
|
int numBackpackArtifactsMoved = 0;
|
|
|
|
for(auto & slot : artsPack)
|
2012-04-14 05:20:22 +03:00
|
|
|
{
|
2022-11-12 19:30:24 +02:00
|
|
|
// When an object gets removed from the backpack, the backpack shrinks
|
|
|
|
// so all the following indices will be affected. Thus, we need to update
|
|
|
|
// the subsequent artifact slots to account for that
|
|
|
|
auto srcPos = slot.srcPos;
|
2022-11-18 22:49:57 +02:00
|
|
|
if(ArtifactUtils::isSlotBackpack(srcPos) && (operation != EBulkArtsOp::BULK_PUT))
|
2022-11-06 23:54:50 +02:00
|
|
|
{
|
2022-11-12 19:30:24 +02:00
|
|
|
srcPos = ArtifactPosition(srcPos.num - numBackpackArtifactsMoved);
|
|
|
|
}
|
2023-02-09 18:06:02 +02:00
|
|
|
const auto * slotInfo = artSet->getSlot(srcPos);
|
2022-11-12 19:30:24 +02:00
|
|
|
assert(slotInfo);
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * art = const_cast<CArtifactInstance *>(slotInfo->getArt());
|
2022-11-12 19:30:24 +02:00
|
|
|
assert(art);
|
|
|
|
switch(operation)
|
|
|
|
{
|
|
|
|
case EBulkArtsOp::BULK_MOVE:
|
|
|
|
const_cast<CArtifactInstance*>(art)->move(
|
|
|
|
ArtifactLocation(srcArtHolder, srcPos), ArtifactLocation(dstArtHolder, slot.dstPos));
|
|
|
|
break;
|
|
|
|
case EBulkArtsOp::BULK_REMOVE:
|
|
|
|
art->removeFrom(ArtifactLocation(dstArtHolder, srcPos));
|
|
|
|
break;
|
|
|
|
case EBulkArtsOp::BULK_PUT:
|
|
|
|
art->putAt(ArtifactLocation(srcArtHolder, slot.dstPos));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2022-11-06 23:54:50 +02:00
|
|
|
}
|
|
|
|
|
2023-08-19 23:22:31 +02:00
|
|
|
if(srcPos >= ArtifactPosition::BACKPACK_START)
|
2022-11-06 23:54:50 +02:00
|
|
|
{
|
2022-11-12 19:30:24 +02:00
|
|
|
numBackpackArtifactsMoved++;
|
2022-11-06 23:54:50 +02:00
|
|
|
}
|
2012-04-14 05:20:22 +03:00
|
|
|
}
|
2022-11-12 19:30:24 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
if(swap)
|
|
|
|
{
|
|
|
|
// Swap
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * leftSet = getSrcHolderArtSet();
|
|
|
|
auto * rightSet = getDstHolderArtSet();
|
2022-11-13 12:04:51 +02:00
|
|
|
CArtifactFittingSet artFittingSet(leftSet->bearerType());
|
2022-11-06 23:54:50 +02:00
|
|
|
|
2022-11-13 12:04:51 +02:00
|
|
|
artFittingSet.artifactsWorn = rightSet->artifactsWorn;
|
|
|
|
artFittingSet.artifactsInBackpack = rightSet->artifactsInBackpack;
|
2022-11-06 23:54:50 +02:00
|
|
|
|
2022-11-12 19:30:24 +02:00
|
|
|
bulkArtsOperation(artsPack1, rightSet, EBulkArtsOp::BULK_REMOVE);
|
|
|
|
bulkArtsOperation(artsPack0, leftSet, EBulkArtsOp::BULK_MOVE);
|
2022-11-13 12:04:51 +02:00
|
|
|
bulkArtsOperation(artsPack1, &artFittingSet, EBulkArtsOp::BULK_PUT);
|
2022-11-06 23:54:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-11-12 19:30:24 +02:00
|
|
|
bulkArtsOperation(artsPack0, getSrcHolderArtSet(), EBulkArtsOp::BULK_MOVE);
|
2012-04-14 05:20:22 +03:00
|
|
|
}
|
2010-12-26 16:34:11 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void AssembledArtifact::applyGs(CGameState *gs)
|
2011-01-22 05:43:20 +02:00
|
|
|
{
|
2022-11-18 01:32:25 +02:00
|
|
|
CArtifactSet * artSet = al.getHolderArtSet();
|
2023-04-10 16:44:41 +02:00
|
|
|
[[maybe_unused]] const CArtifactInstance *transformedArt = al.getArt();
|
2011-01-22 05:43:20 +02:00
|
|
|
assert(transformedArt);
|
2022-11-18 22:49:57 +02:00
|
|
|
bool combineEquipped = !ArtifactUtils::isSlotBackpack(al.slot);
|
2023-04-20 21:03:28 +02:00
|
|
|
assert(vstd::contains_if(ArtifactUtils::assemblyPossibilities(artSet, transformedArt->artType->getId(), combineEquipped), [=](const CArtifact * art)->bool
|
2022-12-18 12:28:30 +02:00
|
|
|
{
|
2023-01-02 15:58:56 +02:00
|
|
|
return art->getId() == builtArt->getId();
|
2022-12-18 12:28:30 +02:00
|
|
|
}));
|
2011-01-22 05:43:20 +02:00
|
|
|
|
2023-06-18 14:21:35 +02:00
|
|
|
auto * combinedArt = new CArtifactInstance(builtArt);
|
2011-01-28 04:11:58 +02:00
|
|
|
gs->map->addNewArtifactInstance(combinedArt);
|
2022-11-18 01:32:25 +02:00
|
|
|
// Retrieve all constituents
|
2023-07-03 18:15:40 +02:00
|
|
|
for(const CArtifact * constituent : builtArt->getConstituents())
|
2011-01-22 05:43:20 +02:00
|
|
|
{
|
2023-01-02 15:58:56 +02:00
|
|
|
ArtifactPosition pos = combineEquipped ? artSet->getArtPos(constituent->getId(), true, false) :
|
|
|
|
artSet->getArtBackpackPos(constituent->getId());
|
2023-08-19 23:22:31 +02:00
|
|
|
assert(pos != ArtifactPosition::PRE_FIRST);
|
2022-11-18 01:32:25 +02:00
|
|
|
CArtifactInstance * constituentInstance = artSet->getArt(pos);
|
2011-01-22 05:43:20 +02:00
|
|
|
|
|
|
|
//move constituent from hero to be part of new, combined artifact
|
2012-09-28 23:49:23 +03:00
|
|
|
constituentInstance->removeFrom(ArtifactLocation(al.artHolder, pos));
|
2022-11-18 01:32:25 +02:00
|
|
|
if(combineEquipped)
|
|
|
|
{
|
2023-07-03 22:11:56 +02:00
|
|
|
if(!vstd::contains(combinedArt->artType->getPossibleSlots().at(artSet->bearerType()), al.slot)
|
|
|
|
&& vstd::contains(combinedArt->artType->getPossibleSlots().at(artSet->bearerType()), pos))
|
2022-11-18 01:32:25 +02:00
|
|
|
al.slot = pos;
|
2023-06-06 13:37:48 +02:00
|
|
|
if(al.slot == pos)
|
|
|
|
pos = ArtifactPosition::PRE_FIRST;
|
2022-11-18 01:32:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-11-18 22:49:57 +02:00
|
|
|
al.slot = std::min(al.slot, pos);
|
2023-05-17 16:01:22 +02:00
|
|
|
pos = ArtifactPosition::PRE_FIRST;
|
2023-06-06 13:37:48 +02:00
|
|
|
}
|
2023-07-03 18:15:40 +02:00
|
|
|
combinedArt->addPart(constituentInstance, pos);
|
2011-01-22 05:43:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//put new combined artifacts
|
2012-04-14 05:20:22 +03:00
|
|
|
combinedArt->putAt(al);
|
2011-01-22 05:43:20 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void DisassembledArtifact::applyGs(CGameState *gs)
|
2011-01-22 05:43:20 +02:00
|
|
|
{
|
2023-06-18 14:21:35 +02:00
|
|
|
auto * disassembled = al.getArt();
|
2011-01-24 01:49:17 +02:00
|
|
|
assert(disassembled);
|
|
|
|
|
2023-07-03 18:15:40 +02:00
|
|
|
auto parts = disassembled->getPartsInfo();
|
2012-04-14 05:20:22 +03:00
|
|
|
disassembled->removeFrom(al);
|
2023-06-18 14:21:35 +02:00
|
|
|
for(auto & part : parts)
|
2011-01-24 01:49:17 +02:00
|
|
|
{
|
2023-06-18 14:21:35 +02:00
|
|
|
ArtifactLocation partLoc = al;
|
|
|
|
// ArtifactPosition::PRE_FIRST is value of main part slot -> it'll replace combined artifact in its pos
|
|
|
|
partLoc.slot = (ArtifactUtils::isSlotEquipment(part.slot) ? part.slot : al.slot);
|
|
|
|
disassembled->detachFrom(*part.art);
|
|
|
|
part.art->putAt(partLoc);
|
2011-01-24 01:49:17 +02:00
|
|
|
}
|
2011-01-28 04:11:58 +02:00
|
|
|
gs->map->eraseArtifactInstance(disassembled);
|
2011-01-22 05:43:20 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void HeroVisit::applyGs(CGameState *gs)
|
2011-05-10 01:20:47 +03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetAvailableArtifacts::applyGs(CGameState * gs) const
|
2010-06-26 19:02:10 +03:00
|
|
|
{
|
|
|
|
if(id >= 0)
|
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
if(auto * bm = dynamic_cast<CGBlackMarket *>(gs->map->objects[id].get()))
|
2010-06-26 19:02:10 +03:00
|
|
|
{
|
|
|
|
bm->artifacts = arts;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-08-10 18:39:27 +02:00
|
|
|
logNetwork->error("Wrong black market id!");
|
2010-06-26 19:02:10 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CGTownInstance::merchantArtifacts = arts;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void NewTurn::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
|
|
|
gs->day = day;
|
2015-12-25 00:46:44 +02:00
|
|
|
|
|
|
|
// Update bonuses before doing anything else so hero don't get more MP than needed
|
2018-03-05 08:51:35 +02:00
|
|
|
gs->globalEffects.removeBonusesRecursive(Bonus::OneDay); //works for children -> all game objs
|
2017-09-09 14:25:55 +02:00
|
|
|
gs->globalEffects.reduceBonusDurations(Bonus::NDays);
|
|
|
|
gs->globalEffects.reduceBonusDurations(Bonus::OneWeek);
|
2015-12-25 00:46:44 +02:00
|
|
|
//TODO not really a single root hierarchy, what about bonuses placed elsewhere? [not an issue with H3 mechanics but in the future...]
|
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const NewTurn::Hero & h : heroes) //give mana/movement point
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2009-04-04 01:34:31 +03:00
|
|
|
CGHeroInstance *hero = gs->getHero(h.id);
|
2016-01-28 21:48:51 +02:00
|
|
|
if(!hero)
|
|
|
|
{
|
2017-08-11 19:03:05 +02:00
|
|
|
logGlobal->error("Hero %d not found in NewTurn::applyGs", h.id.getNum());
|
2016-01-28 21:48:51 +02:00
|
|
|
continue;
|
|
|
|
}
|
2023-07-11 16:51:14 +02:00
|
|
|
|
|
|
|
hero->setMovementPoints(h.move);
|
|
|
|
hero->mana = h.mana;
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-07-12 11:29:05 +02:00
|
|
|
gs->heroesPool->onNewDay();
|
2023-07-11 14:16:02 +02:00
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const auto & re : res)
|
2009-11-28 03:42:08 +02:00
|
|
|
{
|
2023-08-27 00:35:38 +02:00
|
|
|
assert(re.first.isValidPlayer());
|
2023-02-09 18:06:02 +02:00
|
|
|
gs->getPlayerState(re.first)->resources = re.second;
|
2009-11-28 03:42:08 +02:00
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
for(const auto & creatureSet : cres) //set available creatures in towns
|
2013-03-14 23:44:00 +03:00
|
|
|
creatureSet.second.applyGs(gs);
|
2009-03-07 17:55:56 +02:00
|
|
|
|
2013-06-29 16:05:48 +03:00
|
|
|
for(CGTownInstance* t : gs->map->towns)
|
2011-08-26 23:32:05 +03:00
|
|
|
t->builded = 0;
|
2015-11-30 23:44:58 +02:00
|
|
|
|
|
|
|
if(gs->getDate(Date::DAY_OF_WEEK) == 1)
|
|
|
|
gs->updateRumor();
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetObjectProperty::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2013-02-14 02:55:42 +03:00
|
|
|
CGObjectInstance *obj = gs->getObjInstance(id);
|
2009-03-07 17:55:56 +02:00
|
|
|
if(!obj)
|
2009-08-22 16:59:15 +03:00
|
|
|
{
|
2017-08-10 18:39:27 +02:00
|
|
|
logNetwork->error("Wrong object ID - property cannot be set!");
|
2009-08-22 16:59:15 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * cai = dynamic_cast<CArmedInstance *>(obj);
|
2011-03-08 09:40:14 +02:00
|
|
|
if(what == ObjProperty::OWNER && cai)
|
2009-08-22 16:59:15 +03:00
|
|
|
{
|
2012-09-23 21:01:04 +03:00
|
|
|
if(obj->ID == Obj::TOWN)
|
2011-02-21 06:13:00 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * t = dynamic_cast<CGTownInstance *>(obj);
|
|
|
|
assert(t);
|
2023-08-24 20:35:01 +02:00
|
|
|
|
|
|
|
PlayerColor oldOwner = t->tempOwner;
|
|
|
|
if(oldOwner.isValidPlayer())
|
|
|
|
{
|
|
|
|
auto * state = gs->getPlayerState(oldOwner);
|
|
|
|
state->towns -= t;
|
|
|
|
|
|
|
|
if(state->towns.empty())
|
|
|
|
*state->daysWithoutCastle = 0;
|
|
|
|
}
|
2023-08-27 00:35:38 +02:00
|
|
|
if(PlayerColor(val).isValidPlayer())
|
2016-08-23 06:57:57 +02:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
PlayerState * p = gs->getPlayerState(PlayerColor(val));
|
2023-02-09 18:06:02 +02:00
|
|
|
p->towns.emplace_back(t);
|
2016-08-23 06:57:57 +02:00
|
|
|
|
|
|
|
//reset counter before NewTurn to avoid no town message if game loaded at turn when one already captured
|
|
|
|
if(p->daysWithoutCastle)
|
2023-04-16 19:42:56 +02:00
|
|
|
p->daysWithoutCastle = std::nullopt;
|
2016-08-23 06:57:57 +02:00
|
|
|
}
|
2011-02-21 06:13:00 +02:00
|
|
|
}
|
2011-03-08 09:40:14 +02:00
|
|
|
|
2022-11-06 01:26:13 +02:00
|
|
|
CBonusSystemNode & nodeToMove = cai->whatShouldBeAttached();
|
|
|
|
nodeToMove.detachFrom(cai->whereShouldBeAttached(gs));
|
2011-03-08 09:40:14 +02:00
|
|
|
obj->setProperty(what,val);
|
2022-11-06 01:26:13 +02:00
|
|
|
nodeToMove.attachTo(cai->whereShouldBeAttached(gs));
|
2009-08-22 16:59:15 +03:00
|
|
|
}
|
2011-03-08 09:40:14 +02:00
|
|
|
else //not an armed instance
|
2011-02-22 11:47:25 +02:00
|
|
|
{
|
|
|
|
obj->setProperty(what,val);
|
|
|
|
}
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void PrepareHeroLevelUp::applyGs(CGameState * gs)
|
2016-09-07 23:24:05 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * hero = gs->getHero(heroId);
|
2018-03-10 21:19:55 +02:00
|
|
|
assert(hero);
|
|
|
|
|
|
|
|
auto proposedSkills = hero->getLevelUpProposedSecondarySkills();
|
2016-09-07 23:24:05 +02:00
|
|
|
|
|
|
|
if(skills.size() == 1 || hero->tempOwner == PlayerColor::NEUTRAL) //choose skill automatically
|
|
|
|
{
|
2018-03-10 21:19:55 +02:00
|
|
|
skills.push_back(*RandomGeneratorUtil::nextItem(proposedSkills, hero->skillsInfo.rand));
|
2016-09-07 23:24:05 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
skills = proposedSkills;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void HeroLevelUp::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * hero = gs->getHero(heroId);
|
2018-03-10 21:19:55 +02:00
|
|
|
assert(hero);
|
|
|
|
hero->levelUp(skills);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void CommanderLevelUp::applyGs(CGameState * gs) const
|
2012-05-16 20:29:05 +03:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
auto * hero = gs->getHero(heroId);
|
2018-03-10 21:19:55 +02:00
|
|
|
assert(hero);
|
|
|
|
auto commander = hero->commander;
|
|
|
|
assert(commander);
|
2012-05-16 20:29:05 +03:00
|
|
|
commander->levelUp();
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleStart::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
assert(battleID == gs->nextBattleID);
|
|
|
|
|
|
|
|
gs->currentBattles.emplace_back(info);
|
|
|
|
|
|
|
|
info->battleID = gs->nextBattleID;
|
|
|
|
info->localInit();
|
|
|
|
|
2023-09-05 16:22:11 +02:00
|
|
|
gs->nextBattleID = vstd::next(gs->nextBattleID, 1);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleNextRound::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-08-28 16:43:57 +02:00
|
|
|
gs->getBattle(battleID)->nextRound();
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleSetActiveStack::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
gs->getBattle(battleID)->nextTurn(stack);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleTriggerEffect::applyGs(CGameState * gs) const
|
2011-10-08 16:02:58 +03:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
CStack * st = gs->getBattle(battleID)->getStack(stackID);
|
2017-07-04 13:24:46 +02:00
|
|
|
assert(st);
|
2023-05-01 00:20:01 +02:00
|
|
|
switch(static_cast<BonusType>(effect))
|
2011-10-08 16:02:58 +03:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
case BonusType::HP_REGENERATION:
|
2017-07-04 13:24:46 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
int64_t toHeal = val;
|
|
|
|
st->heal(toHeal, EHealLevel::HEAL, EHealPower::PERMANENT);
|
2017-07-04 13:24:46 +02:00
|
|
|
break;
|
|
|
|
}
|
2023-05-01 00:20:01 +02:00
|
|
|
case BonusType::MANA_DRAIN:
|
2017-07-04 13:24:46 +02:00
|
|
|
{
|
|
|
|
CGHeroInstance * h = gs->getHero(ObjectInstanceID(additionalInfo));
|
2017-07-20 06:08:49 +02:00
|
|
|
st->drainedMana = true;
|
2017-07-04 13:24:46 +02:00
|
|
|
h->mana -= val;
|
|
|
|
vstd::amax(h->mana, 0);
|
|
|
|
break;
|
|
|
|
}
|
2023-05-01 00:20:01 +02:00
|
|
|
case BonusType::POISON:
|
2017-07-04 13:24:46 +02:00
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
auto b = st->getBonusLocalFirst(Selector::source(BonusSource::SPELL_EFFECT, SpellID::POISON)
|
|
|
|
.And(Selector::type()(BonusType::STACK_HEALTH)));
|
2017-07-04 13:24:46 +02:00
|
|
|
if (b)
|
|
|
|
b->val = val;
|
|
|
|
break;
|
|
|
|
}
|
2023-05-01 00:20:01 +02:00
|
|
|
case BonusType::ENCHANTER:
|
|
|
|
case BonusType::MORALE:
|
2017-07-04 13:24:46 +02:00
|
|
|
break;
|
2023-05-01 00:20:01 +02:00
|
|
|
case BonusType::FEAR:
|
2017-07-20 06:08:49 +02:00
|
|
|
st->fear = true;
|
2017-07-04 13:24:46 +02:00
|
|
|
break;
|
|
|
|
default:
|
2017-08-11 19:03:05 +02:00
|
|
|
logNetwork->error("Unrecognized trigger effect type %d", effect);
|
2011-10-08 16:02:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleUpdateGateState::applyGs(CGameState * gs) const
|
2016-01-29 21:35:11 +02:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
if(gs->getBattle(battleID))
|
|
|
|
gs->getBattle(battleID)->si.gateState = state;
|
2016-01-29 21:35:11 +02:00
|
|
|
}
|
|
|
|
|
2023-09-05 16:22:11 +02:00
|
|
|
void BattleCancelled::applyGs(CGameState * gs) const
|
|
|
|
{
|
|
|
|
auto currentBattle = boost::range::find_if(gs->currentBattles, [&](const auto & battle)
|
|
|
|
{
|
|
|
|
return battle->battleID == battleID;
|
|
|
|
});
|
|
|
|
|
|
|
|
assert(currentBattle != gs->currentBattles.end());
|
|
|
|
gs->currentBattles.erase(currentBattle);
|
|
|
|
}
|
|
|
|
|
2023-04-06 17:34:07 +02:00
|
|
|
void BattleResultAccepted::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-06-30 17:59:45 +02:00
|
|
|
// Remove any "until next battle" bonuses
|
|
|
|
for(auto & res : heroResult)
|
2012-05-07 15:54:22 +03:00
|
|
|
{
|
2023-06-30 17:59:45 +02:00
|
|
|
if(res.hero)
|
2023-07-22 21:04:32 +02:00
|
|
|
res.hero->removeBonusesRecursive(Bonus::OneBattle);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(winnerSide != 2)
|
|
|
|
{
|
|
|
|
// Grow up growing artifacts
|
|
|
|
const auto hero = heroResult[winnerSide].hero;
|
|
|
|
|
|
|
|
if (hero)
|
|
|
|
{
|
|
|
|
if(hero->commander && hero->commander->alive)
|
|
|
|
{
|
|
|
|
for(auto & art : hero->commander->artifactsWorn)
|
|
|
|
art.second.artifact->growingUp();
|
|
|
|
}
|
|
|
|
for(auto & art : hero->artifactsWorn)
|
|
|
|
{
|
|
|
|
art.second.artifact->growingUp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(VLC->settings()->getBoolean(EGameSettings::MODULE_STACK_EXPERIENCE))
|
|
|
|
{
|
|
|
|
if(heroResult[0].army)
|
2023-06-30 17:59:45 +02:00
|
|
|
heroResult[0].army->giveStackExp(heroResult[0].exp);
|
|
|
|
if(heroResult[1].army)
|
|
|
|
heroResult[1].army->giveStackExp(heroResult[1].exp);
|
2012-03-06 19:59:55 +03:00
|
|
|
CBonusSystemNode::treeHasChanged();
|
2011-02-13 15:11:09 +02:00
|
|
|
}
|
|
|
|
|
2023-08-25 17:23:15 +02:00
|
|
|
auto currentBattle = boost::range::find_if(gs->currentBattles, [&](const auto & battle)
|
|
|
|
{
|
|
|
|
return battle->battleID == battleID;
|
|
|
|
});
|
|
|
|
|
|
|
|
assert(currentBattle != gs->currentBattles.end());
|
|
|
|
gs->currentBattles.erase(currentBattle);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleLogMessage::applyGs(CGameState *gs)
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
{
|
|
|
|
//nothing
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleLogMessage::applyBattle(IBattleState * battleState)
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
{
|
|
|
|
//nothing
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleStackMoved::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
applyBattle(gs->getBattle(battleID));
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleStackMoved::applyBattle(IBattleState * battleState)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
battleState->moveUnit(stack, tilesToMove.back());
|
|
|
|
}
|
2016-01-22 11:53:01 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleStackAttacked::applyGs(CGameState * gs)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
applyBattle(gs->getBattle(battleID));
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
2016-02-27 17:39:37 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleStackAttacked::applyBattle(IBattleState * battleState)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
|
|
|
battleState->setUnitState(newState.id, newState.data, newState.healthDelta);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleAttack::applyGs(CGameState * gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
CStack * attacker = gs->getBattle(battleID)->getStack(stackAttacking);
|
2017-07-04 13:24:46 +02:00
|
|
|
assert(attacker);
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
attackerChanges.applyGs(gs);
|
2010-05-20 13:54:24 +03:00
|
|
|
|
2016-09-30 01:09:02 +02:00
|
|
|
for(BattleStackAttacked & stackAttacked : bsa)
|
2009-03-21 14:49:58 +02:00
|
|
|
stackAttacked.applyGs(gs);
|
2009-08-07 14:22:17 +03:00
|
|
|
|
2018-03-05 08:51:35 +02:00
|
|
|
attacker->removeBonusesRecursive(Bonus::UntilAttack);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void StartAction::applyGs(CGameState *gs)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
CStack *st = gs->getBattle(battleID)->getStack(ba.stackNumber);
|
2009-09-10 14:28:34 +03:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
if(ba.actionType == EActionType::END_TACTIC_PHASE)
|
2011-02-12 18:12:48 +02:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
gs->getBattle(battleID)->tacticDistance = 0;
|
2011-02-12 18:12:48 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-25 17:23:15 +02:00
|
|
|
if(gs->getBattle(battleID)->tacticDistance)
|
2012-03-27 23:08:54 +03:00
|
|
|
{
|
|
|
|
// moves in tactics phase do not affect creature status
|
|
|
|
// (tactics stack queue is managed by client)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-08-17 19:20:12 +02:00
|
|
|
if (ba.isUnitAction())
|
2011-02-11 21:12:08 +02:00
|
|
|
{
|
2023-08-17 19:20:12 +02:00
|
|
|
assert(st); // stack must exists for all non-hero actions
|
2009-09-10 14:28:34 +03:00
|
|
|
|
2023-08-17 19:20:12 +02:00
|
|
|
switch(ba.actionType)
|
|
|
|
{
|
|
|
|
case EActionType::DEFEND:
|
|
|
|
st->waiting = false;
|
|
|
|
st->defending = true;
|
|
|
|
st->defendingAnim = true;
|
|
|
|
break;
|
|
|
|
case EActionType::WAIT:
|
|
|
|
st->defendingAnim = false;
|
|
|
|
st->waiting = true;
|
|
|
|
st->waitedThisTurn = true;
|
|
|
|
break;
|
|
|
|
case EActionType::HERO_SPELL: //no change in current stack state
|
|
|
|
break;
|
|
|
|
default: //any active stack action - attack, catapult, heal, spell...
|
|
|
|
st->waiting = false;
|
|
|
|
st->defendingAnim = false;
|
|
|
|
st->movedThisRound = true;
|
|
|
|
break;
|
|
|
|
}
|
2011-02-11 21:12:08 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-08-17 19:20:12 +02:00
|
|
|
if(ba.actionType == EActionType::HERO_SPELL)
|
2023-08-25 17:23:15 +02:00
|
|
|
gs->getBattle(battleID)->sides[ba.side].usedSpellsHistory.push_back(ba.spell);
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleSpellCast::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
if(castByHero)
|
2011-04-23 12:57:51 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
if(side < 2)
|
2011-04-23 12:57:51 +03:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
gs->getBattle(battleID)->sides[side].castSpellsCount++;
|
2011-04-23 12:57:51 +03:00
|
|
|
}
|
|
|
|
}
|
2015-04-13 07:51:23 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetStackEffect::applyGs(CGameState *gs)
|
2015-04-13 07:51:23 +02:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
applyBattle(gs->getBattle(battleID));
|
2009-05-17 18:24:50 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void SetStackEffect::applyBattle(IBattleState * battleState)
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
for(const auto & stackData : toRemove)
|
|
|
|
battleState->removeUnitBonus(stackData.first, stackData.second);
|
2014-03-07 16:21:09 +03:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
for(const auto & stackData : toUpdate)
|
|
|
|
battleState->updateUnitBonus(stackData.first, stackData.second);
|
2011-04-23 12:57:51 +03:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
for(const auto & stackData : toAdd)
|
|
|
|
battleState->addUnitBonus(stackData.first, stackData.second);
|
|
|
|
}
|
2016-09-29 14:23:28 +02:00
|
|
|
|
2016-11-02 19:11:01 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void StacksInjured::applyGs(CGameState *gs)
|
2017-07-20 06:08:49 +02:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
applyBattle(gs->getBattle(battleID));
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void StacksInjured::applyBattle(IBattleState * battleState)
|
2009-04-16 03:28:54 +03:00
|
|
|
{
|
2013-06-29 16:05:48 +03:00
|
|
|
for(BattleStackAttacked stackAttacked : stacks)
|
2017-07-20 06:08:49 +02:00
|
|
|
stackAttacked.applyBattle(battleState);
|
2009-04-16 03:28:54 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleUnitsChanged::applyGs(CGameState *gs)
|
2009-08-04 20:05:49 +03:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
applyBattle(gs->getBattle(battleID));
|
2009-08-04 20:05:49 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleUnitsChanged::applyBattle(IBattleState * battleState)
|
2009-08-19 13:59:42 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
for(auto & elem : changedStacks)
|
2009-08-19 13:59:42 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
switch(elem.operation)
|
2009-08-19 13:59:42 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
case BattleChanges::EOperation::RESET_STATE:
|
|
|
|
battleState->setUnitState(elem.id, elem.data, elem.healthDelta);
|
|
|
|
break;
|
|
|
|
case BattleChanges::EOperation::REMOVE:
|
|
|
|
battleState->removeUnit(elem.id);
|
|
|
|
break;
|
|
|
|
case BattleChanges::EOperation::ADD:
|
|
|
|
battleState->addUnit(elem.id, elem.data);
|
|
|
|
break;
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
case BattleChanges::EOperation::UPDATE:
|
|
|
|
battleState->updateUnit(elem.id, elem.data);
|
|
|
|
break;
|
2017-07-20 06:08:49 +02:00
|
|
|
default:
|
2023-02-09 18:06:02 +02:00
|
|
|
logNetwork->error("Unknown unit operation %d", static_cast<int>(elem.operation));
|
2017-07-20 06:08:49 +02:00
|
|
|
break;
|
2009-08-19 13:59:42 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleObstaclesChanged::applyGs(CGameState * gs)
|
2014-06-24 17:17:25 +03:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
applyBattle(gs->getBattle(battleID));
|
2014-06-24 17:17:25 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleObstaclesChanged::applyBattle(IBattleState * battleState)
|
2009-09-01 16:54:13 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
for(const auto & change : changes)
|
2009-09-01 16:54:13 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
switch(change.operation)
|
2009-09-07 15:30:10 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
case BattleChanges::EOperation::REMOVE:
|
|
|
|
battleState->removeObstacle(change.id);
|
|
|
|
break;
|
|
|
|
case BattleChanges::EOperation::ADD:
|
|
|
|
battleState->addObstacle(change);
|
|
|
|
break;
|
2020-02-12 19:12:12 +02:00
|
|
|
case BattleChanges::EOperation::UPDATE:
|
|
|
|
battleState->updateObstacle(change);
|
|
|
|
break;
|
2017-07-20 06:08:49 +02:00
|
|
|
default:
|
2023-02-09 18:06:02 +02:00
|
|
|
logNetwork->error("Unknown obstacle operation %d", static_cast<int>(change.operation));
|
2017-07-20 06:08:49 +02:00
|
|
|
break;
|
2009-09-07 15:30:10 +03:00
|
|
|
}
|
2009-09-01 16:54:13 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
CatapultAttack::CatapultAttack() = default;
|
2013-12-08 20:54:13 +03:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
CatapultAttack::~CatapultAttack() = default;
|
2013-12-08 20:54:13 +03:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void CatapultAttack::applyGs(CGameState * gs)
|
2009-09-05 17:10:26 +03:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
applyBattle(gs->getBattle(battleID));
|
2009-09-05 17:10:26 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void CatapultAttack::visitTyped(ICPackVisitor & visitor)
|
|
|
|
{
|
|
|
|
visitor.visitCatapultAttack(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CatapultAttack::applyBattle(IBattleState * battleState)
|
2011-10-01 22:56:54 +03:00
|
|
|
{
|
2023-02-09 18:06:02 +02:00
|
|
|
const auto * town = battleState->getDefendedTown();
|
2017-07-20 06:08:49 +02:00
|
|
|
if(!town)
|
2011-10-01 22:56:54 +03:00
|
|
|
return;
|
2012-02-29 04:31:48 +03:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
if(town->fortLevel() == CGTownInstance::NONE)
|
|
|
|
return;
|
2015-03-10 22:14:58 +02:00
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
for(const auto & part : attackedParts)
|
|
|
|
{
|
2023-01-13 01:09:24 +02:00
|
|
|
auto newWallState = SiegeInfo::applyDamage(battleState->getWallState(part.attackedPart), part.damageDealt);
|
2017-07-20 06:08:49 +02:00
|
|
|
battleState->setWallState(part.attackedPart, newWallState);
|
|
|
|
}
|
2011-10-01 22:56:54 +03:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void BattleSetStackProperty::applyGs(CGameState * gs) const
|
2011-10-02 16:59:12 +03:00
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
CStack * stack = gs->getBattle(battleID)->getStack(stackID);
|
2017-07-04 13:24:46 +02:00
|
|
|
switch(which)
|
2011-10-02 16:59:12 +03:00
|
|
|
{
|
|
|
|
case CASTS:
|
|
|
|
{
|
2017-07-04 13:24:46 +02:00
|
|
|
if(absolute)
|
|
|
|
logNetwork->error("Can not change casts in absolute mode");
|
2011-10-02 16:59:12 +03:00
|
|
|
else
|
2017-07-14 18:14:34 +02:00
|
|
|
stack->casts.use(-val);
|
2011-10-02 16:59:12 +03:00
|
|
|
break;
|
|
|
|
}
|
2011-10-09 10:20:23 +03:00
|
|
|
case ENCHANTER_COUNTER:
|
|
|
|
{
|
2023-08-25 17:23:15 +02:00
|
|
|
auto & counter = gs->getBattle(battleID)->sides[gs->getBattle(battleID)->whatSide(stack->unitOwner())].enchanterCounter;
|
2017-07-04 13:24:46 +02:00
|
|
|
if(absolute)
|
2013-07-22 01:01:29 +03:00
|
|
|
counter = val;
|
2011-10-09 10:20:23 +03:00
|
|
|
else
|
2013-07-22 01:01:29 +03:00
|
|
|
counter += val;
|
|
|
|
vstd::amax(counter, 0);
|
2011-10-09 10:20:23 +03:00
|
|
|
break;
|
|
|
|
}
|
2011-10-17 11:24:51 +03:00
|
|
|
case UNBIND:
|
|
|
|
{
|
2023-05-01 00:20:01 +02:00
|
|
|
stack->removeBonusesRecursive(Selector::type()(BonusType::BIND_EFFECT));
|
2011-10-17 11:24:51 +03:00
|
|
|
break;
|
|
|
|
}
|
2012-02-10 16:13:24 +03:00
|
|
|
case CLONED:
|
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
stack->cloned = true;
|
2012-02-10 16:13:24 +03:00
|
|
|
break;
|
|
|
|
}
|
2015-09-14 19:13:26 +02:00
|
|
|
case HAS_CLONE:
|
|
|
|
{
|
|
|
|
stack->cloneID = val;
|
|
|
|
break;
|
|
|
|
}
|
2011-10-02 16:59:12 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void PlayerCheated::applyGs(CGameState * gs) const
|
2017-06-02 02:34:50 +02:00
|
|
|
{
|
2017-06-03 07:25:10 +02:00
|
|
|
if(!player.isValidPlayer())
|
|
|
|
return;
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
gs->getPlayerState(player)->enteredLosingCheatCode = losingCheatCode;
|
|
|
|
gs->getPlayerState(player)->enteredWinningCheatCode = winningCheatCode;
|
2017-06-02 02:34:50 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void YourTurn::applyGs(CGameState * gs) const
|
2009-03-07 17:55:56 +02:00
|
|
|
{
|
2023-08-25 00:08:48 +02:00
|
|
|
gs->actingPlayers.clear();
|
|
|
|
gs->actingPlayers.insert(player);
|
2023-08-24 20:35:01 +02:00
|
|
|
}
|
2013-12-06 22:44:11 +03:00
|
|
|
|
2023-08-24 20:35:01 +02:00
|
|
|
void DaysWithoutTown::applyGs(CGameState * gs) const
|
|
|
|
{
|
2013-12-06 22:44:11 +03:00
|
|
|
auto & playerState = gs->players[player];
|
2015-10-24 16:21:30 +02:00
|
|
|
playerState.daysWithoutCastle = daysWithoutCastle;
|
2009-03-07 17:55:56 +02:00
|
|
|
}
|
|
|
|
|
2023-08-13 12:06:35 +02:00
|
|
|
void TurnTimeUpdate::applyGs(CGameState *gs) const
|
|
|
|
{
|
|
|
|
auto & playerState = gs->players[player];
|
2023-08-14 00:16:25 +02:00
|
|
|
playerState.turnTimer = turnTimer;
|
2023-08-13 12:06:35 +02:00
|
|
|
}
|
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
Component::Component(const CStackBasicDescriptor & stack)
|
2023-03-10 14:54:12 +02:00
|
|
|
: id(EComponentType::CREATURE)
|
2023-04-05 02:26:29 +02:00
|
|
|
, subtype(stack.type->getId())
|
2023-02-09 18:06:02 +02:00
|
|
|
, val(stack.count)
|
2010-04-02 05:07:40 +03:00
|
|
|
{
|
2011-09-24 04:15:36 +03:00
|
|
|
}
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
|
2023-02-12 09:23:39 +02:00
|
|
|
void EntitiesChanged::applyGs(CGameState * gs)
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
{
|
|
|
|
for(const auto & change : changes)
|
|
|
|
gs->updateEntity(change.metatype, change.entityIndex, change.data);
|
|
|
|
}
|
2022-07-26 15:07:42 +02:00
|
|
|
|
2022-11-06 23:54:50 +02:00
|
|
|
const CArtifactInstance * ArtSlotInfo::getArt() const
|
|
|
|
{
|
2022-11-10 17:45:54 +02:00
|
|
|
if(locked)
|
2022-11-06 23:54:50 +02:00
|
|
|
{
|
2022-11-10 17:45:54 +02:00
|
|
|
logNetwork->warn("ArtifactLocation::getArt: This location is locked!");
|
|
|
|
return nullptr;
|
2022-11-06 23:54:50 +02:00
|
|
|
}
|
2022-11-10 17:45:54 +02:00
|
|
|
return artifact;
|
2022-11-06 23:54:50 +02:00
|
|
|
}
|
|
|
|
|
2022-11-07 14:13:36 +02:00
|
|
|
CArtifactSet * BulkMoveArtifacts::getSrcHolderArtSet()
|
2022-11-06 23:54:50 +02:00
|
|
|
{
|
2023-04-15 03:33:00 +02:00
|
|
|
return std::visit(GetBase<CArtifactSet>(), srcArtHolder);
|
2022-11-06 23:54:50 +02:00
|
|
|
}
|
|
|
|
|
2022-11-07 14:13:36 +02:00
|
|
|
CArtifactSet * BulkMoveArtifacts::getDstHolderArtSet()
|
2022-11-06 23:54:50 +02:00
|
|
|
{
|
2023-04-15 03:33:00 +02:00
|
|
|
return std::visit(GetBase<CArtifactSet>(), dstArtHolder);
|
2022-11-06 23:54:50 +02:00
|
|
|
}
|
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|