mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Initial version of AI object value config
This commit is contained in:
parent
df00ced204
commit
b37ba8e046
@ -13,6 +13,9 @@
|
|||||||
"name": {
|
"name": {
|
||||||
"type":"string",
|
"type":"string",
|
||||||
},
|
},
|
||||||
|
"defaultAiValue": {
|
||||||
|
"type":"number",
|
||||||
|
},
|
||||||
|
|
||||||
"handler": {
|
"handler": {
|
||||||
"type":"string",
|
"type":"string",
|
||||||
|
@ -13,6 +13,9 @@
|
|||||||
"name": {
|
"name": {
|
||||||
"type":"string",
|
"type":"string",
|
||||||
},
|
},
|
||||||
|
"aiValue": {
|
||||||
|
"type":"number",
|
||||||
|
},
|
||||||
|
|
||||||
"sounds": {
|
"sounds": {
|
||||||
"type":"object",
|
"type":"object",
|
||||||
|
@ -206,6 +206,11 @@ CObjectClassesHandler::ObjectContainter * CObjectClassesHandler::loadFromJson(co
|
|||||||
obj->handlerName = json["handler"].String();
|
obj->handlerName = json["handler"].String();
|
||||||
obj->base = json["base"];
|
obj->base = json["base"];
|
||||||
obj->id = selectNextID(json["index"], objects, 256);
|
obj->id = selectNextID(json["index"], objects, 256);
|
||||||
|
if(json["defaultAiValue"].isNull())
|
||||||
|
obj->groupDefaultAiValue = boost::none;
|
||||||
|
else
|
||||||
|
obj->groupDefaultAiValue = json["defaultAiValue"].Integer();
|
||||||
|
|
||||||
for (auto entry : json["types"].Struct())
|
for (auto entry : json["types"].Struct())
|
||||||
{
|
{
|
||||||
loadObjectEntry(entry.first, entry.second, obj);
|
loadObjectEntry(entry.first, entry.second, obj);
|
||||||
@ -387,6 +392,11 @@ std::string CObjectClassesHandler::getObjectHandlerName(si32 type) const
|
|||||||
return objects.at(type)->handlerName;
|
return objects.at(type)->handlerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::optional<si32> CObjectClassesHandler::getObjGroupAiValue(si32 primaryID) const
|
||||||
|
{
|
||||||
|
return objects.at(primaryID)->groupDefaultAiValue;
|
||||||
|
}
|
||||||
|
|
||||||
AObjectTypeHandler::AObjectTypeHandler():
|
AObjectTypeHandler::AObjectTypeHandler():
|
||||||
type(-1), subtype(-1)
|
type(-1), subtype(-1)
|
||||||
{
|
{
|
||||||
@ -457,6 +467,11 @@ void AObjectTypeHandler::init(const JsonNode & input, boost::optional<std::strin
|
|||||||
for(const JsonNode & node : input["sounds"]["removal"].Vector())
|
for(const JsonNode & node : input["sounds"]["removal"].Vector())
|
||||||
sounds.removal.push_back(node.String());
|
sounds.removal.push_back(node.String());
|
||||||
|
|
||||||
|
if(input["aiValue"].isNull())
|
||||||
|
aiValue = boost::none;
|
||||||
|
else
|
||||||
|
aiValue = input["aiValue"].Integer();
|
||||||
|
|
||||||
initTypeData(input);
|
initTypeData(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,6 +560,11 @@ const RandomMapInfo & AObjectTypeHandler::getRMGInfo()
|
|||||||
return rmgInfo;
|
return rmgInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::optional<si32> AObjectTypeHandler::getAiValue() const
|
||||||
|
{
|
||||||
|
return aiValue;
|
||||||
|
}
|
||||||
|
|
||||||
bool AObjectTypeHandler::isStaticObject()
|
bool AObjectTypeHandler::isStaticObject()
|
||||||
{
|
{
|
||||||
return false; // most of classes are not static
|
return false; // most of classes are not static
|
||||||
|
@ -146,6 +146,8 @@ class DLL_LINKAGE AObjectTypeHandler : public boost::noncopyable
|
|||||||
std::vector<ObjectTemplate> templates;
|
std::vector<ObjectTemplate> templates;
|
||||||
|
|
||||||
SObjectSounds sounds;
|
SObjectSounds sounds;
|
||||||
|
|
||||||
|
boost::optional<si32> aiValue;
|
||||||
protected:
|
protected:
|
||||||
void preInitObject(CGObjectInstance * obj) const;
|
void preInitObject(CGObjectInstance * obj) const;
|
||||||
virtual bool objectFilter(const CGObjectInstance *, const ObjectTemplate &) const;
|
virtual bool objectFilter(const CGObjectInstance *, const ObjectTemplate &) const;
|
||||||
@ -184,6 +186,8 @@ public:
|
|||||||
|
|
||||||
const RandomMapInfo & getRMGInfo();
|
const RandomMapInfo & getRMGInfo();
|
||||||
|
|
||||||
|
boost::optional<si32> getAiValue() const;
|
||||||
|
|
||||||
virtual bool isStaticObject();
|
virtual bool isStaticObject();
|
||||||
|
|
||||||
virtual void afterLoadFinalization();
|
virtual void afterLoadFinalization();
|
||||||
@ -215,6 +219,10 @@ public:
|
|||||||
{
|
{
|
||||||
h & sounds;
|
h & sounds;
|
||||||
}
|
}
|
||||||
|
if(version >= 788)
|
||||||
|
{
|
||||||
|
h & aiValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -237,6 +245,8 @@ class DLL_LINKAGE CObjectClassesHandler : public IHandlerBase
|
|||||||
|
|
||||||
SObjectSounds sounds;
|
SObjectSounds sounds;
|
||||||
|
|
||||||
|
boost::optional<si32> groupDefaultAiValue;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
h & name;
|
h & name;
|
||||||
@ -252,6 +262,10 @@ class DLL_LINKAGE CObjectClassesHandler : public IHandlerBase
|
|||||||
{
|
{
|
||||||
h & sounds;
|
h & sounds;
|
||||||
}
|
}
|
||||||
|
if(version >= 788)
|
||||||
|
{
|
||||||
|
h & groupDefaultAiValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -306,7 +320,7 @@ public:
|
|||||||
/// Returns handler string describing the handler (for use in client)
|
/// Returns handler string describing the handler (for use in client)
|
||||||
std::string getObjectHandlerName(si32 type) const;
|
std::string getObjectHandlerName(si32 type) const;
|
||||||
|
|
||||||
|
boost::optional<si32> getObjGroupAiValue(si32 primaryID) const; //default AI value of objects belonging to particular primaryID
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int version)
|
template <typename Handler> void serialize(Handler &h, const int version)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include "../ConstTransitivePtr.h"
|
#include "../ConstTransitivePtr.h"
|
||||||
#include "../GameConstants.h"
|
#include "../GameConstants.h"
|
||||||
|
|
||||||
const ui32 SERIALIZATION_VERSION = 787;
|
const ui32 SERIALIZATION_VERSION = 788;
|
||||||
const ui32 MINIMAL_SERIALIZATION_VERSION = 753;
|
const ui32 MINIMAL_SERIALIZATION_VERSION = 753;
|
||||||
const std::string SAVEGAME_MAGIC = "VCMISVG";
|
const std::string SAVEGAME_MAGIC = "VCMISVG";
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user