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/AIScript/E_CacaoBud.lua

402 lines
7.6 KiB

require( "common" )
EVENT_DATA =
{ ----------------------
--[[ 1~ 40 ]]
{
--[[<EFBFBD>ּҷ<EFBFBD><EFBFBD><EFBFBD>]] MinLev = 1,
--[[<EFBFBD>ִ<EFBFBD><EFBFBD>]] MaxLev = 40,
--[[ <EFBFBD><EFBFBD>ȯ<EFBFBD><EFBFBD> ]] MobIndex = "E_CaCaoSlime",
--[[<EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>]] AniIndex = "Slime_Attack1_1",
--[[ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ]] MapIndex = "RouCos02",
--[[<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ê]] SucChat = "My favorite fruit! Raise some more and eat it later.",
--[[<EFBFBD><EFBFBD><EFBFBD>и<EFBFBD>ê]] FailChat = "Well. That was nothing worth keeping.",
},
--[[ 41~ 80 ]]
{
--[[<EFBFBD>ּҷ<EFBFBD><EFBFBD><EFBFBD>]] MinLev = 41,
--[[<EFBFBD>ִ<EFBFBD><EFBFBD>]] MaxLev = 80,
--[[ <EFBFBD><EFBFBD>ȯ<EFBFBD><EFBFBD> ]] MobIndex = "E_CaCaoPrisoner",
--[[<EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>]] AniIndex = "Prisoner_Attack1_1",
--[[ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ]] MapIndex = "EldCem01",
--[[<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ê]] SucChat = "What is this? Would it grow a Cacao fruit?",
--[[<EFBFBD><EFBFBD><EFBFBD>и<EFBFBD>ê]] FailChat = "Hmm.. Well that was a failed attempt.",
},
--[[ 81~115 ]]
{
--[[<EFBFBD>ּҷ<EFBFBD><EFBFBD><EFBFBD>]] MinLev = 81,
--[[<EFBFBD>ִ<EFBFBD><EFBFBD>]] MaxLev = 125,
--[[ <EFBFBD><EFBFBD>ȯ<EFBFBD><EFBFBD> ]] MobIndex = "E_CaCaoMineMole",
--[[<EFBFBD><EFBFBD><EFBFBD>ݸ<EFBFBD><EFBFBD><EFBFBD>]] AniIndex = "Mole_attack",
--[[ <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ]] MapIndex = "UrgFire01",
--[[<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ê]] SucChat = "Wow, that's great. I was hungry. Raise it well.",
--[[<EFBFBD><EFBFBD><EFBFBD>и<EFBFBD>ê]] 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
-- <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 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
-- <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>
Var["Master"] = cGetMaster( Var["Handle"] )
if Var["Master"] == nil then
cAIScriptSet( Var["Handle"] )
cNPCVanish( Var["Handle"] )
MemBlock[Handle] = nil
return ReturnAI["END"]
end
-- <EFBFBD><EFBFBD> üũ
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
-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> üũ
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
-- <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><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>
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 )
-- <EFBFBD>ʿ<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>ʱ<EFBFBD>ȭ
Var["ChkTime"] = cCurrentSecond()
Var["EventStep"] = 1
Var["EventMobRegenX"] = locX
Var["EventMobRegenY"] = locY
end
-- <EFBFBD>̺<EFBFBD>Ʈ<EFBFBD><EFBFBD> üũ
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()
-- <EFBFBD>Ÿ<EFBFBD> üũ<EFBFBD>ϸ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> üũ
elseif Var["EventStep"] == 2 then
if Var["ChkTime"] <= CurSec then
local rndNum = cRandomInt( 1, 100 )
if rndNum >= EVENT_SUC_PERCENT then
-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cNPCChatTest( Var["EventMob"], EVENT_DATA[Var["GroupNum"]]["SucChat"] )
cDropItem( EVENT_SUC_DROP_ITEM, Var["Handle"], Var["Master"], 1000000 )
else
-- <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cNPCChatTest( Var["EventMob"], EVENT_DATA[Var["GroupNum"]]["FailChat"] )
end
cAnimate( Var["EventMob"], "stop" )
Var["ChkTime"] = CurSec + 2
Var["EventStep"] = Var["EventStep"] + 1
end
-- <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ, <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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
-- <EFBFBD>̺<EFBFBD>Ʈ<EFBFBD><EFBFBD> ó<EFBFBD><EFBFBD> <EFBFBD>Լ<EFBFBD>
-- <EFBFBD>ƹ<EFBFBD> ó<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>ϰ<EFBFBD> DeadTime<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD> DeadTime <EFBFBD><EFBFBD><EFBFBD>Ŀ<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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