require( "common" ) EVENT_DATA = { ---------------------- --[[ 1~ 40 ]] { --[[ÃÖ¼Ò·¹º§]] MinLev = 1, --[[ÃÖ´ë·¹º§]] MaxLev = 40, --[[ ¼Òȯ¸÷ ]] MobIndex = "E_CaCaoSlime", --[[°ø°Ý¸ð¼Ç]] AniIndex = "Slime_Attack1_1", --[[ Àå¼Ò ]] MapIndex = "RouCos02", --[[¼º°ø¸÷ê]] SucChat = "My favorite fruit! Raise some more and eat it later.", --[[½ÇÆи÷ê]] FailChat = "Well. That was nothing worth keeping.", }, --[[ 41~ 80 ]] { --[[ÃÖ¼Ò·¹º§]] MinLev = 41, --[[ÃÖ´ë·¹º§]] MaxLev = 80, --[[ ¼Òȯ¸÷ ]] MobIndex = "E_CaCaoPrisoner", --[[°ø°Ý¸ð¼Ç]] AniIndex = "Prisoner_Attack1_1", --[[ Àå¼Ò ]] MapIndex = "EldCem01", --[[¼º°ø¸÷ê]] SucChat = "What is this? Would it grow a Cacao fruit?", --[[½ÇÆи÷ê]] FailChat = "Hmm.. Well that was a failed attempt.", }, --[[ 81~115 ]] { --[[ÃÖ¼Ò·¹º§]] MinLev = 81, --[[ÃÖ´ë·¹º§]] MaxLev = 125, --[[ ¼Òȯ¸÷ ]] MobIndex = "E_CaCaoMineMole", --[[°ø°Ý¸ð¼Ç]] AniIndex = "Mole_attack", --[[ Àå¼Ò ]] MapIndex = "UrgFire01", --[[¼º°ø¸÷ê]] SucChat = "Wow, that's great. I was hungry. Raise it well.", --[[½ÇÆи÷ê]] FailChat = "Yuck! What flavor is this suppose to be?", }, } ---------------------- EVENT_FAIL_MAP = "ValenCaCao_UseFail_Map" EVENT_FAIL_ITEM = "ValenCaCao_UseFail_Item" EVENT_MOB_REGEN_DIST = 600 EVENT_MOB_STOP_INTERVAL = 40 EVENT_MOB_STOP_CHK_DIST = ((EVENT_MOB_STOP_INTERVAL + 10) * (EVENT_MOB_STOP_INTERVAL + 10)) EVENT_SUC_PERCENT = 50 EVENT_SUC_DROP_ITEM = "E_CacaoBean" EVENT_MOB_DEF_DEAD_TIME = 50 EVENT_MOB_END_DEAD_TIME = 5 MemBlock = {} function E_CacaoBud( Handle, MapIndex ) cExecCheck( "E_CacaoBud" ) if cIsObjectDead( Handle ) == 1 then cAIScriptSet( Handle ) MemBlock[Handle] = nil return ReturnAI["END"] end local Var = MemBlock[Handle] if Var ~= nil then -- ±âÁ¸ ¸¶½ºÅÍ ¹øÈ£¶û Áö±Ý ¹øÈ£¶û ´Ù¸£¸é ÃʱâÈ­ local CurMaster = cGetMaster( Handle ) if CurMaster == nil then cAIScriptSet( Handle ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil return ReturnAI["END"] end if Var["Master"] ~= CurMaster then MemBlock[Handle] = nil return ReturnAI["END"] end if cPlayerExist( Var["Master"] ) == nil then cAIScriptSet( Handle ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil return ReturnAI["END"] end end if Var == nil then MemBlock[Handle] = {} Var = MemBlock[Handle] Var["MapIndex"] = MapIndex Var["Handle"] = Handle -- ¸¶½ºÅÍ Ã¼Å© -- ½ÇÆнà ¸Þ½ÃÁö ´ë»ó ¾Ë±â À§ÇØ ¸¶½ºÅÍÇÚµéºÎÅÍ ±¸ÇÔ Var["Master"] = cGetMaster( Var["Handle"] ) if Var["Master"] == nil then cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil return ReturnAI["END"] end -- ¸Ê üũ for i = 1, #EVENT_DATA do if Var["MapIndex"] == EVENT_DATA[i]["MapIndex"] then Var["GroupNum"] = i break end end if Var["GroupNum"] == nil then cScriptMessage_Obj( Var["Master"], EVENT_FAIL_MAP ) cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil return ReturnAI["END"] end -- ¸¶½ºÅÍ ·¹º§ üũ local MasterLv = cGetLevel( Var["Master"] ) if MasterLv == nil then cScriptMessage_Obj( Var["Master"], EVENT_FAIL_ITEM ) cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil return ReturnAI["END"] end if MasterLv < EVENT_DATA[Var["GroupNum"]]["MinLev"] or MasterLv > EVENT_DATA[Var["GroupNum"]]["MaxLev"] then cScriptMessage_Obj( Var["Master"], EVENT_FAIL_MAP ) cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil return ReturnAI["END"] end -- ¼ÒȯµÈ Ä«Ä«¿À¾¾¾ÑÀÇ ÁÂÇ¥ -- ºÎÅÍ Æ¯Á¤ °Å¸®ÀÇ ·£´ý ¹æÇâÀÇ ÁÂÇ¥¸¦ ±¸ÇÏ°í -- ±× ÁÂÇ¥¿¡ À̺¥Æ®¸÷À» ¼ÒȯÇÏ°í -- Ä«Ä«¿À¾¾¾ÑÀ¸·Î À̺¥Æ®¸÷ À̵¿ local dir = cRandomInt( 1, 90 ) * 4 local locX, locY = cGetAroundCoord( Var["Handle"], dir, EVENT_MOB_REGEN_DIST ) if locX == nil or locY == nil then cScriptMessage_Obj( Var["Master"], EVENT_FAIL_ITEM ) cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil return ReturnAI["END"] end Var["EventMob"] = cMobRegen_XY( Var["MapIndex"], EVENT_DATA[Var["GroupNum"]]["MobIndex"], locX, locY, dir ) if Var["EventMob"] == nil then cScriptMessage_Obj( Var["Master"], EVENT_FAIL_ITEM ) cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil return ReturnAI["END"] end if cAIScriptSet( Var["EventMob"], Var["Handle"] ) == nil then cScriptMessage_Obj( Var["Master"], EVENT_FAIL_ITEM ) cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) cNPCVanish( Var["EventMob"] ) MemBlock[Handle] = nil return ReturnAI["END"] end if cAIScriptFunc( Var["EventMob"], "Entrance", "EventMobMain" ) == nil then cScriptMessage_Obj( Var["Master"], EVENT_FAIL_ITEM ) cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) cNPCVanish( Var["EventMob"] ) MemBlock[Handle] = nil return ReturnAI["END"] end MemBlock[Var["EventMob"]] = {} MemBlock[Var["EventMob"]]["DeadTime"] = cCurrentSecond() + EVENT_MOB_DEF_DEAD_TIME cFollow( Var["EventMob"], Var["Handle"], EVENT_MOB_STOP_INTERVAL, 10000 ) -- ÇÊ¿äÇÑ º¯¼ö ÃʱâÈ­ Var["ChkTime"] = cCurrentSecond() Var["EventStep"] = 1 Var["EventMobRegenX"] = locX Var["EventMobRegenY"] = locY end -- À̺¥Æ®¸÷ üũ if Var["EventMob"] == nil then cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil return ReturnAI["END"] end if cIsObjectDead( Var["EventMob"] ) == 1 then cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil return ReturnAI["END"] end local CurSec = cCurrentSecond() -- °Å¸® üũÇÏ¸ç ´ë±â if Var["EventStep"] == 1 then if Var["ChkTime"] <= CurSec then Var["ChkTime"] = CurSec + 1 if cDistanceSquar( Var["Handle"], Var["EventMob"] ) <= EVENT_MOB_STOP_CHK_DIST then cAnimate( Var["EventMob"], "start", EVENT_DATA[Var["GroupNum"]]["AniIndex"] ) Var["ChkTime"] = CurSec + 2 Var["EventStep"] = Var["EventStep"] + 1 end end -- ¼º°ø ½ÇÆРüũ elseif Var["EventStep"] == 2 then if Var["ChkTime"] <= CurSec then local rndNum = cRandomInt( 1, 100 ) if rndNum >= EVENT_SUC_PERCENT then -- ¼º°ø cNPCChatTest( Var["EventMob"], EVENT_DATA[Var["GroupNum"]]["SucChat"] ) cDropItem( EVENT_SUC_DROP_ITEM, Var["Handle"], Var["Master"], 1000000 ) else -- ½ÇÆÐ cNPCChatTest( Var["EventMob"], EVENT_DATA[Var["GroupNum"]]["FailChat"] ) end cAnimate( Var["EventMob"], "stop" ) Var["ChkTime"] = CurSec + 2 Var["EventStep"] = Var["EventStep"] + 1 end -- ¸÷ ¿øÀ§Ä¡, Á¾·á elseif Var["EventStep"] == 3 then if Var["ChkTime"] <= CurSec then cRunTo( Var["EventMob"], Var["EventMobRegenX"], Var["EventMobRegenY"] ) MemBlock[Var["EventMob"]]["DeadTime"] = CurSec + EVENT_MOB_END_DEAD_TIME cAIScriptSet( Var["Handle"] ) cNPCVanish( Var["Handle"] ) MemBlock[Handle] = nil end end return ReturnAI["END"] end -- À̺¥Æ®¸÷ ó¸® ÇÔ¼ö -- ¾Æ¹« ó¸® ¾ÈÇÏ°í DeadTimeÀÌ ¼³Á¤µÇ¸é DeadTime ÀÌÈÄ¿¡ Á¦°Å function EventMobMain( Handle, MapIndex ) cExecCheck( "EventMobMain" ) if cIsObjectDead( Handle ) == 1 then cAIScriptSet( Handle ) MemBlock[Handle] = nil return ReturnAI["END"] end local Var = MemBlock[Handle] if Var == nil then cAIScriptSet( Handle ) cNPCVanish( Handle ) MemBlock[Handle] = nil return ReturnAI["END"] end if Var["DeadTime"] ~= nil then if Var["DeadTime"] <= cCurrentSecond() then cAIScriptSet( Handle ) cNPCVanish( Handle ) MemBlock[Handle] = nil return ReturnAI["END"] end end return ReturnAI["END"] end