alejandro762
Well-Known Member
- Joined
- Sep 6, 2021
- Messages
- 225
- Reaction score
- 63
Hello,
This script made by Sarah Wesker, i wish to know how to convert it 'when a player attacks, has 2% chance to create a summon for 20s and get the condition'.
Since i made a mistake on the last thread saying i want it onEquip, but I was wrong, it was when the object is equipped and the player attacks, he has a 2% chance of summon monster and get the condition.
This script made by Sarah Wesker, i wish to know how to convert it 'when a player attacks, has 2% chance to create a summon for 20s and get the condition'.
Since i made a mistake on the last thread saying i want it onEquip, but I was wrong, it was when the object is equipped and the player attacks, he has a 2% chance of summon monster and get the condition.
Lua:
local config = {
chance = 2,
summon = 'rat',
bonus = CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE,
bonusPercent = 2,
duration = 20
}
local summons = {}
local summonTest = MoveEvent()
function summonTest.onEquip(player, item, slot, isCheck)
if isCheck then
return true
end
if math.random(100) <= config.chance then
local monster = Game.createMonster(config.summon, player:getPosition())
if monster then
monster:setMaster(player)
monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT)
summons[player:getId()] = monster:getId()
local bonus = Condition(CONDITION_ATTRIBUTES)
bonus:setParameter(CONDITION_PARAM_TICKS, config.duration * 1000)
bonus:setParameter(config.bonus, config.bonusPercent)
player:addCondition(bonus)
return true
end
end
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
summonTest:id(10300)
summonTest:register()
local summonTest = MoveEvent()
function summonTest.onDeEquip(player, item, slot)
local playerId = player:getId()
if summons[playerId] then
local monster = Monster(summons[playerId])
if monster then
monster:remove()
summons[playerId] = nil
end
end
return true
end
summonTest:id(10300)
summonTest:register()