Nenth
I'm just cleaning here;
- Joined
- Mar 20, 2016
- Messages
- 46
- Reaction score
- 12
Note: This code was orginally written for TFS 0.3 by Dantez from tibia.net.pl!
I just a little bit changed it to make it work on TFS 1.x.
Code allows you to set different effect for each vocation.
effect="29" <-- Here you can put effect ID
effectInterval="1000" <-- Here you can set Interval
The Forgotten Server 1.x version
Configuration:
Player.cpp
after:
add:
after:
add:
Player.h
after:
add:
Vocation.cpp
after:
add:
Vocation.h
after:
add:
after:
add:
The Forgotten Server 0.3/0.4 version
Configuration:
Vocation.h
find:
change for:
find:
add under:
Vocation.cpp
find:
add under:
find:
add under:
Player.h
find:
add under:
Player.cpp
find:
change to:
find:
add under:
Note: If your engine after adding this code will keep crashing, then go to your source directory and delete /obj folder and compile your server again. This only happens in TFS 0.3/0.4!
Enjoy!
I just a little bit changed it to make it work on TFS 1.x.
Code allows you to set different effect for each vocation.
effect="29" <-- Here you can put effect ID
effectInterval="1000" <-- Here you can set Interval
The Forgotten Server 1.x version
Configuration:
Code:
effect="29" effectInterval="1000"
Player.cpp
after:
Code:
lastPong = lastPing;
Code:
lastEffect = lastPong;
Code:
int64_t timeNow = OTSYS_TIME();
Code:
if (vocation && vocation->getEffect() && timeNow - lastEffect >= vocation->getEffectInterval())
{
g_game.addMagicEffect(getPosition(), vocation->getEffect());
lastEffect = timeNow;
}
Player.h
after:
Code:
uint64_t manaSpent;
Code:
uint64_t lastEffect;
Vocation.cpp
after:
Code:
if ((attr = vocationNode.attribute("description"))) {
voc.description = attr.as_string();
}
Code:
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
after:
Code:
uint64_t getReqMana(uint32_t magLevel);
Code:
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; }
Code:
uint32_t baseSpeed;
Code:
uint32_t effect;
uint32_t effectInterval;
The Forgotten Server 0.3/0.4 version
Configuration:
Code:
effect="29" interval="1000"
Vocation.h
find:
Code:
uint32_t id, fromVocation, baseSpeed, attackSpeed;
change for:
Code:
uint32_t id, fromVocation, baseSpeed, attackSpeed, effect, effectInterval;
find:
Code:
uint64_t getReqMana(uint32_t magLevel);
add under:
Code:
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
find:
Code:
name = description = "";
add under:
Code:
effect = 0;
effectInterval = 4000; --here you can configure default interval value
find:
Code:
if(readXMLInteger(p, "lessloss", intValue))
voc->setLessLoss(intValue);
add under:
Code:
if(readXMLInteger(p, "effect", intValue))
voc->setEffect(intValue);
if(readXMLInteger(p, "interval", intValue))
voc->setEffectInterval(intValue);
Player.h
find:
Code:
uint64_t lastAttack;
add under:
Code:
uint64_t lastEffect;
Player.cpp
find:
Code:
lastLoad = lastPing = lastPong = OTSYS_TIME();
change to:
Code:
lastLoad = lastPing = lastPong = lastEffect = OTSYS_TIME();
find:
Code:
int64_t timeNow = OTSYS_TIME();
add under:
Code:
if(vocation && vocation->getEffect() && timeNow - lastEffect >= vocation->getEffectInterval())
{
g_game.addMagicEffect(getPosition(), vocation->getEffect());
lastEffect = timeNow;
}
Note: If your engine after adding this code will keep crashing, then go to your source directory and delete /obj folder and compile your server again. This only happens in TFS 0.3/0.4!
Enjoy!
Last edited: