alejandro762
Well-Known Member
- Joined
- Sep 6, 2021
- Messages
- 225
- Reaction score
- 63
Hello everyone,
Im testing on TFS 1.3 to create onEquip and deEquip an item, getting for example 2% chance to create a summon who helps the player for 20 seconds, but also giving a bonus stat for 20 seconds.
I start the script like this:
Thanks in advance if anyone could explain me,
Regards
Im testing on TFS 1.3 to create onEquip and deEquip an item, getting for example 2% chance to create a summon who helps the player for 20 seconds, but also giving a bonus stat for 20 seconds.
I start the script like this:
Lua:
local summonTest = MoveEvent()
local config = {
chance = 2,
summon = 'rat',
bonus = 'SKILL_CRITICAL_HIT_CHANCE',
bonus.percent = 2,
duration = 20
}
function summonTest.onEquip(player, item, slot, isCheck, fromPosition)
if isCheck then
return true
end
local pos = player:getPosition()
local chance = math.random(100)
pos:sendMagicEffect(CONST_ME_TELEPORT)
if chance then
game.createmonster(config.summon, pos? player:getposition() ?) -- There im not sure
-- player:addSkill(config.bonus, bonus.percent) or
-- addEvent(config.bonus, bonus.percent, config.duration)
end
end
summonTest:type("equip")
summonTest:id(10300)
summonTest:register()
function summonTest.onDeEquip(player, item, slot, spectators)
local pos = player:getPosition()
pos:sendMagicEffect(CONST_ME_POFF)
stopEvent(config.bonus)
-- there dit we need to use getSpectators() if spectator:isPlayer() or isMonster () then spectator:remove() ?
-- for i = 1, #spectators do
-- if spectator:isMonster() then -- how register a duration here ?
-- spectator:remove()
-- end
summonTest:type("deequip")
summonTest:id(10300)
summonTest:register()
Thanks in advance if anyone could explain me,
Regards