Posted 25 January 2013 - 04:50 AM
I need help for my new RPG game. I tried implementing NPCs, but they seem buggy. Can anyone
please take a look at it? :)/>
Link:
http://pastebin.com/x3WDk4Va
NPC functions:
please take a look at it? :)/>
Link:
http://pastebin.com/x3WDk4Va
NPC functions:
function drawNPC(nx,ny,npos,nchar,nmode)
npcon = true
npcx = nx
npcy = ny
npcchar = nchar
npcmode = nmode
npcpos = npos
drawMap()
end
function updateNPC()
if npcmode == "dumb" then
turn = math.random(1,4)
if (turn == 1) and (map[npcpos-9] == "-") then
npcpos = npcpos-9
npcy = npcy-1
elseif (turn == 2) and (map[npcpos+9] == "-") then
npcpos = npcpos+9
npcy = npcy+1
elseif (turn == 3) and (map[npcpos-1] == "-") then
npcpos = npcpos-1
npcy = npcx-1
elseif (turn == 4) and (map[npcpos+1] == "-") then
npcpos = npcpos+1
npcy = npcx+1
end
end
end