Last updated on
石器时代LNS仿梦幻开宝箱放宝宝LUA脚本
脚本名称:石器时代LNS仿梦幻开宝箱放宝宝LUA脚本 功能描述:仿梦幻挖五宝,最后在特定地方出现1级宠物宝宝,出现时全服通知。 脚本来源:9292石器时代研究中心
--[[
注意 事件响应函数必须使用指定的参数格式如下面的函数
而且每种事件的响应函数的参数格式都不一定一样
当然参数名可以自定义
--]]
--Init事件返回值为 true 或 false
--_MeIndex 是本NPC的索引
function JZ_TestNewNpc_Init( _MeIndex )
if (Char.SetTalkedEvent(nil, "JZ_TestNewNpc_Talked", _MeIndex) < 0) then
print("JZ_TestNewNpc_Talked 注册事件失败。");
return false;
end
return true;
end
function petcatch_Init( _MeIndex )
if (Char.SetTalkedEvent(nil, "petcatch_Talked", _MeIndex) < 0) then
print("petcatch注册事件失败。");
return false;
end
Char.SetData(_MeIndex, %对象_形象%, petm[petr]);
Char.SetData(_MeIndex, %对象_原形%, petm[petr]);
Char.SetData(_MeIndex, %对象_原名%, petn[petr]);
--设置NPC所在地图
Char.SetData(_MeIndex,%对象_地图%,floor[fr]);
--设置X坐标
Char.SetData(_MeIndex,%对象_X%,fx[fr]);
--设置Y坐
Char.SetData(_MeIndex,%对象_Y%,fy[fr]);
--设置NPC方向
Char.SetData(_MeIndex,%对象_方向%,%右下%);
NLG.UpChar(_MeIndex);
return true;
end
--Talked事件不需要返回值所以 return ; 既可
--_MeIndex 是本NPC的索引
--_PlayerIndex 触发事件的玩家索引
--_Msg 玩家说话的内容
--_Color 说话的颜色
--_Channel 这个是频道
function JZ_TestNewNpc_Talked( _MeIndex, _PlayerIndex, _Msg, _Color, _Channel)
--这里检查玩家是否站在NPC面前
bBattle[_MeIndex]=0;
petBattle[_MeIndex]=0;
local gift = {21181, 21180,21179,21178,21181, 21180,21179,21178,21177,21176};
rg = math.floor(math.random(1, 10));
if(NLG.CheckInFront(_PlayerIndex, _MeIndex, 1) == false) then
return ;
end
local playername=Char.GetData(_PlayerIndex,%对象_原名%);
pet={1660,1609,1592,1601,2573,353};
petm={100850,100871,100854,100863,100373,100374};
petn={"杨格斯","普鲁夏","里拉拉","戈登尔顿","水5火5红暴","帖拉所伊朵"};
petr=math.floor(math.random(1, 6));
r=math.floor(math.random(1, 15));
print(r);
if(Char.FindItemId(_PlayerIndex, 20839) >= 0)then
if(r==1) then
local pindex;
fn={"萨伊那斯","萨伊那斯","加鲁卡","加鲁卡","加鲁卡","五十年前的波拉岛","五十年前的波拉岛","五十年前的波拉岛"};
floor={100,100,200,200,200,500,500,500};
fx={153,295,365,257,504,147,363,533};
fy={463,559,310,372,809,403,529,655};
fr=math.floor(math.random(1, 8));
NLG.TalkToCli(-1, "[宝箱通告]探宝者["..playername.."]意外放出一只LV1的["..petn[petr].."]在"..fn[fr].."地图"..fx[fr]..","..fy[fr].."!大家快去抓啊!", %紫色%, 0, -1);
pindex = NL.CreateNpc("./data/npc/lua/test/testnewnpc.lua", "petcatch_Init");
NLG.Warp(pindex, floor[fr], fx[fr], fy[fr]);
NLG.DelItem(_PlayerIndex,20839);
NL.DelNpc(_MeIndex);
lastpet=petn[petr];
e=e-1;
elseif(r==2)then
bBattle[_MeIndex] = NLG.CreateBattle( _PlayerIndex, _MeIndex, nil, {2757});
Battle.SetWinEvent("data/npc/lua/test/testnewnpc.lua","bb",bBattle[_MeIndex]);
NLG.DelItem(_PlayerIndex,20839);
NL.DelNpc(_MeIndex);
NLG.TalkToCli(-1, "[宝箱通告]宝箱被探宝者["..playername.."]挖走了1个!", %紫色%, 0, -1);
NLG.UpChar(_MeIndex);
e=e-1;
else
NLG.TalkToCli(_PlayerIndex, "被你找到了没办法..俺要消失了。", _Color, 0, _MeIndex);
NLG.DelItem(_PlayerIndex,20839);
NLG.GiveItem( _PlayerIndex, gift[rg]);
NL.DelNpc(_MeIndex);
e=e-1;
NLG.TalkToCli(-1, "[宝箱通告]宝箱被探宝者["..playername.."]挖走了1个!", %紫色%, 0, -1);
NLG.UpChar( _MeIndex);
end
return ;
else
NLG.TalkToCli(_PlayerIndex, "你没有钥匙啊!找到我也没用,可惜啊!", _Color, 0, _MeIndex);
end
return ;
end
function bb( _BattleIndex, _CreateIndex,_PlayerIndex)
PlayerIndex = Battle.GetPlayIndex(_BattleIndex,0,0);
if(NLG.GiveItem( PlayerIndex , 21178) <= 0)then
NLG.TalkToCli(PlayerIndex, "道具栏位不足!", %黄色%, 0, -1);
end
end
function petcatch_Talked( _MeIndex, _PlayerIndex, _Msg, _Color, _Channel)
NLG.TalkToCli(-1, "[宝箱通告]放出LV1的["..lastpet.."]被"..Char.GetData(_PlayerIndex,%对象_原名%).."遇到了!", %黄色%, 0, -1);
petBattle[_MeIndex] = NLG.CreateBattle( _PlayerIndex, _MeIndex, nil, {pet[petr]});
Battle.SetWinEvent("data/npc/lua/test/testnewnpc.lua","pet",petBattle[_MeIndex]);
NL.DelNpc(_MeIndex);
end