Hey there.
I think my confusion may be with which NPC system I need to be using exactly.
After spending about 20 - 30 minutes searching and reading various threads, I couldn't figure out my issue.
I'm pretty sure I'm probably using the wrong NPC system, but I'm not 100%.
I know I've been asking a lot of questions but you guys have been awesome and answering them for me. The assistance on this community rocks!
The Version I'm using is TFS_02 (Mystic) I believe. I know there are newer versions out there, but I'm comfortable with this one and I love the 9.6 client.
I found Emire's NPC program and it is awesome. It's making my NPC XMLs like this:
However, the NPC Lua I have setup is the following:
Does anyone have any insight or know why I'm having issues with NPCs not answering to their keywords?
I think my confusion may be with which NPC system I need to be using exactly.
After spending about 20 - 30 minutes searching and reading various threads, I couldn't figure out my issue.
I'm pretty sure I'm probably using the wrong NPC system, but I'm not 100%.
I know I've been asking a lot of questions but you guys have been awesome and answering them for me. The assistance on this community rocks!
The Version I'm using is TFS_02 (Mystic) I believe. I know there are newer versions out there, but I'm comfortable with this one and I love the 9.6 client.
I found Emire's NPC program and it is awesome. It's making my NPC XMLs like this:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Hobo" script="data/npc/scripts/default.lua" walkinterval="1500" speed="100" walkradius="2" floorchange="0">
<health max="100" now="100"/>
<look type="153" head="97" body="40" legs="114" feet="114" addons="0" mount="0"/>
<parameters>
<!--MESSAGES-->
<parameter key="message_greet" value="Can you spare a coin, |PLAYERNAME|?"/>
<parameter key="message_farewell" value="Off with you then, |PLAYERNAME|."/>
<!--KEYWORDS-->
<parameter key="module_keywords" value="1"/>
<parameter key="keywords" value="Job;Quest"/>
<parameter key="keyword_reply1" value="What? Job...? No way. Not me...not anymore."/>
<parameter key="keyword_reply2" value="You know...the only thing in town I've heard is there's some unclaimed gold in some chests in the sewer and underneath the bakery...I'd go but I'm not as able bodied as I use to be."/>
</parameters>
</npc>
However, the NPC Lua I have setup is the following:
Code:
-- Including the Advanced NPC System
dofile('data/npc/lib/npcsystem/npcsystem.lua')
function getDistanceToCreature(id)
if id == 0 or id == nil then
selfGotoIdle()
end
local creaturePosition = getCreaturePosition(id)
cx = creaturePosition.x
cy = creaturePosition.y
cz = creaturePosition.z
if cx == nil then
return nil
end
sx, sy, sz = selfGetPosition()
return math.max(math.abs(sx - cx), math.abs(sy - cy))
end
function moveToPosition(x,y,z)
selfMoveTo(x, y, z)
end
function moveToCreature(id)
if id == 0 or id == nil then
selfGotoIdle()
end
tx, ty, tz = getCreaturePosition(id)
if tx == nil then
selfGotoIdle()
else
moveToPosition(tx, ty, tz)
end
end
function selfGotoIdle()
following = false
attacking = false
selfAttackCreature(0)
target = 0
end
function isPlayerPremiumCallback(cid)
return isPremium(cid)
end
function msgcontains(message, keyword)
local message, keyword = message:lower(), keyword:lower()
if message == keyword then
return true
end
return message:find(keyword) and not message:find('(%w+)' .. keyword)
end
function selfSayChannel(cid, message)
return selfSay(message, cid, FALSE)
end
function doPosRemoveItem(_itemid, n, position)
local thing = getThingfromPos({x = position.x, y = position.y, z = position.z, stackpos = 1})
if thing.itemid == _itemid then
doRemoveItem(thing.uid, n)
else
return false
end
return true
end
function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
local amount, subType, ignoreCap, item = amount or 1, subType or 0, ignoreCap and TRUE or FALSE, 0
ignoreCap = FALSE
if isItemStackable(itemid) then
if(inBackpacks) then
stuff = doCreateItemEx(backpack, 1)
item = doAddContainerItem(stuff, itemid, math.min(100, amount))
else
stuff = doCreateItemEx(itemid, math.min(100, amount))
end
return doPlayerAddItemEx(cid, stuff, ignoreCap) ~= RETURNVALUE_NOERROR and 0 or amount, 0
end
local a = 0
if(inBackpacks) then
local container, b = doCreateItemEx(backpack, 1), 1
for i = 1, amount do
local item = doAddContainerItem(container, itemid, subType)
if(isInArray({(getContainerCapById(backpack) * b), amount}, i) == TRUE) then
if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then
b = b - 1 --
break
end
a = i -- a = a + i
if(amount > i) then
container = doCreateItemEx(backpack, 1)
b = b + 1
end
end
end
return a, b
end
for i = 1, amount do -- normal method for non-stackable items
local item = doCreateItemEx(itemid, subType)
if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
break
end
a = i
end
return a, 0
end
local func = function(pars)
if isPlayer(pars.pcid) == TRUE then
doCreatureSay(pars.cid, pars.text, pars.type, false, pars.pcid, getCreaturePosition(pars.cid))
pars.e.done = TRUE
end
end
function doCreatureSayWithDelay(cid, text, type, delay, e, pcid)
if isPlayer(pcid) == TRUE then
e.done = FALSE
e.event = addEvent(func, delay < 1 and 1000 or delay, {cid=cid, text=text, type=type, e=e, pcid=pcid})
end
end
Does anyone have any insight or know why I'm having issues with NPCs not answering to their keywords?