• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Portal Rune

gr33nd3v1l

You see a Green Devil.
Joined
Feb 12, 2008
Messages
140
Reaction score
0
Location
Croatia
Hi there, me again.. Been a long long time since i last worked on Genesis...
I deleted the map, as well -.-
Stupid of me.

Well, I've been bored lately, so I'm trying to remake Genesis :)

And since i haven't scripted in a few years, I'd like some quick helps to remind myself >.<

Alright, first off: I'm trying to make a portal rune. It works like animate dead, but by sacrificing a freshly killed human (so i need a very certain ID, i believe it's from 3058-3066, because it would need to be a player)

After that, it sends a big smoke cloud on 1 square only, and summons a PoI monster at random.

And this is the code that i managed to crash my server with, and now need halp plx.

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)

local area = createCombatArea(AREA_CIRCLE1X1)
setCombatArea(combat, area)

function onTargetTile(cid, pos)
	local position = pos
	position.stackpos = 255
	local item = getThingfromPos(position)
	if item.itemid > 0 then
		if isInArray(CORPSES, item.itemid) == TRUE then
			doRemoveItem(item.uid,1)
			if math.random(0, 5) == 0 then 
				doRemoveItem(itemEx.uid)
				local creature = doSummonCreature("Hellhound", pos)
				doSendMagicEffect(pos, CONST_ME_BIGCLOUDS)
			elseif math.random(0, 5) == 1 then 
				doRemoveItem(itemEx.uid)
				local creature = doSummonCreature("Defiler", pos)
				doSendMagicEffect(pos, CONST_ME_BIGCLOUDS)
			elseif math.random(0, 5) == 2 then 
				doRemoveItem(itemEx.uid)
				local creature = doSummonCreature("Juggernaut", pos)
				doSendMagicEffect(pos, CONST_ME_BIGCLOUDS)
			elseif math.random(0, 5) == 3 then 
				doRemoveItem(itemEx.uid)
				local creature = doSummonCreature("Grim Reaper", pos)
				doSendMagicEffect(pos, CONST_ME_BIGCLOUDS)
			elseif math.random(0, 5) == 4 then 
				doRemoveItem(itemEx.uid)
				local creature = doSummonCreature("Fury", pos)
				doSendMagicEffect(pos, CONST_ME_BIGCLOUDS)
			elseif math.random(0, 5) == 5 then 
				doRemoveItem(itemEx.uid)
				local creature = doSummonCreature("Dark Torturer", pos)
				doSendMagicEffect(pos, CONST_ME_BIGCLOUDS)
			end
		end
	end
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end

PS
what's with the downtime?
 
Last edited:
Is this a spell or a rune? do you want it to be that if you use a rune on a freshly killed corpse then it will summon at random any of the monsters?
 
Is this a spell or a rune? do you want it to be that if you use a rune on a freshly killed corpse then it will summon at random any of the monsters?


That exactly.

The rune would be a rare drop from a special raid.


I believe i emphasised it's a rune o.0
 
ok then you can just ignore doing it "onCastSpell" and do it "onUse".

That's just the end of the code, for battle sign. I'm wondering about the code itself xD

PS
Yes, i tried it and it still crashes my server.
It might be something with math calls, i don't know.
 
Try this, it's onUse:
Code:
local summon = {
	[{1, 5}] = {"Hellhound"},
	[{6, 10}] = {"Defiler"},
	[{11, 15}] = {"Juggernaut"},
	[{16, 20}] = {"Grim Reaper"},
	[{21, 25}] = {"Fury"},
	[{26, 30}] = {"Dark Torturer"}
	}
function onUse(cid, item, toPosition, itemEx, fromPosition)
local corpse = {3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066}
	if isInArray(corpse, itemEx.itemid) then
		for i, k in pairs(summon) do
			local v = math.random(30)
			if v > i[1] and v < i[2] then
				doRemoveItem(item.uid,1)
				doRemoveItem(itemEx.uid,1)
				doSummonCreature(k[1], toPosition)
				doSendMagicEffect(toPosition, CONST_ME_BIGCLOUDS)
				break
			end
		end
	end
return true 
end
Just use the rune on one of the dead bodies and it should work.

PS
About the code it will not work because you need to add an addEvent, I'll try to fix the one you submitted.
 
Last edited:
This should work
Lua:
local t = {
[0] = "Hellhound",
[1] = "Defiler",
[2] = "Juggernaut",
[3] = "Grim Reaper",
[4] = "Fury",
[5] = "Dark Torturer"
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(CORPSES, itemEx.itemid) then
   for k, v in pairs(t) do
       if math.random(0, 5) == k then
          doRemoveItem(item.uid) 
          doRemoveItem(itemEx.uid)
          doSummonCreature(v[1], toPosition)
          doSendMagicEffect(toPosition, CONST_ME_BIGCLOUDS)
       end
   end
end
return true
end
 
Here, I'm not sure if it will work(I'm bad at spell making), but what you do here is stand in front of the dead body and cast the spell, in this one it does not need any runes.
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)

local area = createCombatArea(AREA_CIRCLE1X1)
setCombatArea(combat, area)

local summon = {
	[{1, 5}] = {"Hellhound"},
	[{6, 10}] = {"Defiler"},
	[{11, 15}] = {"Juggernaut"},
	[{16, 20}] = {"Grim Reaper"},
	[{21, 25}] = {"Fury"},
	[{26, 30}] = {"Dark Torturer"}
	}

function onTargetTile(cid, pos)
	local position = pos
	position.stackpos = 255
	local item = getThingfromPos(position)
	local corpse = {3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066}
	if isInArray(corpse, itemEx.itemid) then
		for i = 1, k in pairs(summon) do
			local v = math.random(30)
			if v > i[1] and v < i[2] then
				doRemoveItem(item.uid,1)
				doSummonCreature(k[1], position)
				doSendMagicEffect(position, CONST_ME_BIGCLOUDS)
				break
			end
		end
	end
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(cid, var)
	addEvent(onTargetTile, 0, {cid = cid, pos = getCreatureLookPosition(cid)})
	return doCombat(cid, combat, var)
end
 
This should work
Lua:

Okay, could you just tell me how to edit the CORPSES part to only use certain (human - player bodies)

ED: i see Shinmaru helped me out with that part :)


Here, I'm not sure if it will work(I'm bad at spell making), but what you do here is stand in front of the dead body and cast the spell, in this one it does not need any runes.
Lua:

Thank you Shinmaru, but i really need it to be a rune, since the rune will be, as i said, a rare drop from a special raid of ritualists.
____________________________________________________________________________________________________________________________________

ED:
Code:
Warning: [Event::checkScript] Event onCastSpell not found. /scripts/summon/porta
l rune.lua
> changed onUse to onCastSpell

maybe because i use 8.62 Mystic Spirit TFS

new error:
Code:
Lua Script Error: [Spell Interface]
data/spells/scripts/summon/portal rune.lua:onCastSpell

data/spells/scripts/summon/portal rune.lua:11: attempt to index local 'itemEx' (
a nil value)
stack traceback:
        data/spells/scripts/summon/portal rune.lua:11: in function <data/spells/
scripts/summon/portal rune.lua:10>
 
Last edited:
This should work
data/actions/scripts/portal rune.lua
Lua:
local t = {
[0] = "Hellhound",
[1] = "Defiler",
[2] = "Juggernaut",
[3] = "Grim Reaper",
[4] = "Fury",
[5] = "Dark Torturer"
}

local corpses = {3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(corpses, itemEx.itemid) then
   for k, v in pairs(t) do
       if math.random(0, 5) == k then
          doRemoveItem(item.uid) 
          doRemoveItem(itemEx.uid)
          doSummonCreature(v[1], toPosition)
          doSendMagicEffect(toPosition, CONST_ME_BIGCLOUDS)
       end
   end
end
return true
end

actions.xml
XML:
<action itemid="ITEMID_OF_RUNE" event="script" value="portal rune.lua"/>
 
Yeah i thought about switching the thing to actions too. How do i set the magic levels and levels for usage then?

I left this line in spells.xml
<rune name="Demon Portal" id="2275" allowfaruse="1" charges="1" lvl="120" maglv="80" exhaustion="2000" blocktype="solid"/>

Will that work, without script part?


error:
Lua:
Lua Script Error: [Action Interface]
data/actions/scripts/portal rune.lua:onUse

luaDoSummonCreature(). Monster name() not found

Lua Script Error: [Action Interface]
data/actions/scripts/portal rune.lua:onUse

luaDoRemoveItem(). Item not found

Lua Script Error: [Action Interface]
data/actions/scripts/portal rune.lua:onUse

luaDoRemoveItem(). Item not found

Lua Script Error: [Action Interface]
data/actions/scripts/portal rune.lua:onUse

luaDoSummonCreature(). Monster name() not found


It removed the rune and body

I think it's the random math part
I dont know what the for k, v in pairs(t) does, so im really lost here, can't help ya out :S

'Kay, some more stuff
It should remove a charge. (It removes a whole rune with 100 charges left)
And it should be usable on distance

This way:
You cannot use this object. - Northeast, NW, or SW of body
It removes the body, rune and summons clouds, but no monster SE of body
Removes body and rune N, E, S, and W of body
Probably random due to the error
On distance it doesn't work.


It might have to be done in runes :S

If you guys have time to test it or something, please do. I will be back tomorrow or later evening.
Thank you for your help so far
rep+ to both of you for your work

and <3
:)
 
Last edited:
ok here this is for the runes on spells :
~demonportal.lua~
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)

local area = createCombatArea(AREA_CIRCLE1X1)
setCombatArea(combat, area)

local summon = {
	[{1, 5}] = {"Hellhound"},
	[{6, 10}] = {"Defiler"},
	[{11, 15}] = {"Juggernaut"},
	[{16, 20}] = {"Grim Reaper"},
	[{21, 25}] = {"Fury"},
	[{26, 30}] = {"Dark Torturer"}
	}

function onTargetTile(cid, pos)
	local position = pos
	position.stackpos = 255
	local item = getThingfromPos(position)
	local corpse = {3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066}
	if isInArray(corpse, item.itemid) then
		for i, k in pairs(summon) do
			local v = math.random(30)
			if v > i[1] and v < i[2] then
				doRemoveItem(item.uid,1)
				doSummonCreature(position, k[1])
				doSendMagicEffect(position, CONST_ME_BIGCLOUDS)
				break
			end
		end
	end
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(cid, var)
	addEvent(onTargetTile, 0, {cid = cid, pos = getCreatureLookPosition(cid)})
	return doCombat(cid, combat, var)
end

XML:
<rune name="Demon Portal" id="2275" allowfaruse="0" charges="3" lvl="14" maglv="0" exhaustion="2000" blocktype="solid" event="script" value="demonportal.lua"/>

No it will not work without the script part.

Give it a try and let us know, also you need to be looking to the direction of the body, if this works then I'll try to make some checks so it doesn't waste charges.
 
ok here this is for the runes on spells :
~demonportal.lua~
Lua:

XML:
<rune name="Demon Portal" id="2275" allowfaruse="0" charges="3" lvl="14" maglv="0" exhaustion="2000" blocktype="solid" event="script" value="demonportal.lua"/>

No it will not work without the script part.

Give it a try and let us know, also you need to be looking to the direction of the body, if this works then I'll try to make some checks so it doesn't waste charges.

What i meant with my question is: Will the rune be mlevel and level restricted if i make the scripts for it in actions, and add the restrictions in spells.xml such as i wrote in my previous post.
If you understood my question, and answered as such, then thanks ^^
I am well aware that a script can't work if it's not directed to a lua in scripts folder, don't worry :)
And this is what it needs to look like for my server, i think
XML:
 	<rune name="Demon Portal" id="2275" allowfaruse="1" charges="3" lvl="140" maglv="80" exhaustion="2000" blocktype="solid" script="summon/portal rune.lua"/>

I'll see now if it works.
ED:
Crashed again, no error.
o.0

Each startup it crashes again.
You can't use this item before i changed the line. Other lines in spells.xml look like that^
 
Last edited:
If you want the action script to check for the players magic level & level simply use these

Lua:
if getPlayerMagLevel(cid) => 10 then
if getPlayerLevel(cid) => 100 then
 
Yeah but the action script only half worked, as well.
Neither of these managed to randomly summon one of the 5 monsters, and remove one charge from the rune, and one body at a designated square.
 
Yeah but the action script only half worked, as well.
Neither of these managed to randomly summon one of the 5 monsters, and remove one charge from the rune, and one body at a designated square.

Try this:
Lua:
local t = {
[1] = "Hellhound",
[2] = "Defiler",
[3] = "Juggernaut",
[4] = "Grim Reaper",
[5] = "Fury",
[6] = "Dark Torturer"
}
 
local corpses = {3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(corpses, itemEx.itemid) then
   if getPlayerMagLevel(cid) >= 1 then
      if getPlayerLevel(cid) >= 14 then
         for k, v in pairs(t) do
             if math.random(1, 6) == k then
                if item.type > 1 then
                   doTransformItem(item.uid, item.type-1)
                else
                    doRemoveItem(item.uid, 1)
                end 
                doRemoveItem(itemEx.uid)
                doSummonCreature(v[1], toPosition)
                doSendMagicEffect(toPosition, CONST_ME_BIGCLOUDS)
             end
         end
      else
            doPlayerSendCancel(cid, "You dont have the required lvl")
      end
   else
         doPlayerSendCancel(cid, "Not enough ml nub!!!!!!")
  end
end
return true
end
 
Last edited:
That in actions?

This time.. No errors. Nothing happens.
Wtf?

ED:
I dont know why, but now, when i reopened tibia:
Code:
Lua Script Error: [Action Interface]
data/actions/scripts/portal rune.lua:onUse

luaDoRemoveItem(). Item not found

Lua Script Error: [Action Interface]
data/actions/scripts/portal rune.lua:onUse

luaDoRemoveItem(). Item not found

Lua Script Error: [Action Interface]
data/actions/scripts/portal rune.lua:onUse

luaDoSummonCreature(). Monster name() not found

Rune with 82 charges: Removed corpse, left rune with 82, summoned clouds. No monster
Rune with 0 (one) charge: Removed rune, removed corps, summoned clouds sometimes. No monster


So i edited your script to remove [1] after v in doSummonCreature

Lua:
local t = {
[1] = "Hellhound",
[2] = "Defiler",
[3] = "Juggernaut",
[4] = "Grim Reaper",
[5] = "Fury",
[6] = "Dark Torturer"
}
 
local corpses = {3058, 3059, 3060, 3061, 3062, 3063, 3064, 3065, 3066}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isInArray(corpses, itemEx.itemid) then
   if getPlayerMagLevel(cid) >= 1 then
      if getPlayerLevel(cid) >= 14 then
         for k, v in pairs(t) do
             if math.random(1, 6) == k then
                if item.type > 1 then
                   doTransformItem(item.uid, item.type-1)
                else
                    doRemoveItem(item.uid, 1)
                end 
                doRemoveItem(itemEx.uid)
                doSummonCreature(v, toPosition)
                doSendMagicEffect(toPosition, CONST_ME_BIGCLOUDS)
             end
         end
      else
            doPlayerSendCancel(cid, "You dont have the required lvl")
      end
   else
         doPlayerSendCancel(cid, "Not enough ml nub!!!!!!")
  end
end
return true
end

^This:
Summons 1-3 monsters, sometimes shows clouds so far, and pops this error in console.
Also doesn't remove charges.

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/portal rune.lua:onUse

luaDoRemoveItem(). Item not found
Saving server...
Notice: Map save (relational) took : 3.234 s








Oh, another little thing.

The rune removes frickin ANYTHING. Walls, flowers, trees.
xD
 
Last edited:
Back
Top