mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-06 09:09:40 +02:00
- Removed integer parameters from CCreature, all stats are now handled by Bonus System Only
- Parsing for creature format http://wiki.vcmi.eu/index.php?title=Creature_Format Needs rearrangement of some info to work
This commit is contained in:
@@ -1597,15 +1597,15 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
|
|||||||
creatureAnim = new CCreaturePic(159, 4, creature, false);
|
creatureAnim = new CCreaturePic(159, 4, creature, false);
|
||||||
|
|
||||||
Rect sizes(287, 4, 96, 18);
|
Rect sizes(287, 4, 96, 18);
|
||||||
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[190], CGI->generaltexth->fcommands[0], creature->attack));
|
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[190], CGI->generaltexth->fcommands[0], creature->Attack()));
|
||||||
sizes.y+=20;
|
sizes.y+=20;
|
||||||
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[191], CGI->generaltexth->fcommands[1], creature->defence));
|
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[191], CGI->generaltexth->fcommands[1], creature->Defense()));
|
||||||
sizes.y+=21;
|
sizes.y+=21;
|
||||||
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[199], CGI->generaltexth->fcommands[2], creature->damageMin, creature->damageMax));
|
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[199], CGI->generaltexth->fcommands[2], creature->getMinDamage(), creature->getMaxDamage()));
|
||||||
sizes.y+=20;
|
sizes.y+=20;
|
||||||
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[388], CGI->generaltexth->fcommands[3], creature->hitPoints));
|
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[388], CGI->generaltexth->fcommands[3], creature->MaxHealth()));
|
||||||
sizes.y+=21;
|
sizes.y+=21;
|
||||||
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[193], CGI->generaltexth->fcommands[4], creature->speed));
|
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[193], CGI->generaltexth->fcommands[4], creature->valOfBonuses(Bonus::STACKS_SPEED)));
|
||||||
sizes.y+=20;
|
sizes.y+=20;
|
||||||
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[194], CGI->generaltexth->fcommands[5], town->creatureGrowth(level)));
|
values.push_back(new LabeledValue(sizes, CGI->generaltexth->allTexts[194], CGI->generaltexth->fcommands[5], town->creatureGrowth(level)));
|
||||||
|
|
||||||
|
|||||||
@@ -501,6 +501,7 @@ void CCreatureWindow::recreateSkillList(int Pos)
|
|||||||
for (n = numSkills; n < bonusItems.size(); ++n)
|
for (n = numSkills; n < bonusItems.size(); ++n)
|
||||||
{
|
{
|
||||||
bonusItems[n]->visible = false;
|
bonusItems[n]->visible = false;
|
||||||
|
if (n < selectableBonuses.size())
|
||||||
selectableBonuses[n]->deactivate();
|
selectableBonuses[n]->deactivate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "Filesystem/CResourceLoader.h"
|
#include "Filesystem/CResourceLoader.h"
|
||||||
#include "VCMI_Lib.h"
|
#include "VCMI_Lib.h"
|
||||||
#include "CGameState.h"
|
#include "CGameState.h"
|
||||||
#include "JsonNode.h"
|
|
||||||
#include "CHeroHandler.h"
|
#include "CHeroHandler.h"
|
||||||
#include "CModHandler.h"
|
#include "CModHandler.h"
|
||||||
|
|
||||||
@@ -317,22 +316,16 @@ void CCreatureHandler::loadCreatures()
|
|||||||
ncre.growth = readNumber(befi, i, andame, buf);
|
ncre.growth = readNumber(befi, i, andame, buf);
|
||||||
ncre.hordeGrowth = readNumber(befi, i, andame, buf);
|
ncre.hordeGrowth = readNumber(befi, i, andame, buf);
|
||||||
|
|
||||||
ncre.hitPoints = readNumber(befi, i, andame, buf);
|
ncre.addBonus(readNumber(befi, i, andame, buf), Bonus::STACK_HEALTH);
|
||||||
ncre.addBonus(ncre.hitPoints, Bonus::STACK_HEALTH);
|
ncre.addBonus(readNumber(befi, i, andame, buf), Bonus::STACKS_SPEED);
|
||||||
ncre.speed = readNumber(befi, i, andame, buf);
|
ncre.addBonus(readNumber(befi, i, andame, buf), Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK);
|
||||||
ncre.addBonus(ncre.speed, Bonus::STACKS_SPEED);
|
ncre.addBonus(readNumber(befi, i, andame, buf), Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE);
|
||||||
ncre.attack = readNumber(befi, i, andame, buf);
|
ncre.addBonus(readNumber(befi, i, andame, buf), Bonus::CREATURE_DAMAGE, 1);
|
||||||
ncre.addBonus(ncre.attack, Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK);
|
ncre.addBonus(readNumber(befi, i, andame, buf), Bonus::CREATURE_DAMAGE, 2);
|
||||||
ncre.defence = readNumber(befi, i, andame, buf);
|
ncre.addBonus(readNumber(befi, i, andame, buf), Bonus::SHOTS);
|
||||||
ncre.addBonus(ncre.defence, Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE);
|
|
||||||
ncre.damageMin = readNumber(befi, i, andame, buf); //not used anymore?
|
|
||||||
ncre.addBonus(ncre.damageMin, Bonus::CREATURE_DAMAGE, 1);
|
|
||||||
ncre.damageMax = readNumber(befi, i, andame, buf);
|
|
||||||
ncre.addBonus(ncre.damageMax, Bonus::CREATURE_DAMAGE, 2);
|
|
||||||
|
|
||||||
ncre.shots = readNumber(befi, i, andame, buf);
|
//spells - not used?
|
||||||
ncre.addBonus(ncre.shots, Bonus::SHOTS);
|
readNumber(befi, i, andame, buf);
|
||||||
ncre.spells = readNumber(befi, i, andame, buf);
|
|
||||||
ncre.ammMin = readNumber(befi, i, andame, buf);
|
ncre.ammMin = readNumber(befi, i, andame, buf);
|
||||||
ncre.ammMax = readNumber(befi, i, andame, buf);
|
ncre.ammMax = readNumber(befi, i, andame, buf);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
#include "../lib/HeroBonus.h"
|
#include "HeroBonus.h"
|
||||||
#include "../lib/ConstTransitivePtr.h"
|
#include "ConstTransitivePtr.h"
|
||||||
#include "ResourceSet.h"
|
#include "ResourceSet.h"
|
||||||
#include "GameConstants.h"
|
#include "GameConstants.h"
|
||||||
|
#include "JsonNode.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* CCreatureHandler.h, part of VCMI engine
|
* CCreatureHandler.h, part of VCMI engine
|
||||||
@@ -26,9 +27,8 @@ public:
|
|||||||
std::string namePl, nameSing, nameRef; //name in singular and plural form; and reference name
|
std::string namePl, nameSing, nameRef; //name in singular and plural form; and reference name
|
||||||
TResources cost; //cost[res_id] - amount of that resource
|
TResources cost; //cost[res_id] - amount of that resource
|
||||||
std::set<ui32> upgrades; // IDs of creatures to which this creature can be upgraded
|
std::set<ui32> upgrades; // IDs of creatures to which this creature can be upgraded
|
||||||
ui32 hitPoints, speed, attack, defence;
|
//damage, hp. etc are handled by Bonuses
|
||||||
ui32 fightValue, AIValue, growth, hordeGrowth, shots, spells;
|
ui32 fightValue, AIValue, growth, hordeGrowth;
|
||||||
ui32 damageMin, damageMax;
|
|
||||||
ui32 ammMin, ammMax;
|
ui32 ammMin, ammMax;
|
||||||
ui8 level; // 0 - unknown
|
ui8 level; // 0 - unknown
|
||||||
std::string abilityText; //description of abilities
|
std::string abilityText; //description of abilities
|
||||||
@@ -77,8 +77,8 @@ public:
|
|||||||
h & static_cast<CBonusSystemNode&>(*this);
|
h & static_cast<CBonusSystemNode&>(*this);
|
||||||
h & namePl & nameSing & nameRef
|
h & namePl & nameSing & nameRef
|
||||||
& cost & upgrades
|
& cost & upgrades
|
||||||
& fightValue & AIValue & growth & hordeGrowth & hitPoints & speed & attack & defence & shots & spells
|
& fightValue & AIValue & growth & hordeGrowth
|
||||||
& damageMin & damageMax & ammMin & ammMax & level
|
& ammMin & ammMax & level
|
||||||
& abilityText & abilityRefs & animDefName
|
& abilityText & abilityRefs & animDefName
|
||||||
& idNumber & faction
|
& idNumber & faction
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,118 @@ void CModHandler::saveConfigToFile (std::string name)
|
|||||||
std::ofstream file(CResourceHandler::get()->getResourceName(ResourceID("config/" + name +".json")), std::ofstream::trunc);
|
std::ofstream file(CResourceHandler::get()->getResourceName(ResourceID("config/" + name +".json")), std::ofstream::trunc);
|
||||||
//file << savedConf;
|
//file << savedConf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CCreature * CModHandler::loadCreature (const JsonNode &node)
|
||||||
|
{
|
||||||
|
CCreature * cre = new CCreature();
|
||||||
|
cre->idNumber = creatures.size();
|
||||||
|
const JsonNode *value; //optional value
|
||||||
|
|
||||||
|
//TODO: ref name
|
||||||
|
auto name = node["name"];
|
||||||
|
cre->nameSing = name["singular"].String();
|
||||||
|
cre->namePl = name["plural"].String();
|
||||||
|
//TODO: map name->id
|
||||||
|
|
||||||
|
auto cost = node["cost"];
|
||||||
|
if (cost.getType() == JsonNode::DATA_FLOAT) //gold
|
||||||
|
{
|
||||||
|
cre->cost[Res::GOLD] = cost.Float();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
BOOST_FOREACH (auto val, cost.Vector())
|
||||||
|
{
|
||||||
|
cre->cost[i++] = val.Float();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cre->level = node["level"].Float();
|
||||||
|
cre->faction = -1; //TODO: node["faction"].String() to id or just node["faction"].Float();
|
||||||
|
cre->fightValue = node["fightValue"].Float();
|
||||||
|
cre->AIValue = node["aiValue"].Float();
|
||||||
|
cre->growth = node["growth"].Float();
|
||||||
|
|
||||||
|
cre->addBonus(node["hitPoints"].Float(), Bonus::STACK_HEALTH);
|
||||||
|
cre->addBonus(node["speed"].Float(), Bonus::STACKS_SPEED);
|
||||||
|
cre->addBonus(node["attack"].Float(), Bonus::PRIMARY_SKILL, PrimarySkill::ATTACK);
|
||||||
|
cre->addBonus(node["defense"].Float(), Bonus::PRIMARY_SKILL, PrimarySkill::DEFENSE);
|
||||||
|
auto vec = node["damage"].Vector();
|
||||||
|
cre->addBonus(vec[0].Float(), Bonus::CREATURE_DAMAGE, 1);
|
||||||
|
cre->addBonus(vec[1].Float(), Bonus::CREATURE_DAMAGE, 2);
|
||||||
|
|
||||||
|
//optional
|
||||||
|
value = &node["shots"];
|
||||||
|
if (!value->isNull())
|
||||||
|
cre->addBonus(value->Float(), Bonus::SHOTS);
|
||||||
|
|
||||||
|
value = &node["spellPoints"];
|
||||||
|
if (!value->isNull())
|
||||||
|
cre->addBonus(value->Float(), Bonus::CASTS);
|
||||||
|
|
||||||
|
value = &node["doubleWide"];
|
||||||
|
if (!value->isNull())
|
||||||
|
cre->doubleWide = value->Bool();
|
||||||
|
else
|
||||||
|
cre->doubleWide = false;
|
||||||
|
|
||||||
|
value = &node["abilities"];
|
||||||
|
if (!value->isNull())
|
||||||
|
{
|
||||||
|
BOOST_FOREACH (const JsonNode &bonus, value->Vector())
|
||||||
|
{
|
||||||
|
cre->addNewBonus(ParseBonus(bonus));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//graphics
|
||||||
|
|
||||||
|
auto graphics = node["graphics"];
|
||||||
|
cre->animDefName = graphics["animation"].String();
|
||||||
|
cre->timeBetweenFidgets = graphics["timeBetweenFidgets"].Float();
|
||||||
|
cre->troopCountLocationOffset = graphics["troopCountLocationOffset"].Float();
|
||||||
|
cre->attackClimaxFrame = graphics["attackClimaxFrame"].Float();
|
||||||
|
|
||||||
|
auto animationTime = graphics["animationTime"];
|
||||||
|
cre->walkAnimationTime = animationTime["walk"].Float();
|
||||||
|
cre->attackAnimationTime = animationTime["attack"].Float();
|
||||||
|
cre->flightAnimationDistance = animationTime["flight"].Float(); //?
|
||||||
|
//TODO: background?
|
||||||
|
auto missle = graphics["missle"];
|
||||||
|
auto offsets = missle["offset"];
|
||||||
|
cre->upperRightMissleOffsetX = offsets["upperX"].Float();
|
||||||
|
cre->upperRightMissleOffsetY = offsets["upperY"].Float();
|
||||||
|
cre->rightMissleOffsetX = offsets["middleX"].Float();
|
||||||
|
cre->rightMissleOffsetY = offsets["middleY"].Float();
|
||||||
|
cre->lowerRightMissleOffsetX = offsets["lowerX"].Float();
|
||||||
|
cre->lowerRightMissleOffsetY = offsets["lowerY"].Float();
|
||||||
|
int i = 0;
|
||||||
|
BOOST_FOREACH (auto angle, missle["frameAngles"].Vector())
|
||||||
|
{
|
||||||
|
cre->missleFrameAngles[i++] = angle.Float();
|
||||||
|
}
|
||||||
|
//we need to know creature id to add it
|
||||||
|
VLC->creh->idToProjectile[cre->idNumber] = value->String();
|
||||||
|
|
||||||
|
//TODO: sounds
|
||||||
|
//how to pass info to Client?
|
||||||
|
auto sounds = node["sound"];
|
||||||
|
//CreaturesBattleSounds cbs;
|
||||||
|
//cbs.attack = sounds["attack"].String();
|
||||||
|
//cbs.defend = sounds["defend"].String();
|
||||||
|
//cbs.killed = sounds["killed"].String(); // was killed or died
|
||||||
|
//cbs.move = sounds["move"].String();
|
||||||
|
//cbs.shoot = sounds["shoot"].String(); // range attack
|
||||||
|
//cbs.wince = sounds["wince"].String(); // attacked but did not die
|
||||||
|
//cbs.ext1 = ""; // creature specific extension
|
||||||
|
//cbs.ext2 = ""; // creature specific extension
|
||||||
|
//cbs.startMoving = sounds["moveStart"].String(); // usually same as ext1
|
||||||
|
//cbs.endMoving = sounds["moveEnd"].String(); // usually same as ext2
|
||||||
|
//CCS->soundh->CBattleSounds.push_back(cbs);
|
||||||
|
|
||||||
|
creatures.push_back(cre);
|
||||||
|
return cre;
|
||||||
|
}
|
||||||
void CModHandler::recreateHandlers()
|
void CModHandler::recreateHandlers()
|
||||||
{
|
{
|
||||||
//TODO: consider some template magic to unify all handlers?
|
//TODO: consider some template magic to unify all handlers?
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ public:
|
|||||||
|
|
||||||
void loadConfigFromFile (std::string name);
|
void loadConfigFromFile (std::string name);
|
||||||
void saveConfigToFile (std::string name);
|
void saveConfigToFile (std::string name);
|
||||||
|
CCreature * loadCreature (const JsonNode &node); //TODO: handler collections now use ModHandler vector index. Should they be aligned according to mods actually used??
|
||||||
void recreateHandlers();
|
void recreateHandlers();
|
||||||
|
|
||||||
struct DLL_LINKAGE hardcodedFeatures
|
struct DLL_LINKAGE hardcodedFeatures
|
||||||
|
|||||||
@@ -1148,10 +1148,10 @@ void CGHeroInstance::UpdateSpeciality()
|
|||||||
switch (it->subtype)
|
switch (it->subtype)
|
||||||
{
|
{
|
||||||
case PrimarySkill::ATTACK:
|
case PrimarySkill::ATTACK:
|
||||||
param = creatures[it->additionalInfo]->attack;
|
param = creatures[it->additionalInfo]->Attack();
|
||||||
break;
|
break;
|
||||||
case PrimarySkill::DEFENSE:
|
case PrimarySkill::DEFENSE:
|
||||||
param = creatures[it->additionalInfo]->defence;
|
param = creatures[it->additionalInfo]->Defense();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0);
|
assert(0);
|
||||||
|
|||||||
@@ -199,3 +199,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
DLL_LINKAGE Bonus * ParseBonus (const JsonVector &ability_vec);
|
DLL_LINKAGE Bonus * ParseBonus (const JsonVector &ability_vec);
|
||||||
|
DLL_LINKAGE Bonus * ParseBonus (const JsonNode &bonus);
|
||||||
Reference in New Issue
Block a user