JDB
OtLand Veteran
- Joined
- Jun 1, 2009
- Messages
- 4,145
- Solutions
- 2
- Reaction score
- 115
Credits:
v1.0 - JDB - 0.3.6pl1+
v1.1 - JDB - 0.3.6pl1+
v2.0 - JDB - Not Tested
Notice
You must restart your server after adding these in because if you do not, there is a chance that it may crash.
Please report any errors you may have and I will try to assist you.
data/creaturescripts/scripts/login.lua
data/creaturescripts/creaturescripts.xml
Version 1.0
data/creaturescripts/scripts/portals.lua
Version 1.1
data/creaturescripts/scripts/portals.lua
Version 2.0
This version has not been tested, but it's supposed to give creatures multiple lives.
data/creaturescripts/scripts/portals.lua
Comments are always appreciated, but if you feel like flaming, just leave.
If you feel this script needs to be improved, feel free to private message me with suggestions.
Kind Regards,
JDB.
v1.0 - JDB - 0.3.6pl1+
v1.1 - JDB - 0.3.6pl1+
v2.0 - JDB - Not Tested
Notice
You must restart your server after adding these in because if you do not, there is a chance that it may crash.
Please report any errors you may have and I will try to assist you.
data/creaturescripts/scripts/login.lua
Code:
registerCreatureEvent(cid, "MonsterPortal")
data/creaturescripts/creaturescripts.xml
Code:
<event type="kill" name="MonsterPortal" event="script" value="portals.lua"/>
Version 1.0
data/creaturescripts/scripts/portals.lua
Code:
function onKill(cid, target)
local m = {
["Morgaroth"] = {
message = "Escape through the teleport quickly before it closes!",
cfg = {
{
time = 10, -- Seconds until tp closes.
to = { x = 95, y = 117, z = 7 }, -- Where the tp takes you.
tp = { x = 95, y = 112, z = 7 } -- Where the tp creates.
},
}
}
}
if isPlayer(target) then
return true
end
local monster = m[getCreatureName(target)]
if monster then
for i = 1, #monster.cfg do
local c = monster.cfg[i]
local function deleteTeleport()
local teleport = getTileItemById(c.tp, 1387).uid
if(teleport > 0) then
doRemoveItem(teleport)
doSendMagicEffect(c.tp, CONST_ME_POFF)
end
return true
end
doCreateTeleport(1387, c.to, c.tp)
doSendMagicEffect(c.tp, CONST_ME_ENERGYAREA)
addEvent(deleteTeleport, c.time * 1000)
end
doCreatureSay(cid, monster.message, TALKTYPE_ORANGE_1)
end
return true
end
Version 1.1
data/creaturescripts/scripts/portals.lua
Code:
function onKill(cid, target)
local m = {
["Morgaroth"] = {
message = "Escape through the teleport quickly before it closes!",
cfg = {
{
time = 10, -- Seconds until tp closes.
to = { x = 95, y = 117, z = 7 }, -- Where the tp takes you.
tp = { x = 95, y = 112, z = 7 } -- Where the tp creates.
},
}
}
}
if isPlayer(target) then
return true
end
local monster = m[getCreatureName(target)]
if monster then
for i = 1, #monster.cfg do
local c = monster.cfg[i]
return doCreateTeleport(c.to, c.tp) and doSendMagicEffect(c.tp, CONST_ME_TELEPORT) and doCreatureSay(cid, monster.message, TALKTYPE_ORANGE_1) and addEvent(function() doRemoveItem(getTileItemById(c.tp, 1387).uid) end, c.time * 1000)
end
end
return true
end
Version 2.0
This version has not been tested, but it's supposed to give creatures multiple lives.
data/creaturescripts/scripts/portals.lua
Code:
function onKill(cid, target)
local m = {
["Morgaroth"] = {
message = "Escape through the teleport quickly before it closes!",
teaser = { "You can't kill me!", "I am invincible!" }
cfg = {
{
deaths = 1, -- How many times the monster must die.
time = 10, -- Seconds until tp closes.
to = { x = 95, y = 117, z = 7 }, -- Where the tp takes you.
tp = { x = 95, y = 112, z = 7 } -- Where the tp creates.
},
}
}
}
if isPlayer(target) then
return true
end
local monster = m[getCreatureName(target)]
local check = getGlobalStorageValue(monster)
if monster then
for i = 1, #monster.cfg do
local c = monster.cfg[i]
return check >= c.deaths and c.deaths ~= 0 and setGlobalStorageValue(monster, ((c.deaths ~= nil and (check == -1 and 1) or check + 1) or -1)) and doCreatureAddHealth(monster, getCreatureMaxHealth(monster), true) and doCreatureSay(monster, monster.teaser[math.random(1, #monster.teaser)], TALKTYPE_ORANGE_1) and doCreateTeleport(c.to, c.tp) and doSendMagicEffect(c.tp, CONST_ME_TELEPORT) and addEvent(function() doRemoveItem(getTileItemById(c.tp, 1387).uid) end, c.time * 1000) or c.deaths <= 1 and doCreatureSay(cid, monster.message, TALKTYPE_ORANGE_1) and doCreateTeleport(c.to, c.tp) and doSendMagicEffect(c.tp, CONST_ME_TELEPORT) and addEvent(function() doRemoveItem(getTileItemById(c.tp, 1387).uid) end, c.time * 1000)
end
end
return true
end
Comments are always appreciated, but if you feel like flaming, just leave.
If you feel this script needs to be improved, feel free to private message me with suggestions.
Kind Regards,
JDB.
Last edited: