Muito bom conteúdo! Deu pra aprender umas técnicas de c++ também, obrigado ![]()
- Fórum
- OTServ
- Recursos
- Linguagens de Programação
- C e C++
- Vocações - Sistema de Intervalo de Efeitos
PE
c++
Vocações - Sistema de Intervalo de Efeitos
Por Peedbew, 03 de jul. de 2016 em C e C++
vocação
mudar efeito
change effec
interval
system
sistema
script
2
3k


info
Grupo: Campones
Registrado: 29/06/16
Posts: 39
Reputação: +16
Gênero: Masculino
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:
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:
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
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 valueprocure 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!