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.

163 lines
3.7 KiB

--------------------------------------------------------------------------------
-- Pet Routine Main File --
--------------------------------------------------------------------------------
require( "common" )
require( "PetSystem/SubFunc" )
require( "PetSystem/PetCommon" ) -- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> SubFunc <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
require( "PetSystem/PetBaseActionData" )
require( "PetSystem/PetBaseSubFunc" )
require( "PetSystem/PetBaseSettingFunc" )
require( "PetSystem/PetBaseIdleActionFunc" )
require( "PetSystem/PetBaseRoutineFunc" )
function PetBase( nHandle, sMapIndex )
cExecCheck( "PetBase" )
return PetBaseMain( nHandle, sMapIndex )
end
function PetBaseMain( nHandle, sMapIndex )
cExecCheck( "PetBaseMain" )
-- <EFBFBD>޸<EFBFBD><EFBFBD><EFBFBD> Ȯ<EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD>ʱ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if gPetAIMemory == nil
then
gPetAIMemory = {}
DebugLog( "PetBaseMain::Initialized - gPetAIMemory" )
end
if gPetAIMemory["PetBase"] == nil
then
gPetAIMemory["PetBase"] = {}
DebugLog( "PetBaseMain::Initialized - gPetAIMemory[\"PetBase\"]" )
end
local nInvalidHandle = 65535
if nHandle == nil or nHandle == nInvalidHandle
then
DebugLog( "PetBaseMain::nHandle is nil or invalid" )
return ReturnAI["END"]
end
if sMapIndex == nil
then
DebugLog( "PetBaseMain::sMapIndex is nil" )
return ReturnAI["END"]
end
local PetMem = gPetAIMemory["PetBase"][ nHandle ]
if PetMem == nil
then
DebugLog( "PetBaseMain::Initialized Start - gPetAIMemory[\"PetBase\"]["..nHandle.."]" )
-- <EFBFBD>޸𸮰<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̹Ƿ<EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>Ѵ<EFBFBD>.
gPetAIMemory["PetBase"][ nHandle ] = {}
PetMem = gPetAIMemory["PetBase"][ nHandle ]
if PetBaseInit( PetMem, nHandle, sMapIndex ) == false
then
ErrorLog( "PetBaseMain::PetBaseInit Failed : "..nHandle.." "..sMapIndex )
gPetAIMemory["PetBase"][ nHandle ] = nil
cAIScriptSet( nHandle )
return ReturnAI["END"]
end
DebugLog( "PetBaseMain::Initialized End - gPetAIMemory[\"PetBase\"]["..nHandle.."]" )
PetMem["Func"] = PetBaseRoutine
else
-- <EFBFBD><EFBFBD>ƾ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if PetMem["CurSec"] + 0.2 > cCurrentSecond()
then
return
else
PetMem["CurSec"] = cCurrentSecond()
end
-- DebugLog( "PetBaseMain::Check & Update Start - gPetAIMemory[\"PetBase\"]["..nHandle.."]" )
-- <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>.
local bReset = false
local sReason = ""
local nMasterHandle = -1
local nMasterRegNum = -1
if bReset == false
then
nMasterHandle = cGetMaster( nHandle )
if nMasterHandle == nil
then
bReset = true
sReason = sReason.."nMasterHandle == nil; "
else
if PetMem["MasterInfo"]["nHandle"] ~= nMasterHandle
then
bReset = true
sReason = sReason.."nMasterHandle ~= memValue; "
end
end
end
if bReset == false
then
nMasterRegNum = cGetRegistNumber( nMasterHandle )
if nMasterRegNum == nil
then
bReset = true
sReason = sReason.."nMasterRegNum == nil; "
else
if PetMem["MasterInfo"]["nRegNo"] ~= nMasterRegNum
then
bReset = true
sReason = sReason.."nMasterRegNum == memValue; "
end
end
end
if bReset == false
then
if PetBaseUpdate( PetMem ) == false
then
ErrorLog( "PetBaseMain::PetBaseUpdate Failed : "..nHandle.." "..sMapIndex )
bReset = true
sReason = sReason.."Update Failed; "
end
end
if bReset == true
then
ErrorLog( "PetBaseMain::PetBaseReload Failed by "..sReason.." : "..nHandle.." "..sMapIndex )
gPetAIMemory["PetBase"][ nHandle ] = nil
cAIScriptSet( nHandle )
return ReturnAI["END"]
end
-- DebugLog( "PetBaseMain::Check & Update End - gPetAIMemory[\"PetBase\"]["..nHandle.."]" )
PetMem["Func"] = PetBaseRoutine
end
if PetMem["CurSec"] == nil
then
PetMem["CurSec"] = cCurrentSecond()
end
-- <EFBFBD>ش<EFBFBD> <EFBFBD>Լ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
PetMem["Func"]( PetMem )
end