-------------------------------------------------- -- -- ホムンクルス用くるくるライブラリ -- -- revolver.lua -- -- ver.2006/08/29 -- -------------------------------------------------- -- -- require "./AI/USER_AI/revolver.lua" -- AI.luaの文頭に追加 -- -- if Revolver () then return end -- OnIDLE_ST () 索敵とケミ距離判定の間に挿入 -- -- ResetRevolver () -- AIメイン関数の最後に追加 -- -------------------------------------------------- -- 設定項目 AI.luaのグローバル変数部分に移動すると変更が容易 -------------------------------------------------- RoundCtrl = true -- 回転動作許可 true / false RoundType = 3 -- 0:その場で小さく、1:円形、2:十字、3:四角、4:菱形、9:ランダム、10:周囲のキャラ RoundRadius = 2 -- 回転半径 RoundMirror = 0 -- 0:そのまま(時計回り)、1:左右反転(反時計回り) RoundHomSP = 90 -- 回転を開始するホムのSPパーセンテージ RoundStart = 4000 -- 最初の回転を開始する時間 RoundNext = 2000 -- 次の回転を開始する時間 ---------------------------------- 10:周囲のキャラ RoundArea = 10 -- ケミからの移動範囲 RoundLover = 2 -- 0:プレイヤーのみ、1:ホムンクルスのみ、2:両方、9:特定のID LoveID = {} -- 特定のIDをカンマ区切り -------------------------------------------------- RoundSub = math.ceil (RoundRadius * 2 / 3) -- 擬似円形点 RoundTick = 0 -- 時間調節 RoundTick2 = 0 -- 時間調節 RoundCount = 1 -- 回転調節 RoundCount2 = 1 -- 回転調節 LaX, LaY = 0, 0 -- 座標保持 -------------------------------------------------- -- 回転パターンリスト -------------------------------------------------- RoundArray = {} RoundArray[0] = {step = 4, {x = -1, y = 1}, {x = 1, y = 1}, {x = 1, y = -1}, {x = -1, y = -1}} RoundArray[1] = {step = 10, {x = 0, y = -1 * RoundRadius}, {x = -1 * RoundSub, y = -1 * RoundRadius}, {x = -1 * RoundRadius, y = -1 * RoundSub}, {x = -1 * RoundRadius, y= RoundSub}, {x = -1 * RoundSub, y = RoundRadius}, {x = RoundSub, y = RoundRadius}, {x = RoundRadius, y = RoundSub}, {x = RoundRadius, y = -1 * RoundSub}, {x = RoundSub, y = -1 * RoundRadius}, {x = 0, y = -1 * RoundRadius}} RoundArray[2] = {step = 9, {x = 0, y = -1}, {x = -1 * RoundRadius, y = 0}, {x = -1, y = 0}, {x = 0, y= RoundRadius}, {x = 0, y = 1}, {x = RoundRadius, y = 0}, {x = 1, y = 0}, {x = 0, y = -1 * RoundRadius}, {x = 0, y= -1}} RoundArray[3] = {step = 6, {x = 0, y = -1 * RoundRadius}, {x = -1 * RoundRadius, y = -1 * RoundRadius}, {x = -1 * RoundRadius, y = RoundRadius}, {x = RoundRadius, y= RoundRadius}, {x = RoundRadius, y = -1 * RoundRadius}, {x = 0, y = -1 * RoundRadius}} RoundArray[4] = {step = 5, {x = 0, y = -1 * RoundRadius}, {x = -1 * RoundRadius, y = 0}, {x = 0, y = RoundRadius}, {x = RoundRadius, y= 0}, {x = 0, y = -1 * RoundRadius}} RoundArray[9] = {step = 1, {x = 0, y = 0}} RoundArray[10] = {step = 5, {x = 0, y = -1}, {x = -1, y = 0}, {x = 0, y = 1}, {x = 1, y = 0}, {x = 0, y = -1}} -------------------------------------------------- function Revolver (id) id = id or GetV (V_OWNER, MyID) local OwX, OwY = GetV (V_POSITION, id) local MyX, MyY = GetV (V_POSITION, MyID) if (LaX ~= OwX or LaY ~= OwY) then RoundTick, RoundCount, RoundCount2 = 0, 1, 1 RoundTick2 = GetTick () + RoundStart end LaX, LaY = OwX, OwY if (RoundCtrl and RoundTick2 < GetTick () and GetV (V_MAXSP, MyID) * RoundHomSP < GetV (V_SP, MyID) * 100) then if (RoundTick < GetTick ()) then if (RoundType == 0) then NeX = MyX + RoundArray[RoundType][RoundCount].x * (-1) ^ RoundMirror NeY = MyY + RoundArray[RoundType][RoundCount].y elseif (RoundType == 9) then NeX = OwX + math.random((-1)*RoundRadius,RoundRadius) NeY = OwY + math.random((-1)*RoundRadius,RoundRadius) elseif (RoundType == 10) then OwX, OwY = GetV (V_POSITION, GetRoundTarget ()) NeX = OwX + RoundArray[RoundType][RoundCount].x * (-1) ^ RoundMirror NeY = OwY + RoundArray[RoundType][RoundCount].y else NeX = OwX + RoundArray[RoundType][RoundCount].x * (-1) ^ RoundMirror NeY = OwY + RoundArray[RoundType][RoundCount].y end Move (MyID, NeX, NeY) RoundTick = GetTick () + math.sqrt ((MyX - NeX) ^ 2 + (MyY - NeY) ^ 2) * 150 if RoundCount == RoundArray[RoundType].step then RoundCount = 0 if (RoundType == 10) then RoundCount2 = RoundCount2 + 1 end RoundTick = RoundTick + RoundNext end RoundCount = RoundCount + 1 end return true end end function ResetRevolver () if (MyState ~= IDLE_ST) then RoundTick, RoundCount, RoundCount2 = 0, 1, 1 LaX, LaY = 0, 0 end end function GetRoundTarget () local owner = GetV (V_OWNER, MyID) local target = {} local index = 1 local motion for i, v in ipairs (GetActors ()) do if (v ~= owner and v ~= MyID and IsLover (v) == 1 and GetDistance2 (owner, v) < RoundArea) then motion = GetV (V_MOTION, v) if (motion == MOTION_STAND or motion == MOTION_SIT) then target[index] = v index = index + 1 end end end if (index == 1) then return owner elseif (index <= RoundCount2) then RoundCount2 = 1 end return target[RoundCount2] end function IsLover (id) if ((RoundLover == 0 or RoundLover == 2) and 100000 < id) then return 1 end if ((RoundLover == 1 or RoundLover == 2) and id < 100000) then local Ty = GetV (7, id) if (0 < Ty and Ty < 17) then return 1 end end if (RoundLover == 9) then for i, v in ipairs (LoveID) do if (id == v) then return 1 end end end return 0 end