ITPub博客

天龙八部玄武岛BOSS

原创 数据架构 作者:loovpfoxmail 时间:2018-09-07 13:42:40 0 删除 编辑

在玩天龙八部的时候, 玄武岛BOSS 在脚本里面是一个什么样的构造呢?就让小的来位大家说说,我们拿SF的脚本示例如下:


x810100_CreateChildTbl = {


MotherID=962, CreateTime=5*1000, CreateNum=2, AllChildNum=5, ChildID=1082, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=10*1000 }


--玄武岛BOSS 毒蛤王刷小怪....

{ MotherID=9100, CreateTime=60000, CreateNum=6, AllChildNum=900, ChildID=9150, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=45000 },

--玄武岛BOSS 小BOSS刷小怪....

{ MotherID=9101, CreateTime=60000, CreateNum=6, AllChildNum=900, ChildID=9151, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=45000 },

{ MotherID=9102, CreateTime=60000, CreateNum=6, AllChildNum=900, ChildID=9152, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=45000 },

{ MotherID=9103, CreateTime=60000, CreateNum=6, AllChildNum=900, ChildID=9153, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=45000 },

{ MotherID=9104, CreateTime=60000, CreateNum=6, AllChildNum=900, ChildID=9154, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=45000 },

{ MotherID=9105, CreateTime=60000, CreateNum=6, AllChildNum=900, ChildID=9155, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=45000 },

{ MotherID=9106, CreateTime=60000, CreateNum=6, AllChildNum=900, ChildID=9156, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=45000 },

{ MotherID=9107, CreateTime=60000, CreateNum=6, AllChildNum=900, ChildID=9157, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=45000 },

{ MotherID=9108, CreateTime=60000, CreateNum=6, AllChildNum=900, ChildID=9158, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=45000 },

{ MotherID=9109, CreateTime=60000, CreateNum=6, AllChildNum=900, ChildID=9159, BaseAI=0, ExtAIScript=-1, ScriptID=-1, LifeTime=45000 },


}


--小怪刷新点列表....

--坐标为相对于本BOSS的相对坐标....可以填写任意数目个坐标....刷小怪时从中随机选取一个使用....

x810100_MonsterPosTbl = {


{ x = 0,  y = 0  },


}


x810100_IDX_UpdateMonsterTime = 1

x810100_IDX_NeedCreateMonsterNum = 2

x810100_IDX_EnableCreateMonster = 1

x810100_IDX_CombatFlag = 2


function x810100_OnDie( sceneId, selfId, killerId )

MonsterAI_SetIntParamByIndex(sceneId, selfId,  x810100_IDX_UpdateMonsterTime, 0)

MonsterAI_SetIntParamByIndex(sceneId, selfId,  x810100_IDX_NeedCreateMonsterNum, 0)

MonsterAI_SetBoolParamByIndex(sceneId, selfId, x810100_IDX_EnableCreateMonster, 0)

MonsterAI_SetBoolParamByIndex(sceneId, selfId, x810100_IDX_CombatFlag, 0)

end


function x810100_OnHeartBeat(sceneId, selfId, nTick)


--检测是不是死了....

if LuaFnIsCharacterLiving(sceneId, selfId) ~= 1 then

return

end


--检测是否不在战斗状态....

if 0 == MonsterAI_GetBoolParamByIndex(sceneId, selfId, x810100_IDX_CombatFlag) then

return

end


--检测是否已经不需要再刷小怪了....

if 0 == MonsterAI_GetBoolParamByIndex(sceneId, selfId, x810100_IDX_EnableCreateMonster) then

return

end


--还未到刷小怪的时间....

local UpdateTime = MonsterAI_GetIntParamByIndex(sceneId, selfId, x810100_IDX_UpdateMonsterTime)

if nTick < UpdateTime then

UpdateTime = UpdateTime - nTick

MonsterAI_SetIntParamByIndex(sceneId, selfId,  x810100_IDX_UpdateMonsterTime, UpdateTime)

return

end



--到了刷小怪的时间了....刷小怪....


--寻找本BOSS的刷怪数据表....

local BossDataID = GetMonsterDataID( sceneId, selfId )

local bFind = 0

local CreateData

for _, Data in x810100_CreateChildTbl do

if BossDataID == Data.MotherID then

CreateData = Data

bFind = 1

break

end

end


local CreateNum = 0

local NeedCreateNum = MonsterAI_GetIntParamByIndex(sceneId, selfId,  x810100_IDX_NeedCreateMonsterNum, 0)


if NeedCreateNum <= CreateData.CreateNum then

CreateNum = NeedCreateNum

MonsterAI_SetBoolParamByIndex(sceneId, selfId, x810100_IDX_EnableCreateMonster, 0)

else

CreateNum = CreateData.CreateNum

end

LuaFnNpcChat(sceneId, selfId, 0, "不知死活的家伙,我的手下就能干掉你!")

for i = 1, CreateNum do

x810100_CreateChildMonster( sceneId, selfId, CreateData )

end


MonsterAI_SetIntParamByIndex(sceneId, selfId,  x810100_IDX_NeedCreateMonsterNum, NeedCreateNum-CreateNum)

MonsterAI_SetIntParamByIndex(sceneId, selfId,  x810100_IDX_UpdateMonsterTime, CreateData.CreateTime)


end


function x810100_OnInit(sceneId, selfId)


--寻找本BOSS的刷怪数据表....

local BossDataID = GetMonsterDataID( sceneId, selfId )

local bFind = 0

local CreateData

for _, Data in x810100_CreateChildTbl do

if BossDataID == Data.MotherID then

CreateData = Data

bFind = 1

break

end

end


--初始化AI参数....

MonsterAI_SetIntParamByIndex(sceneId, selfId,  x810100_IDX_UpdateMonsterTime, 0)

MonsterAI_SetIntParamByIndex(sceneId, selfId,  x810100_IDX_NeedCreateMonsterNum, 0)

MonsterAI_SetBoolParamByIndex(sceneId, selfId, x810100_IDX_EnableCreateMonster, 0)

MonsterAI_SetBoolParamByIndex(sceneId, selfId, x810100_IDX_CombatFlag, 0)


if bFind == 1 then

if CreateData.CreateTime>0 and CreateData.CreateNum>0 and CreateData.AllChildNum>0 then

MonsterAI_SetIntParamByIndex(sceneId, selfId,  x810100_IDX_UpdateMonsterTime, CreateData.CreateTime)

MonsterAI_SetIntParamByIndex(sceneId, selfId,  x810100_IDX_NeedCreateMonsterNum, CreateData.AllChildNum)

MonsterAI_SetBoolParamByIndex(sceneId, selfId, x810100_IDX_EnableCreateMonster, 1)

end

end


end


function x810100_OnKillCharacter(sceneId, selfId, targetId)


--LuaFnNpcChat(sceneId, selfId, 0, "我杀死一个人了....去死吧你....")


--if(-1~=targetId) then

--local szTarget = GetName(sceneId, targetId)

--local str = format( "我杀死一个人了....%s(杀死的玩家名),我早看你不爽了....", szTarget )

--LuaFnNpcChat(sceneId, selfId, 0, str)

--end


end


function x810100_OnEnterCombat(sceneId, selfId, enmeyId)

--LuaFnNpcChat(sceneId, selfId, 0, "我进入战斗了....你们等着去找孟婆吧....")

MonsterAI_SetBoolParamByIndex(sceneId, selfId, x810100_IDX_CombatFlag, 1)

end


function x810100_OnLeaveCombat(sceneId, selfId)

--LuaFnNpcChat(sceneId, selfId, 0, "我离开战斗了....大家先停下吃点药吧....")

MonsterAI_SetBoolParamByIndex(sceneId, selfId, x810100_IDX_CombatFlag, 0)

end


--创建一个小怪....

function x810100_CreateChildMonster(sceneId, selfId, CreateData)


local PosX, PosY = LuaFnGetWorldPos( sceneId, selfId )

local PosNum = getn( x810100_MonsterPosTbl )

local PosIndex = random( PosNum )

PosX = PosX + x810100_MonsterPosTbl[PosIndex].x

PosY = PosY + x810100_MonsterPosTbl[PosIndex].y


MonId = LuaFnCreateMonster(sceneId, CreateData.ChildID, PosX, PosY, CreateData.BaseAI, CreateData.ExtAIScript, CreateData.ScriptID )

if CreateData.LifeTime > 0 then

SetCharacterDieTime(sceneId, MonId, CreateData.LifeTime )

end


end


相信有部分伙伴们还是不大明白,这里需要懂一定LUA脚本语言基础的就能看明白了。(脚本中也有注释)


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31553491/viewspace-2213751/,如需转载,请注明出处,否则将追究法律责任。

上一篇: 没有了~
请登录后发表评论 登录
全部评论
生活中每个人都有他的事故,好比喝酒的人有故事,抽烟的人有心事。

注册时间:2018-09-05

  • 博文量
    2
  • 访问量
    696