local timenum=9500--预设延迟,1000毫秒=1秒
jmx_item_num = {}--聚魔香需要和MakeItemJMX.lua联动,表为全局表,聚魔香道具,自动次数==耐久值
jmx_item_num[79405]=1--自动聚魔香道具1
jmx_item_num[79441]=1
jmx_item_num[79442]=1
jmx_item_num[79443]=1
jmx_item_num[79444]=1
jmx_item_num[79445]=1
jmx_item_num[79446]=1
jmx_item_num[79447]=1--特殊聚魔香
jmx_item_num[79448]=1
local ymx_item_num = {}--诱魔香道具,自动次数==耐久值
ymx_item_num[79404]=1--自动诱魔香道具1
ymx_item_num[79436]=1
ymx_item_num[79437]=1
ymx_item_num[79439]=1
ymx_item_num[79433]=1
ymx_item_num[79451]=1
Auto_battle_limit_mapID = {}--禁止使用自动香的地图
Auto_battle_limit_mapID[777]=1--设置一个777地图
------------------------------------------------------------------------------------------
Global_Reg.RegLogoutEvent ("Auto_Battle_longin")--登出
Global_Reg.RegLoginGateEvent ("Auto_Battle_longin2")--登回记录点
Global_Reg.RegTalkEvent ("Auto_Battle_speak");--玩家说话
Global_Reg.RegItemUseEvent ("Auto_Battle_useritem");--创建一个所有玩家双击道具栏物品就会触发的Lua函数。
--Global_Reg.RegBattleEscape("Auto_Battle_Escape")--战斗中逃跑事件,佣兵脚本已经注册
Auto_battle_x_save=Auto_battle_x_save or {}
Auto_battle_x_save2=Auto_battle_x_save2 or {}
local Auto_battle_x_save3 = Auto_battle_x_save3 or {}
function Auto_Battle_useritem(player, ItemIndex)
local itemid = Item.GetData(ItemIndex,%道具_ID%)
if Auto_battle_x_save[player] and (jmx_item_num[itemid] or ymx_item_num[itemid]) then
NLG.SystemMessage(player,"[系统]:您已经打开[自动香]了")
return -1
end
return 0--通过
end
function Auto_Battle_Escape(player, Escape)--(1为成功,0为失败)
if Escape==1 then
local ifpet = Char.GetData(player,0)
if ifpet==1 then
local dz = Char.GetData(player,11556)
if dz == 1 or dz == 0 then--是队长
if Auto_battle_x_save[player] then
Char.SetLoopEvent(nil, "YMXAutoBattle_Loop",player, timenum)
end
if Auto_battle_x_save3[player] then
Char.SetLoopEvent(nil, nil,player, 0)
Auto_battle_x_save3[player]=nil
end
else
if Auto_battle_x_save[player] then
Char.SetLoopEvent(nil, nil,player, 0)
Auto_battle_x_save[player]=nil
if Auto_battle_x_save2[player] then
Auto_battle_x_save2[player]=nil
end
NLG.SystemMessage(player,"[系统]:[自动香]只有组队队长可以使用")
end
end
end
end
return Escape;
end
function Auto_Battle_speak(player, Msg, color, range, size,channeltype)
if Msg=="P|/停止自动" or Msg=="P|/3" then
if Auto_battle_x_save[player] then
Auto_battle_x_save[player]=nil
if Auto_battle_x_save2[player] then
Auto_battle_x_save2[player]=nil
end
if Auto_battle_x_save3[player]==nil then
Auto_battle_x_save3[player]=1
end
NLG.SystemMessage(player,"[系统]:你把[自动香]的盖子拧上了")
end
end
end
function Auto_Battle_longin(player)
if Auto_battle_x_save[player] then
Char.SetLoopEvent(nil, nil,player, 0)
Auto_battle_x_save[player]=nil
if Auto_battle_x_save2[player] then
Auto_battle_x_save2[player]=nil
end
end
return 0;
end
function Auto_Battle_longin2(player)
if Auto_battle_x_save[player] then
Char.SetLoopEvent(nil, nil,player, 0)
Auto_battle_x_save[player]=nil
if Auto_battle_x_save2[player] then
Auto_battle_x_save2[player]=nil
end
end
return 0;
end
function Auto_Battle_walk(player)
if Auto_battle_x_save[player] then
local ZD = Char.GetData(player,%对象_是否战斗中%)
if ZD<1 then
Char.SetLoopEvent(nil, nil,player, 0)
else
if Auto_battle_x_save3[player]==nil then
Auto_battle_x_save3[player]=1
end
end
Auto_battle_x_save[player]=nil
if Auto_battle_x_save2[player] then
Auto_battle_x_save2[player]=nil
end
NLG.SystemMessage(player,"[系统]:你把[自动香]的盖子拧上了(因转身或移动)")
end
return 0;
end
function Auto_Battle_over(battleIndex)
local GetType = Battle.GetType(battleIndex)--返回 0 失败返回 1 人物正常战斗返回 2 人物PK中返回 3 人物观战中
if GetType==1 then
for Num=0,9 do
local player = Battle.GetPlayIndex(battleIndex,0,Num)
if player >= 0 then
local ifpet = Char.GetData(player,0)
if ifpet==1 then
local dz = Char.GetData(player,11556)
if dz == 1 or dz == 0 then--是队长
if Auto_battle_x_save[player] then
Char.SetLoopEvent(nil, "YMXAutoBattle_Loop",player, timenum)
end
if Auto_battle_x_save3[player] then
Char.SetLoopEvent(nil, nil,player, 0)
Auto_battle_x_save3[player]=nil
end
else
if Auto_battle_x_save[player] then
Char.SetLoopEvent(nil, nil,player, 0)
Auto_battle_x_save[player]=nil
if Auto_battle_x_save2[player] then
Auto_battle_x_save2[player]=nil
end
NLG.SystemMessage(player,"[系统]:[自动香]只有组队队长可以使用")
end
end
end
end
end
end
return 0
end
function Auto_Battle_start(battleIndex)
local GetType = Battle.GetType(battleIndex)--返回 0 失败返回 1 人物正常战斗返回 2 人物PK中返回 3 人物观战中
if GetType==1 then
for Num=0,9 do
local player = Battle.GetPlayIndex(battleIndex,0,Num)
if player >= 0 then
local ifpet = Char.GetData(player,0)--返回:3是宠,1是人
if ifpet==1 then
Char.SetLoopEvent(nil, nil,player, 0)
if Auto_battle_x_save2[player] then
Auto_battle_x_save2[player]=nil
end
local dz = Char.GetData(player,11556)
if dz == 2 then--不是队长(表作回收)
if Auto_battle_x_save[player] then
Auto_battle_x_save[player]=nil
NLG.SystemMessage(player,"[系统]:[自动香]只有组队队长可以使用")
end
end
end
end
end
end
return 0
end
function YMXAutoBattle_Loop(player)
if Auto_battle_x_save2[player]~=nil then
local diaohun = Char.GetData(player,150)
local shoushang = Char.GetData(player,%对象_受伤%)
if diaohun>0 or shoushang>26 then--掉魂或者受到粉伤
Auto_battle_x_save[player]=nil
Auto_battle_x_save2[player]=nil
Char.SetLoopEvent(nil, nil,player, 0)
NLG.SystemMessage(player,"[系统]:您受了重伤,生存本能驱使着你把[自动香]的盖子拧上了")
else
local ZD = Char.GetData(player,%对象_是否战斗中%)
if ZD<1 then
local djpos = Char.FindItemId(player, Auto_battle_x_save[player]) or -1
if djpos~= -1 then
local Itemindex = Char.GetItemIndex(player,djpos) or -1
local naijiu = Item.GetData(Itemindex, %道具_耐久%) or -1
if naijiu>1 then
local a=NLG.CreateBattle(player)
if a==1 then
return 0;
else
Item.SetData(Itemindex, %道具_耐久%,naijiu-1)
Item.UpItem(player,djpos);
NLG.SystemMessage(player,"[自动香]的气味吸引了魔物")
Char.SetLoopEvent(nil,nil,player, 0)
end
elseif naijiu==1 then
local a=NLG.CreateBattle(player)
if a==1 then
return 0;
else
local tNum = NLG.DelItemByPos(player,djpos);
Auto_battle_x_save[player]=nil
Auto_battle_x_save2[player]=nil
Char.SetLoopEvent(nil, nil,player, 0)
NLG.SystemMessage(player,"[自动香]的气味吸引了魔物")
NLG.SystemMessage(player,"[自动香]耗尽了")
end
else
local tNum = NLG.DelItemByPos(player,djpos);
Auto_battle_x_save[player]=nil
Auto_battle_x_save2[player]=nil
Char.SetLoopEvent(nil, nil,player, 0)
NLG.SystemMessage(player,"[自动香]耗尽了")
end
else
Auto_battle_x_save[player]=nil
Auto_battle_x_save2[player]=nil
Char.SetLoopEvent(nil, nil,player, 0)
NLG.SystemMessage(player,"您没有[自动香]")
end
end
end
else
Auto_battle_x_save2[player]=1
return 0;
end
return 0;
end
|
|