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

Action Health-mana pet!

Jikoe II

Member
Joined
Feb 7, 2009
Messages
174
Reaction score
9
screenshot :
fm1201.png


Credits to :
Doggynub for making the script!

put this in data->spells->scripts

heal pet :
PHP:
local amount = 200 -- amount of hp
local times = 1 -- in sec
local name = "Heal pet" -- monster name , make sure that the monster is convinced
 local storage = 6746 -- player who have this storage will be able to use
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, TRUE)
 
local function heal(cid)
			local p = getThingPos(cid)
			local healing = false
			if(#getCreatureSummons(cid) >= 1) then
				for _,pid in ipairs(getCreatureSummons(cid)) do
					if string.lower(getCreatureName(pid)) == string.lower(name) then
						healing = true 
						break
					end
				end
			end
			if healing == true then
				doCreatureAddHealth(cid,amount)
				doSendMagicEffect(getThingPos(cid),CONST_ME_MAGIC_BLUE)
				addEvent(heal,times*1000,cid)
					for _,pid in ipairs(getCreatureSummons(cid)) do
						if string.lower(getCreatureName(pid)) == string.lower(name) then
							doSendMagicEffect(getThingPos(pid),CONST_ME_MAGIC_BLUE)
							doSendAnimatedText(getThingPos(pid),"Healing",math.random(1,255))
							break
						end
					end
			end
			return true
		end
	local function check(cid)
				local checked = 0
				local place = { x=0,y=0,z=0}
				local h = getThingPos(cid)
				local frompos = {x=h.x-2,y=h.y-2,z=h.z}
				local topos = {x=h.x+2,y=h.y+2,z=h.z}
				for g = frompos.x,topos.x do
					for d = frompos.y,topos.y do
						local poss = {x=g,y=d,z=h.z}
						local tid = getTopCreature(poss).uid
						if isMonster(tid) or isPlayer(tid) or getTilePzInfo(poss) == TRUE or doTileQueryAdd(cid, poss) ~= 1 then
							checked = checked + 1
						else
							place.x = poss.x
							place.y = poss.y
							place.z = poss.z
							break
						end
					end
				end
				if checked >= 25 then
					return checked
				elseif checked < 25 then
					return place
				end
				return true
			end
function onCastSpell(cid, var)
	if getPlayerStorageValue(cid,storage) < 1 then
		return doPlayerSendCancel(cid,"You cant use this") and doSendMagicEffect(getThingPos(cid),2) and false
	end
	local search = false
	if(#getCreatureSummons(cid) >= 1) then
		for _,pid in ipairs(getCreatureSummons(cid)) do
			if string.lower(getCreatureName(pid)) == string.lower(name) then
				search = true 
				break
			end
		end
	end
	if search == true then
		doPlayerSendCancel(cid,"You already have a "..string.lower(name).." summoned.")
		doSendMagicEffect(getThingPos(cid),2)
		return false
	else
		local f = getThingPos(cid)
		local pos = {x=f.x+1,y=f.y,z=f.z}
		if not tonumber(check(cid)) then
			doConvinceCreature(cid,doSummonCreature(string.lower(name), check(cid)))
			heal(cid) 
			doCombat(cid,combat,var)
 
		else
			doPlayerSendCancel(cid,"You cant summon here.")
			doSendMagicEffect(getThingPos(cid),2)
		return false
		end
		return true
	end
 
	return true
end

mana pet :
PHP:
local amount = 100 -- amount of hp
local times = 1 -- in sec
local name = "Mana pet" -- monster name , make sure that the monster is convinced
 local storage = 6745 -- player who have this storage will be able to use
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_GREEN)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, TRUE)
 
local function heal(cid)
			local p = getThingPos(cid)
			local mana = false
			if(#getCreatureSummons(cid) >= 1) then
				for _,pid in ipairs(getCreatureSummons(cid)) do
					if string.lower(getCreatureName(pid)) == string.lower(name) then
						mana = true 
						break
					end
				end
			end
			if mana == true then
				doCreatureAddMana(cid,amount)
				doSendMagicEffect(getThingPos(cid),CONST_ME_MAGIC_BLUE)
				addEvent(heal,times*1000,cid)
					for _,pid in ipairs(getCreatureSummons(cid)) do
						if string.lower(getCreatureName(pid)) == string.lower(name) then
							doSendMagicEffect(getThingPos(pid),CONST_ME_MAGIC_BLUE)
							doSendAnimatedText(getThingPos(pid),"Mana",math.random(1,255))
							break
						end
					end
			end
			return true
		end
	local function check(cid)
				local checked = 0
				local place = { x=0,y=0,z=0}
				local h = getThingPos(cid)
				local frompos = {x=h.x-2,y=h.y-2,z=h.z}
				local topos = {x=h.x+2,y=h.y+2,z=h.z}
				for g = frompos.x,topos.x do
					for d = frompos.y,topos.y do
						local poss = {x=g,y=d,z=h.z}
						local tid = getTopCreature(poss).uid
						if isMonster(tid) or isPlayer(tid) or getTilePzInfo(poss) == TRUE or doTileQueryAdd(cid, poss) ~= 1 then
							checked = checked + 1
						else
							place.x = poss.x
							place.y = poss.y
							place.z = poss.z
							break
						end
					end
				end
				if checked >= 25 then
					return checked
				elseif checked < 25 then
					return place
				end
				return true
			end
function onCastSpell(cid, var)
	if getPlayerStorageValue(cid,storage) < 1 then
		return doPlayerSendCancel(cid,"You cant use this") and doSendMagicEffect(getThingPos(cid),2) and false
	end
	local search = false
	if(#getCreatureSummons(cid) >= 1) then
		for _,pid in ipairs(getCreatureSummons(cid)) do
			if string.lower(getCreatureName(pid)) == string.lower(name) then
				search = true 
				break
			end
		end
	end
	if search == true then
		doPlayerSendCancel(cid,"You already have a "..string.lower(name).." summoned.")
		doSendMagicEffect(getThingPos(cid),2)
		return false
	else
		local f = getThingPos(cid)
		local pos = {x=f.x+1,y=f.y,z=f.z}
		if not tonumber(check(cid)) then
			doConvinceCreature(cid,doSummonCreature(string.lower(name), check(cid)))
			heal(cid) 
			doCombat(cid,combat,var)
 
		else
			doPlayerSendCancel(cid,"You cant summon here.")
			doSendMagicEffect(getThingPos(cid),2)
		return false
		end
		return true
	end
 
	return true
end

add at in data->spells->spells.xml

PHP:
	<instant name="Sumonmana pet" words="manavip" lvl="8" mana="100" prem="0"  exhaustion="2000" needlearn="0" event="script" value="mana pet.lua">
		<vocation id="1"/>
		<vocation id="2"/>
		<vocation id="3"/>
		<vocation id="4"/>
		<vocation id="5"/>
		<vocation id="6"/>
		<vocation id="7"/>
		<vocation id="8"/>
	</instant>
	<instant name="Summon healthpet" words="healthvip" lvl="8" mana="100" prem="0"  exhaustion="2000" needlearn="0" event="script" value="health pet.lua">
		<vocation id="1"/>
		<vocation id="2"/>
		<vocation id="3"/>
		<vocation id="4"/>
		<vocation id="5"/>
		<vocation id="6"/>
		<vocation id="7"/>
		<vocation id="8"/>
	</instant>

its working with storageid for this is a action.

put this in data-->actions-->actions.xml
PHP:
	<action itemid="2347" script="petmanadonation.lua"/>
	<action itemid="2348" script="pethealthdonation.lua"/>

make 2 new files and call them petmanadonation and pethealthdonation
put in healthpetdonation :

PHP:
function onUse(cid, item, frompos, item2, topos)

if item.itemid == 2347 then
if getPlayerLevel(cid) > 1 then
getPlayerStorageValue(cid, 6746)
doSendAnimatedText(getPlayerPosition(cid), "Gratz!", TEXTCOLOR_RED) 
doCreatureSay(cid, "CONGRATULATIONS! You can now summon your healthpet with : healthvip!. ", TALKTYPE_ORANGE_1)
setPlayerStorageValue(cid, 6746, 1)
doRemoveItem(item.uid, 1)
else
doPlayerSendCancel(cid,'You are not a donator.')
doRemoveItem(item.uid, 1)
end
else
end
return 1
end
petmanadonation :

PHP:
function onUse(cid, item, frompos, item2, topos)

if item.itemid == 2348 then
if getPlayerLevel(cid) > 1 then
getPlayerStorageValue(cid, 6745)
doSendAnimatedText(getPlayerPosition(cid), "Gratz!", TEXTCOLOR_RED) 
doCreatureSay(cid, "CONGRATULATIONS! You can now summon your manapet with : healthmana!. ", TALKTYPE_ORANGE_1)
setPlayerStorageValue(cid, 6745, 1)
doRemoveItem(item.uid, 1)
else
doPlayerSendCancel(cid,'You are not a donator.')
doRemoveItem(item.uid, 1)
end
else
end
return 1
end

now the last thing at monsters.xml add :

PHP:
    	<monster name="Heal pet" file="Heal pet.xml"/>  
    	<monster name="mana pet" file="mana pet.xml"/>

create 2 new monsters and call them mana pet and heal pet.

just an example :

PHP:
<?xml version="1.0" encoding="UTF-8"?>
<monster name="mana pet" nameDescription="a pet" race="blood" experience="5" speed="1534" manacost="2000000">
	<health now="20000" max="20000"/>
	<look type="21" corpse="5964"/>
	<targetchange interval="2000" chance="0"/>
	<strategy attack="100" defense="0"/>
	<flags>
		<flag summonable="1"/>
		<flag attackable="1"/>
		<flag hostile="1"/>
		<flag illusionable="1"/>
		<flag convinceable="1"/>
		<flag pushable="1"/>
		<flag canpushitems="0"/>
		<flag canpushcreatures="0"/>
		<flag targetdistance="1"/>
		<flag staticattack="90"/>
		<flag runonhealth="5"/>
	</flags>
	<attacks>
		<attack name="melee" interval="2000" skill="10" attack="10"/>
	</attacks>
	<defenses armor="1" defense="2"/>
	<elements>
		<element earthPercent="100"/>
		<element holyPercent="100"/>
		<element icePercent="100"/>
		<element deathPercent="100"/>
	</elements>
	<voices interval="5000" chance="10">
		<voice sentence="Meep!"/>
	</voices>
	<loot>
    <item id="2696" chance="40750" /><!-- cheese -->
    <item id="1987" chance="100000"><!-- bag -->
        <inside>
            <item id="2148" countmax="4" chance="43750" /><!-- gold coin -->
        </inside>
    </item>
</loot>






</monster>

by using the items "2347" and "2348" you can use the command !viphealth or !vipmana

~~!Remember all credits are for doggynub he created the most important script!~~

enjoy

jikoe
 
Make that you can summon your pet if he is too far away, or one floor under you...

EDIT; or dismiss your pet...
 
Hello, great script I love it. But one thing when I log out i get these three errors does anyone know why?

[Error - Spell Interface]
[01/08/2011 23:15:37] In a timer event called from:
[01/08/2011 23:15:37] data/spells/scripts/summon/mana pet.lua:eek:nCastSpell
[01/08/2011 23:15:37] Description:
[01/08/2011 23:15:37] (luaGetThingPosition) Thing not found

[01/08/2011 23:15:37] [Error - Spell Interface]
[01/08/2011 23:15:37] In a timer event called from:
[01/08/2011 23:15:37] data/spells/scripts/summon/mana pet.lua:eek:nCastSpell
[01/08/2011 23:15:37] Description:
[01/08/2011 23:15:37] (luaGetCreatureSummons) Creature not found

[01/08/2011 23:15:37] [Error - Spell Interface]
[01/08/2011 23:15:37] In a timer event called from:
[01/08/2011 23:15:37] data/spells/scripts/summon/mana pet.lua:eek:nCastSpell
[01/08/2011 23:15:37] Description:
[01/08/2011 23:15:37] data/spells/scripts/summon/mana pet.lua:13: attempt to get length of a boolean value
[01/08/2011 23:15:37] stack traceback:
[01/08/2011 23:15:37] data/spells/scripts/summon/mana pet.lua:13: in function <data/spells/scripts/summon/mana pet.lua:10>
 
Can you make like if the pet's gets + level make Health up?
Will be awesome xD
 
Got same problem as goyk, something is spelled wrong and I don't know how to fix it, trying to learn it tho
 
Back
Top