mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-26 22:57:00 +02:00
0b70baa95e
* Indirect spell effects loading * Json serializer improvements * spell->canBeCastAt do not allow useless cast for any spell * Added proxy caster class for spell-created obstacles * Handle damage from spell-created obstacles inside mechanics * Experimental GameState integration/regression tests * Ignore mod settings and load only "vcmi" mod when running tests * fixed https://bugs.vcmi.eu/view.php?id=2765 (with tests) * Huge improvements of BattleAI regarding spell casts * AI can cast almost any combat spell except TELEPORT, SACRIFICE and obstacle placement spells. * Possible fix for https://bugs.vcmi.eu/view.php?id=1811 * CStack factored out to several classes * [Battle] Allowed RETURN_AFTER_STRIKE effect on server side to be optional * [Battle] Allowed BattleAction have multiple destinations * [Spells] Converted limit|immunity to target condition * [Spells] Use partial configuration reload for backward compatibility handling * [Tests] Started tests for CUnitState * Partial fixes of fire shield effect * [Battle] Do HP calculations in 64 bits * [BattleAI] Use threading for spell cast evaluation * [BattleAI] Made AI be able to evaluate modified turn order (on hypothetical battle state) * Implemented https://bugs.vcmi.eu/view.php?id=2811 * plug rare freeze when hypnotized unit shots vertically * Correctly apply ONLY_MELEE_FIGHT / ONLY_DISTANCE_FIGHT for unit damage, attack & defense * [BattleAI] Try to not waste a cast if battle is actually won already * Extended JsonSerializeFormat API * fixed https://bugs.vcmi.eu/view.php?id=2847 * Any unit effect can be now chained (not only damage like Chain Lightning) ** only damage effect for now actually uses "chainFactor" * Possible quick fix for https://bugs.vcmi.eu/view.php?id=2860
139 lines
3.2 KiB
C++
139 lines
3.2 KiB
C++
/*
|
|
* Magic.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
|
|
|
|
/**
|
|
* High-level interface for spells subsystem
|
|
*/
|
|
|
|
|
|
class CSpell;
|
|
class PlayerColor;
|
|
struct MetaString;
|
|
struct CPackForClient;
|
|
|
|
namespace battle
|
|
{
|
|
class Unit;
|
|
class Destination;
|
|
}
|
|
|
|
namespace spells
|
|
{
|
|
|
|
class Mechanics;
|
|
class BattleCast;
|
|
using Destination = ::battle::Destination;
|
|
|
|
using Target = std::vector<Destination>;
|
|
|
|
struct SchoolInfo;
|
|
|
|
enum class Mode
|
|
{
|
|
//ACTIVE, //todo: use
|
|
HERO, //deprecated
|
|
AFTER_ATTACK,
|
|
BEFORE_ATTACK,
|
|
MAGIC_MIRROR,
|
|
CREATURE_ACTIVE, //deprecated
|
|
ENCHANTER,
|
|
SPELL_LIKE_ATTACK,
|
|
PASSIVE//f.e. opening battle spells
|
|
};
|
|
|
|
enum class AimType
|
|
{
|
|
NO_TARGET,
|
|
CREATURE,
|
|
OBSTACLE,
|
|
LOCATION
|
|
};
|
|
|
|
class DLL_LINKAGE PacketSender
|
|
{
|
|
public:
|
|
virtual ~PacketSender(){};
|
|
virtual void sendAndApply(CPackForClient * info) const = 0;
|
|
virtual void complain(const std::string & problem) const = 0;
|
|
};
|
|
|
|
class DLL_LINKAGE Problem
|
|
{
|
|
public:
|
|
typedef int Severity;
|
|
|
|
enum ESeverity
|
|
{
|
|
LOWEST = std::numeric_limits<Severity>::min(),
|
|
NORMAL = 0,
|
|
CRITICAL = std::numeric_limits<Severity>::max()
|
|
};
|
|
|
|
virtual ~Problem() = default;
|
|
|
|
virtual void add(MetaString && description, Severity severity = CRITICAL) = 0;
|
|
|
|
virtual void getAll(std::vector<std::string> & target) const = 0;
|
|
};
|
|
|
|
class DLL_LINKAGE Spell
|
|
{
|
|
public:
|
|
virtual ~Spell() = default;
|
|
|
|
virtual int32_t getIndex() const = 0;
|
|
|
|
virtual void forEachSchool(const std::function<void (const SchoolInfo &, bool &)> & cb) const = 0;
|
|
};
|
|
|
|
class DLL_LINKAGE Caster
|
|
{
|
|
public:
|
|
virtual ~Caster() = default;
|
|
|
|
/// returns level on which given spell would be cast by this(0 - none, 1 - basic etc);
|
|
/// caster may not know this spell at all
|
|
/// optionally returns number of selected school by arg - 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic
|
|
virtual ui8 getSpellSchoolLevel(const Spell * spell, int * outSelectedSchool = nullptr) const = 0;
|
|
|
|
///default spell school level for effect calculation
|
|
virtual int getEffectLevel(const Spell * spell) const = 0;
|
|
|
|
///applying sorcery secondary skill etc
|
|
virtual int64_t getSpellBonus(const Spell * spell, int64_t base, const battle::Unit * affectedStack) const = 0;
|
|
|
|
///only bonus for particular spell
|
|
virtual int64_t getSpecificSpellBonus(const Spell * spell, int64_t base) const = 0;
|
|
|
|
///default spell-power for damage/heal calculation
|
|
virtual int getEffectPower(const Spell * spell) const = 0;
|
|
|
|
///default spell-power for timed effects duration
|
|
virtual int getEnchantPower(const Spell * spell) const = 0;
|
|
|
|
///damage/heal override(ignores spell configuration, effect level and effect power)
|
|
virtual int64_t getEffectValue(const Spell * spell) const = 0;
|
|
|
|
virtual const PlayerColor getOwner() const = 0;
|
|
|
|
///only name substitution
|
|
virtual void getCasterName(MetaString & text) const = 0;
|
|
|
|
///full default text
|
|
virtual void getCastDescription(const Spell * spell, MetaString & text) const = 0;
|
|
virtual void getCastDescription(const Spell * spell, const std::vector<const battle::Unit *> & attacked, MetaString & text) const = 0;
|
|
|
|
virtual void spendMana(const PacketSender * server, const int spellCost) const = 0;
|
|
};
|
|
|
|
}
|