Well, normally I do not want to give any script if I can not test it first.
I use firts smallg pet.lua script above.
Attached it to combat soldier, and ran it, and it work ok.
So, I notice the soldier should be facetting to the player to work.
Then try adding "LookAtPlayer(e)"
--script by smallg
--key to issue commands to pet
local input_key = "e"
local state = {}
local pressed = 0
function pet_init(e)
state[e] = "stay"
CharacterControlUnarmed(e)
end --init
function pet_main(e)
if state[e] == "stay" then
if GetPlayerDistance(e) < 160 then
LookAtPlayer(e)
PromptLocal(e,"follow?")
if g_InKey == input_key and pressed == 0 then
pressed = 1
state[e] = "follow"
end
end
elseif state[e] == "follow" then
if GetPlayerDistance(e) > 300 then
SetCharacterToRun(e)
ModulateSpeed(e,1.1)
elseif GetPlayerDistance(e) > 160 and GetPlayerDistance(e) < 275 then
SetCharacterToWalk(e)
ModulateSpeed(e,1)
end
if GetPlayerDistance(e) > 160 then
AIEntityGoToPosition(g_Entity[e]['obj'],g_PlayerPosX,g_PlayerPosZ)
else
AIEntityGoToPosition(g_Entity[e]['obj'],g_Entity[e]['x'],g_Entity[e]['z'])
AIEntityStop(e)
end
if GetPlayerDistance(e) < 130 then
PromptLocal(e,"stay?")
if g_InKey == input_key and pressed == 0 then
state[e] = "stay"
AIEntityGoToPosition(g_Entity[e]['obj'],g_Entity[e]['x'],g_Entity[e]['z'])
AIEntityStop(e)
pressed = 1
end
end
end
if pressed == 1 and g_InKey ~= input_key then
pressed = 0
end
end --main
3com
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz
OS: Windows 8.1 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics