Vivelo
New Member
- Joined
- Aug 30, 2018
- Messages
- 34
- Reaction score
- 3
Hello,
I don't know how to write a script that will open a portal after killing a few monsters, not just one type of "Boss".
I have "standard" .lua without any options/commands of this.
at the start i thinking about add to this line ( ["dog"] = { )operator "AND" but nothing happen. After that i try to compile this code with a code that determines the amounts of kills of a given type of monster and only opens the portal, but also nothing.
I need one of the two versions ...
First Version:
- You must kill "X" monsters of the same type, like rats.
Second Version:
- You must kill "X" monsters different types, like 3 rats and 6 rotworms, 11 skeleton and 1 mini boss.
I need this to create "dungeon".
THANKS FOR ANY HELP!
I don't know how to write a script that will open a portal after killing a few monsters, not just one type of "Boss".
I have "standard" .lua without any options/commands of this.
Lua:
local config = {
useCountdown = true
}
local t = {
["dog"] = {
toPos = {x = 1275, y = 1053, z = 7, stackpos = 0},
createPos = {x = 1277, y = 1053, z = 7, stackpos = 0},
time = 10,
msg = "You have taken my life!"
},
["cat"] = {
toPos = 'Venore',
createPos = {x = 100, y = 100, z = 7, stackpos = 0},
time = 10,
msg = "You have taken my life!"
}
}
local function remove(position)
local k = getTileItemById(position, 1387).uid
return k > 0 and doRemoveItem(k), doSendMagicEffect(position, CONST_ME_POFF)
end
local function doSendAnimatedText(pos, text, color, cid) -- by J.Dre
if tonumber(text) then
text = tonumber(text)
if cid and isPlayer(cid) then
doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
else
local t = getSpectators(pos, 7, 5, false)
if t then
for _, cid in ipairs(t) do
if isPlayer(cid) then
doPlayerSendTextMessage(cid, MESSAGE_EXPERIENCE_OTHERS, "", text, color, pos)
end
end
end
end
else
if cid and isCreature(cid) then
doCreatureSay(cid, text, TALKTYPE_MONSTER)
else
local t = getSpectators(pos, 7, 5, false)
if t then
for _, cid in ipairs(t) do
if isPlayer(cid) then
doCreatureSay(cid, text, TALKTYPE_MONSTER, false, cid, pos)
end
end
end
end
end
end
function onKill(cid, target, damage, flags)
local v = t[string.lower(getCreatureName(target))]
if(v and (damage == true or bit.band(flags, 1) == 1) and isMonster(target)) then
doCreatureSay(cid, v.msg, TALKTYPE_MONSTER, nil, nil, getCreaturePosition(target))
doSendMagicEffect(v.createPos, CONST_ME_ENERGYAREA)
doCreateTeleport(1387, type(v.toPos) == 'table' and v.toPos or getTownTemplePosition(getTownId(v.toPos)), v.createPos)
if(config.useCountdown) then
for j = 0, v.time do
local i = v.time - j
addEvent(doSendAnimatedText, j * 1000, v.createPos, i > 0 and tostring(i), MESSAGE_EVENT_DEFAULT)
end
end
addEvent(remove, v.time * 1000, v.createPos)
end
return true
end
at the start i thinking about add to this line ( ["dog"] = { )operator "AND" but nothing happen. After that i try to compile this code with a code that determines the amounts of kills of a given type of monster and only opens the portal, but also nothing.
I need one of the two versions ...
First Version:
- You must kill "X" monsters of the same type, like rats.
Second Version:
- You must kill "X" monsters different types, like 3 rats and 6 rotworms, 11 skeleton and 1 mini boss.
I need this to create "dungeon".
THANKS FOR ANY HELP!