• 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!

Spell Summoning Spell..with an error

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

The one that helped me is Chris77 (I believe is correct spelling) and I am simply looking for more help and I believe this is the correct spot for the post so I think I may find more here. The final code does work sort of. It summons two orcs but does no longer require the bodies and if used again it summons about 10 of them.
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..

So what I need help with is two main things. A code to limit the amount of a certain monster can be summoned, or an overall limit to the character summoning as in they can only heve 5 total..may change with level..if that is doable.

And a way to change how many bodies the summon takes. At the moment it takes only one.

Will edit a code someone gave me and the results I got from it. Also this post is now in this thread as I think I put it in the wrong one the first time.

Code:
local summons = getCreatureSummons(cid)

if(table.maxn(summons) >= 2) then
                        doPlayerSendCancel(cid, "You may not summon more than 2 creatures.")
                return TRUE
        end
Above is the code someone gave me on these forums but sadly did not work the way I needed...will show it in code below.

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

Edit- I found out what the Orc one does now it uses any item in the area to summon..it does not need an item but if there happen to be one it will use it. Just now took my spellbook.
 
Last edited:
But do you want to make it like "Undead Legion" where you need dead skeleton bodies (or w/e item) in the floor in order to summon the monsters from the item, or just like the "utevo res" spell which summons when the words are said?

If the answer is the second and you dont mind it being a talkaction instead of a "spell", you could use this one:

http://otland.net/f132/solved-summon-single-creature-rep-36507/

It works perfectly, you could put the words in talkactions.xml as the ones you desire like "utevo mas res" or so and it will be just like a spell ;)
 
Whoops guess I didnt make a post on this thread. Thanks the to the great coding from our server hoster (Zeke) we got the summoning spells to work. There is a slight bug in it but with the new script it only summons the pre-set amount.

Ill +rep you because that would have worked too..thank you
 
I figured out how to do basiclly using storage values to store the amount of creatures a player owns (up to 5).

At the moment I am having an issue when the summon dies, removing it from the players total summon count. Since MyndGamez is using MS 2.3 we dont have the function getCreatureSummons(cid) to get the amount of summons a player controls.

I tried doing something similar to svargrond arena code so when a player kills a creature it removes a storage value. Only problem is that works only if the player kills his own summons, not if someone else kills them or they die to a creature.

Might just look into upgrading to CD 3.xx (what ever the newest one is)..

-Zeke
 
Back
Top