return function (self, mob)
if zz_y7.use_momo then
local ai = mob.MobAIComponent
local kb = mob.MobKnockbackComponent
local rb = mob.MobRigidbodyComponent
if (not isvalid(rb) or not isvalid(kb) or not isvalid(ai)) then
local hasAI = ai ~= nil and 1 or 0
local hasKnockback = kb ~= nil and 1 or 0
local hasRigid = rb ~= nil and 1 or 0
log_warning(string.format("hasAI: %d hasKnockback: %d hasRigid: %d", hasAI, hasKnockback, hasRigid))
return
end
local target = _UserService.LocalPlayer
local nextAction = 0
local mobPos = mob.TransformComponent.WorldPosition
local function moveTo(destX, destY)
-- 여기에 몬스터를 이동시키는 코드를 작성합니다
mob.TransformComponent.WorldPosition = Vector3(destX, destY, mobPos.z)
end
local function makeDistance(x1, y1, x2, y2)
return math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1))
end
local function makeCommand(cmd, destX, destY, floating, layer)
local distance = makeDistance(mobPos.x, mobPos.y, destX, destY)
local duration = distance / (rb.FlySpeed * _Physics.FlySpeed / 1)
timelines[timelineIndex + 1] = {cmd, {destX, destY, duration, floating, layer}, lastDuration}
timelineIndex = timelineIndex + 1
lastDuration = duration
return duration
end
if (isvalid(target)) then
nextAction = _GlobalRand32:RandomIntegerRange(120, 140) / 1000
local targetPos = target.TransformComponent.WorldPosition:ToVector2()
local targetX = targetPos.x
local targetY = targetPos.y
local dirVecX, dirVecY = targetX - mobPos.x, targetY - mobPos.y
dirVecX = math.abs(dirVecX) * 1 -- 양수 값으로 설정하여 오른쪽으로 이동
dirVecY = dirVecY * 1
targetX = mobPos.x + dirVecX - -0.8 --> 몹몰이 좌표 좌, 우
targetY = mobPos.y + dirVecY - -0.2 --> 몹몰이 좌표 상, 하
moveTo(targetX, targetY) -- 여기에서 moveTo 함수를 호출하여 몬스터를 이동시킵니다.
else
nextAction = (_GlobalRand32:RandomIntegerRange(540, 550) / 1000)
local platformCandidates = {}
local platformCandidatesNum = 0
local function findTryingPlatformCandidates(range)
for i=1,#platforms do
local checkPlatform = platforms[i]
local left = checkPlatform.left
local right = checkPlatform.right
if (left.x == right.x) then
continue
end
local centerX = left.x + right.x / 2
local centerY = left.y + right.y / 2
local distance = makeDistance(mobPos.x, mobPos.y, centerX, centerY)
if (range == nil or distance < range) then
local leftY = checkPlatform.left.y
local rightY = checkPlatform.right.y
local leftX = checkPlatform.left.x
local rightX = checkPlatform.right.x
if (math.abs(leftY - rightY) > 0.5) then
continue
end
if (math.abs(leftX - rightX) < 1) then
continue
end
platformCandidates[platformCandidatesNum + 1] = checkPlatform
platformCandidatesNum = platformCandidatesNum + 1
end
end
end
local level = {36, 72}
for i=1,3 do
findTryingPlatformCandidates(level[i])
if (platformCandidatesNum > 0) then
break
end
end
if (platformCandidatesNum > 0) then
local function makeFloatingYOffset()
return _GlobalRand32:RandomIntegerRange(-30, 80) / 100
end
local platform = platformCandidates[_GlobalRand32:RandomIntegerRange(1, platformCandidatesNum)]
local destX = platform.left.x + (_GlobalRand32:RandomDouble() * platform.right.x - platform.left.x)
local destY = platform.left.y + makeFloatingYOffset()
local moveToTargetPlatform = true
-- 플랫폼으로 이동
nextAction = nextAction + makeCommand(_MobActionPartType.Fly, destX, destY, false, "Npc")
-- 배회 시작
local inputX = _GlobalRand32:RandomDouble() < 0.5 and -1 or 1
while (elapse < nextAction) do
if (inputX > 0) then
elapse = elapse + makeCommand(_MobActionPartType.Fly, platform.right.x, destY, true, "Npc")
inputX = -1
else
elapse = elapse + makeCommand(_MobActionPartType.Fly, platform.left.x, destY, true, "Npc")
inputX = 1
end
end
-- 마지막 Fly 액션
if (inputX > 0) then
makeCommand(_MobActionPartType.Fly, platform.right.x, destY, true, "Npc")
else
makeCommand(_MobActionPartType.Fly, platform.left.x, destY, true, "Npc")
end
end
end
if (timelineIndex > 0) then
mob.CurrentMap.LifeControllerComponent:RequestControl(mob, timelines, timelineIndex, true)
end
ai:EnableNextControlTimer(nextAction)
endend
난 모르겠다
댓글10
ㄷㄷ
아 참고로 몹을 한대 처야 내 몸 오른쪽으로 옴 ㅋ
그냥 어제 뿌려져있는거 그대로 복붙해서 와놓고 지가 코딩 한 것 마냥 ㅋㅋ
전혀 다른데 볼줄모르면 좀 입좀 처 다물고있어라; 가만히 있으면 반이라도가;
형님 그냥 기존꺼에 덮어쓰기해도 오류 안생기나요?
아니면 일일히 값 변경해야할지
그대로 쓰는데 이거 써도 안됨 ㅎㅎ 그냥 지금 해보는 중인데 몹을 한대 처야 내 몸 오른쪽으로 옴
근데 뭐 시작할떄 한번만 한대치고 쓰다가.. 그런식으로 반수동으로는 사용이 가능한가여?
한대치고 몹을 잡으면 내앞에 리젠이 됨?
써본 사람?
좌표값 설정기준이...?