Delegate.RegInit("routine_Init");
Delegate.RegDelTalkEvent("routine_talk");
local routine_ItemID=88888
local routine_Name="升级道具"
local routine_exp = {100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500}--需要修炼升级经验
local routine_Gold = {100,200,300,400,500,600,700,800,900,1000,1100,1200,1300,1400,1500}--需要修炼升级魔币
local routine_Item = {10,20,30,40,50,60,70,80,90,100,120,140,160,180,200}--需要修炼升级道具数量
local routine_A = {1,2,3,4,5,7,9,11,13,15,18,21,24,27,30}--增加伤害百分比
local routine_B = {1,2,3,4,5,7,9,11,13,15,18,21,24,27,30}--减免伤害百分比
function routine_talk(player,msg,color,range,size)
if(msg == "jd") then
routine_callback_command(player,msg,color,range,size);
end
end
Delegate.RegDelBattleStartEvent("routine_BattleStart_Event");
Delegate.RegDelBattleOverEvent("routine_BattleOver_Event");
function routine_new_tbl_Event(_Player)
local _tbl_routineinfo =
{
header = "0|0|0";
target = {};
temporary = {};
}
return _tbl_routineinfo;
end
function routine_BattleStart_Event(battleindex)
routine_prebattle(battleindex);
end
function routine_BattleOver_Event(battleindex)
for PwhI=0,4 do
local PIndex = Battle.GetPlayer(battleindex,PwhI);
if(VaildChar(PIndex)==true) then
if Char.GetData(PIndex,%对象_血%) ~= 0 then
routine_postbattle(battleindex,PIndex);
end
end
end
end
ROUTINE_TYPE = {"捕捉","猎杀","搜寻"};
routine_list = {};
routine_lvlist = {};
--目标列表这样写
--显示的名字,ID,数量|显示的名字,ID,数量|.......
--不要以|结尾
--可无限续接
--当类型为捕捉的时候,数量无效,即捕捉只能要求抓一只,但仍然要写上去
--当类型为猎杀的时候,ID无效,但仍然要写上随便一个数字
--奖励列表这样写
--金钱|声望|经验|奖励道具名字,ID,数量|......
--不要以|结尾
--道具可有可无,但前面三个一定要有
routine_list[1] = {};
routine_list[1].type = 3;
routine_list[1].target = "牛排,15215,2";
routine_list[1].reward = "修行经验,10";
--********************************猎 杀 BOSS 类********************************--
--********************************90级 物 品 类********************************--
--等级限制列表
--ids内填写此等级范围内的任务ID
--分配任务组别的优先级按序号从小到大
routine_lvlist[1] = {};
routine_lvlist[1].max = 10;
routine_lvlist[1].min = 1;
routine_lvlist[1].ids = {1}
ROUTINE_WINDOW_SEQUENCE_MAIN = 10000;
ROUTINE_WINDOW_SEQUENCE_OFFER = 10001;
ROUTINE_WINDOW_SEQUENCE_CHECK = 10002;
ROUTINE_WINDOW_SEQUENCE_SUBMIT = 10003;
ROUTINE_WINDOW_SEQUENCE_CANCEL = 10004;
ROUTINE_WINDOW_SEQUENCE_ABANDON = 20000;
function getitemnum(_index,_id)
local count = 0;
for i = 8, 27 do
local index = Char.GetItemIndex(_index,i)
if index ~= -1 and index ~= -2 and index ~= -3 then
if Item.GetData(index,%道具_序%) == _id then
count = count + 1;
end
end
end
return count;
end
function getdata( _flag, _source)
local a,b;
a, b = string.find( _source, _flag.."=");
if( a == nil or b == nil)then
return nil;
end
a = string.find( _source, "|", b);
local ret = tonumber(string.sub( _source, b+1, a-1));
if ret == nil then
ret = 0
end
return ret;
end
function gendata( _flag, _source, _newdata)
local data = getdata( _flag, _source);
local ns;
if( data == nil)then
ns = _source.._flag.."=".._newdata.."|";
else
ns = string.gsub( _source, _flag.."="..data.."|", _flag.."=".._newdata.."|",1);
end
return ns;
end
function splitdata(szFullString, szSeparator)
local nFindStartIndex = 1;
local nSplitIndex = 1;
local nSplitArray = {};
while true do
local nFindLastIndex = string.find(szFullString, szSeparator, nFindStartIndex);
if not nFindLastIndex then
nSplitArray[nSplitIndex] = string.sub(szFullString, nFindStartIndex, string.len(szFullString));
break;
end
nSplitArray[nSplitIndex] = string.sub(szFullString, tonumber(nFindStartIndex),tonumber(nFindLastIndex - 1));
nFindStartIndex = tonumber(nFindLastIndex) + string.len(szSeparator);
nSplitIndex = tonumber(nSplitIndex + 1);
end
return nSplitArray;
end
function genpdata_t(_data)
local tdata = splitdata(_data,"|");
local tn = #tdata;
local pdata = {};
for i = 1, tn do
local ttdata = splitdata(tdata[i],",");
pdata[i] = {ttdata[1],tonumber(ttdata[2]),tonumber(ttdata[3])};
end
return pdata;
end
function genpdata_r(_data)
local pdata = {};
local rrdata = splitdata(_data,",");
pdata[1] = 0;
pdata[2] = 0;
pdata[3] = 0;
pdata[4] = {rrdata[1],tonumber(rrdata[2])};
return pdata;
end
function routine_create()
if(routine_index == nil)then
routine_index = NL.CreateNpc("lua/Module/routine_too.lua","routine_init");
Char.SetData(routine_index,%对象_形象%,100452);
Char.SetData(routine_index,%对象_原形%,100452);
Char.SetData(routine_index,%对象_X%,235);
Char.SetData(routine_index,%对象_Y%,77);
Char.SetData(routine_index,%对象_地图%,1000);
Char.SetData(routine_index,%对象_方向%,4);
Char.SetData(routine_index,%对象_名字%,"日常修炼");
NLG.UpChar(routine_index);
Char.SetTalkedEvent("lua/Module/routine_too.lua", "routine_callback_talk", routine_index);
Char.SetWindowTalkedEvent("lua/Module/routine_too.lua", "routine_callback_window", routine_index);
end
end
function routine_Init()
routine_create();
end
function routine_init(_index)
return true;
end
function routine_offer( _index_me, _index_tome)
local _Player = Playerkey(_index_tome);
local header = nil;
if(tbl_routineinfo ~= nil and tbl_routineinfo[_Player] ~= nil and tbl_routineinfo[_Player].header ~= nil)then
header = tbl_routineinfo[_Player].header;
end
local message = "";
local nowtime = tonumber(os.date("%d",os.time()));
local lv = Char.GetData(_index_tome, %对象_等级%)
if header == nil then
header = "0|0|0";
end
local pheader = splitdata(header,"|");
local flag = tonumber(pheader[1]);
local time = tonumber(pheader[2]);
if flag == 0 or time ~= nowtime then
local seed = 0;
for i = 1, #routine_lvlist do
if lv <= routine_lvlist[i].max and lv >= routine_lvlist[i].min then
local ids2 = routine_lvlist[i].ids;
seed = routine_lvlist[i].ids[math.random(1,#ids2)]
break;
end
end
if seed == 0 then
seed = math.random(1,#routine_list);
end
local tpdata = genpdata_t(routine_list[seed].target);
local rpdata = genpdata_r(routine_list[seed].reward);
local message = "\\n任务已接受"..
"\\n"..
"\\n"..
"\\n任务类型:"..ROUTINE_TYPE[routine_list[seed].type]..
"\\n任务要求:";
for i = 1, #tpdata do
message = message .. tpdata[i][1] .. "×" .. tpdata[i][3] .. " ";
end
message = message .. "\\n任务奖励:";
for i = 4, #rpdata do
message = message .. rpdata[i][1] .. "×" .. rpdata[i][2] .. " ";
end
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_信息框%, %按钮_确定%, ROUTINE_WINDOW_SEQUENCE_OFFER, message);
local nheader = "1|" .. nowtime .. "|" .. seed;
tbl_routineinfo[_Player].header = nheader;
if routine_list[seed].type == 2 then
local tpdata = genpdata_t(routine_list[seed].target);
for i = 1, #tpdata do
tbl_routineinfo[_Player].target[i] = 0;
tbl_routineinfo[_Player].temporary[i] = 0;
end
end
else
local message = "\\n";
if flag == 1 then
message = "\\n今天的日常任务正在进行中,请加油。"
end
if flag == 2 then
message = "\\n今天的日常任务你已经放弃喽,请明天再来。"
end
if flag == 3 then
message = "\\n今天的日常任务你已经完成喽,请明天再来。"
end
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_信息框%, %按钮_确定%, ROUTINE_WINDOW_SEQUENCE_OFFER, message);
end
end
function routine_check( _index_me, _index_tome)
local _Player = Playerkey(_index_tome);
local header = nil;
if(tbl_routineinfo ~= nil and tbl_routineinfo[_Player] ~= nil and tbl_routineinfo[_Player].header ~= nil)then
header = tbl_routineinfo[_Player].header;
end
local message = "";
if header == nil then
header = "0|0|0";
end
local pheader = splitdata(header,"|");
local flag = tonumber(pheader[1]);
local time = tonumber(pheader[2]);
local seed = tonumber(pheader[3]);
if flag == 0 then
message = "\\n你还没开始今天的日常任务。";
elseif flag == 1 then
local tpdata = genpdata_t(routine_list[seed].target);
local rpdata = genpdata_r(routine_list[seed].reward);
message = "\\n任务已接受"..
"\\n"..
"\\n"..
"\\n任务类型:"..ROUTINE_TYPE[routine_list[seed].type]..
"\\n任务要求:";
for i = 1, #tpdata do
message = message .. tpdata[i][1] .. "×" .. tpdata[i][3] .. " ";
end
message = message .. "\\n任务奖励: ";
for i = 4, #rpdata do
message = message .. rpdata[i][1] .. "×" .. rpdata[i][2] .. " ";
end
elseif flag == 2 then
message = "\\n你已经放弃今天的日常任务,请明天再来。";
elseif flag == 3 then
message = "\\n你已经完成了今天的日常任务,请明天再来。";
end
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_信息框%, %按钮_确定%, ROUTINE_WINDOW_SEQUENCE_CHECK, message);
end
function routine_submit( _index_me, _index_tome)
local _Player = Playerkey(_index_tome);
--local header = tbl_routineinfo[_Player].header;
local header = nil;
if(tbl_routineinfo ~= nil and tbl_routineinfo[_Player] ~= nil and tbl_routineinfo[_Player].header ~= nil)then
header = tbl_routineinfo[_Player].header;
end
--local header = Field.Get(_index_tome,"routine_header");
local message = "";
if header == nil then
header = "0|0|0";
end
local pheader = splitdata(header,"|");
local flag = tonumber(pheader[1]);
local time = tonumber(pheader[2]);
local seed = tonumber(pheader[3]);
if flag == 0 then
message = "\\n你还没开始今天的日常任务。";
elseif flag == 1 then
local tpdata = genpdata_t(routine_list[seed].target);
local type = routine_list[seed].type;
if type == 1 then
if Char.ItemSlot(_index_tome) == 20 then
NLG.SystemMessage(_index_tome,"身上的道具太多了。")
return;
end
local clear = true;
for i = 1, #tpdata do
local id = tpdata[i][2];
if Char.HavePet(_index_tome,id)== -1 then
clear = false;
end
if clear == false then
break;
end
end
if clear == false then
message = "\\n你还没有完成今天的日常任务,请加油。";
else
for i = 1,#tpdata do
local id = tpdata[i][2];
NLG.SystemMessage(_index_tome,"交出"..tpdata[i][1].."。");
Char.DelSlotPet(_index_tome,Char.HavePet(_index_tome,id));
end
local rpdata = genpdata_r(routine_list[seed].reward);
local XName = rpdata[4][1];
local XNum = rpdata[4][2];
message = "\\n获得奖励: ";
for i = 4, #rpdata do
message = message .. rpdata[i][1] .. "×" .. rpdata[i][2] .. " ";
end
local nheader = "3|"..time.."|0";
tbl_routineinfo[_Player].header = "0|0|0";
routine_Mysql(_index_tome,2,0,XNum);
end
elseif type == 2 then
if Char.ItemSlot(_index_tome) == 20 then
NLG.SystemMessage(_index_tome,"身上的道具太多了。")
return;
end
local clear = true;
for i = 1, #tpdata do
local tcount = tonumber(tbl_routineinfo[_Player].target[i]);
if tcount == nil then
tcount = 0;
end
if tcount < tpdata[i][3] then
clear = false;
end
if clear == false then
break;
end
end
if clear == false then
message = "\\n你还没有完成今天的日常任务,请加油。";
else
for i = 1, #tpdata do
tbl_routineinfo[_Player].target[i] = 0;
tbl_routineinfo[_Player].temporary[i] = 0;
end
local rpdata = genpdata_r(routine_list[seed].reward);
local XName = rpdata[4][1];
local XNum = rpdata[4][2];
message = "\\n获得奖励: ";
for i = 4, #rpdata do
message = message .. rpdata[i][1] .. "×" .. rpdata[i][2] .. " ";
end
local nheader = "3|"..time.."|0";
tbl_routineinfo[_Player].header = "0|0|0";
routine_Mysql(_index_tome,2,0,XNum);
end
elseif type == 3 then
if Char.ItemSlot(_index_tome) == 20 then
NLG.SystemMessage(_index_tome,"身上的道具太多了。")
return;
end
local clear = true;
for i = 1, #tpdata do
local id = tpdata[i][2];
local num = tpdata[i][3];
if num > Char.ItemNum(_index_tome,id) then
clear = false;
end
if clear == false then
break;
end
end
if clear == false then
message = "\\n你还没有完成今天的日常任务,请加油。";
else
for i = 1, #tpdata do
local id = tpdata[i][2];
local num = tpdata[i][3]
Char.DelItem(_index_tome,id,num);
end
local rpdata = genpdata_r(routine_list[seed].reward);
local XName = rpdata[4][1];
local XNum = rpdata[4][2];
message = "\\n获得奖励: ";
for i = 4, #rpdata do
message = message .. rpdata[i][1] .. "×" .. rpdata[i][2] .. " ";
end
local nheader = "3|"..time.."|0";
tbl_routineinfo[_Player].header = "0|0|0";
routine_Mysql(_index_tome,2,0,XNum);
end
end
elseif flag == 2 then
message = "\\n你已经放弃今天的日常任务,请明天再来。";
elseif flag == 3 then
message = "\\n你已经完成了今天的日常任务,请明天再来。";
end
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_信息框%, %按钮_关闭%,ROUTINE_WINDOW_SEQUENCE_SUBMIT, message);
end
function routine_cancel( _index_me, _index_tome)
local _Player = Playerkey(_index_tome);
local header = nil;
if(tbl_routineinfo ~= nil and tbl_routineinfo[_Player] ~= nil and tbl_routineinfo[_Player].header ~= nil)then
header = tbl_routineinfo[_Player].header;
end
--local header = tbl_routineinfo[_Player].header;
--local header = Field.Get(_index_tome,"routine_header");
local message = "";
if header == nil then
header = "0|0|0";
end
local pheader = splitdata(header,"|");
local flag = tonumber(pheader[1]);
local time = tonumber(pheader[2]);
local seed = tonumber(pheader[3]);
if flag == 0 or flag == 2 or flag == 3 then
message = "\\n你没有正在进行的日常任务。";
elseif flag == 1 then
message = "\\n你确认要放弃今天的日常任务吗?"..
"\\n一旦放弃,需要等到明天才能再接噢!";
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_信息框%, %按钮_是否%,ROUTINE_WINDOW_SEQUENCE_ABANDON,message);
end
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_信息框%, %按钮_关闭%, ROUTINE_WINDOW_SEQUENCE_CANCEL, message);
end
function routine_prebattle(_index_battle)
for pos = 0, 4 do
local index = Battle.GetPlayer( _index_battle, pos);
if( VaildChar(index) == true)then
local _Player = Playerkey(index);
local header = nil;
--local header = Field.Get(index,"routine_header");
--if header == nil then
if(tbl_routineinfo ~= nil and tbl_routineinfo[_Player] ~= nil and tbl_routineinfo[_Player].header ~= nil)then
header = tbl_routineinfo[_Player].header;
end
if header == nil then
header = "0|0|0";
else
header = tbl_routineinfo[_Player].header;
end
local pheader = splitdata(header,"|");
local flag = tonumber(pheader[1]);
local seed = tonumber(pheader[3]);
if flag == 1 and routine_list[seed].type == 2 then
local tpdata = genpdata_t(routine_list[seed].target);
for oppos = 10, 19 do
local opindex = Battle.GetPlayer( _index_battle, oppos);
if( VaildChar(opindex) == true)then
for i = 1, #tpdata do
if( Char.GetData( opindex, %对象_名字%) == tpdata[i][1])then
if(tonumber(tbl_routineinfo[_Player].target[i]) < tpdata[i][3]) then
--if( tonumber( Field.Get( index, "routine_target_"..i)) < tpdata[i][3])then
tbl_routineinfo[_Player].temporary[i] = tbl_routineinfo[_Player].temporary[i] + 1;
--Field.Set( index, "routine_target_temporary_"..i, tostring( tonumber( Field.Get( index, "routine_target_temporary_"..i))+1));
end
end
end
end
end
end
end
end
end
function routine_postbattle( _index_battle, _index_me)
local _Player = Playerkey(_index_me);
--local header = Field.Get(_index_me,"routine_header")
--if header == nil then
local header = nil;
if(tbl_routineinfo ~= nil and tbl_routineinfo[_Player] ~= nil and tbl_routineinfo[_Player].header ~= nil)then
header = tbl_routineinfo[_Player].header;
end
if header == nil then
header = "0|0|0";
else
header = tbl_routineinfo[_Player].header;
end
local pheader = splitdata(header,"|")
local flag = tonumber(pheader[1])
local seed = tonumber(pheader[3])
if flag == 1 and routine_list[seed].type == 2 then
local tpdata = genpdata_t(routine_list[seed].target)
for i = 1, #tpdata do
precount = tbl_routineinfo[_Player].temporary[i];
count = tbl_routineinfo[_Player].target[i];
--precount = tonumber( Field.Get( _index_me, "routine_target_temporary_"..i));
--count = tonumber( Field.Get( _index_me, "routine_target_"..i));
if( precount == nil)then
precount = 0;
end
if( count == nil)then
count = 0;
end
count = count + precount;
tbl_routineinfo[_Player].target[i] = count;
tbl_routineinfo[_Player].temporary[i] = 0;
--Field.Set( _index_me, "routine_target_"..i, tostring( count));
--Field.Set( _index_me, "routine_target_temporary_"..i, 0)
end
end
end
function routine_callback_talk( _index_me, _index_tome)
if(NLG.CheckInFront(_index_tome, _index_me, 1) == false) then
return ;
end
local message = "6"..
"\\n★★★★★★★★★★日常修炼★★★★★★★★★"..
"注意:修行可以增加攻击伤害和伤害减免"..
"\\n注意:攻击伤害不会显示在人物界面"..
"\\n注意:伤害减免不会显示在人物界面"..
"\\n"..
"\\n"..
"\\n修行进度查看";
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_选择框%, %按钮_关闭%,1, message);
return
end
function routine_callback_window( _index_me, _index_tome, _sequence, _select, _data)
if tonumber(_sequence)==0 then
return;
end
local _Player = Playerkey(_index_tome);
if(tbl_routineinfo[_Player] == nil) then
tbl_routineinfo[_Player] = routine_new_tbl_Event(_index_tome);
end
if tonumber(_sequence)==1 then
local argument = tonumber( _data);
if tonumber(argument)==1 then
local message = "6"..
"\\n★★★★★★★★日常任务领取处★★★★★★★"..
"\\n注意:放弃任务后当日无法再重新接任务"..
"\\n注意:提交捕捉任务的时候请不要把自己的与任务"..
"\\n目标相同的宠物带在身上,否则可能会被收走哦。"..
"\\n"..
"\\n接受日常任务"..
"\\n查看当前任务完成进度"..
"\\n提交任务"..
"\\n放弃任务";
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_选择框%, %按钮_关闭%, ROUTINE_WINDOW_SEQUENCE_MAIN, message);
return
elseif tonumber(argument)==2 then
local message = "5"..
"\\n★★★★★★★★修行进度查看★★★★★★★"..
"\\n注意:修行可以增加攻击伤害和伤害减免"..
"\\n注意:攻击伤害不会显示在人物界面"..
"\\n注意:伤害减免不会显示在人物界面"..
"\\n"..
"\\n查看修炼经验"..
"\\n查看修炼属性"..
"\\n升级修炼等级";
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_选择框%, %按钮_关闭%, 10, message);
return
end
end
if _sequence==10 then
local argument = tonumber(_data);
if tonumber(argument) >=1 and tonumber(argument)<=3 then
if argument==1 then
local c1=routine_Mysql(_index_tome,1);
local message = "\\n★★★★★★★★查看修炼经验★★★★★★★"..
"\\n\\n您当前的修炼经验与修炼等级如下:"..
"\\n\\n修炼等级:"..tonumber(c1[1])..
"\\n修炼经验:"..c1[2];
NLG.ShowWindowTalked(_index_tome,_index_me, %窗口_选择框%, %按钮_关闭%,0, message);
elseif argument==2 then
local c1=routine_Mysql(_index_tome,1);
local c2=GetDamage_Init(_index_tome);
local message = "\\n★★★★★★★★查看修炼属性★★★★★★★"..
"\\n\\n您当前的修炼等级与属性如下:"..
"\\n\\n修炼等级:"..tonumber(c1[1])..
"\\n增加伤害:"..c2[1].."%"..
"\\n减免伤害:"..c2[2].."%";
NLG.ShowWindowTalked(_index_tome,_index_me, %窗口_信息框%, %按钮_关闭%,0, message);
elseif argument==3 then
local c1=routine_Mysql(_index_tome,1);
local p1=tonumber(c1[1]);
if tonumber(p1)>=tonumber(#routine_exp) then
local message = "\\n您当前的修炼等级已达到最高等级"..
NLG.ShowWindowTalked(_index_tome,_index_me, %窗口_信息框%, %按钮_确定%,0, message);
end
local p2 = routine_gexp(tonumber(p1));
local c2= Char.ItemNum(_index_tome,routine_ItemID);
local c3= routine_ItemNum(p1);
if c3 <= c2 then
local message = "\\n★★★★★★★★查看修炼属性★★★★★★★"..
"\\n\\n您当前的修炼等级与升级经验如下:"..
"\\n\\n修炼等级:"..tonumber(c1[1])..
"\\n修炼经验:"..tonumber(c1[2]).."/"..tonumber(p2)..
"\\n\\n是否使用:"..c3.."个"..routine_Name..",道具提升等级";
NLG.ShowWindowTalked(_index_tome,_index_me, %窗口_信息框%,3,12, message);
return;
end
local p3="不可升级";
local p4=0;
local p5 = routine_Lv(tonumber(p1));
local p6=1;
if tonumber(c1[2])>= tonumber(p2) then
p3="可以升级\\n需求魔币:"..routine_Gold[p5];
p4=11;
p6=3;
end
local message = "\\n★★★★★★★★查看修炼属性★★★★★★★"..
"\\n\\n您当前的修炼等级与升级经验如下:"..
"\\n\\n修炼等级:"..tonumber(c1[1])..
"\\n修炼经验:"..tonumber(c1[2]).."/"..tonumber(p2)..
"\\n修炼升级:"..p3;
NLG.ShowWindowTalked(_index_tome,_index_me, %窗口_信息框%,p6,p4, message);
end
end
return
end
if _sequence==11 then
local c1=routine_Mysql(_index_tome,1);
local p1=tonumber(c1[1]);
if tonumber(p1)>= tonumber(#routine_exp) then
local message = "\\n您当前的修炼等级已达到最高等级"..
NLG.ShowWindowTalked(_index_tome,_index_me, %窗口_信息框%, %按钮_确定%,0, message);
end
local p2 = routine_gexp(tonumber(p1));
if tonumber(c1[2])< tonumber(p2) then
NLG.SystemMessage(_index_tome, "所需经验不足!")
return ;
end
local p3 = Char.GetData(_index_tome,53);
local p4 = routine_Lv(tonumber(p1));
local p5=routine_Gold[p4];
if p5 > p3 then
NLG.SystemMessage(_index_tome, "所需魔币不足!")
return ;
end
Char.SetData(_index_tome,53,p3-p5);
NLG.UpChar(_index_tome);
local p6=tonumber(c1[2]);
routine_Mysql(_index_tome,2,1,p2-p6);
routine_RegDamage(_index_tome,2,p1+1);
local c2=GetDamage_Init(_index_tome);
local message = "\\n★★★★★★★★查看修炼属性★★★★★★★"..
"\\n\\n您当前的修炼等级与属性如下:"..
"\\n\\n修炼等级:"..tonumber(p1+1)..
"\\n增加伤害:"..c2[1].."%"..
"\\n减免伤害:"..c2[2].."%";
NLG.ShowWindowTalked(_index_tome,_index_me,0,1,0, message);
return
end
if _sequence==12 then
if _select==1 then
local c1=routine_Mysql(_index_tome,1)
local p1=tonumber(c1[1]);
local p2=tonumber(c1[2]);
local x2= Char.ItemNum(_index_tome,routine_ItemID);
local x3= routine_ItemNum(p1);
if x2 < x3 then
NLG.SystemMessage(_index_tome, "所需道具不足!")
return;
end
Char.DelItem(_index_tome,routine_ItemID,x3);
local p3 = routine_gexp(tonumber(p1));
routine_Mysql(_index_tome,2,1,p3-p2);
routine_RegDamage(_index_tome,2,p1+1);
local c2=GetDamage_Init(_index_tome);
local message = "\\n★★★★★★★★查看修炼属性★★★★★★★"..
"\\n\\n您当前的修炼等级与属性如下:"..
"\\n\\n修炼等级:"..tonumber(p1+1)..
"\\n增加伤害:"..c2[1].."%"..
"\\n减免伤害:"..c2[2].."%";
NLG.ShowWindowTalked(_index_tome,_index_me, %窗口_信息框%, %按钮_确定%,0, message);
elseif _select==2 then
local c1=routine_Mysql(_index_tome,1);
local p1=tonumber(c1[1]);
if tonumber(p1)>= tonumber(#routine_exp) then
local message = "\\n您当前的修炼等级已达到最高等级"..
NLG.ShowWindowTalked(_index_tome,_index_me, %窗口_信息框%, %按钮_确定%,0, message);
end
local p2 = routine_gexp(tonumber(p1));
local p3="不可升级";
local p4=0;
local p5 = routine_Lv(tonumber(p1));
if tonumber(c1[2])> tonumber(p2) then
p3="可以升级\\n需求魔币:"..routine_Gold[p5];
p4=11;
end
local message = "\\n★★★★★★★★查看修炼属性★★★★★★★"..
"\\n\\n您当前的修炼等级与升级经验如下:"..
"\\n\\n修炼等级:"..tonumber(p1)..
"\\n修炼经验:"..tonumber(c1[2]).."/"..tonumber(p2)..
"\\n修炼升级:"..p3;
NLG.ShowWindowTalked(_index_tome,_index_me, %窗口_信息框%, %按钮_确定%,p4, message)
end
return
end
if( _sequence == ROUTINE_WINDOW_SEQUENCE_MAIN)then
local argument = tonumber( _data);
if( argument == 1)then
if(Char.GetData(_index_tome,%对象_等级%) <=29)then
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_信息框%, %按钮_关闭%,
ROUTINE_WINDOW_SEQUENCE_CANCEL, "您的等级小于30级,无法接任务。");
return;
end
routine_offer( _index_me, _index_tome)
end
if( argument == 2)then
routine_check( _index_me, _index_tome);
end
if( argument == 3)then
routine_submit( _index_me, _index_tome);
end
if( argument == 4)then
routine_cancel( _index_me, _index_tome);
end
end
if ( _sequence == ROUTINE_WINDOW_SEQUENCE_ABANDON ) then
if ( _select == %按钮_是%) then
local _Player = Playerkey(_index_tome);
local header = nil;
if(tbl_routineinfo ~= nil and tbl_routineinfo[_Player] ~= nil and tbl_routineinfo[_Player].header ~= nil)then
header = tbl_routineinfo[_Player].header;
end
local message = "";
if header == nil then
header = "0|0|0";
end
local pheader = splitdata(header,"|");
local flag = tonumber(pheader[1]);
local time = tonumber(pheader[2]);
local seed = tonumber(pheader[3]);
message = "\\n你今日的日常任务已放弃,需要等明天才能再接喔。";
nheader = "2|"..time.."|0";
tbl_routineinfo[_Player].header = nheader;
NLG.ShowWindowTalked( _index_tome, _index_me, %窗口_信息框%,%按钮_关闭%,ROUTINE_WINDOW_SEQUENCE_CANCEL, message);
end
end
end
function routine_callback_command( _index, _message, _color, _range, _size)
local _Player = Playerkey(_index);
--local header;
--local header = Field.Get(_index,"routine_header")
local header = nil;
if(tbl_routineinfo ~= nil and tbl_routineinfo[_Player] ~= nil and tbl_routineinfo[_Player].header ~= nil)then
header = tbl_routineinfo[_Player].header;
end
if header == nil then
header = "0|0|0";
else
header = tbl_routineinfo[_Player].header;
end
local pheader = splitdata(header,"|")
local flag = tonumber(pheader[1])
local seed = tonumber(pheader[3])
local message = "[日常任务]";
if flag == 1 and routine_list[seed].type == 2 then
local tpdata = genpdata_t(routine_list[seed].target)
for i = 1, #tpdata do
message = message .. tpdata[i][1].."("..tbl_routineinfo[_Player].target[i].."/".. tpdata[i][3]..") "
--message = message .. tpdata[i][1].."("..Field.Get(_index,"routine_target_"..i).."/".. tpdata[i][3]..") "
end
else
message = message .. "没有可以查询的内容。"
end
NLG.SystemMessage(_index,message)
end
function routine_ItemNum(a1)
if tonumber(a1)==15 then
return -10;
end
if tonumber(a1) >=0 and tonumber(a1) <=14 then
local p1=a1+1
return routine_Item[p1]
end
return -1
end
function routine_gexp(a1)
if tonumber(a1)==#routine_exp then
return -10;
end
if tonumber(a1) >=0 and tonumber(a1) <=14 then
local p1=a1+1
return routine_exp[p1]
end
return -1
end
function routine_Lv(a1)
if tonumber(a1)==#routine_exp then
return -10;
end
if tonumber(a1) >=0 and tonumber(a1) <=14 then
local p1=tonumber(a1)+1
if type(routine_exp[p1])=="nil" then
return -1
end
return p1
end
return -1
end
function routine_RegDamage(a1,a2,a3)
if a2==1 then
local c1=routine_Mysql(a1,1)
local p1=tonumber(c1[1]);
if p1 >0 and p1 <= #routine_A then
SetDamage_Init(a1,routine_A[p1],routine_B[p1])
else
SetDamage_Init(a1,0,0);
end
elseif a2 == 2 then
if a3 >0 and a3 <= #routine_A then
SetDamage_Init(a1,routine_A[a3],routine_B[a3])
else
SetDamage_Init(a1,0,0);
end
end
end
function routine_Mysql(a1,a2,a3,a4)
if a1 >= 0 then
local p1=Char.GetData(a1,2002)
local p2=Char.GetData(a1,48)
if a2==1 then
local rt={0,0};
local query = "SELECT Lv,Num FROM tbl_Xiu WHERE Cdkey='"..p1.."' And RegistNumber='"..p2.."'";
local resset = SQL.Run(query);
if(type(resset)~="table")then
query = "INSERT INTO tbl_Xiu (Cdkey,RegistNumber,Lv,Num) VALUES ('"..p1.."','"..p2.."','0','0')";
resset = SQL.Run(query);
return rt;
end
rt[1]=resset["0_0"];
rt[2]=resset["0_1"];
return rt;
elseif a2==2 then
local rt={0,0};
local query = "SELECT Lv,Num FROM tbl_Xiu WHERE Cdkey='"..p1.."' And RegistNumber='"..p2.."'";
local resset = SQL.Run(query);
if(type(resset)~="table")then
query = "INSERT INTO tbl_Xiu (Cdkey,RegistNumber,Lv,Num) VALUES ('"..p1.."','"..p2.."','"..a3.."','"..a4.."')";
resset = SQL.Run(query);
return;
end
local tSQL = "update tbl_Xiu SET Lv=Lv+"..tonumber(a3)..",Num=Num+"..tonumber(a4).." WHERE Cdkey='"..p1.."' and RegistNumber="..p2;
local RS = SQL.Run(tSQL)
end
end
end
function routine_RegMysql()
local tSQL = "CREATE TABLE `tbl_xiu`(`Cdkey` char(30) NOT NULL,`RegistNumber` int(30) NOT NULL,`Lv` int(30) NOT NULL,`Num` int(30) NOT NULL, PRIMARY KEY (`Cdkey`,`RegistNumber`))"
local RS = SQL.Run(tSQL)
end
function routine_CallMysql()
local p1 = "SHOW TABLES LIKE 'tbl_xiu'";
local RS = SQL.Run(p1)
if RS==0 then
routine_RegMysql();
end
end
routine_CallMysql();
|
|