local PetTechCanNpc = {"驯兽师莱恩斯",14549,4,60005,14,8}
local PetTechCanNpcTalk = "我是宠物技能大师莱恩斯,你有带特别的技能宠物来吗?我能帮你抽取一只宠物的《技能》并存贮在《宠物技能书》内,使用《宠物技能书》可以让别的宠物学习存贮的宠物技能。\n\n[注意事项]:被抽取技能的宠物会《直接消失并无法找回》请不要选错宠物"
local PetTechCanItem = {} --罐头道具id
PetTechCanItem[0] = 59883 --默认道具
PetTechCanItem[59883] = 1 --新增道具(增加某个技能书的写法)
local PetTechCanValue = %道具_宝石武%
local PetTechCanPay = 50000 --花费
-------------------------
Global_Reg.RegInit("PetTechchange_Init");
Global_Reg.RegItemUseEvent("PetTechchange_JC")
function PetTechchange_Init()
PetTechchange_Init2();
return 0;
end
function PetTechchange_Init2(PetTechCanNpcIndex)
if PetTechCanNpcIndex == nil or PetTechCanNpcIndex < 0 then
PetTechCanNpcIndex = NL.CreateNpc(nil,"PetTechchange_Init3")
end
Char.SetData(PetTechCanNpcIndex,%对象_形象%,PetTechCanNpc[2])
Char.SetData(PetTechCanNpcIndex,%对象_原形%,PetTechCanNpc[2])
Char.SetData(PetTechCanNpcIndex,%对象_地图%,PetTechCanNpc[4])
Char.SetData(PetTechCanNpcIndex,%对象_X%,PetTechCanNpc[5])
Char.SetData(PetTechCanNpcIndex,%对象_Y%,PetTechCanNpc[6])
Char.SetData(PetTechCanNpcIndex,%对象_方向%,PetTechCanNpc[3])
Char.SetData(PetTechCanNpcIndex,%对象_原名%,PetTechCanNpc[1])
NLG.UpChar(PetTechCanNpcIndex)
LuaNpcIndex["PetTechchange_Index"]=PetTechCanNpcIndex;
InstallNpc("PetTechchange_Index",PetTechCanNpcIndex);
Char.SetTalkedEvent(nil, "PetTechCanNpcTalkedCallBack",PetTechCanNpcIndex)
Char.SetWindowTalkedEvent(nil,"PetTechCanNpcWindowTalkedCallBack",PetTechCanNpcIndex)
return true
end
function PetTechchange_Init3(index)
return true;
end
function PetTechCanNpcTalkedCallBack(npc,player)
if NLG.CanTalk(npc,player) then
NLG.ShowWindowTalked(player,0,34,0,PetTechCanNpcTalk,npc)
end
end
function PetTechCanNpcWindowTalkedCallBack(npc,player,Seqno,Select,Data)
--NLG.SystemMessage(player,"Seqno="..Seqno.." Select="..Select.." Data="..Data)
if NLG.CanTalk(npc,player) or Seqno > 2000 then
if Select ~= 2 then
if Seqno == 0 then
if Select == 32 then
local msg = "2\n请选择你要抽取的宠物:\n"
for i = 0,4 do
local petindex = Char.GetPetIndex(player,i)
if petindex >= 0 then
msg = msg.."\n"..(i+1)..". "..Char.GetData(petindex,%对象_原名%).." Lv"..Char.GetData(petindex,%对象_等级%)
else
msg = msg.."\n"..(i+1)..". 无宠物"
end
end
NLG.ShowWindowTalked(player,2,2,100,msg,npc)
end
elseif Seqno == 100 then
if tonumber(Data) and tonumber(Data) >= 1 and tonumber(Data) <= 5 and math.floor(tonumber(Data)) == tonumber(Data) then
local petindex = Char.GetPetIndex(player,tonumber(Data)-1)
if petindex >= 0 then
local msg = "1\n选择抽取的技能(找不到请调整技能位置):"
for i = 0,7 do
local tech = Pet.GetSkill(petindex,i)
if tech >= 0 then
msg = msg.."\n"..(i+1)..". "..(BaseTechTable[tech][1] or "无技能")
else
msg = msg.."\n"..(i+1)..". 无技能"
end
end
NLG.ShowWindowTalked(player,2,2,100+tonumber(Data)*10,msg,npc)
else
NLG.SystemMessage(player,"请选择正确的宠物。")
end
else
NLG.SystemMessage(player,"请选择正确的选项。")
end
elseif Seqno == 110 or Seqno == 120 or Seqno == 130 or Seqno == 140 or Seqno == 150 then
local petindex = Char.GetPetIndex(player,((Seqno-100)/10)-1)
if petindex >= 0 then
if tonumber(Data) and tonumber(Data) >= 1 and tonumber(Data) <= 8 and math.floor(tonumber(Data)) == tonumber(Data) then
local tech = Pet.GetSkill(petindex,tonumber(Data)-1)
if BaseTechTable[tech] then
local msg = "最终确认:\n\n您选择了["..Char.GetData(petindex,%对象_原名%).." Lv"..Char.GetData(petindex,%对象_等级%).."]"
msg = msg.."\n\n抽取["..BaseTechTable[tech][1].."]技能"
msg = msg.."\n\n*抽取技能需要花费"..PetTechCanPay.."金币"
msg = msg.."\n\n技能抽取后,宠物将会【消失】,仍然要确定抽取吗?"
NLG.ShowWindowTalked(player,2,3,900+Seqno+tonumber(Data),msg,npc)
else
NLG.SystemMessage(player,"请选择正确的技能。")
end
else
NLG.SystemMessage(player,"请选择正确的选项。")
end
else
NLG.SystemMessage(player,"请选择正确的宠物。")
end
elseif Seqno > 1000 and Seqno < 1100 then
if Char.GetData(player,%对象_金币%) >= PetTechCanPay then
local petindex = Char.GetPetIndex(player,math.floor((Seqno-1000)/10)-1)
if petindex >= 0 then
local tech = Pet.GetSkill(petindex,Seqno-math.floor(Seqno/10)*10-1)
if BaseTechTable[tech] and tech~=-1 then
if Char.FindEmptyItemBox(player) >= 1 then
local itemindex=tonumber(unpack(Char.Additem(player,PetTechCanItem[0])))
if itemindex > 0 then
AddGold(player,-PetTechCanPay)--base内置函数,给予player参数B的值的魔币
Item.SetData(itemindex,%道具_名字%,BaseTechTable[tech][1].."之书")
Item.SetData(itemindex,PetTechCanValue,tech)
Item.UpItem(player,-1)
NLG.SystemMessage(player,"放生了"..Char.GetData(petindex,%对象_原名%).."。")
Pet.DeletePet(player,Char.GetData(petindex,%对象_宠物栏位%));
end
else
NLG.SystemMessage(player,"你的东西太多了。")
end
else
NLG.SystemMessage(player,"请选择正确的技能。")
end
else
NLG.SystemMessage(player,"请选择正确的宠物。")
end
else
NLG.SystemMessage(player,"你的钱不够。")
end
elseif Seqno == 2008 then
if tonumber(Data) and tonumber(Data) >= 1 and tonumber(Data) <= 5 and math.floor(tonumber(Data)) == tonumber(Data) then
local petindex = Char.GetPetIndex(player,tonumber(Data)-1)
if petindex >= 0 then
local itemindex = Char.GetItemIndex(player,Seqno-2000)
if itemindex > 0 then
local itemid = Item.GetData(itemindex,%道具_ID%)
if PetTechCanItem[itemid] then
local tech = Item.GetData(itemindex,PetTechCanValue)
local msg = "请确定:\n\n为"..Char.GetData(petindex,%对象_原名%).."学习『"..BaseTechTable[tech][1].."』技能。\n\n注意:默认使用位置更靠前的技能书\n技能栏已满的宠物需要先学习『什么也不做』技能。"
NLG.ShowWindowTalked(player,0,3,Seqno+tonumber(Data)*100,msg,npc)
end
end
else
NLG.SystemMessage(player,"请选择正确的宠物。")
end
else
NLG.SystemMessage(player,"请选择正确的选项。")
end
elseif Seqno >= 2108 and Seqno <= 2527 then
local petindex = Char.GetPetIndex(player,math.floor((Seqno-2000)/100)-1)
if petindex >= 0 then
local itemindex = Char.GetItemIndex(player,Seqno-math.floor(Seqno/100)*100)
if itemindex > 0 then
local itemid = Item.GetData(itemindex,%道具_ID%)
if PetTechCanItem[itemid] then
local tech = Item.GetData(itemindex,PetTechCanValue)
local able = 1
for j = 0,9 do
if Pet.GetSkill(petindex,j) == 15002 then
Pet.DelTech(petindex,15002)
break
end
end
for j = 0,9 do
if Pet.GetSkill(petindex,j) == tech then
--NLG.SystemMessage(player,"不能学习已经学会的技能。")
able = 0
break
end
end
if able == 1 then
able = Pet.AddSkill(petindex,tech)
if able == 0 then
NLG.SystemMessage(player,"技能栏已满,请先学习『什么也不做』技能。")
else
DelItemByPos(player,Seqno-math.floor(Seqno/100)*100)
NLG.SystemMessage(player,Char.GetData(petindex,%对象_原名%).."学会了『"..BaseTechTable[tech][1].."』技能。")
Pet.UpPet(player,petindex)
end
else
NLG.SystemMessage(player,"不能学习已经学会的技能。")
end
end
end
else
NLG.SystemMessage(player,"请选择正确的宠物。")
end
end
end
end
end
function UsePetTechCan(player)
local itemindex = Char.GetItemIndex(player,8)
if itemindex > 0 then
local itemid = Item.GetData(itemindex,%道具_ID%)
if PetTechCanItem[itemid] then
local tech = Item.GetData(itemindex,PetTechCanValue)
local msg = "2\n请选择学习["..BaseTechTable[tech][1].."]的宠物:\n"
for i=0,4 do
local petindex = Char.GetPetIndex(player,i)
if petindex >= 0 then
msg = msg.."\n"..(i+1)..". Lv"..Char.GetData(petindex,%对象_等级%)..Char.GetData(petindex,%对象_原名%).." "
else
msg = msg.."\n"..(i+1)..". 无宠物"
end
end
NLG.ShowWindowTalked(player,2,2,2008,msg,LuaNpcIndex.PetTechchange_Index)
end
end
end
function PetTechchange_JC(player,Itemindex)--让PetTechCanItem[0]这个编号的道具必须在道具栏第一格才能双击
local DJSL = Char.ItemNum(player,PetTechCanItem[0])
if DJSL >= 1 then
local daojuindex = Char.GetItemIndex(player,8)
local daojubianhao = Item.GetData(Itemindex,%道具_ID%)
if daojuindex~=Itemindex and daojubianhao==PetTechCanItem[0] then--如果双击的不是8号道具栏的道具 and 双击的道具编号是宠物技能书
NLG.SystemMessage(player,"请把将要使用的『宠物技能书』放到道具栏第一格。")
return 1
else
return 0
end
end
return 0
end
|
|