SixNine
Active Member
- Joined
- Dec 12, 2018
- Messages
- 452
- Reaction score
- 41
Hello so edited this code so that monsters could cast this spell but for some reason it ignores the maxsummons and it casts more then 1
Lua:
function onCastSpell(creature, var)
local player = Player(creature)
local summonName = "Rat LvL 10"
local maxsummons = 1
local summonsPlayer = creature:getSummons()
local summon = true
if (#summonsPlayer >= 1) then
for _, SummonID in ipairs(summonsPlayer) do
if (string.lower(getCreatureName(SummonID)) == string.lower(summonName)) then
nameSummon = getCreatureName(SummonID)
summon = false
end
end
end
if (#summonsPlayer < maxsummons) and (summon == true) then
for i = 1, maxsummons - #summonsPlayer do
local mid = Game.createMonster(summonName, creature:getPosition())
if not mid then
return
end
end
doCreatureSay(creature, "Go "..summonName.."!", TALKTYPE_ORANGE_1)
elseif (#summonsPlayer >= 1) and (nameSummon == summonName) then
doPlayerSendCancel(creature, "You already have summoned "..summonName..".")
summon = false
return doSendMagicEffect(getThingPos(player), 2) and false
end
return
end
Last edited: