• 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!

Lua Vocation.xml

Akirama

New Member
Joined
Aug 9, 2020
Messages
26
Reaction score
1
Hi...
I need to change magdmg for next transform ( next vocation ) in vocation.xml (like a profit from got transform ). Unfortunately in tfs 1.3 i can';t find something like this:

Lua:
<formula meleeDamage="2.0" distDamage="2.0" wandDamage="2.0" magDamage="2.0" magHealingDamage="2.0" defense="2.0" magDefense="2.0" armor="2.0"/>

In my vocation.xml i have only this:

Code:
        <vocation id="81" clientid="1" name="Shino" description="a Shino" gaincap="25" gainhp="15" gainmana="5" gainhpticks="2" gainhpamount="10" gainmanaticks="4" gainmanaamount="10" manamultiplier="3.0" attackspeed="2000" basespeed="220" soulmax="200" gainsoulticks="15" fromvoc="81">

        <formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />

        <skill id="0" multiplier="1.1" />

        <skill id="1" multiplier="1.1" />

        <skill id="2" multiplier="1.1" />

        <skill id="3" multiplier="1.1" />

        <skill id="4" multiplier="1.4" />

        <skill id="5" multiplier="1.1" />

        <skill id="6" multiplier="1.1" />

</vocation>

Someone have time and desire to help me with this ? :D
 
Last edited:
@Nush try to help me, but that's don't work can someone tell me why?

Vocation.cpp
after:
C++:
 pugi::xml_attribute distDamageAttribute = childNode.attribute("distDamage");
    if (distDamageAttribute) {
        voc.distDamageMultiplier = pugi::cast<float>(distDamageAttribute.value());
    }

paste:
Code:
  pugi::xml_attribute magDamageAttribute = childNode.attribute("magDamage");
    if (magDamageAttribute) {
        voc.magDamageMultiplier = pugi::cast<float>(magDamageAttribute.value());
    }

vocation.h

after:
C++:
float distDamageMultiplier = 1.0f;

paste:
C++:
float magDamageMultiplier = 1.0f;

combat.cpp

in function :
C++:
void Combat::doTargetCombat

after:
C++:
   Player* targetPlayer = target ? target->getPlayer() : nullptr;
    if (targetPlayer && targetPlayer->getSkull() != SKULL_BLACK) {
        damage.primary.value /= 2;
        damage.secondary.value /= 2;
    }

paste:

C++:
   if (damage.origin == ORIGIN_SPELL) {
        damage.primary.value *= casterPlayer->getVocation()->magDamageMultiplier;
    }


and for end... in vocation.xml after:
C++:
distDamage="1.0"

Paste:
C++:
magDamage="1.0"


I try to multiple magDamage="10.0" , 100x... etc and that's not work ;(... I don't have any error in console.
 
Last edited:
Solution up only work on target... i dont test this solution to aoe dmg... and that don;t work on aoe/wave damage
So i try without know c++ to add effect too in aoe dmg.



I try add this :
Lua:
   if (damage.origin == ORIGIN_SPELL) {
        damage.primary.value *= casterPlayer->getVocation()->magDamageMultiplier;
    }

to this script in combat.cpp
Code:
void Combat::doAreaCombat(Creature* caster, const Position& position, const AreaCombat* area, CombatDamage& damage, const CombatParams& params)

in this script:

Code:
if (!params.aggressive || (caster != creature && Combat::canDoCombat(caster, creature) == RETURNVALUE_NOERROR)) {
                    CombatDamage damageCopy = damage; // we cannot avoid copying here, because we don't know if it's player combat or not, so we can't modify the initial damage.
                    if ((damageCopy.primary.value < 0 || damageCopy.secondary.value < 0) && caster) {
                        Player* targetPlayer = creature->getPlayer();
                        if (targetPlayer && caster->getPlayer() && targetPlayer->getSkull() != SKULL_BLACK) {
                            damageCopy.primary.value /= 2;
                            damageCopy.secondary.value /= 2;
                        }
                                 if (damage.origin == ORIGIN_SPELL) {
        damage.primary.value *= casterPlayer->getVocation()->magDamageMultiplier;
        }
                    }

I add :

Code:
                                 if (damage.origin == ORIGIN_SPELL) {
        damage.primary.value *= casterPlayer->getVocation()->magDamageMultiplier;
        }

And this is effect in game:
1616252331322.png


For me only "1093" damage is corret, someone can check why this multiple dmg 10x then min dmg... 80x on other sqm then min dmg and 700x on other sqm then min dmg ? I want only have this "1093" dmg.






Below vocation.xml and spell.lua
Character lvl : 607
mlvl : 4

Lua:
    <vocation id="39" clientid="0" name="Sasuke" description="a Sasuke" gaincap="10" gainhp="20" gainmana="30" gainhptickes="2" gainmanaamount="4" manamultipler="4" attackspeed="2000" basespeed="220" soulmax="200" gainsoulticks="60" fromvoc="39">
    <formula meleeDamage="2.4" distDamage="1" magDamage="8.1" defense="1.5" armor="2" />
    <skill id="0" multiplier="1.1" />
    <skill id="1" multiplier="1.1" />
    <skill id="2" multiplier="1.1" />
    <skill id="3" multiplier="1.1" />
    <skill id="4" multiplier="1.1" />
    <skill id="5" multiplier="1.1" />
    <skill id="6" multiplier="1.1" />
    </vocation>


Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
combat:setArea(createCombatArea(AREA_SQUAREWAVE5))

function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 1.4) + 8
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    local player = Player(creature)
    local playerPos = player:getPosition()
    local playerDir = player:getDirection()
 
    if playerDir == NORTH then
        Position(playerPos.x + 2, playerPos.y - 1, playerPos.z):sendMagicEffect(100)
    elseif playerDir == SOUTH then
        Position(playerPos.x + 2, playerPos.y + 4, playerPos.z):sendMagicEffect(101)
    elseif playerDir == WEST then
        Position(playerPos.x - 2, playerPos.y + 1, playerPos.z):sendMagicEffect(99)
    elseif playerDir == EAST then
        Position(playerPos.x + 4, playerPos.y + 1, playerPos.z):sendMagicEffect(98)
    end
 
    return combat:execute(creature, variant)
end
 
Last edited:
@Ascuas Funkeln
Sorry I dont add this:
First solution up only work on target... i dont test this solution to aoe dmg... and that don't work on aoe spell :( .
So i try without know c++ to add effect too in aoe dmg.
 
@Ascuas Funkeln
Sorry I dont add this:
First solution up only work on target... i dont test this solution to aoe dmg... and that don't work on aoe spell :( .
So i try without know c++ to add effect too in aoe dmg.
Just do it as onHealthChange script
This will help you to make it.
 
Just do it as onHealthChange script
This will help you to make it.

This is example solution :D, I want to got full work vocation.xml with magdmg whose work with target/wave/aoe spells due to script in my first answer or something else in source :).
 
in some cases it's not worth doing this as script, especially if you have hundreds of vocations, multiple hits each spells, etc like DBO/NTO servers and you will need to add the creatureevent in every monster too...
if you haven't a custom server it's okay to do as script.

This is the best way that i found to do it, and you can configure better as you want, lets do it
repeat what u did in vocation.cpp/h

but in combat.cpp search for
C++:
Combat::getCombatDamage
on this line change
C++:
int32_t levelFormula = player->getLevel() * 2 + player->getMagicLevel() * 3;
to
C++:
int32_t levelFormula = player->getLevel() * 2 + player->getMagicLevel() * 3 + player->getVocation()->magDamageMultiplier * 2;

then search for
C++:
ValueCallback::getMinMaxValues
and change this:
C++:
case COMBAT_FORMULA_LEVELMAGIC: {
            //onGetPlayerMinMaxValues(player, level, maglevel)
            lua_pushnumber(L, player->getLevel());
            lua_pushnumber(L, player->getMagicLevel());
            parameters += 2;
            break;
        }
for this:
C++:
case COMBAT_FORMULA_LEVELMAGIC: {
            //onGetPlayerMinMaxValues(player, level, maglevel, magdamage)
            lua_pushnumber(L, player->getLevel());
            lua_pushnumber(L, player->getMagicLevel());
            lua_pushnumber(L, player->getVocation()->magDamageMultiplier);
            parameters += 3;
            break;
        }

Now the configuration inGame will use this formula, you can use to configure better:
Lua:
function onGetFormulaValues(player, level, magicLevel, magDamage)
    local min = (level * 5) + (magicLevel * 2) + (magDamage * 8)
    local max = (level * 5) + (magicLevel * 2) + (magDamage * 8)
    return -min, -max
end

combat1:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

if you don't want magDamage in some spells can just use this
Lua:
function onGetFormulaValues(cid, level, maglevel)
    min = -((level*X) + (maglevel*Y))
    max = -((level*X) + (maglevel*Y))

Remember to delete your changes in Combat.cpp
Hope this helps.
 
Last edited:
Back
Top