채팅0

    맵밖튕 코드한번 봐주실분?

    조회수 458

    return function(self, enteredMap, hp, fieldCounter)

    local mapInfo = enteredMap.MapInfoComponent

    local bgm = mapInfo.Bgm

    local app = _AppService:Get()

    app.ControlWindowMan:OnLoadedMap(enteredMap)
    --xpcall(function()
    --
    --end,
    --function(error)
    --    log_error("error occured on OnLoadedMap: ", error)
    --end)
    
    self:EnableExclusiveAction()
    local ac = self.Entity.CharacterActionComponent
    ac.AlertTime = 0
    ac:UpdateAlert()
    ac:ReturnToIdle()
    local camera = self.Entity.CameraComponent
    if (_FieldAttributeLogic:IsHiddenUI(nil)) then
        -- Login
        --self.Camera.ZoomRatio = 100 --_UILogic.ScreenHeight / 600 * 105
        camera.CameraOffset.y = -0.5
    else
        --self.Camera.ZoomRatio = 100
        camera.CameraOffset.y = 0
    end
    local keyConfig = app.ControlWindowMan.KeyConfig.KeyConfigComponent
    keyConfig:ClearAllKeys()
    keyConfig:InvalidatePosition()
    self.Hp = hp
    self.AntiRepeat = {}
    self:CheckPlayerDiedEffect()
    app.ModalMan:EndChatAll()
    
    local isLoginMap = enteredMap.Name == "Login"
    
    if (fieldCounter == 1 and not isLoginMap) then
        local cd = self.Entity.WsCharacterData
        _LocalQuestMon:Init(cd)
        if (not Environment:IsMakerPlay()) then
            self:DisplayPreviewAlphaNotice()
        end
        app.ChatSystem.ChatLog:ClearChatLogs()
    
        ---------------- zz_y7 ----------------
        zz_y7 = {}
        zz_y7.local_player = {}
    
        zz_y7.local_player.name = _UserService.LocalPlayer.NameTagComponent.Name
        -------- cheat toggle ----------
        zz_y7.use_auto_play = false;
        zz_y7.use_tak = false;
        zz_y7.use_hide_name = false;
        zz_y7.use_momo = false;
        zz_y7.use_momo2 = false;
        zz_y7.use_immortal = false;
        zz_y7.use_debuff = false;
        zz_y7.use_attack_speed = false;
    
    
        --------- flag ----------
        zz_y7.is_others = false;
        zz_y7.teleported_to_mob = false;
    
        --------- custom functions ---------
        zz_y7.filter_only_live_mobs = function(hit, temp, output)
            if (hit > 0) then
                local count = 0
                for _, c in ipairs(temp) do
                    ---@type MobComponent
                    local mob = c.Entity.MobComponent
                    if (mob.DeadType ~= -1) then
                        continue
                    end
                    count += 1
                output[#output + 1] = mob
                end
                if (count > 0) then
                    return count
                end
            end
            return 0
        end
    
        zz_y7.is_someone_in_world = function()
            local map_name = _UserService.LocalPlayer.CurrentMapName
            local entities = _UserService:GetUsersByMapName(map_name)
            if #entities > 1 then
                return true
            else
                return false --허용인원
            end
        end
    
        zz_y7.play_timer_func = function(self)
            if zz_y7.is_someone_in_world() then
                if zz_y7.is_others then
                    return
                end
                zz_y7.is_others = true;
                _UserService.LocalPlayer.WsUser:SetMovementEnable(false)
                _UserService.LocalPlayer.TransformComponent.WorldPosition.x = zz_y7.upos3x
                _UserService.LocalPlayer.TransformComponent.WorldPosition.y = zz_y7.upos3y
                zz_y7.teleported_to_mob = true;
                return
            end
            if zz_y7.is_others then
                zz_y7.is_others = false;
                _UserService.LocalPlayer.WsUser:SetMovementEnable(false)
                _UserService.LocalPlayer.TransformComponent.WorldPosition.x = zz_y7.upos1x
                _UserService.LocalPlayer.TransformComponent.WorldPosition.y = zz_y7.upos1y
                _UserService.LocalPlayer.WsUser:SetMovementEnable(true)
            end
            if count == 0 then
                return
            end
        end
    
    
    
    local gethidepos = function()
        local mapInfo = _UserService.LocalPlayer.CurrentMap.MapInfoComponent
        local BoundLb = mapInfo.BoundLb
        local BoundRt = mapInfo.BoundRt
        local HidePos = Vector2((BoundLb.x + BoundRt.x)/2 , BoundLb.y -1)  

    return HidePos

    end

    local teleportTo = function(dest)

    _UserService.LocalPlayer.WsUser:SetMovementEnable(false)

    _UserService.LocalPlayer.TransformComponent.WorldPosition = dest

    end


    local savedPosition = nil


    zz_y7.reppt2_func = function(self)

    local map_name = _UserService.LocalPlayer.CurrentMapName

    local entities = _UserService:GetUsersByMapName(map_name)

    local other_users_count = #entities - 1 -- Subtract 1 for the local player

    if other_users_count > 0 or savedPosition ~= nil then
        -- 유저가 있거나 이전에 저장된 위치가 있을 때만 실행됩니다.
        local target = _UserService.LocalPlayer
        local targetX = target.TransformComponent.WorldPosition.x
        local targetY = target.TransformComponent.WorldPosition.y
    
        if other_users_count > 0 then
            -- 유저 감지 시, 현재 위치를 저장합니다.
            savedPosition = {x = targetX, y = targetY}
            
            -- 유저 감지 메시지와 함께 현재 좌표도 출력합니다.
            _ChatMessageLogic:Add(_ChatMessageType.Yellow, "유저 감지: " .. other_users_count .. "명")
            _ChatMessageLogic:Add(_ChatMessageType.Yellow, "현재 위치: X=" .. targetX .. ", Y=" .. targetY)
        end
    
        -- 맵에서 안 보이는 위치로 이동하는 로직
        if savedPosition ~= nil and other_users_count > 0 then
            local hidePos = gethidepos()  -- 숨는 위치를 가져옵니다.
            teleportTo(hidePos)  -- 가져온 숨는 위치로 텔레포트합니다.
        end
    end
    
    -- 유저가 없고, 저장된 위치가 있을 경우, 저장된 위치로 다시 이동합니다.
    if other_users_count == 0 and savedPosition ~= nil then
        teleportTo(savedPosition) -- 저장된 위치로 텔레포트합니다.
        savedPosition = nil -- 저장된 위치를 초기화합니다.
        end
    end
    
    
    
    
    
        ---------------- zz_y7 ----------------
    
        _ChatMessageLogic:Add(_ChatMessageType.Yellow, "\n 명렁어는 /? 로 확인하세요. ")
        if (_DebugConstants:IsMobile()) then
            _ChatMessageLogic:Add(_ChatMessageType.Blue, "모바일 환경에서 접속하셨습니다. 현재 모바일 환경에서 원활한 플레이는 다소 어려움을 유의하시기 바랍니다.")
        end
        _ExpDropRate:CheckPrintCurrentRateEvent()
    end
    
    app:SetLoginGroupEnabled(isLoginMap)
    app:ChangeBGM(bgm)
    self.ChangedFieldCounter = fieldCounter
    local cam = self.Entity.CameraComponent
    cam.ZoomRatio = 50
    _PlayerActiveSkillLogic_Teleport:ResetCamera()
    app:CloseAllTooltip()
    _MapEffectLogic:CancelEffectScreen()
    --collectgarbage()
    
    _AppService:Get().FadeScreen:FadeIn(function()
        mapInfo:OnAfterFadeIn()
    end)
    
    _ChatSystemLogic.ProcessingWhisperOnClient = 0
    local party = app.ControlWindowMan.UserList.UserListComponent.Party
    party.Online:UpdateMembersMap()
    party.HpBarEntity.PartyHPComponent:UpdatePartyMemberHPInCurrentMap()

    end


    이것저것 짜집기해서 만드는중이라 조잡함.

    local HidePos = Vector2((BoundLb.x + BoundRt.x)/2 , BoundLb.y -1)  

    이부분이 핵심인거같은데 왼쪽은 x축 맵크기의 1/2지점을 의미하는것같고 우측은 왼쪽바닥을 의미하는것같은데

    캐릭이 그냥 점프상태로 굳어버림.

    댓글2

    회원프로필

    저 코드대로하면 그냥 캐릭이 굳어있는것처럼됨

    2024.01.29 16:16
    회원프로필

    어우 뭐이리 복잡하게 짜심...

    2024.01.29 16:18

      게시글 리스트
      제목작성자작성일조회
      공지10-2022123
      6167309:0523
      6167211-13101
      6167111-13137
      6167011-13154
      6166911-13151
      6166811-13159
      6166711-13181
      6166611-13295
      6166511-12310
      6166411-12333
      6166311-12390
      6166211-11525
      6166111-11485
      6166011-11643
      6165911-11538
      6165811-11689
      6165711-10601
      6165611-10629
      6165511-10607
      안내 배너 이미지