• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Summoning Spells

Captain Orhotek

New Member
Joined
May 20, 2009
Messages
118
Reaction score
1
I made some simple summoning spells but I have no idea how to limit how many things can be summoned.

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

local area = createCombatArea(AREA_CIRCLE3X3)
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)
			local creature = doSummonCreature("Orc", pos)
			doConvinceCreature(cid, creature)
			doSendMagicEffect(pos, CONST_ME_POFF)
		end
	end
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

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

That is a little example of the spell but at the moment all it does is summon a Orc for every dead body. I either want it to summon a couple at a cast or limit how many of that creature can be summoned in all. Like it still uses all dead bodies but only summons 2. And yes this is a crude edit of the summon undead legion spell...unless I am mistaken the code
Code:
doRemoveItem(item.uid,1)
means how many dead bodies you need to summon. But that is the only thing I see..
 
You could use this

Code:
local summons = getCreatureSummons(cid)

if(table.maxn(summons) >= 2) then
                        doPlayerSendCancel(cid, "You may not summon more than 2 creatures.")
                return TRUE
        end
 
sigh I am not much of a coder but I tried that in a couple different ways and at first the spell didnt work then I tried this it worked just like the normal spell..

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

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

local summons = getCreatureSummons(cid)


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)
			local creature = doSummonCreature("Orc", pos)
			doConvinceCreature(cid, creature)
			doSendMagicEffect(pos, CONST_ME_POFF)
if(table.maxn(summons) >= 2) then
                        doPlayerSendCancel(cid, "You may not summon more than 2 creatures.")
                return TRUE
        end

		end
	end
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

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

And no luck..happen to know how I can put it in where it does work...thank you for all the help.
 
If your not such a good coder how come you claim you made this script yet you cant add a single line of code? Lmao

Code:
local summons = getCreatureSummons(cid)

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

local area = createCombatArea(AREA_CIRCLE3X3)
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 and 
		(table.maxn(summons) >= 2) then
                        doPlayerSendCancel(cid, "You may not summon more than 2 creatures.")
                        else
			doRemoveItem(item.uid,1)
			local creature = doSummonCreature("Orc", pos)
			doConvinceCreature(cid, creature)   
			doSendMagicEffect(pos, CONST_ME_POFF)
		end
	end
end

setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end
 
I did not claim I made this...in first post I said "And yes this is a crude edit of the summon undead legion spell"

But as I said thank you for your help.
 
I just tried that code and while it does make two orcs on first use it no longer requires a body and if you use it again it summons about 50 of them...not really 50 but a few of them.
 
I hate to make another post once again but I really do wish for help on this. At the moment I am just letting people on my server have fun with the spell but I do want a way to limit what they can get. I was going to use summon creature spell as a way to limit but seems that is hardcoded and not a script..

If what I am wanting is not doable is there a way to make it where that player can only have a certain amount of summons? Like instead of player being able to have 2 skeletons, 2 bugs, 2...etc he can only have 5 total summons.
 
Last edited:
Back
Top