• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Feature [8.54]Vocation - interval effect system.

sawex

Premium User
Premium User
Joined
Jan 31, 2009
Messages
43
Reaction score
6
Hello.
I will share with my vocation effect system. It is useful for all OTS with transform system etc.

First in vocation.h after:
Code:
std::string name, description;
paste:
Code:
uint8_t effect;

After:
Code:
uint64_t getReqMana(uint32_t magLevel);
add
Code:
uint16_t getEffect() const {return effect;};
void setEffect(int32_t v) {effect = v;};

Now, in vocation.cpp after:
Code:
        else if(!xmlStrcmp(configNode->name, (const xmlChar*)"reflect"))
        {
            if(readXMLInteger(configNode, "percentAll", intValue))
            {
                for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++)
                    voc->increaseReflect(REFLECT_PERCENT, (CombatType_t)i, intValue);
            }

            if(readXMLInteger(configNode, "percentElements", intValue))
            {
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_ENERGYDAMAGE, intValue);
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_FIREDAMAGE, intValue);
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_EARTHDAMAGE, intValue);
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_ICEDAMAGE, intValue);
            }

            if(readXMLInteger(configNode, "percentMagic", intValue))
            {
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_ENERGYDAMAGE, intValue);
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_FIREDAMAGE, intValue);
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_EARTHDAMAGE, intValue);
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_ICEDAMAGE, intValue);
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_HOLYDAMAGE, intValue);
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_DEATHDAMAGE, intValue);
            }

            if(readXMLInteger(configNode, "percentEnergy", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_ENERGYDAMAGE, intValue);

            if(readXMLInteger(configNode, "percentFire", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_FIREDAMAGE, intValue);

            if(readXMLInteger(configNode, "percentPoison", intValue) || readXMLInteger(configNode, "percentEarth", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_EARTHDAMAGE, intValue);

            if(readXMLInteger(configNode, "percentIce", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_ICEDAMAGE, intValue);

            if(readXMLInteger(configNode, "percentHoly", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_HOLYDAMAGE, intValue);

            if(readXMLInteger(configNode, "percentDeath", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_DEATHDAMAGE, intValue);

            if(readXMLInteger(configNode, "percentLifeDrain", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_LIFEDRAIN, intValue);

            if(readXMLInteger(configNode, "percentManaDrain", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_MANADRAIN, intValue);

            if(readXMLInteger(configNode, "percentDrown", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_DROWNDAMAGE, intValue);

            if(readXMLInteger(configNode, "percentPhysical", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_PHYSICALDAMAGE, intValue);

            if(readXMLInteger(configNode, "percentHealing", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_HEALING, intValue);

            if(readXMLInteger(configNode, "percentUndefined", intValue))
                voc->increaseReflect(REFLECT_PERCENT, COMBAT_UNDEFINEDDAMAGE, intValue);

            if(readXMLInteger(configNode, "chanceAll", intValue))
            {
                for(int32_t i = COMBAT_FIRST; i <= COMBAT_LAST; i++)
                    voc->increaseReflect(REFLECT_CHANCE, (CombatType_t)i, intValue);
            }

            if(readXMLInteger(configNode, "chanceElements", intValue))
            {
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_ENERGYDAMAGE, intValue);
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_FIREDAMAGE, intValue);
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_EARTHDAMAGE, intValue);
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_ICEDAMAGE, intValue);
            }

            if(readXMLInteger(configNode, "chanceMagic", intValue))
            {
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_ENERGYDAMAGE, intValue);
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_FIREDAMAGE, intValue);
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_EARTHDAMAGE, intValue);
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_ICEDAMAGE, intValue);
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_HOLYDAMAGE, intValue);
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_DEATHDAMAGE, intValue);
            }

            if(readXMLInteger(configNode, "chanceEnergy", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_ENERGYDAMAGE, intValue);

            if(readXMLInteger(configNode, "chanceFire", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_FIREDAMAGE, intValue);

            if(readXMLInteger(configNode, "chancePoison", intValue) || readXMLInteger(configNode, "chanceEarth", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_EARTHDAMAGE, intValue);

            if(readXMLInteger(configNode, "chanceIce", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_ICEDAMAGE, intValue);

            if(readXMLInteger(configNode, "chanceHoly", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_HOLYDAMAGE, intValue);

            if(readXMLInteger(configNode, "chanceDeath", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_DEATHDAMAGE, intValue);

            if(readXMLInteger(configNode, "chanceLifeDrain", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_LIFEDRAIN, intValue);

            if(readXMLInteger(configNode, "chanceManaDrain", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_MANADRAIN, intValue);

            if(readXMLInteger(configNode, "chanceDrown", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_DROWNDAMAGE, intValue);

            if(readXMLInteger(configNode, "chancePhysical", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_PHYSICALDAMAGE, intValue);

            if(readXMLInteger(configNode, "chanceHealing", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_HEALING, intValue);

            if(readXMLInteger(configNode, "chanceUndefined", intValue))
                voc->increaseReflect(REFLECT_CHANCE, COMBAT_UNDEFINEDDAMAGE, intValue);
        }

Insert our line:

Code:
        else if(!xmlStrcmp(configNode->name, (const xmlChar*)"transform"))
        {
            if(readXMLInteger(configNode, "effect", intValue))
                voc->setEffect(intValue);
        }
And of course, under
Code:
name = description = "";
insert
Code:
effect = 0;

Now in player.h after:
Code:
uint64_t lastAttack;
add:
Code:
uint64_t lastEffect;

and in player.cpp after
Code:
lastLoad = lastPing = lastPong = OTSYS_TIME();
add
Code:
lastEffect = 0;

And after:

Code:
    Creature::onThink(interval);
    int64_t timeNow = OTSYS_TIME();
add our:
Code:
    if((timeNow - lastEffect) >= 2500)
    {//sawex transform
            if(vocation->getEffect() > 0)
                g_game.addMagicEffect(getPosition(), vocation->getEffect());
          
            lastEffect = timeNow;  
    }

Now in our vocation.xml file we can use:
Code:
    <vocation id="1" name="uzumaki naruto" description="a Uzumaki Naruto" needpremium="0" gaincap="20" gainhp="25" gainmana="25" gainhpticks="4" gainhpamount="10" gainmanaticks="4" gainmanaamount="10" manamultiplier="1.3" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1">
        <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/>
        <skill taijutsu="1.1" dodge="1.5" sword="2.0" attackspeed="1.5" dist="2.0" shield="1.5" critical="1.5" experience="1.0"/>
        <transform effect="55"/>
    </vocation>

I wrote it some months ago, so i will be glad if someone will test it and report bugs. If someone will be interestet to get more configurable version, i can upload it (Or all transform system).

P.S
Code:
<skill taijutsu="1.1" dodge="1.5" sword="2.0" attackspeed="1.5" dist="2.0" shield="1.5" critical="1.5" experience="1.0"/>
this line is from my edited OTS so use your own vocation example.
 
Hmm. In creaturescripts would be faster
Code:
local config =
{
storage = 31520,
timee = 1,
efekt1 = 91,
}
function onThink(cid, interval)
    if getPlayerVocation(cid) == 67 and exhaustion.get(cid, config.storage) == false then
        doSendMagicEffect(getPlayerPosition(cid),config.efekt1)
        exhaustion.set(cid,config.storage,config.timee)
    elseif getPlayerVocation(cid) == 69 and exhaustion.get(cid, config.storage) == false then
        doSendMagicEffect(getPlayerPosition(cid),config.efekt1)
        exhaustion.set(cid,config.storage,config.timee)
    end
return true
end
 
For large number of vocations C++ code is faster, and its better to config in vocation.xml.
 
pvIU4sw.png

Not Working!
Tfs 0.3.6
When i want to login server crashed.
 
what does it exactly do? depending on the answer it could pretty much be done by using Lua, no source changes nedded
The usual way people do it in lua is iterating through ALL the players in onThink script and sending an effect if the requirements are met. Either people had horrible idea or the lua way isn't worth doing that.

This c++ modification goes to the playerthink in sources, checks if in vocations.xml a vocation has some effect that should appear e.g. each 4 seconds and sends it. Its like an aura you could say. Definitely easy to bring to tfs 1.x.
 
Back
Top