require( "common" ) ---------------------------------------------------------------------------------------------------- -- ÇÒ·ÎÀ© À̺¥Æ® µ¥ÀÌÅÍ ---------------------------------------------------------------------------------------------------- -- ÇÒ·ÎÀ© À̺¥Æ® ¸Ê Á¢¼Ó Á¤º¸ EVENT_MAP_DATA = { -- À̵¿ÇÒ À̺¥Æ® ¸Ê Á¤º¸ EMD_INDEX = "E_Hwin", EMD_REGEN_X = 914, EMD_REGEN_Y = 238, -- À̺¥Æ® ¸Ê Á¢¼Ó Á¶°Ç EMD_ENTRY_CONDITION = { "StaE_Slime", "StaE_Honeying", "StaE_Phino", "StaE_LizardMan", "StaE_KingCrab", "StaE_SparkDog", "StaE_LavaVivi", "StaE_PhinoFlie", "StaE_MushRoom", "StaE_Spider", "StaE_B_CrackerHumar", "StaE_Helga", "StaE_JackO", "StaE_Kebing", "StaE_ForasChief", "StaE_Zombie", "StaE_MaraCrew", "StaE_MaraElite", "StaE_MaraSailor", "StaE_Psyken", "StaE_PsykenDog", "StaE_Megan", "StaE_Yeti", "StaE_Imp", "StaE_Robo", "StaE_Hob", "StaE_Pinky", "StaE_WarH_Devildom", "StaE_ArkNovice", "StaE_ArkTech", "StaE_Mandragora", "StaE_S_Hayreddin", "StaE_Mara", } } -- À̺¥Æ® °ÔÀÌÆ® ¿¡·¯ ¸Þ½ÃÁö EVENT_ERROR_NOTICE = { EEN_FILENAME = "Event", EEN_INDEX = "SystemMsg_01", } -- ¸Ê À̵¿ ¼­¹ö¸Þ´º Á¤º¸ SERVER_MENU_DATA = { -- ŸÀÌƲ SMD_TITLE = { TITLE_SCRIPT_FILENAME = "MenuString", TITLE_INDEX = "LinkTitle", TITLE_STRING = nil }, -- ¹öÆ° SMD_BT_YES = { BT_SCRIPT_FILENAME = "ETC", BT_INDEX = "Yes", BT_STRING = nil, BT_FUNC = "Click_Yes" }, SMD_BT_NO = { BT_SCRIPT_FILENAME = "ETC", BT_INDEX = "No", BT_STRING = nil, BT_FUNC = "Click_No" } } -- ·Î¹Ö¿ë ¸ó½ºÅÍ Á¤º¸ ROAMING_MOB_DATA = { RMD_CHECK_INTERVAL = 0.1, { RMD_INDEX = "E_HwinPhino", RMD_X = 13881, RMD_Y = 13411, RMG_REGEN_INTERVAL = 10 }, -- 1 { RMD_INDEX = "E_HwinFlie", RMD_X = 13815, RMD_Y = 13411, RMG_REGEN_INTERVAL = 10 }, -- 2 } -- ·Î¹Ö Á¤º¸ ROAMING_PATTERN_DATA = { RPD_CHECK_INTERVAL = 0.1, -- µµÂøÁöÁ¡ È®ÀÎ ½Ã°£ °£°Ý RPD_GOAL_INTERVAL = 10, -- µµÂøÁöÁ¡°úÀÇ Ã¼Å© °Å¸® -- À̵¿ ÁÂÇ¥ { { X = 13881, Y = 13411 }, { X = 14915, Y = 13396 }, { X = 13881, Y = 13411 }, }, -- 1 { { X = 13815, Y = 13411 }, { X = 14721, Y = 13404 }, { X = 13815, Y = 13411 }, }, -- 2 } -- ¸ó½ºÅÍ Ã¤Æà Á¤º¸ MOB_CHAT_DATA = { E_HwinPhino = { MCD_CHAT_INTERVAL = 10, MCD_SCRIPT_FILE = "Event", "E_HwinPhino_Chat01", "E_HwinPhino_Chat02", }, E_HwinFlie = { MCD_CHAT_INTERVAL = 10, MCD_SCRIPT_FILE = "Event", "E_HwinFlie_Chat01", "E_HwinFlie_Chat02", }, } ---------------------------------------------------------------------------------------------------- -- ÇÒ·ÎÀ© À̺¥Æ® Àü¿ª º¯¼ö ---------------------------------------------------------------------------------------------------- -- À̺¥Æ® °ÔÀÌÆ® ¿ë ¹öÆÛ EventGateBuf = {} --[[ EventGateBuf[ Handle ]["RoamingMobChackTime"] = ·Î¹Ö ¸ó½ºÅÍ È®ÀÎ ½Ã°£ EventGateBuf[ Handle ]["RoamingMobList"] = ·Î¹Ö ¸ó½ºÅÍ ¸®½ºÆ® EventGateBuf[ Handle ]["RoamingMobList"][ i ]["MobHandle"] = ·Î¹Ö ¸ó½ºÅÍ ÇÚµé EventGateBuf[ Handle ]["RoamingMobList"][ i ]["RegenTime"] = ·Î¹Ö ¸ó½ºÅÍ ¸®Á¨ ½Ã°£ --]] -- ·Î¹Ö ¸ó½ºÅÍ ¿ë ¹öÆÛ RoamingMobBuf = {} --[[ RoamingMobBuf[ Handle ]["ChatData"] = ¸ó½ºÅÍ Ã¤Æà Á¤º¸ RoamingMobBuf[ Handle ]["ChatTime"] = ¸ó½ºÅÍ Ã¤Æà ½Ã°£ RoamingMobBuf[ Handle ]["ChatStep"] = ¸ó½ºÅÍ Ã¤Æà ½ºÅÇ RoamingMobBuf[ Handle ]["MovePattern"] = À̵¿ ÆÐÅÏ Á¤º¸ RoamingMobBuf[ Handle ]["MoveBack"] = À̵¿ ÆÐÅÏ µ¹¾Æ°¡±â RoamingMobBuf[ Handle ]["MoveStep"] = À̵¿ ÆÐÅÏ ´Ü°è RoamingMobBuf[ Handle ]["MoveCheckTime"] = À̵¿ ÆÐÅÏ È®ÀÎ ½Ã°£ --]] ---------------------------------------------------------------------------------------------------- -- ÇÒ·ÎÀ© À̺¥Æ® ÇÔ¼ö ---------------------------------------------------------------------------------------------------- -- °ÔÀÌÆ® ±âº»ÇÔ¼ö function E_HwinIn( Handle, MapIndex ) cExecCheck "E_HwinIn" local CurSec = cCurrentSecond() -- °ÔÀÌÆ® ÃʱâÈ­ if EventGateBuf[ Handle ] == nil then EventGateBuf[ Handle ] = {} EventGateBuf[ Handle ]["RoamingMobChackTime"] = CurSec EventGateBuf[ Handle ]["RoamingMobList"] = {} cAIScriptFunc( Handle, "NPCClick", "EventGateClick" ) cSetObjectDirect( Handle, 0 ) -- ¼­¹ö¸Þ´º¿¡¼­ »ç¿ëÇÒ ¹®ÀÚ¿­ °¡Á®¿À±â if SERVER_MENU_DATA["SMD_TITLE"]["TITLE_STRING"] == nil then local MapName = cGetMapName( EVENT_MAP_DATA["EMD_INDEX"] ) SERVER_MENU_DATA["SMD_TITLE"]["TITLE_STRING"] = cGetScriptString( SERVER_MENU_DATA["SMD_TITLE"]["TITLE_SCRIPT_FILENAME"], SERVER_MENU_DATA["SMD_TITLE"]["TITLE_INDEX"], MapName ) SERVER_MENU_DATA["SMD_BT_YES"]["BT_STRING"] = cGetScriptString( SERVER_MENU_DATA["SMD_BT_YES"]["BT_SCRIPT_FILENAME"], SERVER_MENU_DATA["SMD_BT_YES"]["BT_INDEX"] ) SERVER_MENU_DATA["SMD_BT_NO"]["BT_STRING"] = cGetScriptString( SERVER_MENU_DATA["SMD_BT_NO"]["BT_SCRIPT_FILENAME"], SERVER_MENU_DATA["SMD_BT_NO"]["BT_INDEX"] ) end -- ·Î¹Ö ¸ó½ºÅÍ ¼Òȯ for i = 1, #ROAMING_MOB_DATA do local dataRoamingMob = ROAMING_MOB_DATA[ i ] local MobHandle = cMobRegen_XY( MapIndex, dataRoamingMob["RMD_INDEX"], dataRoamingMob["RMD_X"], dataRoamingMob["RMD_Y"], 0 ) if MobHandle ~= nil then cAIScriptSet( MobHandle, Handle ) cAIScriptFunc( MobHandle, "Entrance", "RoamingMobRoutine" ) cResetAbstate( MobHandle, "StaImmortal" ) RoamingMobBuf[ MobHandle ] = {} RoamingMobBuf[ MobHandle ]["ChatData"] = MOB_CHAT_DATA[ dataRoamingMob["RMD_INDEX"] ] RoamingMobBuf[ MobHandle ]["ChatTime"] = CurSec RoamingMobBuf[ MobHandle ]["ChatStep"] = 1 RoamingMobBuf[ MobHandle ]["MovePattern"] = ROAMING_PATTERN_DATA[ i ] RoamingMobBuf[ MobHandle ]["MoveBack"] = false RoamingMobBuf[ MobHandle ]["MoveStep"] = 1 RoamingMobBuf[ MobHandle ]["MoveCheckTime"] = CurSec EventGateBuf[ Handle ]["RoamingMobList"][ i ] = {} EventGateBuf[ Handle ]["RoamingMobList"][ i ]["MobHandle"] = MobHandle EventGateBuf[ Handle ]["RoamingMobList"][ i ]["RegenTime"] = 0 cWalkTo( MobHandle, ROAMING_PATTERN_DATA[ i ][ 1 ]["X"], ROAMING_PATTERN_DATA[ i ][ 1 ]["Y"], 500 ) else cAssertLog( "Init - RoamingMob regen fail "..i ) end end end -- °ÔÀÌÆ® Á×À¸¸é ½ºÅ©¸³Æ® ÇØÁ¦ if cIsObjectDead( Handle ) ~= nil then for i = 1, #EventGateBuf[ Handle ]["RoamingMobList"] do local MobHandle = EventGateBuf[ Handle ]["RoamingMobList"][ i ]["MobHandle"] RoamingMobBuf[ MobHandle ] = nil cAIScriptSet( MobHandle ) cNPCVanish( MobHandle ) end EventGateBuf[ Handle ] = nil cAIScriptSet( Handle ) return ReturnAI["END"] end -- ·Î¹Ö ¸ó½ºÅÍ È®ÀÎ if EventGateBuf[ Handle ]["RoamingMobChackTime"] <= CurSec then local RoamingMobList = EventGateBuf[ Handle ]["RoamingMobList"] for i = 1, #RoamingMobList do if RoamingMobList[ i ]["RegenTime"] == 0 -- ¸®Á¨ ½Ã°£ÀÌ ¼³Á¤¾ÈµÈ °æ¿ì then -- ·Î¹Ö ¸ó½ºÅÍ°¡ Á×¾úÀ¸¸é ¸®Á¨ ½Ã°£ ¼³Á¤ if cIsObjectDead( RoamingMobList[ i ]["MobHandle"] ) ~= nil then RoamingMobList[ i ]["RegenTime"] = CurSec + ROAMING_MOB_DATA[ i ]["RMG_REGEN_INTERVAL"] end elseif RoamingMobList[ i ]["RegenTime"] <= CurSec -- ¸®Á¨ ½Ã°£ È®ÀÎ then -- ·Î¹Ö ¸ó½ºÅÍ ¼Òȯ local dataRoamingMob = ROAMING_MOB_DATA[ i ] local MobHandle = cMobRegen_XY( MapIndex, dataRoamingMob["RMD_INDEX"], dataRoamingMob["RMD_X"], dataRoamingMob["RMD_Y"], 0 ) if MobHandle ~= nil then cAIScriptSet( MobHandle, Handle ) cAIScriptFunc( MobHandle, "Entrance", "RoamingMobRoutine" ) cResetAbstate( MobHandle, "StaImmortal" ) RoamingMobBuf[ MobHandle ] = {} RoamingMobBuf[ MobHandle ]["ChatData"] = MOB_CHAT_DATA[ dataRoamingMob["RMD_INDEX"] ] RoamingMobBuf[ MobHandle ]["ChatTime"] = CurSec RoamingMobBuf[ MobHandle ]["ChatStep"] = 1 RoamingMobBuf[ MobHandle ]["MovePattern"] = ROAMING_PATTERN_DATA[ i ] RoamingMobBuf[ MobHandle ]["MoveBack"] = false RoamingMobBuf[ MobHandle ]["MoveStep"] = 1 RoamingMobBuf[ MobHandle ]["MoveCheckTime"] = CurSec RoamingMobList[ i ]["MobHandle"] = MobHandle RoamingMobList[ i ]["RegenTime"] = 0 else cAssertLog( "Init - RoamingMob regen fail "..i ) end end end end return ReturnAI["END"] end -- °ÔÀÌÆ® Ŭ¸¯ function EventGateClick( NPCHandle, PlyHandle, PlyCharNo ) cExecCheck "EventGateClick" -- ÀÔÀå Á¶°Ç È®ÀÎ local dataEntryCondition = EVENT_MAP_DATA[ "EMD_ENTRY_CONDITION" ] for i = 1, #dataEntryCondition do if cAbstateRestTime( PlyHandle, dataEntryCondition[ i ] ) ~= nil then cServerMenu( PlyHandle, NPCHandle, SERVER_MENU_DATA["SMD_TITLE"]["TITLE_STRING"], SERVER_MENU_DATA["SMD_BT_YES"]["BT_STRING"], SERVER_MENU_DATA["SMD_BT_YES"]["BT_FUNC"], SERVER_MENU_DATA["SMD_BT_NO"]["BT_STRING"], SERVER_MENU_DATA["SMD_BT_NO"]["BT_FUNC"] ) return end end -- ÀÔÀå Á¶°ÇÀ» ÃæÁ·ÇÏÁö ¸øÇßÀ» °æ¿ì local MapIndex = cGetCurMapIndex( NPCHandle ) if MapIndex ~= nil then cNotice_Obj( PlyHandle, EVENT_ERROR_NOTICE["EEN_FILENAME"], EVENT_ERROR_NOTICE["EEN_INDEX"] ) end end -- ¿¹ Ŭ¸¯( À̺¥Æ® ¸Ê ÀÔÀå ) function Click_Yes( NPCHandle, PlyHandle, PlyCharNo ) cExecCheck "Click_Yes" -- ÀÔÀå Á¶°Ç È®ÀÎ local dataEntryCondition = EVENT_MAP_DATA[ "EMD_ENTRY_CONDITION" ] for i = 1, #dataEntryCondition do if cAbstateRestTime( PlyHandle, dataEntryCondition[ i ] ) ~= nil then cLinkTo( PlyHandle, EVENT_MAP_DATA["EMD_INDEX"], EVENT_MAP_DATA["EMD_REGEN_X"], EVENT_MAP_DATA["EMD_REGEN_Y"] ) return end end -- ÀÔÀå Á¶°ÇÀ» ÃæÁ·ÇÏÁö ¸øÇßÀ» °æ¿ì local MapIndex = cGetCurMapIndex( NPCHandle ) if MapIndex ~= nil then cNotice_Obj( PlyHandle, EVENT_ERROR_NOTICE["EEN_FILENAME"], EVENT_ERROR_NOTICE["EEN_INDEX"] ) end end -- ¾Æ´Ï¿À Ŭ¸¯ function Click_No( NPCHandle, PlyHandle, PlyCharNo ) cExecCheck "Click_No" end -- ·Î¹Ö ¸ó½ºÅÍ ±âº» ÇÔ¼ö function RoamingMobRoutine( Handle, MapIndex ) cExecCheck "RoamingMobRoutine" local CurSec = cCurrentSecond() -- ÇÔÁ¤ »ì¾Æ ÀÖ´ÂÁö È®ÀÎ if cIsObjectDead( Handle ) ~= nil then RoamingMobBuf[ Handle ] = nil cAIScriptSet( Handle ) return ReturnAI["END"] end -- ÇÔÁ¤ ¹öÆÛ È®ÀÎ local infoMobBuf = RoamingMobBuf[ Handle ] if infoMobBuf == nil then RoamingMobBuf[ Handle ] = nil cAIScriptSet( Handle ) cNPCVanish( Handle ) return ReturnAI["END"] end -- ÇÔÁ¤ Á¤º¸ È®ÀÎ if infoMobBuf["ChatData"] == nil -- ±âº» Á¤º¸ then cAssertLog( "Mob ChatData nil" ) RoamingMobBuf[ Handle ] = nil cAIScriptSet( Handle ) cNPCVanish( Handle ) return ReturnAI["END"] end -- ¸ó½ºÅÍ Ã¤Æà if infoMobBuf["ChatTime"] <= CurSec then if infoMobBuf["ChatStep"] > #infoMobBuf["ChatData"] then infoMobBuf["ChatStep"] = 1 end cMobChat( Handle, infoMobBuf["ChatData"]["MCD_SCRIPT_FILE"], infoMobBuf["ChatData"][ infoMobBuf["ChatStep"] ], false ) infoMobBuf["ChatStep"] = infoMobBuf["ChatStep"] + 1 infoMobBuf["ChatTime"] = CurSec + infoMobBuf["ChatData"]["MCD_CHAT_INTERVAL"] end -- À̵¿ if infoMobBuf["MoveCheckTime"] <= CurSec then local MoveStep = infoMobBuf["MoveStep"] local GoalInterval = ROAMING_PATTERN_DATA["RPD_GOAL_INTERVAL"] * ROAMING_PATTERN_DATA["RPD_GOAL_INTERVAL"] local CurLocate_X, CurLocate_Y = cObjectLocate( Handle ) local MaxMovePattern = #infoMobBuf["MovePattern"] if cDistanceSquar( CurLocate_X, CurLocate_Y, infoMobBuf["MovePattern"][ MoveStep ]["X"], infoMobBuf["MovePattern"][ MoveStep ]["Y"] ) < GoalInterval then -- À̵¿ ´Ü°è °è»ê if infoMobBuf["MoveBack"] == false then MoveStep = MoveStep + 1 if MoveStep > MaxMovePattern then MoveStep = MaxMovePattern - 1 infoMobBuf["MoveBack"] = true end else MoveStep = MoveStep - 1 if MoveStep < 1 then MoveStep = 2 infoMobBuf["MoveBack"] = false end end cWalkTo( Handle, infoMobBuf["MovePattern"][ MoveStep ]["X"], infoMobBuf["MovePattern"][ MoveStep ]["Y"], 500 ) infoMobBuf["MoveStep"] = MoveStep else local AggroListSize = cAggroListSize( Handle ) if AggroListSize <= 0 then --if cGetMoveState( Handle ) == 0 local MoveState, MoveStateTime, MoveStateSetTime = cGetMoveState( Handle ) if MoveState == 0 then cWalkTo( Handle, infoMobBuf["MovePattern"][ MoveStep ]["X"], infoMobBuf["MovePattern"][ MoveStep ]["Y"], 500 ) end end end infoMobBuf["MoveCheckTime"] = CurSec + ROAMING_PATTERN_DATA["RPD_CHECK_INTERVAL"] end return ReturnAI["CPP"] end