LUA宠物进化
function PETTALK_Default_Owner( petindex, talkerindex, msg, color, channel)
--這裡檢查玩家是否站在NPC面前
if(NLG.CheckInFront(talkerindex, petindex, 1) == false) then
return ;
end
--面向玩家
local i;
i = Char.GetData(talkerindex, %对象_方向%);
if i >= 4 then
i = i - 4;
else
i = i + 4;
end
Char.SetData(petindex, %对象_方向%,i);
NLG.UpChar( petindex);
Char.SetWindowTalkedEvent(nil,"PETTALK_Default_OwnerWindow",petindex);
NLG.ShowWindowTalked(talkerindex, 2, 0, 0,
"4\n"..
"\n"..
"\n 【对 话 选 单】"..
"\n"..
"\n 【 聊 天 】"..
"\n 【 进 化 】"..
"\n 【 踹 一 脚 】"..
"\n 【 离 开 】",
petindex);
return ;
end
function PETTALK_Default_Stranger( petindex, talkerindex, msg, color, channel)
--這裡檢查玩家是否站在NPC面前
if(NLG.CheckInFront(talkerindex, petindex, 1) == false) then
return ;
end
--面向玩家
local i;
i = Char.GetData(talkerindex, %对象_方向%);
if i >= 4 then
i = i - 4;
else
i = i + 4;
end
Char.SetData(petindex, %对象_方向%,i);
NLG.UpChar( petindex);
NLG.TalkToCli(talkerindex, "与陌生人说话", _Color, 0);
end
function PETTALK_Default_Gossip( petindex,charaindex)
local talktext = { "吼吼吼~~~~","很无奈的样子","一副很生气的样子"};
NLG.ShowWindowTalked(charaindex, 2, 0, 1,
"6\n"..
"\n"..
"\n 【 聊 天 】"..
"\n"..
"\n "..Char.GetData(petindex,%对象_原名%)..":"..talktext[math.floor(math.random(1,3))]..
"\n"..
"\n 【 离 开 】",
petindex);
end
function PETTALK_Default_OwnerWindow( _MeIndex, _TalkIndex, _Seqno, _Select, _Data)
if(_Seqno == 0)then
if(_Data == "1")then
PETTALK_Default_Gossip( _MeIndex,_TalkIndex);
return;
end
if(_Data == "2")then
if(PETTALK_Evolution(_MeIndex,_TalkIndex,101864)==0)then
NLG.ShowWindowTalked(_TalkIndex, 2, 0, 1,
"7\n"..
"\n"..
"\n 【 进 化 】"..
"\n"..
"\n 恭喜!"..
"\n 进化成功!"..
"\n"..
"\n 【 离 开 】",
_MeIndex);
end
return;
end
if(_Data == "3")then
local i;
i = Char.GetData(_MeIndex, %对象_方向%);
if i >= 4 then
i = i - 4;
else
i = i + 4;
end
NLG.SetAction(_TalkIndex,2);
NLG.UpChar(_TalkIndex);
NLG.WalkMove(_MeIndex,i)
local tmp = "呜呜呜~~";
NLG.TalkToCli(_TalkIndex,tmp,%红色%,nil,_MeIndex);
tmp = Char.GetData(_MeIndex,%对象_原名%).."的忠诚度下降了10点。";
local tmp2 = Char.GetData(_MeIndex,%对象_运%);
tmp2 = ((tmp2 * 0.01)-10)*100;
Char.SetData(_MeIndex,%对象_运%,tmp2);
NLG.TalkToCli(_TalkIndex,tmp,%黄色%);
NLG.SetAction(_MeIndex,5);
NLG.UpChar(_MeIndex);
NLG.UpStateByThird(_MeIndex,%更新3_运气%);
end
end
end
function PETTALK_Evolution( petindex,charaindex,evoimg)
-- tbl_evopet为可进化宠物baseid,项数与tblttl一致.
-- tbl_evotarget内,对应不同进化分支(baseid)
-- tbl_evotarget = { {2,777,90} , {3,777,777,89} };
-- 的意思为
-- tbl_evotarget = { {最大进化分支为2,进化分支1,进化分支2} , {最大进化分支为3,进化分支1,进化分支2,进化分支3} }
-- tbl_evoitem内,对应不同可进化宠物所需要的进化材料,itemid或数量为-1时不需要进化材料
-- tbl_evoitem = { {-1,-1}, {2,1} };
-- 的意思为
-- tbl_evoitem = { {pet1_itemid,pet1_amount}, {pet2_itemid,pet2_amount} };
-- tbl_evolevel内,对应不同可进化宠物可进化等级
-- tblttl为项数
-- 重要事项
-- 各tbl内,项数应与tblttl一致
local tbl_evopet = {91,92,93,94,95,755,756,754};
local tbl_evotarget = { { 20,95,91,92,93,94,5128,5129,5130,5131,5132,31,32,21,12,3,23,54,5,51,302} ,
{ 20,95,91,92,93,94,5128,5129,5130,5131,5132,31,32,21,12,3,23,54,5,51,302} ,
{ 20,95,91,92,93,94,5128,5129,5130,5131,5132,31,32,21,12,3,23,54,5,51,302} ,
{ 20,95,91,92,93,94,5128,5129,5130,5131,5132,31,32,21,12,3,23,54,5,51,302} ,
{ 20,95,91,92,93,94,5128,5129,5130,5131,5132,31,32,21,12,3,23,54,5,51,302} ,
{ 5,5128,5129,5130,5131,5132} ,
{ 5,5128,5129,5130,5131,5132} ,
{ 5,5128,5129,5130,5131,5132} };
local tbl_evoitem = { {24048,1},
{24048,1},
{24048,1},
{24048,1},
{24048,1},
{24055,1},
{24055,1},
{24055,1} };
local tbl_evolevel = {140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140};
local tblttl = 10;
local num = 0;
local evoid = 0;
num = PETTALK_Evolution_tblCheck_evopet(petindex,tbl_evopet,tbl_evolevel,tblttl);
if num > 0 then
if PETTALK_Evolution_tblCheck_evoitem(charaindex,tbl_evoitem,num) < 0 then
NLG.ShowWindowTalked(charaindex, 2, 0, 1,
"6\n"..
"\n"..
"\n 【 进 化 】"..
"\n"..
"\n 缺少进化所需材料"..
"\n"..
"\n 【 离 开 】",
petindex);
return -1;
end
evoid = PETTALK_Evolution_tblCheck_evotarget(tbl_evotarget[num]);
local oldname = Char.GetData(petindex,%对象_原名%);
Char.PetEvolution(petindex,charaindex,evoid,evoimg);
local newname = Char.GetData(petindex,%对象_原名%);
NLG.TalkToCli(-1,"恭喜"..Char.GetData(charaindex,%对象_原名%).."的"..oldname.."进化成"..newname.."!",%红色%)
return 0;
end
NLG.ShowWindowTalked(charaindex, 2, 0, 1,
"6\n"..
"\n"..
"\n 【 进 化 】"..
"\n"..
"\n 这只宠物不能进化"..
"\n"..
"\n 【 离 开 】",
petindex);
return -1;
end
function PETTALK_Evolution_tblCheck_evotarget(tbl)
return tbl[math.floor(math.random(2,tbl[1]+1))];
end
function PETTALK_Evolution_tblCheck_evopet(petindex,tbl,tbl2,max)
local petid = Char.GetData(petindex,%对象_P最高%);
local petlevel = Char.GetData(petindex,%对象_等级%);
while(max>0)do
if petid == tbl[max] then
if petlevel < tbl2[max] then
return -1;
end
return max;
end
max = max - 1;
end
return -1
end
function PETTALK_Evolution_tblCheck_evoitem(charaindex,tbl,num)
if (tbl[num][1] < 0) or (tbl[num][2] < 0 )then
return 0;
end
if Plus_CheckItem(charaindex,tbl[num][1]) < tbl[num][2] then
return -1
end
if NLG.DelItem( charaindex, tbl[num][1], tbl[num][2]) == true then
return 0;
end
return -1;
end
function Plus_CheckItem( _PlayerIndex, _ItemID)
local Item_Amount = 0;
local i = 9;
while(i <= 23)do
if( Char.GetItemId( _PlayerIndex, i) == _ItemID )then
--if( Item.GetData( Char.GetItemIndex( _PlayerIndex, i), %笵ㄣ_帮舼%) > 1) then
Item_Amount = Item_Amount + Item.GetData( Char.GetItemIndex( _PlayerIndex, i), %道具_堆叠%);
--else
--Item_Amount = Item_Amount + 1;
--end
end
i = i + 1;
end
return Item_Amount;
end
function Plus_Checkrepet( _PlayerIndex)
local repet = 0;
if Char.GetPetIndex( _PlayerIndex,%宠栏_1%) <= 0 then
repet = repet + 1;
end
if Char.GetPetIndex( _PlayerIndex,%宠栏_2%) <= 0 then
repet = repet + 1;
end
if Char.GetPetIndex( _PlayerIndex,%宠栏_3%) <= 0 then
repet = repet + 1;
end
if Char.GetPetIndex( _PlayerIndex,%宠栏_4%) <= 0 then
repet = repet + 1;
end
if Char.GetPetIndex( _PlayerIndex,%宠栏_5%) <= 0 then
repet = repet + 1;
end
return repet;
end
function Plus_Checkreitem( _PlayerIndex)
local reitem = 0;
local i = 9;
while(i <= 23)do
if( Char.GetItemIndex( _PlayerIndex, i) < 0 )then
reitem = reitem + 1;
end
i=i+1;
end
return reitem;
end