• 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 TFS 1.3 hunting trap spell

Icaraii

Well-Known Member
Joined
Jan 5, 2020
Messages
469
Solutions
1
Reaction score
58
Hello guys, I would like a help to create a spell where the player say the words and then place a trap (like feroxa silver trap) on the ground that last for 30 seconds. If no enemy step in the trap in 30 seconds, it will disappear. If a enemy step on the trap, it will take a hit based on this formula:
Lua:
function onGetFormulaValues(player, level, magicLevel)
    local min = (level / 5) + (magicLevel * 1.4) + 8
    local max = (level / 5) + (magicLevel * 2.2) + 14
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
To set the trap, it will be just like a MW, the player will choose where to put the trap.
Thanks in advance for the help.
 
To set the trap, it will be just like a MW, the player will choose where to put the trap.

I was trying to do same thing using creating new type of field (like fire field) with trap's sprite. But i had some problem i was struggling with (dunno what was that). Even created a thread.
 

I was trying to do same thing using creating new type of field (like fire field) with trap's sprite. But i had some problem i was struggling with (dunno what was that). Even created a thread.
The best way to do this is by creating a new field, like you were doing, but if I'm not mistaking, to create new fields, you need to edit source. But everything can be done in .lua if the scripter has skills. So if you can't edit source, you need to figure out a way to achiev the same objective with lua. We can take a look at this:

data\movements\scripts\trap
Lua:
local traps = {
    [1510] = {transformTo = 1511, damage = {-50, -100}},
    [1513] = {damage = {-50, -100}},
    [2579] = {transformTo = 2578, damage = {-15, -30}},                              --this one is the normal trap--
    [4208] = {transformTo = 4209, damage = {-15, -30}, type = COMBAT_EARTHDAMAGE}
}

function onStepIn(creature, item, position, fromPosition)
    local trap = traps[item.itemid]
    if not trap then
        return true
    end

    if creature:isMonster() then
        doTargetCombat(0, creature, trap.type or COMBAT_PHYSICALDAMAGE, trap.damage[1], trap.damage[2], CONST_ME_NONE)
    end

    if trap.transformTo then
        item:transform(trap.transformTo)
    end
    return true
end

function onStepOut(creature, item, position, fromPosition)
    item:transform(item.itemid - 1)
    return true
end

function onRemoveItem(item, tile, position)
    local itemPosition = item:getPosition()
    if itemPosition:getDistance(position) > 0 then
        item:transform(item.itemid - 1)
        itemPosition:sendMagicEffect(CONST_ME_POFF)
    end
    return true
end

Depending on what you want, we can edit this script. Explain to me what you need and we can try it out
 
but if I'm not mistaking, to create new fields, you need to edit source. But everything can be done in .lua if the scripter has skills. So if you can't edit source, you need to figure out a way to achiev the same objective with lua. We can take a look at this:

Well, not actually. Just for testing i just changed silver token to the firefield.

Code:
    <item id="25172" article="a" name="fire field">
        <attribute key="type" value="magicfield" />
        <attribute key="replaceable" value="0" />
        <attribute key="field" value="fire">
            <attribute key="initdamage" value="20" />
            <attribute key="ticks" value="10000" />
            <attribute key="count" value="7" />
            <attribute key="damage" value="10" />
        </attribute>
    </item>
Code:
    <movevent event="StepIn" itemid="25172" function="onStepInField" />
    <movevent event="AddItem" itemid="25172" function="onAddField" />

The thing is, it is behaving like a normal fire field. And yeah, to edit specific behaviour of fields you need to change source (i wanted a field that explodes ue on stepIn, and prevent minions to avoid it) :/ The other problem is making a spell spawning a field (dunno how)
 
Well, not actually. Just for testing i just changed silver token to the firefield.

Code:
    <item id="25172" article="a" name="fire field">
        <attribute key="type" value="magicfield" />
        <attribute key="replaceable" value="0" />
        <attribute key="field" value="fire">
            <attribute key="initdamage" value="20" />
            <attribute key="ticks" value="10000" />
            <attribute key="count" value="7" />
            <attribute key="damage" value="10" />
        </attribute>
    </item>
Code:
    <movevent event="StepIn" itemid="25172" function="onStepInField" />
    <movevent event="AddItem" itemid="25172" function="onAddField" />

The thing is, it is behaving like a normal fire field. And yeah, to edit specific behaviour of fields you need to change source (i wanted a field that explodes ue on stepIn, and prevent minions to avoid it) :/ The other problem is making a spell spawning a field (dunno how)
I believe that this is set by source:
<attribute key="field" value="fire">
for example, if you try to put the value as "ice", it won't recognize such field, because in source there is not a ice field.

I'm not a good scripter and don't know if I understand what you want, but you can try something like this:
You want a monster to create a fire field on the floor and if a player step in, it explodes in a greater area, right?

For a monster to create a firefield you can put this line in the monster: (don't forget to edit radius to the size you want)
Lua:
        <attack name="firefield" interval="2000" chance="10" range="7" radius="4" target="0">
            <attribute key="shootEffect" value="fire" />
        </attack>

For the minion not to step on the field you can put this:
Lua:
        <flag canwalkonfire="0" />

the next part would be creating and event that if player step in the field, it will explode in a ue and deal x amount of damage like you want. A creaturescript would do that, however, the problem is that you using fire field to turn the event on, this would mean that every fire field that a player would step in, would turn on the event. I'm trying to figure out a way around this, if I find something I let you know
 
for example, if you try to put the value as "ice", it won't recognize such field, because in source there is not a ice field.

Sure, yeah.

I'm not a good scripter and don't know if I understand what you want, but you can try something like this:
You want a monster to create a fire field on the floor and if a player step in, it explodes in a greater area, right?

Hah, that thread was made in the past. For now, i would like to make a spell for paladin, that allows to spawn traps that do something (paralyze, explosion) when monster step in on it (and make it unavoidable since some monster know how to dodge fields). But same abilities for monsters would be useful too.
 
Sure, yeah.



Hah, that thread was made in the past. For now, i would like to make a spell for paladin, that allows to spawn traps that do something (paralyze, explosion) when monster step in on it (and make it unavoidable since some monster know how to dodge fields). But same abilities for monsters would be useful too.
See if this satisfy you.
Paladin says the spells words and appear the trap in his backpack that last for x amount of seconds. If he uses the trap (it would appear crossair and the player would select where to put it) and it would activate like normal trap. If monster step in, get paralyze and receives damage.
 
Yeah, making this working like a rune is a some solution, but kinda lazy. It allows a player to give it to the other (non-paladin) one.

Edit: oh wait. You can limit rune usage to a vocation with level requirement. That's something.

Btw. I wanted to help you, but we ended up helping me, lmao
 
Yeah, making this working like a rune is a some solution, but kinda lazy. It allows a player to give it to the other (non-paladin) one.

Edit: oh wait. You can limit rune usage to a vocation with level requirement. That's something.

Btw. I wanted to help you, but we ended up helping me, lmao
Did you manage to do it?

Don't worrie about my spells, I change the spell to another thing
 
Back
Top