-- ***************************************************************************************************** --
-- code by http://www.Cgdev.me
-- 自定义登录模块
-- #更新日志#
-- TYPE ***** TIME ***** Editor ***** Text
-- CREATE 2013/01/16 blue
-- ADD 2013/01/16 blue 提供登录欢迎词和原地登录功能,原地登录功能设定:
-- select1:如果在常规地图,能够直接原地登录,剩余次数减 1
-- select2:如果在迷宫地图,迷宫未重组,能够直接原地登录,剩余次数减 1
-- select3:如果在常规地图,迷宫重组了,回到迷宫入口点,剩余次数减 1
-- UPD 2013/01/26 blue 108行增加 tbl_dropinfo[_playerkey].time = os.time(); 207行 --inittable_cleanNpc();
-- #基本设置#
local In_situ_login_on_off = "on" ; --是否开放原地登录 on--开放 off--不开放
local In_situ_login_Count = 5; --默认的原地登录次数,和npc领取后补满
local In_situ_login_TimeOut =7200; --原地登录超时时间,单位为秒
local In_situ_login_Limit = true; --是否开放无限次原地登录
local Is_use_Field = false; --是否使用field库(未完成)
local NPCName = "原地登录领取员"; --设置领取原地登录的NPC名字
--local NPCPoint = {106602,251,17,27,2}; --原地登录领取员的原型,地图,X坐标,Y坐标,方向
local NPCPoint = {14633,777,242,104,6}; --原地登录领取员的原型,地图,X坐标,Y坐标,方向
-- ***************************************************************************************************** --
local MetamoStateList = {}; --形象属性设置表
MetamoStateList[100452] = {"形象属性加成",%道具_生命%,1,3000,%道具_攻击%,1,500,%道具_敏捷%,1,500,%道具_必杀%,1,5,%道具_命中%,1,5,%道具_魔力%,1,1000,%道具_闪躲%,1,5}
--MetamoStateList[100453] = {"竞技形象属性",%道具_生命%,1,3000}
--MetamoStateList[100454] = {"竞技形象属性",%道具_生命%,1,3000}
--MetamoStateList[100455] = {"竞技形象属性",%道具_生命%,1,3000}
-- ***************************************************************************************************** --
--MetamoStateList[100425] = {"竞技形象属性",%道具_魔力%,1,3000}
--MetamoStateList[100426] = {"竞技形象属性",%道具_魔力%,1,3000}
--MetamoStateList[100427] = {"竞技形象属性",%道具_魔力%,1,3000}
--MetamoStateList[100428] = {"竞技形象属性",%道具_魔力%,1,3000}
--MetamoStateList[100429] = {"竞技形象属性",%道具_魔力%,1,3000}
--MetamoStateList[100430] = {"竞技形象属性",%道具_魔力%,1,3000}
-- ***************************************************************************************************** --
--MetamoStateList[100500] = {"竞技形象属性",%道具_攻击%,1,100,%道具_必杀%,1,10}
--MetamoStateList[100501] = {"竞技形象属性",%道具_攻击%,1,100,%道具_必杀%,1,10}
--MetamoStateList[100502] = {"竞技形象属性",%道具_攻击%,1,100,%道具_必杀%,1,10}
--MetamoStateList[100503] = {"竞技形象属性",%道具_攻击%,1,100,%道具_必杀%,1,10}
--MetamoStateList[100504] = {"竞技形象属性",%道具_攻击%,1,100,%道具_必杀%,1,10}
--MetamoStateList[100505] = {"竞技形象属性",%道具_攻击%,1,100,%道具_必杀%,1,10}
-- ***************************************************************************************************** --
--MetamoStateList[100475] = {"竞技形象属性",%道具_敏捷%,1,100,%道具_命中%,1,10}
--MetamoStateList[100476] = {"竞技形象属性",%道具_敏捷%,1,100,%道具_命中%,1,10}
--MetamoStateList[100477] = {"竞技形象属性",%道具_敏捷%,1,100,%道具_命中%,1,10}
--MetamoStateList[100478] = {"竞技形象属性",%道具_敏捷%,1,100,%道具_命中%,1,10}
--MetamoStateList[100479] = {"竞技形象属性",%道具_敏捷%,1,100,%道具_命中%,1,10}
MetamoStateList[100452] = {"竞技形象属性",%道具_敏捷%,1,100,%道具_命中%,1,10}
-- ***************************************************************************************************** --
local MetamoStateItemWord = %道具_鉴前名% --道具使用字段名
local MetamoStateItemPos = 1 --属性附着的装备位置
local bangdingkey = 1 --是否绑定被附加过称号的衣服 1为绑定 其他为不绑定 建议绑定
local renamekey = 0 --是否修改被附加称号衣服的名字 1为修改 其他为不修改
--注册事件委托
Delegate.RegDelLoginEvent("MyLogin_LoginEvent");
Delegate.RegDelAllOutEvent("MyLogin_OutEvent");
Delegate.RegDelWarpEvent("MyLogin_WarpEvent");
Delegate.RegInit("MyLogin_Init");
--[[附常见?谰呤粜宰侄伪恚?
%道具_攻击%
%道具_防御%
%道具_敏捷%
%道具_精神%
%道具_回复%
%道具_必杀%
%道具_反击%
%道具_命中%
%道具_闪躲%
%道具_生命%
%道具_魔力%
%道具_毒抗%
%道具_睡抗%
%道具_石抗%
%道具_醉抗%
%道具_乱抗%
%道具_忘抗%
%道具_魔抗%
]]
--存储掉线信息
tbl_dropinfo = {};
tbl_dropinfo2 = {};
tbl_In_situsetting =
{
defcount = In_situ_login_Count;
timeout = In_situ_login_TimeOut;
limit = In_situ_login_Limit;
};
function new_tbl_dropinfoobject(player)
local lef = 0;
if(tbl_dropinfo[Playerkey(player)] ~= nil)then
lef = tbl_dropinfo[Playerkey(player)].leftCount;
end
local _tbl_dropinfo =
{
leftCount = lef;
LoginCount = Char.GetData(player,%对象_登陆次数%);
MapType = Char.GetData(player,%对象_MAP%);
MapId = Char.GetData(player,%对象_地图%);
X = Char.GetData(player,%对象_X%);
Y = Char.GetData(player,%对象_Y%);
DengonMapId = 0;
DengonName = "";
DengonX = 0;
DengonY = 0;
time = os.time();
};
return _tbl_dropinfo;
end
function new_tbl_dropinfoobject_without_setting(player)
local _tbl_dropinfo =
{
leftCount = 0;
LoginCount = Char.GetData(player,%对象_登陆次数%);
MapType = tbl_dropinfo[Playerkey(player)].MapType;
MapId = tbl_dropinfo[Playerkey(player)].MapId;
X = tbl_dropinfo[Playerkey(player)].X;
Y = tbl_dropinfo[Playerkey(player)].Y;
DengonMapId = 0;
DengonName = "";
DengonX = 0;
DengonY = 0;
time = os.time();
};
return _tbl_dropinfo;
end
function MyLogin_LoginEvent(player)
if(Char.GetData(player,%对象_登陆次数%) == 999)then
Char.SetData(player, %对象_登陆次数% , 1);
end
local suss_link = false; --是否成功原地登录
local suss_Message = "";
local _playerkey = Playerkey(player);
local Drop_list;
if(tbl_dropinfo[_playerkey] ~= nil ) then
Drop_list = tbl_dropinfo[_playerkey]; --获取掉线前的信息
tbl_dropinfo[_playerkey].time = os.time();
else
local PlayerInfo = new_tbl_dropinfoobject(player); --如果是首次登录,获得目前玩家信息,直接返回
tbl_dropinfo[_playerkey] = PlayerInfo;
return;
end
if(tbl_In_situsetting.limit == true) then --如果开放无限次原地登录
suss_Message = "目前服务器开放无限次原地登录,您的连线已经恢复,";
suss_link = true;
end
if (os.time() - Drop_list.time <= tonumber(tbl_In_situsetting.timeout) and tonumber(Char.GetData(player,%对象_登陆次数%)) - Drop_list.LoginCount <= 1 and Drop_list.leftCount > 0)then --是否超时,是否换过线,原地登录次数是否充足
tbl_dropinfo[_playerkey].leftCount = tbl_dropinfo[_playerkey].leftCount - 1; --减掉一次
--print("in is"..tbl_dropinfo[_playerkey].leftCount);
suss_link = true;
end
--NLG.SystemMessage(player,(os.time() - Drop_list.time).." "..tbl_In_situsetting.timeout.." "..tonumber(Char.GetData(player,%对象_登陆次数%)) - Drop_list.LoginCount.." "..Drop_list.leftCount);
if(Drop_list.MapType ~= 0) then --如果是在迷宫内掉线
local Walkable = NLG.Walkable(1,Drop_list.DengonMapId,Drop_list.DengonX,Drop_list.DengonY);
if (NLG.GetMapName(1,Drop_list.DengonMapId) == Drop_list.DengonName and Walkable == 1) then --如果迷宫还未消失,传送回迷宫
Drop_list.MapType = 1;
Drop_list.MapId = Drop_list.DengonMapId;
Drop_list.X = Drop_list.DengonX;
Drop_list.Y = Drop_list.DengonY;
suss_Message = "迷宫尚未消失,您的连线已经恢复,";
else --传送回迷宫口
Drop_list.MapType = 0;
suss_Message = "迷宫消失了,将传送到迷宫入口,";
end
else --如果在常规地图内掉线或者登出
suss_Message = "您的连线已经恢复,";
end
suss_Message = suss_Message.."原地登录次数剩余:"..tbl_dropinfo[_playerkey].leftCount.."次。";
if(In_situ_login_on_off == "on" and suss_link == true ) then
--NLG.SystemMessage(player,Drop_list.MapType.." "..Drop_list.MapId.." "..Drop_list.X.." "..Drop_list.Y.." "..Drop_list.DengonName);
Char.Warp(player,Drop_list.MapType,Drop_list.MapId,Drop_list.X,Drop_list.Y);
if(tonumber(tbl_dropinfo2[Playerkey(player)]) == 1)then
Char.FeverStart(player);
end
NLG.SystemMessage(player,suss_Message);
end
--NLG.SystemMessage(player,Drop_list.MapType.." "..Drop_list.MapId.." "..Drop_list.X.." "..Drop_list.Y.." "..Drop_list.DengonName);
MetamoState13(player)
end
function MetamoState1(MetamoState8)
local MetamoState2 = Item.GetData(MetamoState8,3)
if MetamoState2 >= 10 and MetamoState2 <= 12 then
local MetamoState3 = tonumber(Item.GetData(MetamoState8,%道具_宝石武%))
if MetamoState3 ~= nil and type(MetamoStateList[MetamoState3]) == "table" then
for i = 1,(#MetamoStateList[MetamoState3]-1)/3 do
local MetamoState4 = MetamoStateList[MetamoState3][2+(i-1)*3]
local MetamoState5 = MetamoStateList[MetamoState3][3+(i-1)*3]
local MetamoState6 = MetamoStateList[MetamoState3][4+(i-1)*3]
local MetamoState7 = Item.GetData(MetamoState8,MetamoState4)
if MetamoState5 == 0 then
Item.SetData(MetamoState8,MetamoState4,0)
elseif MetamoState5 == 1 then
Item.SetData(MetamoState8,MetamoState4,MetamoState7-MetamoState6)
end
end
Item.SetData(MetamoState8,%道具_宝石武%,0)
if renamekey == 1 then
Item.SetData(MetamoState8,2001,Item.GetData(MetamoState8,2000))
end
return 1
end
end
return 0
end
function MetamoState9(MetamoState12,MetamoState8,MetamoState10)
for i = 1,(#MetamoStateList[MetamoState10]-1)/3 do
local MetamoState4 = MetamoStateList[MetamoState10][2+(i-1)*3]
local MetamoState5 = MetamoStateList[MetamoState10][3+(i-1)*3]
local MetamoState6 = MetamoStateList[MetamoState10][4+(i-1)*3]
local MetamoState7 = Item.GetData(MetamoState8,MetamoState4)
Item.SetData(MetamoState8,MetamoState4,MetamoState7*MetamoState5+MetamoState6)
end
--Item.SetData(MetamoState8,%道具_自用参数%,MetamoState10)
Item.SetData(MetamoState8,%道具_宝石武%,MetamoState10)
if renamekey == 1 then
Item.SetData(MetamoState8,%道具_鉴前名%,Item.GetData(MetamoState8,%道具_名字%))
Item.SetData(MetamoState8,%道具_名字%,MetamoStateList[MetamoState10][1])
end
if bangdingkey == 1 then
Item.SetData(MetamoState8,%道具_丢地消失%,1)
Item.SetData(MetamoState8,%道具_宠邮%,0)
end
NLG.SystemMessage(MetamoState12,"得到了 "..MetamoStateList[MetamoState10][1].." 的力量!")
end
function MetamoState13(MetamoState12)
local MetamoState8 = Char.GetItemIndex(MetamoState12,MetamoStateItemPos)
if MetamoState8 > 0 then
if MetamoState1(MetamoState8) ~= 0 then
Item.UpItem(MetamoState12,MetamoStateItemPos)
end
end
for i = 8,27 do
MetamoState8 = Char.GetItemIndex(MetamoState12,i)
if MetamoState8 > 0 then
if MetamoState1(MetamoState8) ~= 0 then
Item.UpItem(MetamoState12,i)
end
end
end
local MetamoState11 = Char.GetData(MetamoState12,%对象_原形%)
if type(MetamoStateList[MetamoState11]) == "table" then
MetamoState8 = Char.GetItemIndex(MetamoState12,MetamoStateItemPos)
if MetamoState8 > 0 then
MetamoState9(MetamoState12,MetamoState8,MetamoState11)
Item.UpItem(MetamoState12,MetamoStateItemPos)
else
NLG.SystemMessage(MetamoState12,"附加形象属性失败。您未装备身体位置的道具。")
end
end
return
end
function MyLogin_OutEvent(player)
tbl_dropinfo2[Playerkey(player)] = Char.IsFeverTime(player);
local Playerinfo = new_tbl_dropinfoobject(player);
if(Playerinfo.MapType == 0) then --如果?辉诿怨冢虮4娉9娴赝夹畔ⅰ?
Playerinfo.leftCount = tonumber(tbl_dropinfo[Playerkey(player)].leftCount); --保存当前原地登录次数
--print("key is "..Playerkey(player));
--print("value is "..tbl_dropinfo[Playerkey(player)].leftCount);
tbl_dropinfo[Playerkey(player)] = Playerinfo;
return;
end
if(Playerinfo.MapType == 1) then --如果在迷宫内,则保存迷宫内信息
local dropinfo = new_tbl_dropinfoobject_without_setting(player);
local MapName = NLG.GetMapName(1,Playerinfo.MapId); --获取迷宫名字,如果迷宫消失则回到迷宫口
dropinfo.MapType = 1;
dropinfo.DengonMapId = Playerinfo.MapId;
dropinfo.DengonName = MapName;
dropinfo.DengonX = Playerinfo.X;
dropinfo.DengonY = Playerinfo.Y;
dropinfo.leftCount = tonumber(tbl_dropinfo[Playerkey(player)].leftCount); --保存当前原地登录次数
tbl_dropinfo[Playerkey(player)] = dropinfo;
end
end
function MyLogin_WarpEvent(player)
--[[
local dropinfo = new_tbl_dropinfoobject(player);
if(dropinfo.MapType == 0) then
dropinfo.leftCount = tonumber(tbl_dropinfo[Playerkey(player)].leftCount);
tbl_dropinfo[Playerkey(player)] = dropinfo;
end--]]
local partyNum = Char.PartyNum(player); --保存所有队员进入迷宫前的位置信息
for i=0,partyNum do
local this_player = Char.GetPartyMember(player,i);
if(VaildChar(this_player))then
local dropinfo = new_tbl_dropinfoobject(this_player);
if(dropinfo.MapType == 0) then
tbl_dropinfo[Playerkey(this_player)] = dropinfo;
--NLG.SystemMessage(this_player,dropinfo.X);
end
end
end
end
function inityddlNpc_Init(index)
print("原地登录npc_index = " .. index);
return 1;
end
function inityddlNpc()
if (yddlnpc == nil) then
yddlnpc = NL.CreateNpc("lua/Module/myLogin.lua", "inityddlNpc_Init");
Char.SetData(yddlnpc,%对象_形象%,NPCPoint[1]);
Char.SetData(yddlnpc,%对象_原形%,NPCPoint[1]);
Char.SetData(yddlnpc,%对象_X%,NPCPoint[3]);
Char.SetData(yddlnpc,%对象_Y%,NPCPoint[4]);
Char.SetData(yddlnpc,%对象_地图%,NPCPoint[2]);
Char.SetData(yddlnpc,%对象_方向%,NPCPoint[5]);
Char.SetData(yddlnpc,%对象_原名%,NPCName);
NLG.UpChar(yddlnpc);
--这里是与Npc说话的时候,调用ChangePassMsg函数
Char.SetTalkedEvent("lua/Module/myLogin.lua","yddlnpcMsg", yddlnpc);
end
if (yddlnpc_1 == nil) then
yddlnpc_1 = NL.CreateNpc("lua/Module/myLogin.lua", "inityddlNpc_Init");
Char.SetData(yddlnpc_1,%对象_形象%,NPCPoint[1]);
Char.SetData(yddlnpc_1,%对象_原形%,NPCPoint[1]);
Char.SetData(yddlnpc_1,%对象_X%,34);
Char.SetData(yddlnpc_1,%对象_Y%,35);
Char.SetData(yddlnpc_1,%对象_地图%,777);
Char.SetData(yddlnpc_1,%对象_方向%,4);
Char.SetData(yddlnpc_1,%对象_原名%,NPCName);
NLG.UpChar(yddlnpc_1);
--这里是与Npc说话的时候,调用ChangePassMsg函数
Char.SetTalkedEvent("lua/Module/myLogin.lua","yddlnpcMsg", yddlnpc_1);
end
end
function yddlnpcMsg(_me,_tome)
if (NLG.CanTalk(_me,_tome) == true) then
str_ChangeWindow = "\\n\\n 勇者,您的原地登出次数已重置为"..tbl_In_situsetting.defcount.."次!\\n\\n 登出超过120分钟将返回记录点。";
tbl_dropinfo[Playerkey(_tome)].leftCount = tbl_In_situsetting.defcount;
NLG.ShowWindowTalked(_tome,_me,%窗口_信息框%,%按钮_关闭%,1,str_ChangeWindow);
return;
end
end
function inityddltable_cleanNpc_Init(index)
print("原地登录内存回收员npc_index = " .. index);
return 1;
end
function inittable_cleanNpc()
if (table_cleanNpc == nil) then
table_cleanNpc = NL.CreateNpc("lua/Module/myLogin.lua", "inityddltable_cleanNpc_Init");
Char.SetData(table_cleanNpc,%对象_形象%,231088);
Char.SetData(table_cleanNpc,%对象_原形%,231088);
Char.SetData(table_cleanNpc,%对象_X%,47);
Char.SetData(table_cleanNpc,%对象_Y%,47);
Char.SetData(table_cleanNpc,%对象_地图%,777);
Char.SetData(table_cleanNpc,%对象_方向%,4);
Char.SetData(table_cleanNpc,%对象_原名%,"内存回收员");
NLG.UpChar(table_cleanNpc);
--这里是与Npc说话的时候,调用ChangePassMsg函数
Char.SetLoopEvent("lua/Module/myLogin.lua","table_cleanNpcLoopEvent", table_cleanNpc,1800); --30分钟执行一次table清理。
end
end
function table_cleanNpcLoopEvent(index)
--原地登录table清理相关
--解释:如果超时,那么直接清理掉相关此玩家drop信息。
for i,v in pairs(tbl_dropinfo) do
if(os.time() - v.time > tbl_In_situsetting.timeout )then
tbl_dropinfo = nil;
end
end
--结束
end
function MyLogin_Init()
inityddlNpc();
--inittable_cleanNpc();
end
|
|