• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction [Many] My fully lua PET system (MANY FEATURES)

why this bug? didn't do it before
PHP:
[22/07/2009 18:20:57] Lua Script Error: [TalkAction Interface] 
[22/07/2009 18:20:57] data/talkactions/scripts/pets/!petattack.lua:onSay

[22/07/2009 18:20:57] luaGetCreaturePosition(). Creature not found

[22/07/2009 18:20:57] Lua Script Error: [TalkAction Interface] 
[22/07/2009 18:20:57] data/talkactions/scripts/pets/!petattack.lua:onSay

[22/07/2009 18:20:57] luaGetCreaturePosition(). Creature not found
 
My server crashes when I change
PHP:
<event type="logout" name="logout" script="logout.lua"/>

to

PHP:
<event type="logout" name="PlayerLogout" script="logout.lua"/>
 
can u upgrade for my server is alissow 3.4 plzzz
rep ++
 
Last edited:
is there a way to add a storage value to be able to do this? make it a quest? so i can make it for vip players only :)
 
And make sure to add this on your logout sctipt
Top:

PHP:
dofile("./petConfig.lua")

and inside the onLogut:

PHP:
	if isCreature(getPlayerStorageValue(cid, storages.petUid)) == 1 then
		if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
			setPlayerStorageValue(cid, storages.petIsOnline, 1)
		end
	end

For noobs ¬¬:
PHP:
dofile("./petConfig.lua")

function onLogout(cid)
	if isCreature(getPlayerStorageValue(cid, storages.petUid)) == 1 then
		if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
			setPlayerStorageValue(cid, storages.petIsOnline, 1)
		end
	end
	return TRUE
end



Usage:
1.- !petinfo: this command will let you know the information of your pets. Current params (!peninfo "):
magic level: Magic level of your creature.
mana: Mana of your creature.
health: Health of the creature.
:O I forgot adding creatures items. Will be added leater

2.- !petsay: This command allow you to make you pet talk. For example: !petsay "YOU SUCK MAN!.
xample4qx2.jpg

3.- !petcarry:With this command you can make you pet to carry items. The item should be bellow the pet. Example:
xample1bi5.jpg

4.- !pet: Basiclly, to summon or take out your pet:
xample2ga2.jpg

5.- !petattack: Its used to make your pet attack. You can config the spells editing this table:
PHP:
attacks = {{param = "energy",  theFunction = false, offensive = 1, needLevel = 20, self = 0, needMag = 10, manaSpent = 60, exhausted = 1, range = 6, combatType = COMBAT_ENERGYDAMAGE, combatAni = CONST_ME_ENERGYAREA, area = 2, 
					formula = {maxb = 0.4, maxa = 30, minb = 0.5, mina = 0},
				 },
				 {param = "exori", theFunction = false, offensive = 1, needLevel = 40, self = 0, needMag = 5, manaSpent = 145, exhausted = 1, range = 0, combatType = COMBAT_PHYSICALDAMAGE, combatAni = CONST_ME_HITAREA, area = 2, 
					formula = {maxb = 0.6, maxa = 30, minb = 1.2, mina = 0},
				 },
				 {param = "fireball", theFunction = false, offensive = 1,  needLevel = 50, self = 0, needMag = 15, manaSpent = 100, exhausted = 1, range = 3, combatType = COMBAT_FIREDAMAGE, combatAni = CONST_ME_FIREAREA, area = 6, 
					formula = {maxb = 0.6, maxa = 30, minb = 1.2, mina = 0}
				 },
				 {param = "mini energy", theFunction = false, offensive = 1,  needLevel = 0, self = 0, needMag = 0, manaSpent = 20, exhausted = 1, range = 1, combatType = COMBAT_ENERGYDAMAGE, combatAni = CONST_ME_ENERGYAREA, area = 1, 
					formula = {maxb = 0.13, maxa = 0, minb = 0.262, mina = 0}
				 },
				 {param = "health", theFunction = false, offensive = -1,  needLevel = 10, self = 1, needMag = 0, manaSpent = 100, exhausted = 2, range = 0, combatType = COMBAT_HEALING, combatAni = CONST_ME_MAGIC_BLUE, area = 1, 
					formula = {maxb = 0.4, maxa = 20, minb = 0.7, mina = 0}
				 },
				 {param = "paralize", needLevel = 1, needMag = 0, manaSpent = 300, exhausted = 2,
				 theFunction = function (parameters)
					daPet = getPlayerStorageValue(parameters.cid, storages.petUid)
					if getCreatureTarget(daPet) ~= 0 then
						doAddCondition(getCreatureTarget(parameters.cid), 4)
					end
				 end
				},
				{param = "speed", needLevel = 10, needMag = 4, manaSpent = 60, exhausted = 2,
				 theFunction = function (parameters)				
					doAddCondition(getPlayerStorageValue(parameters.cid, storages.petUid), 11)
				end
				},
				 {param = "double fire", needLevel = 1, needMag = 0, manaSpent = 100, exhausted = 2,
				 theFunction = function (parameters)
					local attackCreature = getPlayerStorageValue(parameters.cid, storages.petUid)
					if getCreatureTarget(getPlayerStorageValue(parameters.cid, storages.petUid)) ~= 0 then
						attackCreature = getCreatureTarget(getPlayerStorageValue(parameters.cid, storages.petUid))
					end
					
					local myAttack = formulaAttack(getPlayerLevel(parameters.cid),  getPlayerStorageValue(parameters.cid, storages.petMag), 0.7, 0, 1.0, 0)
					function doAreaCombatHealthEx(params)
						local randoms = {[1] = math.random(-2, 2),
										 [2] = math.random(-2, 2)				
						}
						

						local posa = getCreaturePosition(attackCreature)
						doAreaCombatHealth(getPlayerStorageValue(parameters.cid, storages.petUid), COMBAT_FIREDAMAGE, {x = posa.x + randoms[1], y = posa.y + randoms[2], z = posa.z},  1, -params.myAttack.minD, -params.myAttack.maxD, CONST_ME_FIREAREA)
						doSendDistanceShoot(getCreaturePosition(getPlayerStorageValue(parameters.cid, storages.petUid)), {x = posa.x + randoms[1], y = posa.y + randoms[2], z = posa.z}, CONST_ANI_FIRE)
						
					end
					doAreaCombatHealthEx({cid = parameters.cid, target = getCreaturePosition(attackCreature), myAttack = myAttack})
					for i = 1, 7 do
						addEvent(doAreaCombatHealthEx, 200*i, {cid = parameters.cid, target = getCreaturePosition(attackCreature), myAttack = myAttack})
					end
				end
				}
			}
You can also make special attacks, editing the field theFunction.

xample5yv9.jpg

6.- !petgetitem: Its used to get your items back, make sure you remember where the pet saved the item!
xample3xy1.jpg

I love making scripts, I dunno why I never publish em's :D.


NPC TO REVIVE PET:

PHP:
local focus = 0
local talk_start = 0
local talk_state = 0
local costPerLevel = 300

dofile("./petConfig.lua")
			 


function onThingMove(creature, thing, oldpos, oldstackpos)

end


function onCreatureAppear(creature)

end


 function onCreatureDisappear(cid, pos)
 	if focus == cid then
         selfSay('How rude!.')
         focus = 0
         talk_start = 0
 	end
 end


function onCreatureTurn(creature)

end


function msgcontains(txt, str)
  	return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end


function onCreatureSay(cid, type, msg)
  	msg = string.lower(msg)
	if getDistanceToCreature(cid) < 4 then
	  	if (msgcontains(msg, 'hi') and (focus == 0)) then
	  		selfSay('Hello ' .. creatureGetName(cid) .. '! I can take you to the train!')
				focus = cid
				talk_start = os.clock()

	  	elseif msgcontains(msg, 'hi') and (focus ~= cid) then
	  		selfSay('Sorry, ' .. creatureGetName(cid) .. '! I talk to you in a minute.')
		end

		if msgcontains(msg, 'revive') and focus == cid then
			if  isCreature(getPlayerStorageValue(cid, storages.petUid)) == 0 then
				if getPlayerStorageValue(cid, storages.petIsOnline) == 2 then
					selfSay('YOUR PET DIED?!, YOU\'R A BAD OWNER, THIS WILL COST YOU ' .. getPlayerLevel(cid)*costPerLevel .. ' GOLD COINS!, AGREE?!')
					talk_state = 1
				else
					selfSay('Your pet is alive.')
				end
			else
				selfSay('Your pet is standing next to you.')
			end
		talk_start = os.clock()
		end
		if msgcontains(msg, 'yes') and focus == cid and talk_state == 1 then
			if doPlayerRemoveMoney(cid, getPlayerLevel(cid)*costPerLevel) == 1 then
				setPlayerStorageValue(cid, storages.petIsOnline, 1)
				selfSay('You can now summon again your pet.')
			else
				selfSay('You don\'t have enought money.')
			end
		talk_state = 0
		talk_start = os.clock()
		end				
				
		if msgcontains(msg, 'bye') then
			selfSay('Good bye, ' .. creatureGetName(cid) .. '!')
			focus = 0
			talk_start = 0
			talk_state = 0
		end
	end
end


function onCreatureChangeOutfit(creature)

end


function onThink()

	doNpcSetCreatureFocus(focus)
  	if (os.clock() - talk_start) > 30 then
  		if focus > 0 then
  			selfSay('Next Please...')
  		end
  			focus = 0
                        talk_state = 0
  	end
	if focus ~= 0 then
 		if getDistanceToCreature(focus) > 5 then
                        talk_state = 0
 			selfSay('Good bye then.')
                        talk_state =  0
 			focus = 0
 		end
 	end
end
NOTE: Make sure all monsters are convinceable.
Everything has been tested on TFS 2.10.
Regards, all credits goes to FedeVI.

what do you mean with "logout script"??? ;(



Edit: done!!! :D
 
Last edited:
yes, it ought to work, if it worked for me @ 0.2.2
 
Btw, in my opinion you should add a new feature to it, optional feature.... it would be source editting but i think it would pwn if you added a "Pet Channel" that tells you everything happening with your pet, the damage it deals and takes, the spells it uses like "Gfb'ing I now have 150 mana left!" also the pet channel could say things like when it picks up or gives you anything... it would just say anything about the pet... and btw you should add a "What are you carrying" command of some sort that tells you what is in which bag
 
nothing

I tried to add, I get no errors, No messages inside the game... Just nothing happend when i say !pet


Any ideas?

Thanks in advane
 
how can i make the monsters use the players spells?
like using the spells in the dir: data/spells/scripts....
thx
 
Wich version? :S

Id like this on a 0.2, but idk what type it is, and i coudltn see if u sayd any verson ^.^
Anhow... nice thing ya got there XD
 
Back
Top