593 lines
15 KiB
Lua
Raw Normal View History

2023-06-26 04:40:53 -07:00
--------------------------------------------------------------------------------
-- <20><> InitDungeon
--------------------------------------------------------------------------------
function InitDungeon( Var )
cExecCheck "InitDungeon"
if Var == nil
then
return
end
-- <20>ν<EFBFBD><CEBD>Ͻ<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20>÷<EFBFBD><C3B7>̾<EFBFBD><CCBE><EFBFBD> ù <20>α<EFBFBD><CEB1><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ٸ<EFBFBD><D9B8><EFBFBD>.
if Var["bPlayerMapLogin"] == nil
then
if Var["InitialSec"] + WAIT_PLAYER_MAP_LOGIN_SEC_MAX <= cCurrentSecond()
then
return
end
return
end
if Var["InitDungeon"] == nil
then
DebugLog( "Start InitDungeon" )
Var["InitDungeon"] = {}
-- <20><> <20><><EFBFBD><EFBFBD>
if Var["Door"] ~= nil
then
-- <20><> <20><><EFBFBD><EFBFBD>1)
if Var["Door"]["GoToKingCrab"] == nil
then
Var["Door"]["GoToKingCrab"] = {}
local CurRegenDoor = RegenInfo["Stuff"]["Door"]["GoToKingCrab"]
if CurRegenDoor == nil
then
ErrorLog( "InitDungeon::Door CurRegenDoor == nil..GoToKingCrab" )
end
local nCurDoorHandle = cDoorBuild( Var["MapIndex"], CurRegenDoor["Index"], CurRegenDoor["x"], CurRegenDoor["y"], CurRegenDoor["dir"], CurRegenDoor["scale"] )
if nCurDoorHandle == nil
then
ErrorLog( "InitDungeon::Door was not created. : GoToKingCrab" )
else
cDoorAction( nCurDoorHandle, CurRegenDoor["DoorBlock"], "close" )
-- <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
Var["Door"]["GoToKingCrab"]["Handle"] = nCurDoorHandle
Var["Door"]["GoToKingCrab"]["DoorBlock"] = CurRegenDoor["DoorBlock"]
Var["Door"]["GoToKingCrab"]["IsOpen"] = false
end
end
-- <20><> <20><><EFBFBD><EFBFBD>2)
if Var["Door"]["GoToLeviathan"] == nil
then
Var["Door"]["GoToLeviathan"] = {}
local CurRegenDoor = RegenInfo["Stuff"]["Door"]["GoToLeviathan"]
if CurRegenDoor == nil
then
ErrorLog( "InitDungeon::Door CurRegenDoor == nil..GoToLeviathan" )
end
local nCurDoorHandle = cDoorBuild( Var["MapIndex"], CurRegenDoor["Index"], CurRegenDoor["x"], CurRegenDoor["y"], CurRegenDoor["dir"], CurRegenDoor["scale"] )
if nCurDoorHandle == nil
then
ErrorLog( "InitDungeon::Door was not created. : GoToLeviathan" )
else
cDoorAction( nCurDoorHandle, CurRegenDoor["DoorBlock"], "close" )
-- <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
Var["Door"]["GoToLeviathan"]["Handle"] = nCurDoorHandle
Var["Door"]["GoToLeviathan"]["DoorBlock"] = CurRegenDoor["DoorBlock"]
Var["Door"]["GoToLeviathan"]["IsOpen"] = false
end
end
end
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>׷캰 <20><><EFBFBD><EFBFBD>
local RegenMobGroupList = RegenInfo["Mob"]["InitDungeon"]["NormalMobGroup"]
if RegenMobGroupList ~= nil
then
for i = 1,#RegenMobGroupList
do
cGroupRegenInstance( Var["MapIndex"], RegenMobGroupList[ i ] )
end
end
-- <20>Ա<EFBFBD><D4B1><EFBFBD> <20><EFBFBD><E2B1B8><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
local RegenExitGate = RegenInfo["Stuff"]["StartExitGate"]
local nExitGateHandle = cDoorBuild( Var["MapIndex"], RegenExitGate["Index"], RegenExitGate["x"], RegenExitGate["y"], RegenExitGate["dir"], RegenExitGate["scale"] )
if nExitGateHandle ~= nil
then
if cSetAIScript ( MainLuaScriptPath, nExitGateHandle ) == nil
then
ErrorLog( "InitDungeon::cSetAIScript ( MainLuaScriptPath, nExitGateHandle ) == nil" )
end
if cAIScriptFunc( nExitGateHandle, "NPCClick", "Click_ExitGate" ) == nil
then
ErrorLog( "InitDungeon::cAIScriptFunc( nExitGateHandle, \"NPCClick\", \"Click_ExitGate\" ) == nil" )
end
end
end
if Var["InitDungeon"] ~= nil
then
Var["InitDungeon"] = nil
Var["StepFunc"] = KingBoogyStep
DebugLog( "End InitDungeon" )
return
end
end
--------------------------------------------------------------------------------
-- <20><> KingBoogyStep
--------------------------------------------------------------------------------
function KingBoogyStep( Var )
cExecCheck "KingBoogyStep"
if Var == nil
then
return
end
if Var["KingBoogyStep"] == nil
then
Var["KingBoogyStep"] = {}
DebugLog( "Start KingBoogyStep" )
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
local CurRegenInfo = RegenInfo["Mob"]["KingBoogyStep"]["Boss"]
local CurHandle = cMobRegen_XY( Var["MapIndex"], CurRegenInfo["Index"], CurRegenInfo["x"], CurRegenInfo["y"], CurRegenInfo["dir"] )
if CurHandle == nil
then
ErrorLog("KingBoogyStep::BossMob Regen Fail")
return
end
if cSetAIScript ( MainLuaScriptPath, CurHandle ) == nil
then
ErrorLog( "KingBoogyStep::cSetAIScript ( MainLuaScriptPath, CurHandle ) == nil" )
end
if cAIScriptFunc( CurHandle, "Entrance", "Routine_BossLive" ) == nil
then
ErrorLog( "KingBoogyStep::cAIScriptFunc( CurHandle, \"Entrance\", \"Routine_BossLive\" ) == nil" )
end
if cAIScriptFunc( CurHandle, "ObjectDied", "Routine_BossDead" ) == nil
then
ErrorLog( "KingBoogyStep::cAIScriptFunc( CurHandle, \"ObjectDied\", \"Routine_BossDead\" ) == nil" )
end
Var["Boss"][CurHandle] = {}
Var["Boss"][CurHandle]["Index"] = CurRegenInfo["Index"]
Var["Boss"][CurHandle]["Door"] = Var["Door"]["GoToKingCrab"]
Var["RoutineTime"][CurHandle] = Var["CurSec"]
-- <20><><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD> <20><><EFBFBD><EFBFBD>
Var["KingBoogyStep"]["DialogTime"] = Var["InitialSec"] + DelayTime["AfterInit"]
Var["KingBoogyStep"]["DialogStep"] = 1
end
if Var["KingBoogyStep"] ~= nil
then
-- <20><><EFBFBD><EFBFBD>ó<EFBFBD><C3B3>
if Var["KingBoogyStep"]["DialogTime"] ~= nil
then
if Var["KingBoogyStep"]["DialogTime"] > Var["CurSec"]
then
return
else
local CurMsg = ChatInfo["KingBoogyStep"]["Start"]
local DialogStep = Var["KingBoogyStep"]["DialogStep"]
local MaxDialogStep = #ChatInfo["KingBoogyStep"]["Start"]
if DialogStep <= MaxDialogStep
then
cScriptMessage( Var["MapIndex"], CurMsg[DialogStep]["Index"] )
Var["KingBoogyStep"]["DialogTime"] = Var["CurSec"] + DelayTime["GapDialog"]
Var["KingBoogyStep"]["DialogStep"] = DialogStep + 1
return
end
if Var["KingBoogyStep"]["DialogStep"] > MaxDialogStep
then
Var["KingBoogyStep"]["DialogTime"] = nil
Var["KingBoogyStep"]["DialogStep"] = nil
end
end
end
-- <20><><EFBFBD><EFBFBD> <20>ܰ<EFBFBD><DCB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD> üũ
if Var["Door"]["GoToKingCrab"] ~= nil
then
local CurDoor = Var["Door"]["GoToKingCrab"]
if CurDoor["IsOpen"] == false
then
return
end
if CurDoor["IsOpen"] == true
then
cDoorAction( CurDoor["Handle"], CurDoor["DoorBlock"], "open" )
Var["KingBoogyStep"] = nil
Var["StepFunc"] = KingCrabStep
DebugLog( "End KingBoogyStep" )
return
end
end
end
end
--------------------------------------------------------------------------------
-- <20><> KingCrabStep
--------------------------------------------------------------------------------
function KingCrabStep( Var )
cExecCheck "KingCrabStep"
if Var["KingCrabStep"] == nil
then
Var["KingCrabStep"] = {}
DebugLog( "Start KingCrabStep" )
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
local CurRegenInfo = RegenInfo["Mob"]["KingCrabStep"]["Boss"]
local CurHandle = cMobRegen_XY( Var["MapIndex"], CurRegenInfo["Index"], CurRegenInfo["x"], CurRegenInfo["y"], CurRegenInfo["dir"] )
if CurHandle == nil
then
ErrorLog("KingCrabStep::BossMob Regen Fail")
return
end
if cSetAIScript ( MainLuaScriptPath, CurHandle ) == nil
then
ErrorLog( "KingCrabStep::cSetAIScript ( MainLuaScriptPath, CurHandle ) == nil" )
end
if cAIScriptFunc( CurHandle, "Entrance", "Routine_BossLive" ) == nil
then
ErrorLog( "KingCrabStep::cAIScriptFunc( CurHandle, \"Entrance\", \"Routine_BossLive\" ) == nil" )
end
if cAIScriptFunc( CurHandle, "ObjectDied", "Routine_BossDead" ) == nil
then
ErrorLog( "KingCrabStep::cAIScriptFunc( CurHandle, \"ObjectDied\", \"Routine_BossDead\" ) == nil" )
end
Var["Boss"][CurHandle] = {}
Var["Boss"][CurHandle]["Index"] = CurRegenInfo["Index"]
Var["Boss"][CurHandle]["Door"] = Var["Door"]["GoToLeviathan"]
Var["RoutineTime"][CurHandle] = Var["CurSec"]
-- <20><><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD> <20><><EFBFBD><EFBFBD>
Var["KingCrabStep"]["DialogTime"] = Var["CurSec"]
Var["KingCrabStep"]["DialogStep"] = 1
end
if Var["KingCrabStep"] ~= nil
then
-- <20><><EFBFBD><EFBFBD>ó<EFBFBD><C3B3>
if Var["KingCrabStep"]["DialogTime"] ~= nil
then
if Var["KingCrabStep"]["DialogTime"] > Var["CurSec"]
then
return
else
local CurMsg = ChatInfo["KingCrabStep"]["AfterKingBoogyDead"]
local DialogStep = Var["KingCrabStep"]["DialogStep"]
local MaxDialogStep = #ChatInfo["KingCrabStep"]["AfterKingBoogyDead"]
if DialogStep <= MaxDialogStep
then
cScriptMessage( Var["MapIndex"], CurMsg[DialogStep]["Index"] )
Var["KingCrabStep"]["DialogTime"] = Var["CurSec"] + DelayTime["GapDialog"]
Var["KingCrabStep"]["DialogStep"] = DialogStep + 1
return
end
if Var["KingCrabStep"]["DialogStep"] > MaxDialogStep
then
Var["KingCrabStep"]["DialogTime"] = nil
Var["KingCrabStep"]["DialogStep"] = nil
end
end
end
-- <20><><EFBFBD><EFBFBD> <20>ܰ<EFBFBD><DCB0><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD>ȴ<EFBFBD><C8B4><EFBFBD> üũ
if Var["Door"]["GoToLeviathan"] ~= nil
then
local CurDoor = Var["Door"]["GoToLeviathan"]
if CurDoor["IsOpen"] == false
then
return
end
if CurDoor["IsOpen"] == true
then
cDoorAction( CurDoor["Handle"], CurDoor["DoorBlock"], "open" )
Var["KingCrabStep"] = nil
Var["StepFunc"] = LeviathanStep
DebugLog( "End KingCrabStep" )
return
end
end
end
end
--------------------------------------------------------------------------------
-- <20><> LeviathanStep
--------------------------------------------------------------------------------
function LeviathanStep( Var )
cExecCheck "LeviathanStep"
if Var["LeviathanStep"] == nil
then
Var["LeviathanStep"] = {}
DebugLog( "Start LeviathanStep" )
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź ( BossMain )<29><><EFBFBD><EFBFBD>
local CurRegenInfo = RegenInfo["Mob"]["LeviathanStep"]["BossMain"]
local CurHandle = cMobRegen_XY( Var["MapIndex"], CurRegenInfo["Index"], CurRegenInfo["x"], CurRegenInfo["y"], CurRegenInfo["dir"] )
if CurHandle == nil
then
ErrorLog("LeviathanStep::BossMain Regen Fail")
return
end
if cSetAIScript ( MainLuaScriptPath, CurHandle ) == nil
then
ErrorLog( "LeviathanStep::cSetAIScript ( MainLuaScriptPath, CurHandle ) == nil" )
end
if cAIScriptFunc( CurHandle, "Entrance", "Routine_Leviathan" ) == nil
then
ErrorLog( "LeviathanStep::cAIScriptFunc( CurHandle, \"Entrance\", \"Routine_Leviathan\" ) == nil" )
end
Var["LeviathanStep"]["BossMain"] = {}
Var["LeviathanStep"]["BossMain"]["Handle"] = CurHandle
Var["RoutineTime"][ CurHandle ] = Var["CurSec"]
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź ( BossHead )<29><><EFBFBD><EFBFBD>
local CurRegenInfo = RegenInfo["Mob"]["LeviathanStep"]["BossHead"]
local CurHandle = cMobRegen_XY( Var["MapIndex"], CurRegenInfo["Index"], CurRegenInfo["x"], CurRegenInfo["y"], CurRegenInfo["dir"] )
if CurHandle == nil
then
ErrorLog("LeviathanStep::BossHead Regen Fail")
return
end
if cSetAIScript ( MainLuaScriptPath, CurHandle ) == nil
then
ErrorLog( "LeviathanStep::cSetAIScript ( MainLuaScriptPath, CurHandle ) == nil" )
end
if cAIScriptFunc( CurHandle, "Entrance", "Routine_Leviathan" ) == nil
then
ErrorLog( "LeviathanStep::cAIScriptFunc( CurHandle, \"Entrance\", \"Routine_Leviathan\" ) == nil" )
end
Var["LeviathanStep"]["BossHead"] = {}
Var["LeviathanStep"]["BossHead"]["Handle"] = CurHandle
Var["RoutineTime"][ CurHandle ] = Var["CurSec"]
-- <20><><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD> <20><><EFBFBD><EFBFBD>
Var["LeviathanStep"]["DialogTime"] = Var["CurSec"]
Var["LeviathanStep"]["DialogStep"] = 1
end
if Var["LeviathanStep"] ~= nil
then
-- <20><><EFBFBD><EFBFBD>ó<EFBFBD><C3B3>
if Var["LeviathanStep"]["DialogTime"] ~= nil
then
if Var["LeviathanStep"]["DialogTime"] > Var["CurSec"]
then
return
else
local CurMsg = ChatInfo["LeviathanStep"]["AfterKingCrabDead"]
local DialogStep = Var["LeviathanStep"]["DialogStep"]
local MaxDialogStep = #ChatInfo["LeviathanStep"]["AfterKingCrabDead"]
if DialogStep <= MaxDialogStep
then
cScriptMessage( Var["MapIndex"], CurMsg[DialogStep]["Index"] )
Var["LeviathanStep"]["DialogTime"] = Var["CurSec"] + DelayTime["GapDialog"]
Var["LeviathanStep"]["DialogStep"] = DialogStep + 1
return
end
if Var["LeviathanStep"]["DialogStep"] > MaxDialogStep
then
Var["LeviathanStep"]["DialogTime"] = nil
Var["LeviathanStep"]["DialogStep"] = nil
end
end
end
-- BossMain <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
if cIsObjectDead( Var["LeviathanStep"]["BossMain"]["Handle"] ) == nil
then
return
end
-- BossMain <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź<EFBFBD><C5BA> <20>׾<EFBFBD><D7BE><EFBFBD><EFBFBD><EFBFBD> ReturnToHome
if cIsObjectDead( Var["LeviathanStep"]["BossMain"]["Handle"] ) == 1
then
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ź <20>Ӹ<EFBFBD><D3B8><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD>δ<EFBFBD>.
if cIsObjectDead( Var["LeviathanStep"]["BossHead"]["Handle"] ) == nil
then
DebugLog("LeviathanStep::BossMain Dead, So Kill BossHead Too...")
cAIScriptSet( Var["LeviathanStep"]["BossHead"]["Handle"] )
cMobSuicide( Var["MapIndex"], Var["LeviathanStep"]["BossHead"]["Handle"] )
end
Var["LeviathanStep"] = nil
Var["StepFunc"] = ReturnToHome
DebugLog( "End LeviathanStep" )
return
end
end
end
--------------------------------------------------------------------------------
-- <20><> ReturnToHome
--------------------------------------------------------------------------------
function ReturnToHome( Var )
cExecCheck "ReturnToHome"
if Var == nil
then
return
end
if Var["ReturnToHome"] == nil
then
Var["ReturnToHome"] = {}
DebugLog( "Start ReturnToHome" )
-- <20><EFBFBD><E2B1B8><EFBFBD><EFBFBD>Ʈ <20><><EFBFBD><EFBFBD>
local RegenExitGate = RegenInfo["Stuff"]["EndExitGate"]
local nExitGateHandle = cDoorBuild( Var["MapIndex"], RegenExitGate["Index"], RegenExitGate["x"], RegenExitGate["y"], RegenExitGate["dir"], RegenExitGate["scale"] )
if nExitGateHandle ~= nil
then
if cSetAIScript ( MainLuaScriptPath, nExitGateHandle ) == nil
then
ErrorLog( "ReturnToHome::cSetAIScript ( MainLuaScriptPath, nExitGateHandle ) == nil" )
end
if cAIScriptFunc( nExitGateHandle, "NPCClick", "Click_ExitGate" ) == nil
then
ErrorLog( "ReturnToHome::cAIScriptFunc( nExitGateHandle, \"NPCClick\", \"Click_ExitGate\" ) == nil" )
end
end
-- <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ ó<><C3B3>
cQuestMobKill_AllInMap( Var["MapIndex"], QuestMobKillInfo["QuestID"], QuestMobKillInfo["MobIndex"], QuestMobKillInfo["MaxKillCount"] )
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>) <20><><EFBFBD><EFBFBD>
local RewardBox = RegenInfo["Stuff"]["RewardBox"]
local CurSummonHandle = cMobRegen_XY( Var["MapIndex"], RewardBox["Index"], RewardBox["x"], RewardBox["y"], RewardBox["dir"] )
if CurSummonHandle == nil
then
ErrorLog( "ReturnToHome::RewardBox Regen Fail" )
end
-- <20><><EFBFBD><EFBFBD> <20><><EFBFBD>̱<EFBFBD>( <20><>, <20><> )
local vanishMOb = LeviathanSkillInfo["Vanish_WhenLeviDead"]
for i = 1, #vanishMOb
do
cVanishAll( Var["MapIndex"], vanishMOb[i] )
end
-- <20><><EFBFBD><EFBFBD><EFBFBD>ð<EFBFBD> <20><><EFBFBD><EFBFBD>
Var["ReturnToHome"]["DialogTime"] = Var["CurSec"]
Var["ReturnToHome"]["DialogStep"] = 1
end
if Var["ReturnToHome"] ~= nil
then
-- <20><><EFBFBD><EFBFBD>ó<EFBFBD><C3B3>
if Var["ReturnToHome"]["DialogTime"] ~= nil
then
if Var["ReturnToHome"]["DialogTime"] > Var["CurSec"]
then
return
else
local CurMsg = ChatInfo["ReturnToHome"]["AfterLeviDead"]
local DialogStep = Var["ReturnToHome"]["DialogStep"]
local MaxDialogStep = #ChatInfo["ReturnToHome"]["AfterLeviDead"]
if DialogStep <= MaxDialogStep
then
cScriptMessage( Var["MapIndex"], CurMsg[DialogStep]["Index"] )
Var["ReturnToHome"]["DialogTime"] = Var["CurSec"] + DelayTime["GapDialog"]
Var["ReturnToHome"]["DialogStep"] = DialogStep + 1
return
end
if Var["ReturnToHome"]["DialogStep"] > MaxDialogStep
then
Var["ReturnToHome"]["DialogTime"] = nil
Var["ReturnToHome"]["DialogStep"] = nil
end
end
end
Var["ReturnToHome"] = nil
Var["StepFunc"] = DummyFunc
DebugLog( "End ReturnToHome" )
return
end
end