• 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 Xikini's Free Scripting Service TFS 1.3

Status
Not open for further replies.

Xikini

I whore myself out for likes
Senator
Premium User
Joined
Nov 17, 2010
Messages
6,788
Solutions
581
Reaction score
5,354
Please request
actions / creatureevents / globalevents / npcs / movements / talkactions

Do not request
spells / weapons / monsters / source editing / database queries

My goal of this thread is to learn TFS 1.3 scripting.

------------------------------------
Support

If you have an issue with one of my scripts, I will attempt to help you, but not in this thread.
Make a thread in the support board.
Ensure to follow all rules of the support board.
Without all neccesary information it's impossible to help you.

------------------------------------
I will only be scripting for TFS 1.3

Not TFS 1.1 / 1.2
Not OTServBR / OTX
and certainly not TFS 0.4

When requesting a script, don't ask for "this script I saw on super popular OT".

I don't care where the idea came from.
I don't want to see a video of the script in action.

I'm here to learn how to script better.
Just describe what the script is supposed to do, and I'll try to make it.

Any script that I make in response to a request from this thread will be shared publically, here, in this thread.

I'm not going to make anything in private, so post your request in this thread only.
Please, for the love of god, don't pm me asking to make a script.
I will actually add you to my ignore list if you do that.
--------------

Anyways!

Thanks for coming by and checking the thread out.
If you think there is a better way to script something, feel free to let me know.
I'm here to learn.

Cheers,

Xikini

----

Completed Scripts

DPS Dummy -> using RevScripts
!playerinfo character name -> using RevScripts
Positional Text talkaction -> using RevScripts
||--> Updated version that can use text & effects
Vocational Item Bonus's -> using RevScripts
||--> Updated version with easier config.
Simple damge buff potion -> using Revscripts
Kill monster in specific area, remove stone for x seconds -> using RevScripts
Training Room Teleporter -> using RevScripts
Lever that removes/adds/transforms objects or ground tiles -> using RevScripts
Loot from monster goes into single backpack, no matter how much loot there is.
Extra loot in monsters, based on chance and tier list -> using RevScripts
||--> Updated version that allows specific monsters to have their own loot table
Random Item chest that disappears after use, and respawns after x time -> using RevScripts
Multiple players required to open passageway.
Monster Arena Lever (x amount of waves, complete all waves, teleport appears) -> using RevScripts
Daily Boosted Creatures (experience & loot chance of items)
||--> Updated main file of boosted creatures, so that it triggers at midnight, instead of when the server starts up.
Reward Chest - Extremely simple. -> using Revscripts
Simple Npc that can sell an item, via text.

----

Extremely useful libs that I use quite often.

data/lib/core/player.lua
Give player items by table

data/lib/core/container.lua
getContainerFreeSlots

----

To-Do List

Shalaby - Player death counter. (Movement and talkaction)
Shalaby - Npc kill monster task, with item reward.
Shalaby - Boss respawn after x time.

-------

Last spot I've read messages
 
Last edited:
example.png
Can you make a script,that you can enter a tp, and it takes you to a specific place, but that when you return it takes you to the site from where you entered, for example if I enter the black tp and do tp back it will return me to the black tp, if I enter the part tp blue and I do tp back I returned to tp blue
 
View attachment 49696
Can you make a script,that you can enter a tp, and it takes you to a specific place, but that when you return it takes you to the site from where you entered, for example if I enter the black tp and do tp back it will return me to the black tp, if I enter the part tp blue and I do tp back I returned to tp blue

Basically it's simple script. You can store "previous position" (when you enter tp) in storages.
It's my old code for "lobby" (place at map that can be entered from every place and it's like "one place/centrum to meet people from all around the map")
You can use it or change to one storage:
Lua:
local STORAGE_BACKPOSX = 260011
local STORAGE_BACKPOSY = 260012
local STORAGE_BACKPOSZ = 260013

local LobbyTeleportPos = Position(363,510,7) -- Item Position of Lobby EXIT teleport
local TeleportToLobby = Position(363,511,7) -- Position, where player appear in Lobby 

local function cleanBackPos(cid)
    cid:setStorageValue(STORAGE_BACKPOSX, 0)
    cid:setStorageValue(STORAGE_BACKPOSY, 0)
    cid:setStorageValue(STORAGE_BACKPOSZ, 0)
end

function onStepIn(creature, item, position, fromPosition)

    local player = creature:getPlayer()
    if not player then
        return true
    end

    local pstorX = getPlayerStorageValue(player, STORAGE_BACKPOSX)
    local pstorY = getPlayerStorageValue(player, STORAGE_BACKPOSY)
    local pstorZ = getPlayerStorageValue(player, STORAGE_BACKPOSZ)

    if position == LobbyTeleportPos then
        print("Teleport back to saved position in storages and clean storages")
        player:teleportTo(Position(pstorX, pstorY, pstorZ))
        cleanBackPos(player)
    else
        print("Teleports to Lobby and Save entered position in storages")
        player:setStorageValue(STORAGE_BACKPOSX, fromPosition.x)
        player:setStorageValue(STORAGE_BACKPOSY, fromPosition.y)
        player:setStorageValue(STORAGE_BACKPOSZ, fromPosition.z)
        player:teleportTo(TeleportToLobby, true)
    end
    
    return true
end
 
Please, i need script so that the critic is influenced by the skill club! the higher the level, the greater the chance and value
 
Basically it's simple script. You can store "previous position" (when you enter tp) in storages.
It's my old code for "lobby" (place at map that can be entered from every place and it's like "one place/centrum to meet people from all around the map")
You can use it or change to one storage:
Lua:
local STORAGE_BACKPOSX = 260011
local STORAGE_BACKPOSY = 260012
local STORAGE_BACKPOSZ = 260013

local LobbyTeleportPos = Position(363,510,7) -- Item Position of Lobby EXIT teleport
local TeleportToLobby = Position(363,511,7) -- Position, where player appear in Lobby

local function cleanBackPos(cid)
    cid:setStorageValue(STORAGE_BACKPOSX, 0)
    cid:setStorageValue(STORAGE_BACKPOSY, 0)
    cid:setStorageValue(STORAGE_BACKPOSZ, 0)
end

function onStepIn(creature, item, position, fromPosition)

    local player = creature:getPlayer()
    if not player then
        return true
    end

    local pstorX = getPlayerStorageValue(player, STORAGE_BACKPOSX)
    local pstorY = getPlayerStorageValue(player, STORAGE_BACKPOSY)
    local pstorZ = getPlayerStorageValue(player, STORAGE_BACKPOSZ)

    if position == LobbyTeleportPos then
        print("Teleport back to saved position in storages and clean storages")
        player:teleportTo(Position(pstorX, pstorY, pstorZ))
        cleanBackPos(player)
    else
        print("Teleports to Lobby and Save entered position in storages")
        player:setStorageValue(STORAGE_BACKPOSX, fromPosition.x)
        player:setStorageValue(STORAGE_BACKPOSY, fromPosition.y)
        player:setStorageValue(STORAGE_BACKPOSZ, fromPosition.z)
        player:teleportTo(TeleportToLobby, true)
    end
   
    return true
end
Hows can install?
 
Hi! Is possible to have a Death Channel showing who die in diferent colors? Like a dead for 1-3 player, monster or field in white text, 4-8 on orange and 9 or more in red?

Like that:

death channel.png
 
Last edited:
Hi! Is possible to have a Death Channel showing who die in diferent colors? Like a dead for 1-3 player, monster or field in white text, 4-8 on orange and 9 or more in red?

Like that:

View attachment 50746
Well yes it's possible. But he's inactive according to the last post which wasn't long ago so I assume he's still inactive. You're better off posting this on the requests section.
 
Please request
actions / creatureevents / globalevents / npcs / movements / talkactions

Do not request
spells / weapons / monsters / source editing / database queries

My goal of this thread is to learn TFS 1.3 scripting.

------------------------------------
Support

If you have an issue with one of my scripts, I will attempt to help you, but not in this thread.
Make a thread in the support board.
Ensure to follow all rules of the support board.
Without all neccesary information it's impossible to help you.

------------------------------------
I will only be scripting for TFS 1.3

Not TFS 1.1 / 1.2
Not OTServBR / OTX
and certainly not TFS 0.4

When requesting a script, don't ask for "this script I saw on super popular OT".

I don't care where the idea came from.
I don't want to see a video of the script in action.

I'm here to learn how to script better.
Just describe what the script is supposed to do, and I'll try to make it.

Any script that I make in response to a request from this thread will be shared publically, here, in this thread.

I'm not going to make anything in private, so post your request in this thread only.
Please, for the love of god, don't pm me asking to make a script.
I will actually add you to my ignore list if you do that.
--------------

Anyways!

Thanks for coming by and checking the thread out.
If you think there is a better way to script something, feel free to let me know.
I'm here to learn.

Cheers,

Xikini

----

Completed Scripts

DPS Dummy -> using RevScripts
!playerinfo character name -> using RevScripts
Positional Text talkaction -> using RevScripts
||--> Updated version that can use text & effects
Vocational Item Bonus's -> using RevScripts
Simple damge buff potion -> using Revscripts
Kill monster in specific area, remove stone for x seconds -> using RevScripts
Training Room Teleporter -> using RevScripts
Lever that removes/adds/transforms objects or ground tiles -> using RevScripts
Loot from monster goes into single backpack, no matter how much loot there is.
Extra loot in monsters, based on chance and tier list -> using RevScripts
||--> Updated version that allows specific monsters to have their own loot table

----

To-Do List

Evil Puncker - Imbuement system ---> waiting for reply
Landera - Guildmaster NPC
Nefinoo - Monster Arena Lever (x amount of waves, complete all waves, teleport appears)
AbraxasCal & Loney - Daily Boosted Creatures
Nefinoo - Simple Npc that sells an item
Shalaby - Multiple players required to open passageway. (stand 3 tiles)
Shalaby - Player death counter. (Movement and talkaction)
Shalaby - Npc kill monster task, with item reward.
Shalaby - Boss respawn after x time.

Nocturno - Random Item chest that disappears after use, and respawns after x time

-------

Last spot I've read messages
I belive @Shalaby 's boss respawn after x time Request on "To do list" can be used using this raid system -raid system for tfs 1.x that can be runned automatic on every x hour/min or manually when wanted, can have broadcast a msg or with no msg, or am i incorrect?
Post automatically merged:

Honestly, this took forever. xD

Got to learn so much stuff creating this. (mostly in terms of revscripts)

View attachment 48887

\data\scripts\creaturescripts\ onHealthChange_training_dummy.lua
Lua:
local creatureevent = CreatureEvent("onHealthChange_Training_Dummy")

local dps_check_time = 5 -- how long in seconds until DPS is shown to player
local DPS_info = {}

local function send_dps_info(playerID, monsterID)
    local player = Player(playerID)
    if player then
        player:say("Your DPS is " .. (math.floor((DPS_info[monsterID][playerID] / dps_check_time) + 0.5)) .. ".", TALKTYPE_MONSTER_SAY, false, player)
    end
    DPS_info[monsterID][playerID] = nil
end

function creatureevent.onHealthChange(monster, creature, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not Player(creature) then
        return false
    end
   
    local monsterID = monster:getId()
    local playerID = creature:getId()
   
    if not DPS_info[monsterID] then
        DPS_info[monsterID] = {}
    end
   
    if not DPS_info[monsterID][playerID] then
        addEvent(send_dps_info, dps_check_time * 1000, playerID, monsterID)
    end

    DPS_info[monsterID][playerID] = (DPS_info[monsterID][playerID] or 0) + primaryDamage + secondaryDamage
    monster:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS, creature)
    return false
end

creatureevent:register()
\data\monster\lua\ training_dummy.lua
Lua:
local mType = Game.createMonsterType("training dummy")
local monster = {}

monster.description = "a training dummy"
monster.outfit = {
    lookTypeEx = 5787
}

monster.health = 1
monster.maxHealth = monster.health
monster.speed = 0

monster.flags = {
    pushable = false,
    summonable = false,
    attackable = true,
    hostile = false,
    convinceable = false
}

mType.onAppear = function(monster, creature)
    if monster:getId() == creature:getId() then
        monster:registerEvent("onHealthChange_Training_Dummy")
    end
end

mType:register(monster)
May i ask how u insert the Training dummy into REMERS map ediot? Cant seem to find a solution for that issue

Thx!
Post automatically merged:

Alright, so I finally got around to it. xD

There are 32 different attributes you can apply to an item.

When registering an item you need to put the itemid in 3 spots.
Config Table, onEquip and onDeEquip.

I should note here that if the item is already registered in regular movements.xml, this code won't work on that item.

data\scripts\movements\ vocations_item_bonus.lua
Lua:
local config  = {
    [1111] = { -- itemid
        slot = "ammo", -- ("head", "necklace", "backpack", "armor", "shield", "weapon", "legs", "feet", "ring", "ammo")
        {
            [{1, 5}] = { -- vocation 1 and vocation 5
                ["statMain"] = {
                    -- flat_bonus_stats
                    {"life increase", 50},
                    {"mana increase", -200}, -- negative numbers will reduce a players stats
                    {"magic", 5},
                    {"melee", 15}, -- sword/axe/club
                    {"fist", 5},
                    {"club", 5}, -- if both melee and club exist on a single item, club will be the one that will trigger.
                    {"sword", 5}, -- example: (melee 20) -> (sword 5) ----> Result: (club 20) (sword 5) (axe 20)
                    {"axe", 5},
                    {"distance", 5},
                    {"shield", 5},
                    {"fishing", 5},
                    {"critical hit chance", 5},
                    {"critical hit damage", 5},
                    {"life leech chance", 5},
                    {"life leech amount", 5},
                    {"mana leech chance", 5},
                    {"mana leech amount", 5},
                    -- percent_bonus_stats
                    {"life increase percent", 200}, -- If using flat_bonus_stats and percent_bonus_stats on the same item, the percent_bonus_stats is the only one that will trigger.
                    {"mana increase percent", 200}, -- same idea as melee/club, but for flat/percent
                    {"magic percent", 3000},
                    {"melee percent", 200},
                    {"fist percent", 200}, -- 200 = 200%  -> 15 fisting would turn into 30
                    {"club percent", 200},
                    {"sword percent", 200},
                    {"axe percent", 200},
                    {"distance percent", 200},
                    {"shield percent", 200},
                    {"fishing percent", 200}
                },
                ["statSpeed"] = {
                    {"speed", 1000} -- when testing, it only gave half of this value. Might just be my client though
                },
                ["statRegen"] = {
                    {"life regen", 5, 5000}, --{type, amount, ticks_in_milliseconds}
                    {"mana regen", 5, 5000}  -- (can't go lower then 1 second)
                },
                ["statSoulRegen"] = {
                    {"soul regen", 5, 5000}
                },
            },
            [{2, 6}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            },
            [{3, 7}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            },
            [{4, 8}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            }
        }
    },
    [2222] = {
        slot = "armor",
        {
            [{1, 5}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            },
            [{2, 6}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            },
            [{3, 7}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            },
            [{4, 8}] = {
                ["statMain"] = {},
                ["statSpeed"] = {},
                ["statRegen"] = {},
                ["statSoulRegen"] = {}
            }
        }
    },
    [3333] = {
        slot = "ammo",
        {
            [{1, 5}] = {["statMain"] = {{"magic", 5}} },
            [{2, 6}] = {["statSpeed"] = {{"speed", 500}} },
            [{3, 7}] = {["statRegen"] = {{"life regen", 5, 5000}} },
            [{4, 8}] = {["statSoulRegen"] = {{"soul regen", 5, 5000}} }
        }
    }
}

local function convertSlotTextToNumber(slot)
    local text = nil
    if slot == "head" then
        slot = 1
    elseif slot == "necklace" then
        slot = 2
    elseif slot == "backpack" then
        slot = 3
    elseif slot == "armor" then
        slot = 4
    elseif slot == "shield" then
        slot = 5
    elseif slot == "weapon" then
        slot = 6
    elseif slot == "legs" then
        slot = 7
    elseif slot == "feet" then
        slot = 8
    elseif slot == "ring" then
        slot = 9
    elseif slot == "ammo" then
        slot = 10
    end
    return slot
end

local condition_ids = {
    CONDITIONID_HEAD,
    CONDITIONID_NECKLACE,
    CONDITIONID_BACKPACK,
    CONDITIONID_ARMOR,
    CONDITIONID_RIGHT,
    CONDITIONID_LEFT,
    CONDITIONID_LEGS,
    CONDITIONID_FEET,
    CONDITIONID_RING,
    CONDITIONID_AMMO
}

local conditions = {
    ["life increase"] = {CONDITION_PARAM_STAT_MAXHITPOINTS},
    ["mana increase"] = {CONDITION_PARAM_STAT_MAXMANAPOINTS},
    ["speed"] = {CONDITION_PARAM_SPEED},
    ["magic"] = {CONDITION_PARAM_STAT_MAGICPOINTS},
    ["melee"] = {CONDITION_PARAM_SKILL_MELEE},
    ["fist"] = {CONDITION_PARAM_SKILL_FIST},
    ["club"] = {CONDITION_PARAM_SKILL_CLUB},
    ["sword"] = {CONDITION_PARAM_SKILL_SWORD},
    ["axe"] = {CONDITION_PARAM_SKILL_AXE},
    ["distance"] = {CONDITION_PARAM_SKILL_DISTANCE},
    ["shield"] = {CONDITION_PARAM_SKILL_SHIELD},
    ["fishing"] = {CONDITION_PARAM_SKILL_FISHING},
    ["critical hit chance"] = {CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE},
    ["critical hit damage"] = {CONDITION_PARAM_SPECIALSKILL_CRITICALHITAMOUNT},
    ["life leech chance"] = {CONDITION_PARAM_SPECIALSKILL_LIFELEECHCHANCE},
    ["life leech amount"] = {CONDITION_PARAM_SPECIALSKILL_LIFELEECHAMOUNT},
    ["mana leech chance"] = {CONDITION_PARAM_SPECIALSKILL_MANALEECHCHANCE},
    ["mana leech amount"] = {CONDITION_PARAM_SPECIALSKILL_MANALEECHAMOUNT},
    ["life increase percent"] = {CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT},
    ["mana increase percent"] = {CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT},
    ["magic percent"] = {CONDITION_PARAM_STAT_MAGICPOINTSPERCENT},
    ["melee percent"] = {CONDITION_PARAM_SKILL_MELEEPERCENT},
    ["fist percent"] = {CONDITION_PARAM_SKILL_FISTPERCENT},
    ["club percent"] = {CONDITION_PARAM_SKILL_CLUBPERCENT},
    ["sword percent"] = {CONDITION_PARAM_SKILL_SWORDPERCENT},
    ["axe percent"] = {CONDITION_PARAM_SKILL_AXEPERCENT},
    ["distance percent"] = {CONDITION_PARAM_SKILL_DISTANCEPERCENT},
    ["shield percent"] = {CONDITION_PARAM_SKILL_SHIELDPERCENT},
    ["fishing percent"] = {CONDITION_PARAM_SKILL_FISHINGPERCENT},
    ["life regen"] = {CONDITION_PARAM_HEALTHGAIN, CONDITION_PARAM_HEALTHTICKS},
    ["mana regen"] = {CONDITION_PARAM_MANAGAIN, CONDITION_PARAM_MANATICKS},
    ["soul regen"] = {CONDITION_PARAM_SOULGAIN, CONDITION_PARAM_SOULTICKS}
}

local main_attributes = {CONDITION_ATTRIBUTES, CONDITION_HASTE, CONDITION_REGENERATION, CONDITION_SOUL}
local main_stats = {"statMain", "statSpeed", "statRegen", "statSoulRegen"}

local function giveItemBonus(playerid)
    local player = Player(playerid)
    local player_equipment = {}
 
    -- find all player equipment
    for i = 1, 10 do
        local slotItem = player:getSlotItem(i)
        if slotItem then
            slotItem = slotItem.itemid
            if not config[slotItem] or convertSlotTextToNumber(config[slotItem].slot) ~= i then
                slotItem = 0
            end
        else
            slotItem = 0
        end
        table.insert(player_equipment, slotItem)
    end
 
    -- remove all buffs from armor
    for i = 1, 10 do
        for n = 1, 4 do
            if player:getCondition(main_attributes[n], condition_ids[i]) then
                player:removeCondition(main_attributes[n], condition_ids[i])
            end
        end
    end
 
    -- add all buffs from equipment
    local vocation = player:getVocation():getId()
    for i = 1, 10 do
        local itemID = player_equipment[i]
        if itemID ~= 0 then
            for voc, _ in pairs(config[itemID][1]) do
                if isInArray(voc, vocation) then
                    for n = 1, 4 do
                        if config[itemID][1][voc][main_stats[n]] then
                            local condition = Condition(main_attributes[n], condition_ids[i])
                            condition:setParameter(CONDITION_PARAM_TICKS, -1)
                            local itemBonusIndex = config[itemID][1][voc][main_stats[n]]
                            for h = 1, #itemBonusIndex do
                                for p = 1, #conditions[itemBonusIndex[h][1]] do
                                    condition:setParameter(conditions[itemBonusIndex[h][1]][p], itemBonusIndex[h][2])
                                end
                            end
                            player:addCondition(condition)
                        end
                    end
                end
            end
        end
    end
    return true
end


-- HEAD -------------------------------------------------------------------------------
local onEquip_Head = MoveEvent()

function onEquip_Head.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onEquip_Head:slot("head")
onEquip_Head:id(1111, 2222, 3333)
onEquip_Head:register()


local onDeEquip_Head = MoveEvent()

function onDeEquip_Head.onDeEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onDeEquip_Head:slot("head")
onDeEquip_Head:id(1111, 2222, 3333)
onDeEquip_Head:register()



-- NECKLACE -------------------------------------------------------------------------------
local onEquip_Necklace = MoveEvent()

function onEquip_Necklace.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onEquip_Necklace:slot("necklace")
onEquip_Necklace:id(1111, 2222, 3333)
onEquip_Necklace:register()


local onDeEquip_Necklace = MoveEvent()

function onDeEquip_Necklace.onDeEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onDeEquip_Necklace:slot("necklace")
onDeEquip_Necklace:id(1111, 2222, 3333)
onDeEquip_Necklace:register()


-- BACKPACK -------------------------------------------------------------------------------
local onEquip_Backpack = MoveEvent()

function onEquip_Backpack.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onEquip_Backpack:slot("backpack")
onEquip_Backpack:id(1111, 2222, 3333)
onEquip_Backpack:register()


local onDeEquip_Backpack = MoveEvent()

function onDeEquip_Backpack.onDeEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onDeEquip_Backpack:slot("backpack")
onDeEquip_Backpack:id(1111, 2222, 3333)
onDeEquip_Backpack:register()


-- ARMOR -------------------------------------------------------------------------------
local onEquip_Armor = MoveEvent()

function onEquip_Armor.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onEquip_Armor:slot("armor")
onEquip_Armor:id(1111, 2222, 3333)
onEquip_Armor:register()


local onDeEquip_Armor = MoveEvent()

function onDeEquip_Armor.onDeEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onDeEquip_Armor:slot("armor")
onDeEquip_Armor:id(1111, 2222, 3333)
onDeEquip_Armor:register()


-- WEAPONS AND SHIELDS (hands) --------------------------------------------------------
local onEquip_Hands = MoveEvent()

function onEquip_Hands.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onEquip_Hands:slot("hand")
onEquip_Hands:id(1111, 2222, 3333)
onEquip_Hands:register()

local onDeEquip_Hands = MoveEvent()

function onDeEquip_Hands.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onDeEquip_Hands:slot("hand")
onDeEquip_Hands:id(1111, 2222, 3333)
onDeEquip_Hands:register()

-- LEGS -------------------------------------------------------------------------------
local onEquip_Legs = MoveEvent()

function onEquip_Legs.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onEquip_Legs:slot("legs")
onEquip_Legs:id(1111, 2222, 3333)
onEquip_Legs:register()


local onDeEquip_Legs = MoveEvent()

function onDeEquip_Legs.onDeEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onDeEquip_Legs:slot("legs")
onDeEquip_Legs:id(1111, 2222, 3333)
onDeEquip_Legs:register()


-- FEET -------------------------------------------------------------------------------
local onEquip_Feet = MoveEvent()

function onEquip_Feet.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onEquip_Feet:slot("feet")
onEquip_Feet:id(1111, 2222, 3333)
onEquip_Feet:register()


local onDeEquip_Feet = MoveEvent()

function onDeEquip_Feet.onDeEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onDeEquip_Feet:slot("feet")
onDeEquip_Feet:id(1111, 2222, 3333)
onDeEquip_Feet:register()


-- RING -------------------------------------------------------------------------------
local onEquip_Ring = MoveEvent()

function onEquip_Ring.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onEquip_Ring:slot("ring")
onEquip_Ring:id(1111, 2222, 3333)
onEquip_Ring:register()


local onDeEquip_Ring = MoveEvent()

function onDeEquip_Ring.onDeEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onDeEquip_Ring:slot("ring")
onDeEquip_Ring:id(1111, 2222, 3333)
onDeEquip_Ring:register()


-- AMMO -------------------------------------------------------------------------------
local onEquip_Ammo = MoveEvent()

function onEquip_Ammo.onEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onEquip_Ammo:slot("ammo")
onEquip_Ammo:id(1111, 2222, 3333)
onEquip_Ammo:register()


local onDeEquip_Ammo = MoveEvent()

function onDeEquip_Ammo.onDeEquip(player, item, slot, isCheck)
    if not isCheck then
        addEvent(giveItemBonus, 0, player:getId())
    end
    return true
end

onDeEquip_Ammo:slot("ammo")
onDeEquip_Ammo:id(1111, 2222, 3333)
onDeEquip_Ammo:register()


-- LOGIN ------------------------------------------------------------------------------
local loginEvent = CreatureEvent("newLoginEvent")
loginEvent:type("login")

function loginEvent.onLogin(player)
    addEvent(giveItemBonus, 0, player:getId())
    return true
end

loginEvent:register()
Is it possible to have the bonus stat show on description when you look at the item? Ex You see a demon helmet bla bla bla, it has 3% crit chance etc etc?

Thx! Great script!
 
Last edited:
Hi Xikini nice scripts.
Can you help me with one script when you equid a helmet send effects around you, when you are in pz dont make damage but when you leave, the effects change and makes a little damage
it doesnt matter if cannot change the outfit.
 

Attachments

and Done. :)
Note: don't trap your players. 😋

View attachment 49241


Put this into any monster you want the script to activate for.
XML:
<script>
    <event name="onDeath_open_passageway" />
</script>

data\scripts\ onDeath_open_passageway.lua
Lua:
local config = {
    positionCheck = {north_west = Position(99, 99, 7), south_east = Position(101, 101, 7)},
    item = {Position(103, 100, 7), 1285}, -- {item_position, itemid}
    timer = 20, -- timer is how long until the 'stone' aka: item, is replaced.
    discoveryText = "A passageway has opened nearby!\nQuickly, get inside!"
}

local toggle = 0
local function changePassageway()
    local item = Tile(config.item[1]):getItemById(config.item[2])
    if item then
        item:remove()
        return true
    end
    config.item[1]:sendMagicEffect(CONST_ME_BIGPLANTS)
    Game.createItem(config.item[2], 1, config.item[1])
    toggle = 0
end

local creatureevent = CreatureEvent("onDeath_open_passageway")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if toggle == 1 then
        return true
    end
    local deathPosition = creature:getPosition()
    if not deathPosition:isInRange(config.positionCheck.north_west, config.positionCheck.south_east) then
        return true
    end
    toggle = 1
    config.item[1]:sendMagicEffect(CONST_ME_POFF)
    changePassageway()
    addEvent(changePassageway, config.timer * 1000)
    creature:say(config.discoveryText, TALKTYPE_MONSTER_SAY, false, nil, deathPosition)   
    return true
end

creatureevent:register()

I love this script, but is there any chance to modify it so it's % chance to open the passage when you hunt in an certain area? - Like 5% per kill it's chance to remove stone/create stairs or so
 
I love this script, but is there any chance to modify it so it's % chance to open the passage when you hunt in an certain area? - Like 5% per kill it's chance to remove stone/create stairs or so
Lua:
local config = {
    positionCheck = {north_west = Position(99, 99, 7), south_east = Position(101, 101, 7)},
    item = {Position(103, 100, 7), 1285}, -- {item_position, itemid}
    timer = 20, -- timer is how long until the 'stone' aka: item, is replaced.
    chance = 5, -- percentage out of 100. 5/100
    discoveryText = "A passageway has opened nearby!\nQuickly, get inside!"
}

local toggle = 0
local function changePassageway()
    local item = Tile(config.item[1]):getItemById(config.item[2])
    if item then
        item:remove()
        return true
    end
    config.item[1]:sendMagicEffect(CONST_ME_BIGPLANTS)
    Game.createItem(config.item[2], 1, config.item[1])
    toggle = 0
end

local creatureevent = CreatureEvent("onDeath_open_passageway")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if toggle == 1 then
        return true
    end
    local deathPosition = creature:getPosition()
    if not deathPosition:isInRange(config.positionCheck.north_west, config.positionCheck.south_east) then
        return true
    end
    if math.random(100) <= config.chance then
        toggle = 1
        config.item[1]:sendMagicEffect(CONST_ME_POFF)
        changePassageway()
        addEvent(changePassageway, config.timer * 1000)
        creature:say(config.discoveryText, TALKTYPE_MONSTER_SAY, false, nil, deathPosition)
    end
    return true
end

creatureevent:register()
 
Lua:
local config = {
    positionCheck = {north_west = Position(99, 99, 7), south_east = Position(101, 101, 7)},
    item = {Position(103, 100, 7), 1285}, -- {item_position, itemid}
    timer = 20, -- timer is how long until the 'stone' aka: item, is replaced.
    chance = 5, -- percentage out of 100. 5/100
    discoveryText = "A passageway has opened nearby!\nQuickly, get inside!"
}

local toggle = 0
local function changePassageway()
    local item = Tile(config.item[1]):getItemById(config.item[2])
    if item then
        item:remove()
        return true
    end
    config.item[1]:sendMagicEffect(CONST_ME_BIGPLANTS)
    Game.createItem(config.item[2], 1, config.item[1])
    toggle = 0
end

local creatureevent = CreatureEvent("onDeath_open_passageway")

function creatureevent.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUnjustified, mostDamageUnjustified)
    if toggle == 1 then
        return true
    end
    local deathPosition = creature:getPosition()
    if not deathPosition:isInRange(config.positionCheck.north_west, config.positionCheck.south_east) then
        return true
    end
    if math.random(100) <= config.chance then
        toggle = 1
        config.item[1]:sendMagicEffect(CONST_ME_POFF)
        changePassageway()
        addEvent(changePassageway, config.timer * 1000)
        creature:say(config.discoveryText, TALKTYPE_MONSTER_SAY, false, nil, deathPosition)
    end
    return true
end

creatureevent:register()

Wow, that was quick. Thanks alot man! <3
 
Status
Not open for further replies.
Back
Top