require("Envir/Market_Def/NpcLua/zh.lua") --个人封装函数
-- {"怪物名称", "怪物数量", "X", "Y", "范围"}
local ttt_monster = {
{{"沃玛教主", 1, 19, 17, 10}, {"祖玛教主", 1, 34, 19, 0}, {"赤月恶魔", 1, 20, 18, 0}, {"沃玛贵族", 1, 19, 17, 10}, {"蝎蛇贵族", 1, 19, 17, 10}, {"钳虫贵族", 1, 19, 17, 10}},
{{"蚁后", 1, 19, 17, 10}, {"牛魔大王", 1, 19, 17, 10}, {"幽冥教主", 1, 19, 17, 10}, {"沃玛贵族", 1, 19, 17, 10}, {"蝎蛇贵族", 1, 19, 17, 10}, {"钳虫贵族", 1, 19, 17, 10}},
{{"幽灵船长", 1, 19, 17, 10}, {"火龙神", 1, 19, 17, 0}, {"蛮荒大王", 1, 19, 17, 10}, {"沃玛贵族", 1, 19, 17, 10}, {"蝎蛇贵族", 1, 19, 17, 10}, {"钳虫贵族", 1, 19, 17, 10}},
{{"雪域皇尊", 1, 19, 17, 10}, {"幽暗冥王", 1, 19, 17, 10}, {"九世蝎狐", 1, 19, 17, 10}, {"沃玛贵族", 1, 19, 17, 10}, {"蝎蛇贵族", 1, 19, 17, 10}, {"钳虫贵族", 1, 19, 17, 10}},
{{"龙后", 1, 3, 19, 0}, {"龙神", 1, 35, 19, 10}, {"魔殿至尊", 1, 19, 17, 10}, {"神殿霸主", 1, 19, 17, 10}, {"沃玛贵族", 1, 19, 17, 10}, {"蝎蛇贵族", 1, 19, 17, 10}, {"钳虫贵族", 1, 19, 17, 10}},
}
local map_floor_name = {
"通天塔一层",
"通天塔二层",
"通天塔三层",
"通天塔四层",
"通天塔底层",
}
function ttt_show(actor)
local pay_point = tonumber(querymoney(actor, 11)) or 0
local str = [[
<Img|x=0|y=-1|width=450|height=345|img=image/bg2.png|bg=1|scale9r=10|scale9t=10|scale9b=10|reset=1|scale9l=10|move=0|show=0>
<Layout|x=450|y=0|width=80|height=80|link=@exit>
<Button|x=450|y=0|nimg=public/1900000510.png|mimg=public/1900000510.png|pimg=public/1900000511.png|width=26|height=42|link=@exit>
<Text|a=4|percentx=50|y=31|children={title_1,title_2,title_3}|color=243|outline=1|size=18|text=通 天 塔>
<Img|a=1|x=-10|y=5|id=title_1|img=image/title_91.png|esc=0>
<Img|a=0|x=84|y=5|id=title_2|img=image/title_92.png|esc=0>
<Img|a=4|percentx=50|y=30|width=380|id=title_3|img=slws/203.png|esc=0>
<RText|x=30|y=70|id=RTEXT_1|color=100|size=14|text=五层通天塔,藏有传说中的秘宝,静待英雄揭开它的奥秘!>
<RText|x=30|y=95|id=RTEXT_2|color=100|size=14|text=刷新各类BOSS,个人专享地图.击杀当层所有怪物后方可进下一层.>
<RText|x=45|y=130|id=RTEXT_3|color=250|size=14|text=充值满100:免费进1次/天,可购买1次/天【500元宝/次】>
<RText|x=45|y=155|id=RTEXT_4|color=250|size=14|text=充值满500:免费进2次/天,可购买3次/天【500元宝/次】>
<Text|x=40|y=200|id=RTEXT_5|color=255|size=14|text=你的充值点:$STM(MONEY_11)>
<Img|a=4|percentx=50|y=230|width=380|id=title_4|img=slws/203.png|esc=0>
<Text|x=80|y=245|id=RTEXT_7|color=254|size=14|text=购买次数|link=@ttt_buy_times>
<Text|x=180|y=245|id=RTEXT_8|color=251|size=14|text=挑 战 通 天 塔|link=@enter_tta>
<Text|x=300|y=245|id=RTEXT_12|color=254|size=14|text=重新刷怪|link=@ttt_map_init>
<RText|x=40|y=280|id=RTEXT_9|color=249|size=14|text=提醒:重新刷怪再进入将扣次数,原地面物品将消失,地图时间重置为2小时>
<RText|x=70|y=305|id=RTEXT_10|color=249|size=14|text=地图有效时间2小时,到期后将自动退出,无法拾取物品.>
]]
local times = getdayint(actor, "通天塔可进次数")
if pay_point >= 500 then
times = times + 2
elseif pay_point >= 100 then
times = times + 1
end
str = str .. "<RText|x=240|y=200|id=RTEXT_6|color=255|size=14|text=今日挑战情况:{" .. getdayint(actor, "通天塔已进次数") .. "/" .. times .. "/FCOLOR=250}次>"
say(actor, str)
end
function ttt_map_init(actor)
local allow_enter_times = getdayint(actor, "通天塔可进次数")
local pay_point = tonumber(querymoney(actor, 11)) or 0
local enter_times = getdayint(actor, "通天塔已进次数")
if pay_point >= 500 then
allow_enter_times = allow_enter_times + 2
elseif pay_point >= 100 then
allow_enter_times = allow_enter_times + 1
end
if allow_enter_times < 1 then
sendmsg9(actor, "你允许进入通天塔的次数为0!")
return
end
if not (enter_times < allow_enter_times) then
sendmsg9(actor, "已进通天塔" .. enter_times .. "次,今日已满")
return
end
messagebox(actor, "\\\\ 确定重刷:\\ 通天塔地图和怪么吗?重刷再次进入将扣除次数", "@ttt_map_init_2", "@exit" )
end
function ttt_map_init_2(actor)
local uid = getbaseinfo(actor, 2)
for i=1, 5 do
local mapid = uid .. "_" .. i
if checkmirrormap(mapid) then
delnpc("挑战下一层", mapid)
delmirrormap(mapid)
end
end
sendmsg6(actor, "重置成功,塔内怪物已重新刷新,请重新进入!")
sendmsg9(actor, "重置成功,塔内怪物已重新刷新,请重新进入!")
end
function ttt_buy_times(actor)
local pay_point = tonumber(querymoney(actor, 11)) or 0
local buy_times = getdayint(actor, "通天塔购买次数") or 0
if pay_point < 100 then
sendmsg9(actor, "你的充值点不足100,无法购买")
return
end
if getingot(actor) < 500 then
sendmsg9(actor, "你的元宝不足500,无法购买")
return
end
if pay_point < 500 and buy_times > 0 then
sendmsg9(actor, "充值满100元,一天只能购买1次,已经购买了" .. buy_times .. "次了!")
return
end
if pay_point >= 500 and buy_times > 2 then
sendmsg9(actor, "充值满500元,一天只能购买3次,已经购买了" .. buy_times .. "次了!")
return
end
if subingot(actor, 500) then
setdayint(actor, "通天塔可进次数", getdayint(actor, "通天塔可进次数") + 1)
setdayint(actor, "通天塔购买次数", getdayint(actor, "通天塔购买次数") + 1)
sendmsg9(actor, "购买成功")
ttt_show(actor)
else
sendmsg9(actor, "扣除元宝失败,无法购买!")
end
end
function enter_tta(actor)
local allow_enter_times = getdayint(actor, "通天塔可进次数")
local pay_point = tonumber(querymoney(actor, 11)) or 0
local enter_times = getdayint(actor, "通天塔已进次数")
if pay_point >= 500 then
allow_enter_times = allow_enter_times + 2
elseif pay_point >= 100 then
allow_enter_times = allow_enter_times + 1
end
if allow_enter_times < 1 then
sendmsg9(actor, "你允许进入通天塔的次数为0!")
return
end
if enter_times == allow_enter_times then
local uid = getbaseinfo(actor, 2)
local map_id = uid .. "_" .. "1"
if checkmirrormap(map_id) then
local mirror_map_time = mirrormaptime(map_id)
map(actor, map_id)
delaygoto(actor, 300, "ttt_clear_delay," .. mirror_map_time)
return
end
return sendmsg9(actor, "已进通天塔" .. enter_times .. "次,今日已满")
end
if enter_times < allow_enter_times then
local map_name = "通天塔一层(" .. getname(actor) .. ")"
local uid = getbaseinfo(actor, 2)
local map_id = uid .. "_" .. "1"
local mirror_map_time
if not checkmirrormap(map_id) then
mirror_map_time = 7200
else
mirror_map_time = mirrormaptime(map_id)
end
if ttt_create_map(actor, map_id, map_name, 1, mirror_map_time) then
ttt_create_npc(actor, map_id, 19, 10)
map(actor, map_id)
delaygoto(actor, 300, "ttt_clear_delay," .. mirror_map_time)
else
sendmsg9(actor, "创建个人镜象地图失败,无法进入通天塔一层!")
end
else
sendmsg9(actor, "已进通天塔" .. enter_times .. "次,今日已满")
return
end
end
-- 创建地图
function ttt_create_map(actor, map_id, map_name, floor, mirror_map_time)
if not checkmirrormap(map_id) then
local res = addmirrormap("jjc06", map_id, map_name, mirror_map_time, "3", nil, 330, 330)
if res then
ttt_spawn_monster(actor, map_id, floor)
end
return res
else
return true
end
end
--创建NPC
function ttt_create_npc(actor, mapid, x, y)
local npcInfo = {
["Idx"] = tonumber(getconst(actor,"<$USERACCOUNT>")) + os.time(), -- 1000 + floor自定义NPC的Idx,NPC点击触发时,触发参数会传回Idx值
["npcname"] = "挑战下一层", -- NPC名称
["appr"] = 8, -- NPC外形效果
["script"] = '/5特殊功能/通天塔', -- NPC相关脚本名称,表示Envir\Market_def\NewNPC.txt
["limit"] = 7200, -- 生命周期 (秒) 引擎64_24.05.23新增
}
-- sendmsg6(actor, npcInfo.Idx)
createnpc(mapid, x, y, tbl2json(npcInfo))
end
-- 刷怪
function ttt_spawn_monster(actor, mapid, floor)
if floor == 1 then
setdayint(actor, "通天塔已进次数", getdayint(actor, "通天塔已进次数") + 1)
end
for i=1, #(ttt_monster[floor]) do
m = ttt_monster[floor][i]
genmon(mapid, m[3], m[4], m[1], m[5], m[2], 245)
end
end
function go_next_tta(actor)
local str = getmap(actor)
local pos = string.find(str, "_")
local uid = getbaseinfo(actor, 2)
local next_floor = tonumber( string.sub(str, pos+1, pos+2) ) + 1
local next_map_id = uid .. "_" .. next_floor
local map_name = map_floor_name[next_floor] .. "(" .. getname(actor) .. ")"
local mon_num = getmoncount(getmap(actor), -1, true)
if mon_num ~= 0 then
sendmsg9(actor, "前地图还剩余" .. mon_num .. "只怪物,消灭完后才能进下一层!")
return
end
if ttt_create_map(actor, next_map_id, map_name, next_floor, mirrormaptime(uid .. "_" .. 1)) then
local mirror_map_time = mirrormaptime(next_map_id)
if next_floor < 5 then
ttt_create_npc(actor, next_map_id, 19, 10)
end
map(actor, next_map_id)
delaygoto(actor, 300, "ttt_clear_delay," .. mirror_map_time)
else
sendmsg9(actor, "创建个人镜象地图失败,无法进入" .. map_name)
end
end
--人物大小退时,回到安全区
function del_mirror_map(actor)
local uid = getbaseinfo(actor, 2)
for i=1, 5 do
local mapid = uid .. "_" .. i
if getmap(actor) == mapid then
mapmove(actor, 3, 330, 330, 6)
end
end
end
function ttt_clear_delay(actor, mirrormaptime)
callscriptex(actor, "senddelaymsg", "地图时间剩余:%s", mirrormaptime, 250, 1, "@huicheng")
end