Olá, vim trazer este código originalmente escrito por Dantez
O membro Nenth da otland modificou para TFS 1.x.
O código permite definir diferentes efeitos para cada vocação:
Citareffect="29" <-- efeito (ID)
effectInterval="1000" <-- Intervalo
The Forgotten Server 1.x
effect="29" effectInterval="1000"
Player.cpp
depois de:
lastPong = lastPing;
add:
lastEffect = lastPong;
depois de:
int64_t timeNow = OTSYS_TIME();
add:
if (vocation && vocation->getEffect() && timeNow - lastEffect >= vocation->getEffectInterval()) { g_game.addMagicEffect(getPosition(), vocation->getEffect()); lastEffect = timeNow; }
Player.h
depois de:
uint64_t manaSpent;
add:
uint64_t lastEffect;
Vocation.cpp
depois de:
if ((attr = vocationNode.attribute("description"))) { voc.description = attr.as_string(); }
add:
if ((attr = vocationNode.attribute("effect"))) { voc.effect = pugi::cast<uint32_t>(attr.value()); } if ((attr = vocationNode.attribute("effectInterval"))) { voc.effectInterval = pugi::cast<uint32_t>(attr.value()); }
Vocation.h
depois de:
uint64_t getReqMana(uint32_t magLevel);
add:
uint32_t getEffect() const { return effect; } void setEffect(uint32_t _effect) { effect = _effect; } uint32_t getEffectInterval() const { return effectInterval; } void setEffectInterval(uint32_t _interval) { effectInterval = _interval; }
depois de:
uint32_t baseSpeed;
add:
uint32_t effect; uint32_t effectInterval;
The Forgotten Server 0.3/0.4
Citareffect="29" interval="1000"
Vocation.h
procure por:
uint32_t id, fromVocation, baseSpeed, attackSpeed;
mude para:
uint32_t id, fromVocation, baseSpeed, attackSpeed, effect, effectInterval;
procure por:
uint64_t getReqMana(uint32_t magLevel);
adicione logo:
uint32_t getEffect() const {return effect;} void setEffect(uint32_t _effect) {effect = _effect;} uint32_t getEffectInterval() const {return effectInterval;} void setEffectInterval(uint32_t _interval) {effectInterval = _interval;}
Vocation.cpp
procure por:
name = description = "";
adicione abaixo:
effect = 0; effectInterval = 4000; --here you can configure default interval value
procure por:
if(readXMLInteger(p, "lessloss", intValue)) voc->setLessLoss(intValue);
adicione abaixo
if(readXMLInteger(p, "effect", intValue)) voc->setEffect(intValue); if(readXMLInteger(p, "interval", intValue)) voc->setEffectInterval(intValue);
Player.h
procure por:
uint64_t lastAttack;
adicione abaixo:
uint64_t lastEffect;
Player.cpp
procure por:
lastLoad = lastPing = lastPong = OTSYS_TIME();
mude para:
lastLoad = lastPing = lastPong = lastEffect = OTSYS_TIME();
procure por:
int64_t timeNow = OTSYS_TIME();
adicione abaixo:
if(vocation && vocation->getEffect() && timeNow - lastEffect >= vocation->getEffectInterval()) { g_game.addMagicEffect(getPosition(), vocation->getEffect()); lastEffect = timeNow; }
Nota: Se sua engine, depois de adicionar este código, continuar quebrando, então vá à sua source e delete o diretório /obj e compile o server novamente. Isto só acontece em TFS 0.3/0.4!