require( "common" ) require( "KQ/KDSpring/KDSpring_Data" ) require( "KQ/KDSpring/KDSpring_StepFunc" ) ------------------------------------------------------------------------------------------ -- Å·´ý Äù½ºÆ® µ¥ÀÌÅÍ ÃʱâÈ­ -- ------------------------------------------------------------------------------------------ function KF_INIT( Field, KSMemory, nCurSec ) cExecCheck "KF_INIT" if Field == nil then -- Çʵå À̸§ È®ÀÎ return end if KSMemory == nil then -- Å·´ý Äù½ºÆ® ¹öÆÛ È®ÀÎ return end if nCurSec == nil then -- ½Ã°£ È®ÀÎ return end -- Å·´ý Äù½ºÆ® ÇÊµå ½ºÅ©¸³Æ® ¼³Á¤ cSetFieldScript( Field, KQ_SCRIPT_NAME ) cFieldScriptFunc( Field, "MapLogin", "KF_MAP_LOGIN" ) -- ij¸¯ÅÍ ¸Ê·Î±×Àνà ȣÃâµÇ´Â ÇÔ¼ö ¼³Á¤ -- ÁøÇà Á¤º¸ ÃʱâÈ­ KSMemory["FIELD_NAME"] = Field KSMemory["WORK_TICK"] = 0 KSMemory["STEP_NO"] = 1 KSMemory["STEP_NEXT_TIME"] = nCurSec + KQ_STEP[1]["KS_NEXT_TIME"] KSMemory["MSG_NO"] = 1 KSMemory["MSG_NEXT_TIME"] = 1 KSMemory["GAME_TYPE"] = KQ_GAME_TYEP["KGT_NORMAL"] -- ±ê¹ß Á¤º¸ ÃʱâÈ­ KSMemory["FLAG_INFO"] = {} KSMemory["FLAG_INFO"]["FHND"] = KQ_INVALID_HANDLE KSMemory["FLAG_INFO"]["FINDEX"] = "" KSMemory["FLAG_INFO"]["FPHND"] = KQ_INVALID_HANDLE KSMemory["FLAG_INFO"]["FPICK_TIME"] = 0 KSMemory["FLAG_INFO"]["FREGEN_TIME"] = 0 KSMemory["FLAG_INFO"]["FREGEN_X"] = KQ_FLAG_POINT["KFP_X"] KSMemory["FLAG_INFO"]["FREGEN_Y"] = KQ_FLAG_POINT["KFP_Y"] -- Ç÷¹ÀÌ¾î ¸®½ºÆ® ÃʱâÈ­ KSMemory["PLAYER_LIST"] = {} -- KSMemory["PLAYER_LIST"][n] = {} -- KSMemory["PLAYER_LIST"][n]["PHND"] = KQ_INVALID_HANDLE -- KSMemory["PLAYER_LIST"][n]["PREG_NO"] = KQ_INVALID_HANDLE -- KSMemory["PLAYER_LIST"][n]["PNAME"] = "" -- KSMemory["PLAYER_LIST"][n]["PTEAM_NO"] = 0 -- KSMemory["PLAYER_LIST"][n]["PIS_MAP"] = false -- KSMemory["PLAYER_LIST"][n]["PPICK_TIME"] = 0 -- ÆÀ Á¤º¸ ÃʱâÈ­ KSMemory["TEAM_LIST"] = { { -- RED TEAM TSCORE = 0, TPOINT_HND = KQ_INVALID_HANDLE, TMEMBER_LIST = {}, }, { -- BLUE TEAM TSCORE = 0, TPOINT_HND = KQ_INVALID_HANDLE, TMEMBER_LIST = {}, }, } -- ¸ó½ºÅÍ Á¤º¸ KSMemory["MOB_LIST"] = {} -- KSMemory["MOB_LIST"][n] = {} -- KSMemory["MOB_LIST"][n]["MHND"] = KQ_INVALID_HANDLE -- KSMemory["MOB_LIST"][n]["MREGEN_TIME"] = 0 -- ¹® ¼Òȯ KSMemory["DOOR_LIST"] = {} for i = 1, #KQ_DOOR do KSMemory["DOOR_LIST"][i] = cDoorBuild( KSMemory["FIELD_NAME"], KQ_DOOR[i]["KD_INDEX"], KQ_DOOR[i]["KD_X"], KQ_DOOR[i]["KD_Y"], KQ_DOOR[i]["KD_DIR"], KQ_DOOR[i]["KD_SCALE"] ) cDoorAction( KSMemory["DOOR_LIST"][i], KQ_DOOR[i]["KD_BLOCK"], "open" ) end end ------------------------------------------------------------------------------------------ -- ¸Ê ·Î±×ÀÎ -- ------------------------------------------------------------------------------------------ function KF_MAP_LOGIN( Field, Handle ) cExecCheck "KF_MAP_LOGIN" local KSMemory = InstanceField[Field] -- Å·´ý Äù½ºÆ® ¹öÆÛ local nCurSec = cCurSec(); -- ÇöÀç ½Ã°£(ÃÊ) if KSMemory == nil then -- Å·´ý Äù½ºÆ® ¹öÆÛ È®ÀÎ return end if Handle == nil then -- Ç÷¹À̾î ÇÚµé È®ÀÎ return end if nCurSec == nil then -- ½Ã°£ È®ÀÎ nCurSec = 0 end local nAdminLevel = cGetAdminLevel( Handle ) -- ¿î¿µÀÚ ·¹º§ local nCharNo = cGetCharNo( Handle ) -- ij¸¯ÅÍ ¹øÈ£ local TeamInfo = KSMemory["TEAM_LIST"] -- Å·´ý Äù½ºÆ® ¹öÆÛ : ÆÀ Á¤º¸ if nAdminLevel > 0 then -- ¿î¿µÀÚ ·¹º§ È®ÀÎ if cAbstateRestTime( Handle, "StaGMHideMode" ) ~= nil then -- Hide »óÅ ȮÀÎ return end end if nCharNo == nil then -- ij¸¯ÅÍ ¹øÈ£ È®ÀÎ return end if TeamInfo == nil then -- ÆÀ Á¤º¸ È®ÀÎ return end local bLinkto = false -- ÆÀ À§Ä¡·Î À̵¿ local bNewPlayer = true -- »õ·Î µé¾î¿Â Ç÷¹À̾î local nPlayerNum = #KSMemory["PLAYER_LIST"] -- Âü¿© Ç÷¹ÀÌ¾î ¼ö local nPlayerIndex = nPlayerNum + 1 -- Ç÷¹ÀÌ¾î ¸ñ·Ï¿¡ »õ·Î Ãß°¡µÉ À妽º local nTeamNo = KQ_TEAM_NO["KTN_DEFAULT"] -- ÆÀ ¹øÈ£ for i = 1, nPlayerNum do -- Ç÷¹ÀÌ¾î ¸ñ·Ï Ž»ö if KSMemory["PLAYER_LIST"][i]["PREG_NO"] == nCharNo then -- Ç÷¹ÀÌ¾î ¸ñ·Ï¿¡ Á¸ÀçÇÏ´Â Ç÷¹À̾î bNewPlayer = false nPlayerIndex = i nTeamNo = KSMemory["PLAYER_LIST"][i]["PTEAM_NO"] if KSMemory["PLAYER_LIST"][i]["PHND"] ~= Handle then -- ¼­¹ö ÀçÁ¢¼ÓÀ¸·Î ÇÚµéÀÌ ¹Ù²ï Ç÷¹À̾î cAssertLog( "Handle Change" ) KSMemory["PLAYER_LIST"][i]["PHND"] = Handle for j = 1, #TeamInfo[nTeamNo] do -- ÆÀ ¸ñ·Ï Ž»ö if TeamInfo[nTeamNo]["TMEMBER_LIST"][j] == KSMemory["PLAYER_LIST"][i]["PHND"] then -- ÆÀ ¸â¹ö È®ÀÎ TeamInfo[nTeamNo]["TMEMBER_LIST"][j] = Handle end end end KSMemory["PLAYER_LIST"][i]["PPICK_TIME"] = nCurSec + KQ_PLAYER_PICK_DELAY -- ±ê¹ß ȹµæ °¡´É ½Ã°£ if KSMemory["PLAYER_LIST"][i]["PIS_MAP"] == false then -- Å·Äù ¾Û¿¡ ÀÖ¾ú´ÂÁö È®ÀÎ bLinkto = true KSMemory["PLAYER_LIST"][i]["PIS_MAP"] = true end break end end if bNewPlayer == true and -- »õ·Î µé¾î¿Â Ç÷¹À̾î nPlayerNum >= KQ_MAX_PLAYER -- Âü°¡ Ç÷¹À̾îÀÇ ¼ö then -- Âü°¡ Ç÷¹À̾î ÃÖ´ë ¼ö È®ÀÎ cLinkTo( Handle, KQ_RETURN_MAP["KRM_INDEX"], KQ_RETURN_MAP["KRM_X"],KQ_RETURN_MAP["KRM_Y"] ) return end if bNewPlayer == true then -- »õ·Î µé¾î¿Â Ç÷¹À̾î KSMemory["PLAYER_LIST"][nPlayerIndex] = {} KSMemory["PLAYER_LIST"][nPlayerIndex]["PHND"] = Handle -- ÇÚµé KSMemory["PLAYER_LIST"][nPlayerIndex]["PREG_NO"] = nCharNo -- ij¸¯ÅÍ ¹øÈ£ KSMemory["PLAYER_LIST"][nPlayerIndex]["PNAME"] = cGetPlayerName( Handle ) -- ij¸¯ÅÍ À̸§ KSMemory["PLAYER_LIST"][nPlayerIndex]["PTEAM_NO"] = KQ_TEAM_NO["KTN_DEFAULT"] -- ÆÀ ¹øÈ£ KSMemory["PLAYER_LIST"][nPlayerIndex]["PIS_MAP"] = true -- ¸Ê¿¡ Á¸ÀçÇÏ´ÂÁö KSMemory["PLAYER_LIST"][nPlayerIndex]["PPICK_TIME"] = nCurSec + KQ_PLAYER_PICK_DELAY -- ±ê¹ß ȹµæ °¡´É ½Ã°£ -- ÆÄƼ ÇØÁ¦ cPartyLeave( Handle ) end -- Á¡¼ö Á¤º¸ º¸³»±â cScoreInfo( Handle, #KQ_TEAM, TeamInfo[KQ_TEAM_NO["KTN_RED"]]["TSCORE"], TeamInfo[KQ_TEAM_NO["KTN_BLUE"]]["TSCORE"] ) -- ¸Ê ·Î±×Àνà »óÅÂÀÌ»ó °É±â cSetAbstate( Handle, KQ_MAPLOGIN_ABSTATE["KMA_INDEX"], KQ_MAPLOGIN_ABSTATE["KMA_STR"], KQ_MAPLOGIN_ABSTATE["KMA_KEEPTIME"] ) if nTeamNo == KQ_TEAM_NO["KTN_DEFAULT"] then -- ÆÀ ¹øÈ£ È®ÀÎ local RedMemberNum = #TeamInfo[KQ_TEAM_NO["KTN_RED"]]["TMEMBER_LIST"] local BlueMemberNum = #TeamInfo[KQ_TEAM_NO["KTN_BLUE"]]["TMEMBER_LIST"] if RedMemberNum > 0 or BlueMemberNum > 0 then -- ÆÀ ¹èÁ¤ ¿©ºÎ È®ÀÎ if cPermileRate( 500 ) == 1 then -- ·£´ýÇÏ°Ô ÆÀ ¹øÈ£ ¼³Á¤ nTeamNo = KQ_TEAM_NO["KTN_RED"] if RedMemberNum > BlueMemberNum then -- ·¹µåÆÀ ÀοøÀÌ ºí·çÆÀº¸´Ù ¸¹À» °æ¿ì nTeamNo = KQ_TEAM_NO["KTN_BLUE"] end else nTeamNo = KQ_TEAM_NO["KTN_BLUE"] if BlueMemberNum > RedMemberNum then -- ºí·çÆÀ ÀοøÀÌ ·¹µåÆÀº¸´Ù ¸¹À» °æ¿ì nTeamNo = KQ_TEAM_NO["KTN_RED"] end end local nIndex = (#TeamInfo[nTeamNo]["TMEMBER_LIST"] + 1) -- ÆÀ ¸â¹ö¿¡ Ãß°¡ TeamInfo[nTeamNo]["TMEMBER_LIST"][nIndex] = Handle KSMemory["PLAYER_LIST"][nPlayerIndex]["PTEAM_NO"] = nTeamNo -- ÆÄƼ Âü°¡ cPartyJoin( TeamInfo[nTeamNo]["TMEMBER_LIST"][1], Handle ) -- ÆÀ ½ÃÀÛÁ¡À¸·Î À̵¿ cLinkTo( Handle, KSMemory["FIELD_NAME"], KQ_TEAM[nTeamNo]["KT_POINT_X"], KQ_TEAM[nTeamNo]["KT_POINT_Y"] ) end return end if bLinkto == true and -- ÆÀ À§Ä¡·Î À̵¿ KQ_STEP[KSMemory["STEP_NO"]]["KS_LINKTO_TEAM"] == true -- ½ºÅÇ Á¤º¸ : ÆÀ À§Ä¡·Î À̵¿ then -- Ç÷¹À̾î ÆÀ À§Ä¡·Î À̵¿ cLinkTo( Handle, KSMemory["FIELD_NAME"], KQ_TEAM[nTeamNo]["KT_POINT_X"], KQ_TEAM[nTeamNo]["KT_POINT_Y"] ) return end for j = 1, #KQ_TEAM[nTeamNo]["KT_UNIFORM"] do -- ÆÀ À¯´ÏÆû ÀÔÈ÷±â cViewSlotEquip( Handle, KQ_TEAM[nTeamNo]["KT_UNIFORM"][j] ) end if KQ_STEP[KSMemory["STEP_NO"]]["KS_TIMER"] == true then -- ŸÀÌ¸Ó Ç¥½Ã ¿©ºÎ È®ÀÎ local nTime = (KSMemory["STEP_NEXT_TIME"] - nCurSec) cTimer_Obj( Handle, nTime ) end end ------------------------------------------------------------------------------------------ -- ¸Þ¼¼Áö Àü¼Û -- ------------------------------------------------------------------------------------------ function KF_MESSAGE( KSMemory, nCurSec ) cExecCheck "KF_MESSAGE" if KSMemory == nil then -- Å·´ý Äù½ºÆ® ¹öÆÛ È®ÀÎ return false end if nCurSec == nil then -- ½Ã°£ È®ÀÎ return false end if KQ_STEP[KSMemory["STEP_NO"]]["KS_MSG"] == nil then -- ÇØ´ç ½ºÅÇ ¸Þ½ÃÁö Á¤º¸ È®ÀÎ return true end if KSMemory["MSG_NEXT_TIME"] > nCurSec then -- ¸Þ½ÃÁö Ãâ·Â ½Ã°£ È®ÀÎ return true end local MsgData = KQ_MSG[KQ_STEP[KSMemory["STEP_NO"]]["KS_MSG"]] -- ¸Þ½ÃÁö Á¤º¸ local MsgStep = KSMemory["MSG_NO"] -- ¸Þ½ÃÁö ´Ü°è if MsgData == nil then -- ¸Þ½ÃÁö Á¤º¸ È®ÀÎ return false end if MsgStep == nil then -- ¸Þ½ÃÁö ´Ü°è È®ÀÎ return false end if #MsgData < MsgStep then --¸Þ½ÃÁö ´Ü°è ÃÖ´ëÄ¡ È®ÀÎ return true end if MsgData[MsgStep]["KM_TYPE"] == KQ_MSG_TYPE["KMT_SHN"] then -- ScriptMessage cScriptMessage( KSMemory["FIELD_NAME"], MsgData[MsgStep]["KM_INDEX"], MsgData[MsgStep]["KM_VAL"] ) elseif MsgData[MsgStep]["KM_TYPE"] == KQ_MSG_TYPE["KMT_TXT"] then -- Notice cNotice( KSMemory["FIELD_NAME"], MsgData[MsgStep]["KM_FILE_NAME"], MsgData[MsgStep]["KM_INDEX"] ) end -- ¸Þ½ÃÁö ´ÙÀ½ ´Ü°è ¼³Á¤ MsgStep = MsgStep + 1 if #MsgData < MsgStep then -- ¸ðµç ¸Þ½ÃÁö ó¸® KSMemory["MSG_NO"] = 1 KSMemory["MSG_NEXT_TIME"] = KSMemory["STEP_NEXT_TIME"] else -- ´ÙÀ½ ´Ü°è ¼³Á¤ KSMemory["MSG_NO"] = MsgStep KSMemory["MSG_NEXT_TIME"] = nCurSec + MsgData[MsgStep]["KM_TIME"] end end ------------------------------------------------------------------------------------------ -- ±ê¹ß ¿ÀºêÁ§Æ® ·çƾ -- ------------------------------------------------------------------------------------------ function KF_FLGAG_OBJECT( Handle, Field ) cExecCheck "KF_FLGAG_OBJECT" local KSMemory = InstanceField[Field] -- Å·´ý Äù½ºÆ® ¹öÆÛ local nCurSec = cCurSec() -- ÇöÀç ½Ã°£(ÃÊ) if KSMemory == nil then -- Å·´ý Äù½ºÆ® ¹öÆÛ È®ÀÎ return ReturnAI.END end if KSMemory["FLAG_INFO"] == nil then -- Å·´ý Äù½ºÆ® ¹öÆÛ : ±ê¹ß Á¤º¸ È®ÀÎ return ReturnAI.END end if KSMemory["FLAG_INFO"]["FPHND"] ~= KQ_INVALID_HANDLE then -- Å·´ý Äù½ºÆ® ¹öÆÛ : ´©±º°¡ ±ê¹ßÀ» °¡Áö°í ÀÖÀ» °æ¿ì cNPCVanish( Handle ) return ReturnAI.END end if KSMemory["PLAYER_LIST"] == nil then -- Å·´ý Äù½ºÆ® ¹öÆÛ : Ç÷¹À̾î Á¤º¸ È®ÀÎ return ReturnAI.END end if nCurSec == nil then -- ½Ã°£ º¯¼ö È®ÀÎ return ReturnAI.END end if nCurSec < KSMemory["FLAG_INFO"]["FPICK_TIME"] then -- ½Ã°£ È®ÀÎ return ReturnAI.END end local nCheckDist = KQ_FLAG["KF_CHECK_DIST"] -- ±ê¹ß üũ °Å¸®(±âº» ±ê¹ß ¿ÀºêÁ§Æ® °Å¸®) if KSMemory["FLAG_INFO"]["FINDEX"] == KQ_FLAG_POINT["KFP_INDEX"] then -- ±ê¹ß Á¾·ù È®ÀÎ ( ±ê¹ß ¿ÀºêÁ§Æ®, ±ê¹ß Æ÷ÀÎÆ® ¿ÀºêÁ§Æ® ) nCheckDist = KQ_FLAG_POINT["KFP_CHECK_DIST"] end -- ±ê¹ß üũ °Å¸® ¾È¿¡ ÀÖ´Â Ç÷¹ÀÌ¾î ¸®½ºÆ® °¡Á®¿À±â local PlayerList = { cNearObjectList( Handle, nCheckDist, ObjectType["Player"] ) } for i = 1, #PlayerList do for j = 1, #KSMemory["PLAYER_LIST"] do if KSMemory["PLAYER_LIST"][j]["PHND"] == PlayerList[i] and -- ÇÚµé KSMemory["PLAYER_LIST"][j]["PTEAM_NO"] ~= KQ_TEAM_NO["KTN_DEFAULT"] and -- ÆÀ ¹øÈ£ KSMemory["PLAYER_LIST"][j]["PPICK_TIME"] <= nCurSec -- ±ê¹ß ȹµæ°¡´É ½Ã°£ then -- ±ê¹ß ȹµæ °¡´É ÃÊ°Ç È®ÀÎ -- ±ê¹ß Á¤º¸ ¼³Á¤ KSMemory["FLAG_INFO"]["FHND"] = KQ_INVALID_HANDLE -- ±ê¹ß ÇÚµé KSMemory["FLAG_INFO"]["FPHND"] = PlayerList[i] -- ±ê¹ß ȹµæ Ç÷¹À̾î ÇÚµé -- ±ê¹ß »óÅÂÀÌ»ó °É±â for k = 1, #KQ_FLAG_ABSTATE do cSetAbstate( KSMemory["FLAG_INFO"]["FPHND"], KQ_FLAG_ABSTATE[k]["KFA_INDEX"], KQ_FLAG_ABSTATE[k]["KFA_STR"], KQ_FLAG_ABSTATE[k]["KFA_KEEPTIME"] ) end -- ±ê¹ß ȹµæ ¾Ë¸² cScriptMessage( KSMemory["FIELD_NAME"], KQ_FLAG_SCRIPT_MSG["KFSM_HAVE"], KSMemory["PLAYER_LIST"][j]["PNAME"] ) -- ¸®Á¨ Æ÷ÀÎÆ® »ý¼º local nTeamNo = KSMemory["PLAYER_LIST"][j]["PTEAM_NO"] if nTeamNo ~= nil then -- ÆÀ ¹øÈ£ È®ÀÎ if KSMemory["TEAM_LIST"][nTeamNo]["TPOINT_HND"] == KQ_INVALID_HANDLE then -- ¸®Á¨ Æ÷ÀÎÆ® ÇÚµå È®ÀÎ KSMemory["TEAM_LIST"][nTeamNo]["TPOINT_HND"] = cMobRegen_XY( Field, KQ_TEAM[nTeamNo]["KT_POINT_INDEX"], KQ_TEAM[nTeamNo]["KT_POINT_X"], KQ_TEAM[nTeamNo]["KT_POINT_Y"], 0 ) end for k = 1, #KSMemory["TEAM_LIST"][nTeamNo]["TMEMBER_LIST"] do cPlaySound( KSMemory["TEAM_LIST"][nTeamNo]["TMEMBER_LIST"][k], KQ_SOUND["KS_GETFLAG"] ); end end -- ±ê¹ß »èÁ¦ cNPCVanish( Handle ) return ReturnAI.END end end end return ReturnAI.END end ------------------------------------------------------------------------------------------ -- ¸ÞÀÎ ÇÔ¼ö -- ------------------------------------------------------------------------------------------ function Main( Field ) cExecCheck "Main" local nCurSec = cCurSec() -- ÇöÀç ½Ã°£(ÃÊ) local KSMemory = InstanceField[Field] -- Å·´ý Äù½ºÆ® ¹öÆÛ if KSMemory == nil then -- Å·´ý Äù½ºÆ® ¹öÆÛ È®ÀÎ -- Å·´ý Äù½ºÆ® ¹öÆÛ ÃʱâÈ­ InstanceField[Field] = {} KSMemory = InstanceField[Field] KF_INIT( Field, KSMemory, nCurSec ) end if KSMemory["STEP_NO"] == nil then -- ó¸® ´Ü°è È®ÀÎ return end if KQ_STEP[KSMemory["STEP_NO"]]["KS_FUNC"]( KSMemory, nCurSec ) == false then -- ½ºÅÇ ÇÔ¼ö ½ÇÇà ½ÇÆÐ cLinkToAll( KSMemory["FIELD_NAME"], KQ_RETURN_MAP["KRM_INDEX"], KQ_RETURN_MAP["KRM_X"], KQ_RETURN_MAP["KRM_Y"] ) cEndOfKingdomQuest( KSMemory["FIELD_NAME"] ) end end