1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +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.
This commit is contained in:
AlexVinS
2018-03-17 17:58:30 +03:00
committed by AlexVinS
parent 11bb46780a
commit ecaa9f5d0b
475 changed files with 22491 additions and 7123 deletions

View File

@@ -0,0 +1,62 @@
/*
* ApplyDamage.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
*
*/
#include "StdInc.h"
#include <vcmi/Environment.h>
#include "ApplyDamage.h"
#include "../../lib/NetPacks.h"
namespace events
{
SubscriptionRegistry<ApplyDamage> * ApplyDamage::getRegistry()
{
static std::unique_ptr<SubscriptionRegistry<ApplyDamage>> Instance = make_unique<SubscriptionRegistry<ApplyDamage>>();
return Instance.get();
}
CApplyDamage::CApplyDamage(const Environment * env_, BattleStackAttacked * pack_, std::shared_ptr<battle::Unit> target_)
: env(env_),
pack(pack_),
target(target_)
{
initalDamage = pack->damageAmount;
}
bool CApplyDamage::isEnabled() const
{
return true;
}
int64_t CApplyDamage::getInitalDamage() const
{
return initalDamage;
}
int64_t CApplyDamage::getDamage() const
{
return pack->damageAmount;
}
void CApplyDamage::setDamage(int64_t value)
{
pack->damageAmount = value;
}
const battle::Unit * CApplyDamage::getTarget() const
{
return target.get();
}
};

39
lib/events/ApplyDamage.h Normal file
View File

@@ -0,0 +1,39 @@
/*
* ApplyDamage.h, 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
*
*/
#pragma once
#include <vcmi/events/ApplyDamage.h>
namespace events
{
class DLL_LINKAGE CApplyDamage : public ApplyDamage
{
public:
CApplyDamage(const Environment * env_, BattleStackAttacked * pack_, std::shared_ptr<battle::Unit> target_);
bool isEnabled() const override;
int64_t getInitalDamage() const override;
int64_t getDamage() const override;
void setDamage(int64_t value) override;
const battle::Unit * getTarget() const override;
private:
int64_t initalDamage;
const Environment * env;
BattleStackAttacked * pack;
std::shared_ptr<battle::Unit> target;
};
}

View File

@@ -0,0 +1,39 @@
/*
* GameResumed.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
*
*/
#include "StdInc.h"
#include "GameResumed.h"
#include <vcmi/events/EventBus.h>
namespace events
{
SubscriptionRegistry<GameResumed> * GameResumed::getRegistry()
{
static std::unique_ptr<SubscriptionRegistry<GameResumed>> Instance = make_unique<SubscriptionRegistry<GameResumed>>();
return Instance.get();
}
void GameResumed::defaultExecute(const EventBus * bus)
{
CGameResumed event;
bus->executeEvent(event);
}
CGameResumed::CGameResumed() = default;
bool CGameResumed::isEnabled() const
{
return true;
}
}

26
lib/events/GameResumed.h Normal file
View File

@@ -0,0 +1,26 @@
/*
* GameResumed.h, 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
*
*/
#pragma once
#include <vcmi/events/GameResumed.h>
namespace events
{
class DLL_LINKAGE CGameResumed : public GameResumed
{
public:
CGameResumed();
bool isEnabled() const override;
};
}

View File

@@ -0,0 +1,55 @@
/*
* ObjectVisitEnded.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
*
*/
#include "StdInc.h"
#include "ObjectVisitEnded.h"
#include <vcmi/events/EventBus.h>
namespace events
{
SubscriptionRegistry<ObjectVisitEnded> * ObjectVisitEnded::getRegistry()
{
static std::unique_ptr<Sub> Instance = make_unique<Sub>();
return Instance.get();
}
void ObjectVisitEnded::defaultExecute(const EventBus * bus, const ExecHandler & execHandler,
const PlayerColor & player, const ObjectInstanceID & heroId)
{
CObjectVisitEnded event(player, heroId);
bus->executeEvent(event, execHandler);
}
CObjectVisitEnded::CObjectVisitEnded(const PlayerColor & player_, const ObjectInstanceID & heroId_)
: player(player_),
heroId(heroId_)
{
}
bool CObjectVisitEnded::isEnabled() const
{
return true;
}
PlayerColor CObjectVisitEnded::getPlayer() const
{
return player;
}
ObjectInstanceID CObjectVisitEnded::getHero() const
{
return heroId;
}
}

View File

@@ -0,0 +1,34 @@
/*
* ObjectVisitEnded.h, 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
*
*/
#pragma once
#include <vcmi/events/ObjectVisitEnded.h>
#include "../GameConstants.h"
namespace events
{
class DLL_LINKAGE CObjectVisitEnded : public ObjectVisitEnded
{
public:
CObjectVisitEnded(const PlayerColor & player_, const ObjectInstanceID & heroId_);
PlayerColor getPlayer() const override;
ObjectInstanceID getHero() const override;
bool isEnabled() const override;
private:
PlayerColor player;
ObjectInstanceID heroId;
bool enabled;
};
}

View File

@@ -0,0 +1,67 @@
/*
* ObjectVisitStarted.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
*
*/
#include "StdInc.h"
#include "ObjectVisitStarted.h"
#include <vcmi/events/EventBus.h>
namespace events
{
SubscriptionRegistry<ObjectVisitStarted> * ObjectVisitStarted::getRegistry()
{
static std::unique_ptr<Sub> Instance = make_unique<Sub>();
return Instance.get();
}
void ObjectVisitStarted::defaultExecute(const EventBus * bus, const ExecHandler & execHandler,
const PlayerColor & player, const ObjectInstanceID & heroId, const ObjectInstanceID & objId)
{
CObjectVisitStarted event(player, heroId, objId);
bus->executeEvent(event, execHandler);
}
CObjectVisitStarted::CObjectVisitStarted(const PlayerColor & player_, const ObjectInstanceID & heroId_, const ObjectInstanceID & objId_)
: player(player_),
heroId(heroId_),
objId(objId_),
enabled(true)
{
}
PlayerColor CObjectVisitStarted::getPlayer() const
{
return player;
}
ObjectInstanceID CObjectVisitStarted::getHero() const
{
return heroId;
}
ObjectInstanceID CObjectVisitStarted::getObject() const
{
return objId;
}
bool CObjectVisitStarted::isEnabled() const
{
return enabled;
}
void CObjectVisitStarted::setEnabled(bool enable)
{
enabled = enable;
}
}

View File

@@ -0,0 +1,38 @@
/*
* ObjectVisitStarted.h, 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
*
*/
#pragma once
#include <vcmi/events/ObjectVisitStarted.h>
#include "../GameConstants.h"
namespace events
{
class DLL_LINKAGE CObjectVisitStarted : public ObjectVisitStarted
{
public:
CObjectVisitStarted(const PlayerColor & player_, const ObjectInstanceID & heroId_, const ObjectInstanceID & objId_);
PlayerColor getPlayer() const override;
ObjectInstanceID getHero() const override;
ObjectInstanceID getObject() const override;
bool isEnabled() const override;
void setEnabled(bool enable) override;
private:
PlayerColor player;
ObjectInstanceID heroId;
ObjectInstanceID objId;
bool enabled;
};
}

View File

@@ -0,0 +1,61 @@
/*
* PlayerGotTurn.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
*
*/
#include "StdInc.h"
#include "PlayerGotTurn.h"
#include <vcmi/events/EventBus.h>
namespace events
{
SubscriptionRegistry<PlayerGotTurn> * PlayerGotTurn::getRegistry()
{
static std::unique_ptr<SubscriptionRegistry<PlayerGotTurn>> Instance = make_unique<SubscriptionRegistry<PlayerGotTurn>>();
return Instance.get();
}
void PlayerGotTurn::defaultExecute(const EventBus * bus, const ExecHandler & execHandler, PlayerColor & player)
{
CPlayerGotTurn event;
event.setPlayer(player);
bus->executeEvent(event, execHandler);
player = event.getPlayer();
}
CPlayerGotTurn::CPlayerGotTurn() = default;
bool CPlayerGotTurn::isEnabled() const
{
return true;
}
PlayerColor CPlayerGotTurn::getPlayer() const
{
return player;
}
void CPlayerGotTurn::setPlayer(const PlayerColor & value)
{
player = value;
}
int32_t CPlayerGotTurn::getPlayerIndex() const
{
return player.getNum();
}
void CPlayerGotTurn::setPlayerIndex(int32_t value)
{
player = PlayerColor(value);
}
}

View File

@@ -0,0 +1,36 @@
/*
* PlayerGotTurn.h, 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
*
*/
#pragma once
#include <vcmi/events/PlayerGotTurn.h>
#include "../GameConstants.h"
namespace events
{
class DLL_LINKAGE CPlayerGotTurn : public PlayerGotTurn
{
public:
CPlayerGotTurn();
bool isEnabled() const override;
PlayerColor getPlayer() const override;
void setPlayer(const PlayerColor & value) override;
int32_t getPlayerIndex() const override;
void setPlayerIndex(int32_t value) override;
private:
PlayerColor player;
};
}

View File

@@ -0,0 +1,39 @@
/*
* TurnStarted.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
*
*/
#include "StdInc.h"
#include "TurnStarted.h"
#include <vcmi/events/EventBus.h>
namespace events
{
SubscriptionRegistry<TurnStarted> * TurnStarted::getRegistry()
{
static std::unique_ptr<SubscriptionRegistry<TurnStarted>> Instance = make_unique<SubscriptionRegistry<TurnStarted>>();
return Instance.get();
}
void TurnStarted::defaultExecute(const EventBus * bus)
{
CTurnStarted event;
bus->executeEvent(event);
}
CTurnStarted::CTurnStarted() = default;
bool CTurnStarted::isEnabled() const
{
return true;
}
}

26
lib/events/TurnStarted.h Normal file
View File

@@ -0,0 +1,26 @@
/*
* TurnStarted.h, 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
*
*/
#pragma once
#include <vcmi/events/TurnStarted.h>
namespace events
{
class DLL_LINKAGE CTurnStarted : public TurnStarted
{
public:
CTurnStarted();
bool isEnabled() const override;
static void defaultExecute(const EventBus * bus);
};
}