Hi, I've written a script to show complete dialog at once, then the AI soldier is supposed to move to a certain xz of a static object elsewhere in the map. Sometimes the AI soldier moves to the coordinates using AIEntityGoToPosition() just fine for 1 or 2 test moves, but then stops moving at all (except to rotate to the player). I'm not sure if I've made a coding mistake or something else is interfering. Gameguru goes through all the code just fine, displaying the 3 lines of text, Prompt, then the AIEnityGoToPostion() code, but AI goes nowhere. Would anyone mind checking if I've made some error?
local text_lines = {}
local text_finished = 0
function chad_dialog1a_init_name(e,name)
weapon_name[e] = name
end
function chad_dialog1a_main(e)
PlayerDist = GetPlayerDistance(e)
local EntObjNoflower = 350 -- flower entity's ID to move AI to
local EntObjNo = g_Entity[e]['obj'] -- AI soldier entity number
AISetEntityControl(EntObjNo,AI_MANUAL)
CharacterControlUnarmed(e)
SetCharacterToWalk(e)
ai_start_x[e] = g_Entity[EntObjNoflower]['x'] -- flower object's X
ai_start_z[e] = g_Entity[EntObjNoflower]['z'] -- flower object's Z
if weapon_name[e] == "chad" and PlayerDist < 120 and text_finished == 0 then
RotateToPlayer(e)
local text_lines_num = 3 -- change to number of text lines.
text_lines[1] = weapon_name[e]..": Hey recruit.."
text_lines[2] = "I've been ordered to give you some combat training.'"
text_lines[3] = "Please follow me..."
send = gen_text(text_lines,text_lines_num)
if send >= text_lines_num then
Prompt ("Press [E] to finish")
if g_KeyPressE > 0 then
text_finished = 1
end
end
end
if text_finished == 1 then
AIEntityGoToPosition(EntObjNo,ai_start_x[e],ai_start_z[e])
end
end
function gen_text(texting, num)
y = 40
for i = 1, num, 1 do
TextCenterOnXColor(50,y,1,texting[i], 100,255,255)
y = y + 2
i_num = i + 1
end
return i_num
end
Thanks in advance for any help.
Windows 10 64bit, Intel(R) Core(TM) i5-4590 CPU @ 3.30GHz, 3301 Mhz, 4 Core(s), NVIDIA GeForce GTX 960 2 gig GDDR5, 16 gigs ram