I realized after reading 3com's post that I need to refine my goals. I want to fulfill two main conditions, of which do not require waypoints.
Condition #1: NPC does a repetitive task until terminated by the player.
Condition #2: NPC does a repetitive task until approached by player, where the NPC either runs away (wildlife script) or attacks (charge script, or similar).
Let me dissect the script I'm using so far. I have been attempting to do a continuous "GEN_idle_conversation" that is why that code is repeated. So I get a short conversation near and away from NPC.
https://forum.game-guru.com/thread/213322 ------ Where I got it.
-- The AI Talking -------------------------------------------- New Description.
local PlayerDist_near = 100; --------- Condition location.
local PlayerDist_far = 150; --------- Condition location.
local sat = {} --------- Current player position?
local talk_duration = 4000 ---------- I have changed this and it does not seem to do anything.
function ai_talk_init(e)
sat[e] = 1 ----------------------- (sat) here, seams to reference the first line of active code.
SetCharacterSoundSet(e)
end
function ai_talk_main(e)
PlayerDist = GetPlayerDistance(e) -------------- Tells the program where player is in relation to NPC.
if sat[e] == 1 and g_Entity[e]['animating'] == 0 then
StartTimer(e)
SetAnimationFrames(3110,3420) ------------- Animation code which is imbedded in the character .fpe file.
PlayAnimation(e) ------------ Plays animation listed above, of course.
-------------------------- If I add: "loopanimation" or "playanimineditor =1", here or after the animation below - it does nothing.
sat[e] = 2
elseif sat[e] == 2 then
if GetTimer(e) > talk_duration then
SetAnimationFrames(3110,3420)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
sat[e] = 2
end
end
if PlayerDist < PlayerDist_near and sat[e] == 2 then ----- This condition happens when player walks away.
LookAtPlayer(e);
PlaySound(e,8000,500);
SetAnimationFrames(3110,3420)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
sat[e] = 3
elseif PlayerDist > PlayerDist_far and sat[e] == 3 then ---- Does this reference players current location?
SetAnimationFrames(3110,3420)
PlayAnimation(e)
g_Entity[e]['animating'] = 1
sat[e] = 1
end
end
I understand that there is a connection between the script .lua and the .fpe file. I know "playanimineditor =1" is crucial to the process, but I don't really know how to set it up in the .fpe file.