Boa tarde, venho compartilhar o código feito por @Oneshot, com adaptação para tfs 0.3.6 (854). Bem, ele postou para tfs 0.4 (860), dai eu só mexi em umas linhas parar funcionar no tfs 0.3.6(854), dai vou compartilhar com vocês.
Com o monster level system, o monstro passa a ter level e ganha mais HP, dá mais dano, tem mais defesa, dependendo dele.
monsters.h
procure por:
bool isSummonable, isIllusionable, isConvinceable, isAttackable, isHostile, isLureable, isWalkable, canPushItems, canPushCreatures, pushable, hideName, hideHealth;
Substitua por:
bool isSummonable, isIllusionable, isConvinceable, isAttackable, isHostile, isLureable, isWalkable, canPushItems, canPushCreatures, pushable, hideName, hideHealth, hideLevel;
Procure por:
int32_t defense, armor, health, healthMax, baseSpeed, lookCorpse, corpseUnique, corpseAction, maxSummons, targetDistance, runAwayHealth, conditionImmunities, damageImmunities, lightLevel, lightColor, changeTargetSpeed, changeTargetChance;
Substitua por:
int32_t defense, armor, health, healthMax, baseSpeed, lookCorpse, corpseUnique, corpseAction, maxSummons, targetDistance, runAwayHealth, conditionImmunities, damageImmunities, lightLevel, lightColor, changeTargetSpeed, changeTargetChance, levelMin, levelMax;
monsters.cpp
Procure por:
canPushItems = canPushCreatures = isSummonable = isIllusionable = isConvinceable = isLureable = isWalkable = hideName = hideHealth = false;
Substitua por:
canPushItems = canPushCreatures = isSummonable = isIllusionable = isConvinceable = isLureable = isWalkable = hideName = hideHealth = hideLevel = false;
Procure por:
baseSpeed = 200;
Logo abaixo, adicione:
levelMin = levelMax = 1;
Localize:
if(readXMLInteger(p, "max", intValue)) mType->healthMax = intValue; else { SHOW_XML_ERROR("Missing health.max"); monsterLoad = false; } }
abaixo adicione:
else if(!xmlStrcmp(p->name, (const xmlChar*)"level")) { if(!readXMLInteger(p, "max", intValue)) mType->levelMax = 1; else mType->levelMax = intValue; if(!readXMLInteger(p, "min", intValue)) mType->levelMin = mType->levelMax; else mType->levelMin = intValue; }
procure por:
if(readXMLString(tmpNode, "shield", strValue)) mType->partyShield = getPartyShield(strValue);
logo baixo adicione:
if(readXMLString(tmpNode, "hidelevel", strValue)) mType->hideLevel = booleanString(strValue);
Monster.h
Procure:
virtual ~Monster(); std::string name, nameDescription;
abaixo adicione:
std::string name, nameDescription;int32_t level;double bonusAttack, bonusDefense;
Procure:
virtual const std::string& getName() const {return mType->name;}virtual const std::string& getNameDescription() const {return mType->nameDescription;}virtual std::string getDescription(int32_t) const {return mType->nameDescription + ".";}
Substitua por:
virtual const std::string& getName() const {return name;}virtual const std::string& getNameDescription() const {return nameDescription;}virtual std::string getDescription(int32_t) const {return nameDescription + ".";}
Monster.cpp
Logo abaixo de:
isIdle = true;
Adicione:
name = _mType->name;nameDescription = _mType->nameDescription;level = (int32_t)random_range(_mType->levelMin, _mType->levelMax, DISTRO_NORMAL);bonusAttack = 1.0;bonusDefense = 1.0;
Procure por está função:
Monster::onCreatureAppear
Apague e coloque está função:
void Monster::onCreatureAppear(const Creature* creature){ Creature::onCreatureAppear(creature); if(creature == this) { //We just spawned lets look around to see who is there. if(isSummon()) { std::string value;// this->master->getStorage((uint32_t)"1996", value); this->master->getStorage((uint32_t)"1996", value); uint8_t intValue = atoi(value.c_str()); if(intValue || value == "0") level = intValue; else level = 1; isMasterInRange = canSee(master->getPosition()); } if(g_config.getBool(ConfigManager::MONSTER_HAS_LEVEL)) { this->healthMax = std::floor(this->getMaxHealth() * (1. + (0.1 * (level - 1)))); this->health = this->healthMax; this->bonusAttack += (0.01 * (level - 1)); this->bonusDefense += (0.005 * (level - 1)); } updateTargetList(); updateIdleStatus(); } else onCreatureEnter(const_cast<Creature*>(creature));}
Substitua todos:
g_config.getDouble(ConfigManager::RATE_MONSTER_DEFENSE)
Por:
g_config.getDouble(ConfigManager::RATE_MONSTER_DEFENSE) * bonusDefense
Substitua todos:
g_config.getDouble(ConfigManager::RATE_MONSTER_ATTACK)
Por:
g_config.getDouble(ConfigManager::RATE_MONSTER_ATTACK) * bonusAttack
Map.cpp
Procure por:
#include "game.h"
Adicione em baixo:
#include "configmanager.h"
Procure por:
extern Game g_game;
Adicione em baixo:
extern ConfigManager g_config;
Procure por está função:
bool Map::placeCreature(const Position& centerPos, Creature* creature, bool extendedPos /*= false*/, bool forced /*= false*/){
Abaixo do " { " adicione:
Monster* monster = creature->getMonster(); if(monster && g_config.getBool(ConfigManager::MONSTER_HAS_LEVEL)) { uint8_t level; if(!monster->getMonsterType()->hideLevel) { if(monster->isSummon()) { std::string value;// monster->getMaster()->getStorage((uint32_t)"1996", value); monster->getMaster()->getStorage((uint32_t)"1996", value); uint8_t intValue = atoi(value.c_str()); if(intValue || value == "0") level = intValue; else level = 1; } else level = monster->level; char buffer [10]; monster->name = monster->getName() + " [" + itoa(level, buffer, 10) + "]"; } }
configmanager.h
Procure por:
ADDONS_PREMIUM,
e abaixo adicione logo em baixo:
MONSTER_HAS_LEVEL,
configmanager.cpp
procure por:
m_confBool[ADDONS_PREMIUM] = getGlobalBool("addonsOnlyPremium", true);
e logo em baixo adicione:
m_confBool[MONSTER_HAS_LEVEL] = getGlobalBool("monsterHasLevel", true);
no Config.lua adicione:
monsterHasLevel = true -- true para monstros nascerem com level, false para não nascerem com level
São muitas modificações para fazer, mas o resultado é garantido e é uma funcionalidade a mais para seu servidor.
Como está programado, a cada level, monstros ganham 10% de HP, 1% de dano e 0.5% de defesa.
Para configurar level mínimo e máximo, é só adicionar no XML do monstro:
<level min="1" max="10"/> -- level minimo, level maximo
E alterar a seu gosto.
Se você fizer certo irá ficar assim:
Créditos:
@Oneshot