-- AI : Neutral Character ai_neutral_neutral = require "scriptbank\\ai\\module_neutral" local firstPass = true local speechNum = 1 local maxSpeech = 4 local SP_delayT = 4000 local SP_delayW = 500 local SP_state = 'none' local SP_timer = math.huge -- Bubble Speech Decal Y offsets -- Ent name Ent name Bubble Text local speeches = {{'short', 'hello', 80, 2}, {'thought', 'iwonder', 80, 4}, {'medium', 'haha', 80, 4}, {'long', 'goodbye', 80, 2} }; function ai_neutral_sb_init(e) ai_neutral_neutral.init(e) end function ai_neutral_sb_main(e) ai_neutral_neutral.main(e) if firstPass then if SpeechBubbleRegister ~= nil then SpeechBubbleRegister(e, speeches) firstPass = false end else -- got here so must have registered speeches if GetPlayerDistance(e) < 350 and g_Entity[e].plrvisible == 1 then if SP_state == 'none' then SP_state = 'show' SP_timer = g_Time + SP_delayT elseif SP_state == 'show' then if g_Time > SP_timer then if speechNum < maxSpeech then speechNum = speechNum + 1 SP_state = 'wait' SP_timer = g_Time + SP_delayW return else SP_state = 'hide' SP_timer = math.huge end end SpeechBubbleShow(e, speechNum) elseif SP_state == 'wait' then if g_Time > SP_timer then SP_state = 'show' SP_timer = g_Time + SP_delayT end end elseif SP_state == 'hide' then SP_state = 'none' speechNum = 1 end end end