• 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 TSF 1.3 Summon deal damage base on player(summon master) skill and level

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
300
Solutions
1
Reaction score
38
Hello guys, I'm trying to make summons more interesting trying to make their damage vary according to player level and skill. So I've tried this out:

spells/scripts/monster/summon_damage
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 7)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 4)

function onCastSpell(creature, variant)
    if summon then
        summon:setMaster(creature)
    local maxHealth = creature:getMaxHealth()
    local maxMana = creature:getMaxMana()
    local playlvl = creature:getLevel()
    local shield = creature:getSkillLevel(SKILL_SHIELD)
    local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 2) + (attack * 2) + (skill * 4)) * 0,5
    local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 2) + (attack * 2) + (skill * 4)) * 1,0
    local damage = math.random(math.floor(min), math.floor(max))
    for _, target in ipairs(combat:getTargets(creature, variant)) do
        creature:addDamageCondition(target, CONDITION_FIRE, DAMAGELIST_EXPONENTIAL_DAMAGE, damage)
    end
    end
    return true
end

No erros appear on TFS, I can still summon the creature and everything, but he jusn't doesn't hit. Can somebody help me out?
 
Solution
I will test it and remove the condition part aswel, it won't make a big difference in what I wanted
Post automatically merged:

The problem is that it won't get the formula from spell to damage, it still using min and max from the monster.xml. Don't know how to achiev what I needed
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 7)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 4)

local function getWeapon(player)
    local weapon = player:getSlotItem(CONST_SLOT_LEFT)
    
    if not weapon then
        weapon = player:getSlotItem(CONST_SLOT_RIGHT)
    end

    return weapon and ItemType(weapon:getId()) or nil
end

local function calculateDamage(player)...
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
300
Solutions
1
Reaction score
38
You need to call combat:execute(creature, variant)
True and I also just realize that I forgot to put the parameters skill, attack, shield, factor.

I will test and get back to you, thanks
Post automatically merged:

It kinda work. The summon is now attacking, but he ain't using the min and max damage I stablesh on the spell, it is using the amount of damage of monster.xml

XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<monster name="Iron Robot" nameDescription="an iron robot" race="energy" experience="210" speed="190">
    <health now="350" max="350" />
    <look type="395" corpse="13486" />
    <targetchange interval="4000" chance="10" />
    <flags>
        <flag summonable="1" />
        <flag attackable="1" />
        <flag hostile="1" />
        <flag illusionable="0" />
        <flag convinceable="0" />
        <flag pushable="1" />
        <flag canpushitems="1" />
        <flag canpushcreatures="0" />
        <flag targetdistance="1" />
        <flag staticattack="70" />
        <flag runonhealth="0" />
        <flag canwalkonenergy="1" />
        <flag canwalkonfire="1" />
    </flags>
    <attacks>
        <attack name="robot burn" interval="2000" min="0" max="-100" />
    </attacks>
    <defenses armor="15" defense="15" />
    <elements>
        <element physicalPercent="10" />
        <element firePercent="-10" />
    </elements>
    <voices interval="5000" chance="10">
        <voice sentence="klonk klonk klonk" />
        <voice sentence="Rrrtttarrrttarrrtta" />
        <voice sentence="Awaiting orders." />
        <voice sentence="Processing." />
    </voices>
</monster>

Do you have any idea how to solve this?
 
Last edited:

slayzer

Klaffen
Joined
Dec 28, 2008
Messages
274
Solutions
2
Reaction score
24
Location
Norway
True and I also just realize that I forgot to put the parameters skill, attack, shield, factor.

I will test and get back to you, thanks
Post automatically merged:

It kinda work. The summon is now attacking, but he ain't using the min and max damage I stablesh on the spell, it is using the amount of damage of monster.xml

XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<monster name="Iron Robot" nameDescription="an iron robot" race="energy" experience="210" speed="190">
    <health now="350" max="350" />
    <look type="395" corpse="13486" />
    <targetchange interval="4000" chance="10" />
    <flags>
        <flag summonable="1" />
        <flag attackable="1" />
        <flag hostile="1" />
        <flag illusionable="0" />
        <flag convinceable="0" />
        <flag pushable="1" />
        <flag canpushitems="1" />
        <flag canpushcreatures="0" />
        <flag targetdistance="1" />
        <flag staticattack="70" />
        <flag runonhealth="0" />
        <flag canwalkonenergy="1" />
        <flag canwalkonfire="1" />
    </flags>
    <attacks>
        <attack name="robot burn" interval="2000" min="0" max="-100" />
    </attacks>
    <defenses armor="15" defense="15" />
    <elements>
        <element physicalPercent="10" />
        <element firePercent="-10" />
    </elements>
    <voices interval="5000" chance="10">
        <voice sentence="klonk klonk klonk" />
        <voice sentence="Rrrtttarrrttarrrtta" />
        <voice sentence="Awaiting orders." />
        <voice sentence="Processing." />
    </voices>
</monster>

Do you have any idea how to solve this?
Tried not including min and max on the attack? Dont think you need it.
 

slayzer

Klaffen
Joined
Dec 28, 2008
Messages
274
Solutions
2
Reaction score
24
Location
Norway
When I don't include min and max, the effect of the damage appear, but no damage is dealt
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 7)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 4)

function onCastSpell(creature, variant)
    local player = creature:getMaster()
    if  not player then
        return false
    end

    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local playlvl = player:getLevel()
    local mlvl = player:getMagicLevel()
    local shielding = player:getSkillLevel(SKILL_SHIELD)
    local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 2) + (shielding * 2) + (mlvl * 4)) * 0,5
    local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 2) + (shielding * 2) + (mlvl * 4)) * 1,0
    local damage = math.random(math.floor(min), math.floor(max))
    for _, target in ipairs(combat:getTargets(creature, variant)) do
        creature:addDamageCondition(target, CONDITION_FIRE, DAMAGELIST_EXPONENTIAL_DAMAGE, damage)
    end
    return true
end
This bit seem to work now. Damage is very low for some reason though. When i printed it it was suppose to be 11k+ on my GM, but it only dealt 25~ damage for some reason. Guess its the condition part i dont fully understand.
 
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
300
Solutions
1
Reaction score
38
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 7)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 4)

function onCastSpell(creature, variant)
    local player = creature:getMaster()
    if  not player then
        return false
    end

    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local playlvl = player:getLevel()
    local mlvl = player:getMagicLevel()
    local shielding = player:getSkillLevel(SKILL_SHIELD)
    local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 2) + (shielding * 2) + (mlvl * 4)) * 0,5
    local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 2) + (shielding * 2) + (mlvl * 4)) * 1,0
    local damage = math.random(math.floor(min), math.floor(max))
    for _, target in ipairs(combat:getTargets(creature, variant)) do
        creature:addDamageCondition(target, CONDITION_FIRE, DAMAGELIST_EXPONENTIAL_DAMAGE, damage)
    end
    return true
end
This bit seem to work now. Damage is very low for some reason though. When i printed it it was suppose to be 11k+ on my GM, but it only dealt 25~ damage for some reason. Guess its the condition part i dont fully understand.
I will test it and remove the condition part aswel, it won't make a big difference in what I wanted
Post automatically merged:

The problem is that it won't get the formula from spell to damage, it still using min and max from the monster.xml. Don't know how to achiev what I needed
 
Last edited:

slayzer

Klaffen
Joined
Dec 28, 2008
Messages
274
Solutions
2
Reaction score
24
Location
Norway
I will test it and remove the condition part aswel, it won't make a big difference in what I wanted
Post automatically merged:

The problem is that it won't get the formula from spell to damage, it still using min and max from the monster.xml. Don't know how to achiev what I needed
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, 7)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 4)

local function getWeapon(player)
    local weapon = player:getSlotItem(CONST_SLOT_LEFT)
    
    if not weapon then
        weapon = player:getSlotItem(CONST_SLOT_RIGHT)
    end

    return weapon and ItemType(weapon:getId()) or nil
end

local function calculateDamage(player)
    local maxHealth = player:getMaxHealth()
    local maxMana = player:getMaxMana()
    local playlvl = player:getLevel()
    local mlvl = player:getMagicLevel()
    local shielding = player:getSkillLevel(SKILL_SHIELD)
    local weapon = getWeapon(player)

    local skill = weapon and player:getSkillLevel(weapon:getWeaponType()) or 1
    local attack = weapon and weapon:getAttack() or 1
    local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 2) + (shielding * 2) + (mlvl * 4) + (attack * 2) + (skill * 4)) * 0,5
    local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 2) + (shielding * 2) + (mlvl * 4) + (attack * 2) + (skill * 4)) * 1,0
    return math.floor(min), math.floor(max)
end

function onCastSpell(creature, variant)
    local player = creature:getMaster()
    if  not player then
        return false
    end

    local min, max = calculateDamage(player)
    combat:setFormula(COMBAT_FORMULA_DAMAGE, -min, 0, -max, 0)
    combat:execute(creature, variant)   
    return true
end
Dont set a min and max in monster.xml.

Example from my test monster:
XML:
    <attacks>
        <attack name="testSpell" interval="2000" chance="50"/>
    </attacks>
 
Solution
OP
OP
I

Icaraii

Active Member
Joined
Jan 5, 2020
Messages
300
Solutions
1
Reaction score
38
local combat = Combat() combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE) combat:setParameter(COMBAT_PARAM_EFFECT, 7) combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, 4) local function getWeapon(player) local weapon = player:getSlotItem(CONST_SLOT_LEFT) if not weapon then weapon = player:getSlotItem(CONST_SLOT_RIGHT) end return weapon and ItemType(weapon:getId()) or nil end local function calculateDamage(player) local maxHealth = player:getMaxHealth() local maxMana = player:getMaxMana() local playlvl = player:getLevel() local mlvl = player:getMagicLevel() local shielding = player:getSkillLevel(SKILL_SHIELD) local weapon = getWeapon(player) local skill = weapon and player:getSkillLevel(weapon:getWeaponType()) or 1 local attack = weapon and weapon:getAttack() or 1 local min = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 2) + (shielding * 2) + (mlvl * 4) + (attack * 2) + (skill * 4)) * 0,5 local max = ((playlvl < 300 and playlvl or 300) + ((maxHealth + maxMana) / 2) + (shielding * 2) + (mlvl * 4) + (attack * 2) + (skill * 4)) * 1,0 return math.floor(min), math.floor(max) end function onCastSpell(creature, variant) local player = creature:getMaster() if not player then return false end local min, max = calculateDamage(player) combat:setFormula(COMBAT_FORMULA_DAMAGE, -min, 0, -max, 0) combat:execute(creature, variant) return true end
Thank you very much, it work just as I wanted
 
Top