You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SigFiesta/LuaScript/ID/WarNH/WarNHRoutine.lua

518 lines
10 KiB

--[[***** *****]]--
--[[***** <EFBFBD><EFBFBD><EFBFBD≯<EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ƾ *****]]--
--[[***** : HP<EFBFBD><EFBFBD>ȭ<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ִϸ<EFBFBD><EFBFBD>̼ǰ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̻<EFBFBD><EFBFBD><EFBFBD> ó<EFBFBD><EFBFBD> *****]]--
--[[***** *****]]--
function FriendMobRoutine( Handle, MapIndex )
cExecCheck( "FriendMobRoutine" )
if InstanceField[MapIndex] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
if InstanceField[MapIndex]["Guardian"] == nil then
if InstanceField[MapIndex]["Airi"] == Handle then
InstanceField[MapIndex]["Airi"] = nil
end
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
local Var = InstanceField[MapIndex]["Guardian"][Handle]
if Var == nil then
if InstanceField[MapIndex]["Airi"] == Handle then
InstanceField[MapIndex]["Airi"] = nil
end
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
if cIsObjectDead( Handle ) then
if InstanceField[MapIndex]["Airi"] == Handle then
InstanceField[MapIndex]["Airi"] = nil
end
cAIScriptSet( Handle )
InstanceField[MapIndex]["Guardian"][Handle] = nil
return ReturnAI["END"]
end
if Var["State"] == FM_STATE["Stop"] then
return ReturnAI["END"]
end
local CurSec = cCurrentSecond()
if Var["CheckTime"] + MOB_CHK_DELAY > CurSec then
return
end
Var["CheckTime"] = CurSec
local CurHP, MaxHP = cObjectHP( Var["Handle"] )
local HPRate = (CurHP * 1000) / MaxHP
if Var["Data"]["InjuryHPRate"] > HPRate then
if Var["State"] == FM_STATE["Normal"] then
Var["State"] = FM_STATE["Injury"]
cSetAbstate( Var["Handle"], STA_IMMORTAL, 1, 20000000 )
cAnimate( Var["Handle"], "start", Var["Data"]["InjuryAniIndex"] )
end
else
if Var["State"] == FM_STATE["Injury"] then
Var["State"] = FM_STATE["Normal"]
cResetAbstate( Var["Handle"], STA_IMMORTAL )
cAnimate( Var["Handle"], "stop" )
end
end
local rtn = ReturnAI["CPP"]
if Var["State"] == FM_STATE["Injury"] then
rtn = ReturnAI["END"]
end
return rtn
end
--[[***** *****]]--
--[[***** <EFBFBD>Ϲ<EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ƾ *****]]--
--[[***** : <EFBFBD><EFBFBD>ȯ<EFBFBD><EFBFBD> <EFBFBD>Ϲ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>׾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> üũ *****]]--
--[[***** *****]]--
function NormalMobRoutine( Handle, MapIndex )
cExecCheck( "NormalMobRoutine" )
if InstanceField[MapIndex] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
if InstanceField[MapIndex]["NormalMobList"] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
local Var = InstanceField[MapIndex]["NormalMobList"][Handle]
if Var == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
if cIsObjectDead( Handle ) then
cAIScriptSet( Handle )
InstanceField[MapIndex]["NormalMobList"][Handle] = nil
return ReturnAI["END"]
end
return ReturnAI["CPP"]
end
--[[***** *****]]--
--[[***** <EFBFBD>Ӽ<EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ƾ *****]]--
--[[***** : <EFBFBD><EFBFBD>ȯ<EFBFBD><EFBFBD> <EFBFBD>Ӽ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>׾<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> üũ, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ȯó<EFBFBD><EFBFBD> *****]]--
--[[***** *****]]--
function ElementMobRoutine( Handle, MapIndex )
cExecCheck( "ElementMobRoutine" )
if InstanceField[MapIndex] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
if InstanceField[MapIndex]["ElementMobList"] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
local Var = InstanceField[MapIndex]["ElementMobList"][Handle]
if Var == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
if cIsObjectDead( Handle ) then
cAIScriptSet( Handle )
InstanceField[MapIndex]["ElementMobList"][Handle] = nil
return ReturnAI["END"]
end
if Var["SummonStep"] ~= nil then
if Var["SummonStep"] > 0 then
local CurSec = cCurrentSecond()
if Var["CheckTime"] + MOB_CHK_DELAY <= CurSec then
Var["CheckTime"] = CurSec
local CurHP, MaxHP = cObjectHP( Var["Handle"] )
local HPRate = (CurHP * 1000) / MaxHP
if HPRate < BossSummonElite[Var["SummonStep"]]["HPRate"] then
local CenterCoord = {}
CenterCoord["x"], CenterCoord["y"] = cObjectLocate( Var["Handle"] )
local MobNum = 0
if Var["Grade"] == E_MOB_GRADE["Boss"] then
MobNum = BossSummonElite[Var["SummonStep"]]["EliteNum"]
else
-- ġ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ȯ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>ܰ<EFBFBD> <EFBFBD><EFBFBD>ȯ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŭ<EFBFBD><EFBFBD>
MobNum = BossSummonElite[#BossSummonElite]["EliteNum"]
end
for i=1, MobNum do
local RegenMob = {}
RegenMob["Handle"] = cMobRegen_Circle( MapIndex, Var["SummonIndex"],
CenterCoord["x"],
CenterCoord["y"],
BossSummonElite[Var["SummonStep"]]["Range"] )
if RegenMob["Handle"] ~= nil then
RegenMob["CheckTime"] = CurSec
RegenMob["Grade"] = E_MOB_GRADE["Elite"]
cSetAIScript( SCRIPT_MAIN, RegenMob["Handle"] )
cAIScriptFunc( RegenMob["Handle"], "Entrance", "ElementMobRoutine" )
InstanceField[MapIndex]["ElementMobList"][RegenMob["Handle"]] = RegenMob
end
end
Var["SummonStep"] = Var["SummonStep"] - 1
end
end
end
end
return ReturnAI["CPP"]
end
--[[***** *****]]--
--[[***** <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ƾ *****]]--
--[[***** : <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HP ȸ<EFBFBD><EFBFBD><EFBFBD>ؼ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> *****]]--
--[[***** *****]]--
function OreRoutine( Handle, MapIndex )
cExecCheck( "OreRoutine" )
if InstanceField[MapIndex] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
if InstanceField[MapIndex]["OreList"] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
local Var = InstanceField[MapIndex]["OreList"][Handle]
if Var == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
if cIsObjectDead( Handle ) then
cAIScriptSet( Handle )
InstanceField[MapIndex]["OreList"][Handle] = nil
return ReturnAI["END"]
end
local CurSec = cCurrentSecond()
if Var["CheckTime"] + MOB_CHK_DELAY > CurSec then
return ReturnAI["END"]
end
Var["CheckTime"] = CurSec
local CurHP, MaxHP = cObjectHP( Var["Handle"] )
cHeal( Var["Handle"], MaxHP )
return ReturnAI["END"]
end
--[[***** *****]]--
--[[***** <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>ƾ *****]]--
--[[***** : <EFBFBD>̵<EFBFBD>, <EFBFBD><EFBFBD>ų<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ó<EFBFBD><EFBFBD> *****]]--
--[[***** *****]]--
function TrapMobRoutine( Handle, MapIndex )
cExecCheck( "TrapMobRoutine" )
if InstanceField[MapIndex] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
if InstanceField[MapIndex]["TrapMobList"] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
local Var = InstanceField[MapIndex]["TrapMobList"][Handle]
if Var == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
return ReturnAI["END"]
end
if cIsObjectDead( Handle ) then
cAIScriptSet( Handle )
InstanceField[MapIndex]["TrapMobList"][Handle] = nil
return ReturnAI["END"]
end
local CurSec = cCurrentSecond()
-- <EFBFBD>̵<EFBFBD> ó<EFBFBD><EFBFBD>
if Var["CheckTime"] + MOB_CHK_DELAY <= CurSec then
local CurCoord = {}
local GoalCoord = Var["PatrolPath"][Var["CurGoal"]]
CurCoord["x"], CurCoord["y"] = cObjectLocate( Var["Handle"] )
if cDistanceSquar( CurCoord["x"], CurCoord["y"], GoalCoord["x"], GoalCoord["y"] ) < (TRAP_GOAL_INTERVAL * TRAP_GOAL_INTERVAL) then
Var["CurGoal"] = Var["CurGoal"] + 1
if Var["CurGoal"] > #Var["PatrolPath"] then
Var["CurGoal"] = 1
end
cRunTo( Var["Handle"], Var["PatrolPath"][Var["CurGoal"]]["x"], Var["PatrolPath"][Var["CurGoal"]]["y"] )
end
Var["CheckTime"] = CurSec
end
-- <EFBFBD><EFBFBD>ų <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if Var["DelayTime"] + Var["Data"]["Interval"] <= CurSec then
if cSkillBlast( Var["Handle"], Var["Handle"], Var["Data"]["SkillIndex"] ) ~= nil then
-- <EFBFBD><EFBFBD>ų <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>üũ<EFBFBD><EFBFBD> <EFBFBD>ð<EFBFBD> <EFBFBD><EFBFBD><EFBFBD>
Var["DelayTime"] = CurSec
end
end
return ReturnAI["END"]
end
--[[***** *****]]--
--[[***** <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ <EFBFBD><EFBFBD>ƾ *****]]--
--[[***** : <EFBFBD>ƹ<EFBFBD> ó<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> *****]]--
--[[***** *****]]--
GateMapIndex = {} -- <EFBFBD><EFBFBD><EFBFBD>Ǿ<EFBFBD>Ŭ<EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ʾ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD>ε<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
function GateRoutine( Handle, MapIndex )
cExecCheck( "GateRoutine" )
if InstanceField[MapIndex] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
GateMapIndex[Handle] = nil
return ReturnAI["END"]
end
if InstanceField[MapIndex]["ExitGateList"] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
GateMapIndex[Handle] = nil
return ReturnAI["END"]
end
if InstanceField[MapIndex]["ExitGateList"][Handle] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
GateMapIndex[Handle] = nil
return ReturnAI["END"]
end
if cIsObjectDead( Handle ) then
cAIScriptSet( Handle )
InstanceField[MapIndex]["ExitGateList"][Handle] = nil
GateMapIndex[Handle] = nil
return ReturnAI["END"]
end
if GateMapIndex[Handle] == nil then
cAIScriptSet( Handle )
cNPCVanish( Handle )
InstanceField[MapIndex]["ExitGateList"][Handle] = nil
return ReturnAI["END"]
end
return ReturnAI["END"]
end
function GateClick( NPCHandle, PlyHandle, RegistNumber )
cExecCheck( "GateClick" )
local MapIndex = GateMapIndex[NPCHandle]
if MapIndex == nil then
return
end
if InstanceField[MapIndex] == nil then
return
end
if InstanceField[MapIndex]["ExitGateList"] == nil then
return
end
local Var = InstanceField[MapIndex]["ExitGateList"][NPCHandle]
if Var == nil then
return
end
cServerMenu( PlyHandle, NPCHandle, GateMenu["Title"],
GateMenu["Yes"], "LinkToVillage",
GateMenu["No"], "GateDummy")
end
function LinkToVillage( NPCHandle, PlyHandle, RegistNumber )
cExecCheck( "LinkToVillage" )
local MapIndex = GateMapIndex[NPCHandle]
if MapIndex == nil then
return
end
if InstanceField[MapIndex] == nil then
return
end
if InstanceField[MapIndex]["ExitGateList"] == nil then
return
end
local Var = InstanceField[MapIndex]["ExitGateList"][NPCHandle]
if Var == nil then
return
end
cLinkTo( PlyHandle, Var["Data"]["Field"], Var["Data"]["x"], Var["Data"]["y"] )
end
function GateDummy( NPCHandle, PlyHandle, RegistNumber )
end