• 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 Trap (only damage for monsters not for players)

Tampek

ECHO 'Zarkonia.online';
Joined
Dec 29, 2015
Messages
478
Solutions
5
Reaction score
33
Location
Spain
Hello today im reproducing grimvale event and now looking the trap for kill first step for feroxa.
Looking trap script i can see the damage hit all players:
Code:
local traps = {
    [1510] = {transformTo = 1511, damage = {-50, -100}},
    [1513] = {damage = {-50, -100}},
    [2579] = {transformTo = 2578, damage = {-15, -30}, ignorePlayer = (Game.getWorldType() == WORLD_TYPE_NO_PVP) },
    [4208] = {transformTo = 4209, damage = {-15, -30}, type = COMBAT_EARTHDAMAGE},
    [24715] = {transformTo = 24730, damage = {-999, -1000}, type = COMBAT_DROWNDAMAGE},   
    [11099] = {transformTo = 2021},
    [10546] = {transformTo = 2021}   
}

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

    if trap.ignorePlayer and creature:isPlayer() then
        return true
    end

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

    doTargetCombatHealth(0, creature, trap.type or COMBAT_PHYSICALDAMAGE, trap.damage[1], trap.damage[2], CONST_ME_NONE)
    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

Then how i can change the damage only for monsters and not for players
[24715] = {transformTo = 24730, damage = {-999, -1000}, type = COMBAT_DROWNDAMAGE},

thnx for advance

Fixed sorry
 
Last edited by a moderator:
Hello today im reproducing grimvale event and now looking the trap for kill first step for feroxa.
Looking trap script i can see the damage hit all players:
Code:
local traps = {
    [1510] = {transformTo = 1511, damage = {-50, -100}},
    [1513] = {damage = {-50, -100}},
    [2579] = {transformTo = 2578, damage = {-15, -30}, ignorePlayer = (Game.getWorldType() == WORLD_TYPE_NO_PVP) },
    [4208] = {transformTo = 4209, damage = {-15, -30}, type = COMBAT_EARTHDAMAGE},
    [24715] = {transformTo = 24730, damage = {-999, -1000}, type = COMBAT_DROWNDAMAGE},  
    [11099] = {transformTo = 2021},
    [10546] = {transformTo = 2021}  
}

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

    if trap.ignorePlayer and creature:isPlayer() then
        return true
    end

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

    doTargetCombatHealth(0, creature, trap.type or COMBAT_PHYSICALDAMAGE, trap.damage[1], trap.damage[2], CONST_ME_NONE)
    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

Then how i can change the damage only for monsters and not for players
[24715] = {transformTo = 24730, damage = {-999, -1000}, type = COMBAT_DROWNDAMAGE},

thnx for advance

Rules for the Support board
#8
 
  1. if trap.ignorePlayer and creature:isPlayer() then
  2. return false
  3. else
  4. return true
  5. end
  6. # wait it actionally worked? lmao
Love this post, that’s how easy it is to formulate a script. No matter how difficult it seems, just walk through the steps, write it out, and then all you have to do is translate to code
 
Back
Top