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

0.2 npc yell exsist?

zippy

Member
Joined
Feb 1, 2011
Messages
233
Reaction score
8
Hi, i added this into towncryer that he yell words, but doesnt work.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Towncryer" script="data/npc/scripts/default.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="131" head="95" body="86" legs="10" feet="114" addons="1"/>
<voices>
<voice text="Hear me! Hear me! The mage Wyrdin in the Edron academy is looking for brave adventurers to undertake a task!" interval1="1" margin="1" yell="no"/>
<voice text="Hear me! Hear me! The postmaster's guild has open spots for aspiring postmen! Contact Kevin Postner at the post office in the plains south of Kazordoon!" interval2="100" margin="1" yell="no"/>
<voice text="Hear me! Hear me! The inquisition is looking for daring people to fight evil! Apply at the inquisition headquarters next to the Thaian jail!" interval2="100" margin="1" yell="no"/>
</voices>
</npc>
 
the voice xml tag doesn't exist in 0.2/1.0, you'll have to use the onThink npc event instead
 
test
Lua:
local YELL = {
	"Hear me! Hear me! The mage Wyrdin in the Edron academy is looking for brave adventurers to undertake a task!",
	"Hear me! Hear me! The postmaster's guild has open spots for aspiring postmen! Contact Kevin Postner at the post office in the plains south of Kazordoon!",
	"Hear me! Hear me! The inquisition is looking for daring people to fight evil! Apply at the inquisition headquarters next to the Thaian jail!"
}


local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)


function onThink() npcHandler:onThink() end


yell_delay = 8
frequency = 10


function onYell()
	if ((os.time() - yell_delay) >= frequency) then
		yell_delay = os.time()
		doCreatureSay(getNpcCid(), YELL[math.random(#YELL)], 1)
	end
	return true
end


npcHandler:setCallback(CALLBACK_ONTHINK, onYell)
npcHandler:addModule(FocusModule:new())
 
It works perfectly, but question. If i want to add it into global.lua, could i just add the function onYell into the global and then reuse it whenever i want without have it inside in every npc file?
 
I'd not do that
use local variables for every NPC or use different var everytime you add this to npc
eg yell_delay1, yell_delay2... yell_delayn
 
Back
Top