-------------------------------------------------- -- -- ホムンクルス用アラートライブラリ -- -- alert.lua -- -- ver.2006/09/16 -- -------------------------------------------------- -- -- require "./AI/USER_AI/alert.lua" -- AI.luaの文頭に追加 -- -- if Alert () then return end -- OnIDLE_ST () などの先頭に挿入 -- -- SetAlert (start, stop) -- アラート設定 start/開始ミリ秒 省略(nil):即時, stop /終了ミリ秒 省略(nil):2 ^ 30 (約13日) -- -- ResetAlert () -- アラート取消/終了 -- -------------------------------------------------- AlertEnd = 0 -- 時間調節 AlertTick = 0 -- 時間調節 AlertTick2 = 0 -- 時間調節 AlertCount = 1 -- 回転調節 AlertCount2 = -1 -- 回転調節 -------------------------------------------------- function Alert () local OwX, OwY = GetV (V_POSITION, GetV (V_OWNER, MyID)) local MyX, MyY = GetV (V_POSITION, MyID) if (AlertTick2 == 0) then return false elseif (AlertEnd < GetTick ()) then ResetAlert () return false elseif (AlertTick2 < GetTick ()) then if (AlertTick < GetTick ()) then local NeX = OwX + AlertCount2 * (1 - AlertCount) local NeY = OwY + AlertCount2 * AlertCount Move (MyID, NeX, NeY) AlertTick = GetTick () + math.sqrt ((MyX - NeX) ^ 2 + (MyY - NeY) ^ 2) * 150 AlertCount = 1 - AlertCount AlertCount2 = AlertCount2 * (-1) ^ AlertCount end return true end end function SetAlert (start, stop) AlertTick2 = GetTick () + start or -1 AlertEnd = AlertTick2 + stop or 2 ^ 30 end function ResetAlert () AlertEnd, AlertTick, AlertTick2 = 0, 0, 0 AlertCount, AlertCount2 = 1, -1 end