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

Monster with damage based on owner (for summoner)

Paulix

Active Member
Joined
Sep 13, 2012
Messages
129
Solutions
7
Reaction score
26
im creating a creature that will only exists if summoned by player, is there any way to make the monster hit based on level and magic level from its owner?
 
Solution
In monster's xml file you can add spells like that.
XML:
<attack type="instant" name="MY NEW EXORI" interval="2000" chance="100" range="4"/>

And here is my simple MY_NEW_EXORI.lua what hits are based on master's lvl and mlv:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)

function onGetFormulaValues(cid)
    local master = getCreatureMaster(cid)
    local level, maglevel = 0, 0
    if master ~= cid and isPlayer(master) == true then
        level = getPlayerLevel(master)
        maglevel = getPlayerMagLevel(master)
    end
    min = -(level + maglevel * 4) * 0.2
    max = -(level + maglevel * 4) * 0.3
    return min, max...
Lua:
local master = creature:getMaster()

if Player(master) then

-- change spell damage numbers
-- local skill = master:getSkillLevel( skill type here )
-- something = something + skill

end

skill types:
SKILL_FIST
SKILL_CLUB
SKILL_SWORD
SKILL_AXE
SKILL_DISTANCE
SKILL_SHIELD
SKILL_FISHING
SKILL_MAGLEVEL
SKILL_LEVEL

you also have to write spells in lua to be able to manipulate these numbers
 
Lua:
local master = creature:getMaster()

if Player(master) then

-- change spell damage numbers
-- local skill = master:getSkillLevel( skill type here )
-- something = something + skill

end

skill types:
SKILL_FIST
SKILL_CLUB
SKILL_SWORD
SKILL_AXE
SKILL_DISTANCE
SKILL_SHIELD
SKILL_FISHING
SKILL_MAGLEVEL
SKILL_LEVEL

you also have to write spells in lua to be able to manipulate these numbers
forgot to say that i'm using tfs 0.3.6, is it the same way? create a spell, and get master info and make the monster use it?
 
In monster's xml file you can add spells like that.
XML:
<attack type="instant" name="MY NEW EXORI" interval="2000" chance="100" range="4"/>

And here is my simple MY_NEW_EXORI.lua what hits are based on master's lvl and mlv:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)

function onGetFormulaValues(cid)
    local master = getCreatureMaster(cid)
    local level, maglevel = 0, 0
    if master ~= cid and isPlayer(master) == true then
        level = getPlayerLevel(master)
        maglevel = getPlayerMagLevel(master)
    end
    min = -(level + maglevel * 4) * 0.2
    max = -(level + maglevel * 4) * 0.3
    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local area = createCombatArea({
{0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 3, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0}
})
setCombatArea(combat, area)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
 
Solution
In monster's xml file you can add spells like that.
XML:
<attack type="instant" name="MY NEW EXORI" interval="2000" chance="100" range="4"/>

And here is my simple MY_NEW_EXORI.lua what hits are based on master's lvl and mlv:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)

function onGetFormulaValues(cid)
    local master = getCreatureMaster(cid)
    local level, maglevel = 0, 0
    if master ~= cid and isPlayer(master) == true then
        level = getPlayerLevel(master)
        maglevel = getPlayerMagLevel(master)
    end
    min = -(level + maglevel * 4) * 0.2
    max = -(level + maglevel * 4) * 0.3
    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local area = createCombatArea({
{0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 3, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0}
})
setCombatArea(combat, area)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
this is what i was thinking, just didn't know it was possible, thank you!
 
In monster's xml file you can add spells like that.
XML:
<attack type="instant" name="MY NEW EXORI" interval="2000" chance="100" range="4"/>

And here is my simple MY_NEW_EXORI.lua what hits are based on master's lvl and mlv:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)

function onGetFormulaValues(cid)
    local master = getCreatureMaster(cid)
    local level, maglevel = 0, 0
    if master ~= cid and isPlayer(master) == true then
        level = getPlayerLevel(master)
        maglevel = getPlayerMagLevel(master)
    end
    min = -(level + maglevel * 4) * 0.2
    max = -(level + maglevel * 4) * 0.3
    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local area = createCombatArea({
{0, 0, 0, 0, 0, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 3, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 0, 0, 0, 0, 0}
})
setCombatArea(combat, area)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
Sorry for digging up the topic but I was wondering If you could help me out guys. I used the spell that you have written but my summon doesn't deal any damage to trainers. The spell itself works (animation) but there is no damage. I was also wandering if I could change magic level with for example SKILL_AXE or something?
 
Maybe you are using different server's distro. The original code was written for TFS 0.3
If you are using TFS 1.0+ then you have slightly adjust code to the new TFS. Of course it is possible to make it able to use SKILL_AXE also.
 
Back
Top