-- Author 老高
-- Date 2024-04-17
-- 实现NPC界面显示和传送功能
require("Envir/Market_Def/NpcLua/zh.lua") --个人封装函数
local map_lv1 = {"初级地图", "危险地图", "高级地图","终极地图"} --地图导航分组
local map_lv2 = { -- 地图分组下面对应的地图
["初级地图"] = {"沃玛寺庙","石墓洞穴", "蜈蚣洞穴","祖玛之家","赤月峡谷","封魔殿堂"},
["危险地图"] = {"幻境之门","牛魔大厅","幽冥洞穴","蚂蚁巢穴","玛雅神殿", "桃源之门"},
["高级地图"] = {"火龙巢穴","蛮荒部落","幽灵船","雪域荒原","地下城堡", "迷失之城"},
["终极地图"] = {"弑神殿","屠魔殿","寻龙殿","龙神殿"},
}
local map_info = { --地图介绍说明,进入条件,费用,等级
-- 初级地图
["沃玛寺庙"] = {mapid = "D022", x = 339, y = 356, range=0, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="35级,2000金币/次", mmap_img = "000005.png", map_title_img="map1-1.png", level=35, gold=2000 },
["石墓洞穴"] = {mapid = "d713", x = 31, y=191, range=5, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="35级,2000金币/次", mmap_img = "000032.png", map_title_img="map1-2.png", level=35, gold=2000 },
["蜈蚣洞穴"] = {mapid = "d601", x = 205, y=231, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="35级,2000金币/次", mmap_img = "000025.png", map_title_img="map1-3.png", level=35, gold=2000 },
["祖玛之家"] = {mapid = "d505", x = 98, y=100, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="35级,2000金币/次", mmap_img = "012225.png", map_title_img="map1-4.png", level=35, gold=2000 },
["赤月峡谷"] = {mapid = "d10031", x ="288", y="150", jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="35级,2000金币/次", mmap_img = "013329.png", map_title_img="map1-5.png", level=35, gold=2000 },
["封魔殿堂"] = {mapid = "d2008", x = 78, y=77, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="35级,2000金币/次", mmap_img = "000128.png", map_title_img="map1-6.png", level=35, gold=2000 },
--危险地图
["幻境之门"] = {mapid = "h008", x = 78, y = 79, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="45级,5000金币/次", mmap_img = "000067.png", map_title_img="map2-1.png", level=45, gold=5000 },
["牛魔大厅"] = {mapid = "d2074", x = 36, y = 29, range=5, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="45级,5000金币/次", mmap_img = "000184.png", map_title_img="map2-2.png", level=45, gold=5000 },
["幽冥洞穴"] = {mapid = "D2064", x = 17, y = 35, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="45级,5000金币/次", mmap_img = "000173.png", map_title_img="map2-3.png", level=45, gold=5000 },
["蚂蚁巢穴"] = {mapid = "E602", x = 75, y = 78, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="45级,5000金币/次", mmap_img = "000067.png", map_title_img="map2-4.png", level=45, gold=5000 },
["玛雅神殿"] = {mapid = "maya1", x = 83, y = 84, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="45级,5000金币/次", mmap_img = "000125.png", map_title_img="map2-5.png", level=45, gold=5000 },
["桃源之门"] = {mapid = "h106", x= 100, y= 100, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="45级,5000金币/次", mmap_img = "000041.png", map_title_img="map2-6.png", level=45, gold=5000 },
-- 高级地图
["火龙巢穴"] = {mapid = "D2081", x= 30, y= 45, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="50级,10000金币/次", mmap_img = "000303.png", map_title_img="map3-1.png", level=50, gold=10000 },
["蛮荒部落"] = {mapid = "60", x = 126, y = 155, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="50级,10000金币/次", mmap_img = "000190.png", map_title_img="map3-2.png", level=50, gold=10000 },
["幽灵船"] = {mapid = "sj00", x = "27", y = "67", range=2, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="50级,10000金币/次", mmap_img = "001002.png", map_title_img="map3-3.png", level=50, gold=10000 },
["雪域荒原"] = {mapid = "90", x = "nil", y = "nil", jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="50级,10000金币/次", mmap_img = "020008.png", map_title_img="map3-4.png", level=50, gold=10000 },
["地下城堡"] = {mapid = "93a", x = 53, y = 32, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="50级,10000金币/次", mmap_img = "020099.png", map_title_img="map3-5.png", level=50, gold=10000 },
["迷失之城"] = {mapid = "92a", x = 35, y = 125, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="50级,10000金币/次", mmap_img = "012049.png", map_title_img="map3-6.png", level=50, gold=10000 },
-- 终极地图
["弑神殿"] = {mapid = "tmd1", x = 50, y = 45, range=2, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="55级,20000金币/次", mmap_img = "000188.png", map_title_img="map4-1.png", level=55, gold=20000 },
["屠魔殿"] = {mapid = "tumod01", x = 7, y = 52, range=2, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="55级,20000金币/次", mmap_img = "010042.png", map_title_img="map4-2.png", level=55, gold=20000 },
["寻龙殿"] = {mapid = "LH004", x= 80, y= 79, range=2, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="55级,20000金币/次", mmap_img = "000131.png", map_title_img="map4-3.png", level=55, gold=20000 },
["龙神殿"] = {mapid = "dbfd", x= 181, y= 171, jieshao="本地图共一层", mon_time ="小怪10分钟,BOSS30分钟", enter_condi="55级,20000金币/次", mmap_img = "010212.png", map_title_img="map4-4.png", level=55, gold=20000 },
}
local mon_item_drop = { -- 地图爆率展示物品
-- 初级地图
["沃玛寺庙"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["石墓洞穴"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["蜈蚣洞穴"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["祖玛之家"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["赤月峡谷"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["封魔殿堂"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
--危险地图
["幻境之门"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["牛魔大厅"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["幽冥洞穴"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["蚂蚁巢穴"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["玛雅神殿"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["桃源之门"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
-- 高级地图
["火龙巢穴"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["蛮荒部落"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["幽灵船"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["雪域荒原"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["地下城堡"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["迷失之城"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
-- 终极地图
["弑神殿"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["屠魔殿"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["寻龙殿"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
["龙神殿"] = {"圣战戒指", "法神戒指", "天尊戒指", "屠龙", "开天", "天魔神甲", "战神腰带"},
}
local map_enter_sendmsg = { --进入地图的公告, 前景色, 后景色
["初级地图"] = {"ぐ【系统】勇敢的勇士:“%s”进入%s地图寻找高级装备去了,大家祝福他吧…", 117, 94},
["危险地图"] = {"ぐ【系统】勇敢的勇士:“%s”进入%s地图寻找高级装备去了,大家祝福他吧…", 117, 94},
["高级地图"] = {"ぐ【系统】勇敢的勇士:“%s”进入%s地图寻找高级装备去了,大家祝福他吧…", 117, 94},
["终极地图"] = {"ぐ【系统】勇敢的勇士:“%s”进入%s地图寻找高级装备去了,大家祝福他吧…", 250, 94}
}
function show(actor ,map_lv1_name, map_lv2_name, cache)
-- @parm1 map_lv1_name 地图分类名字,如初级地图
-- @parm2 map_lv2_name 地图名称
-- 显示传送界面
-- sendmsg6(actor, "map_lv1_name=" .. map_lv2_name)
if map_lv1_name == "" or map_lv1_name == nil then
map_lv1_name = map_lv1[1]
end
if map_lv2_name == "" or map_lv2_name == nil then
map_lv2_name = map_lv2[map_lv1_name][1]
end
local msg = [[
<Img|width=630|height=410|show=4|reset=1|bg=1|move=1|loadDelay=1|img=custom/npc_map_bg/1.png|esc=1>
<Layout|x=629|y=18|width=80|height=80|link=@exit>
<Button|x=629|y=18|nimg=public/1900000510.png|pimg=public/1900000511.png|link=@exit>
]]
local lv1_btn_x = 28
for i=1, #map_lv1 do --拼接顶排按钮
if map_lv1_name == map_lv1[i] then
msg = msg .. "<Button|x=" .. lv1_btn_x .. "|y=50|width=120|height=35|color=100|size=16|outline=2|nimg=image/button_32.png|pimg=image/button_31.png>|mimg=image/button_32.png|text=" .. map_lv1[i] .. "|link=@show," .. map_lv1[i] .. ">"
else
msg = msg .. "<Button|x=" .. lv1_btn_x .. "|y=50|width=120|height=35|color=10|size=16|outline=2|nimg=image/button_31.png|pimg=image/button_31.png>|mimg=image/button_32.png|text=" .. map_lv1[i] .. "|link=@show," .. map_lv1[i] .. ">"
end
lv1_btn_x = lv1_btn_x + 121
end
msg = msg .. [[
<Img|x=28|y=86|width=590|img=custom/npc_map_bg/image_10.png>
<Img|x=280|y=85|height=315|img=custom/npc_map_bg/26.png|esc=0>
]]
--拼接分组对应的地图按钮
local choice_lv2_name = map_lv2[map_lv1_name]
local map_number = #choice_lv2_name
local lv2_btn_y = 195
local lv2_btn_color = 255
if map_number == 6 then --6地图情况
for i=1, map_number do
if choice_lv2_name[i] == map_lv2_name then --选中按钮颜色
lv2_btn_color = 251
msg = msg .. "<Button|x=404|y=355|width=100|height=36|nimg=custom/npc_map_bg/an1.png|mimg=custom/npc_map_bg/an1.png|pimg=custom/pc_map_bg/an1.png|color=251|size=16|text=进入地图|link=@enter_map,".. map_lv1_name .. "," .. map_lv2_name .. ">"
else
lv2_btn_color = 255
end
if i % 2 == 1 then
msg = msg .. "<Button|x=315|y=" .. lv2_btn_y .. "|width=120|height=34|pimg=custom/pc_map_bg/1900000674.png|outlinecolor=0|nimg=custom/npc_map_bg/1900000673.png|outline=1|color=" .. lv2_btn_color .. "|size=17|text=" .. choice_lv2_name[i] .. "|link=@show,".. map_lv1_name .. "," .. choice_lv2_name[i] .. ">"
else
msg = msg .."<Button|x=475|y=" .. lv2_btn_y .. "|width=120|height=34|pimg=custom/pc_map_bg/1900000674.png|outlinecolor=0|nimg=custom/npc_map_bg/1900000673.png|outline=1|color=" .. lv2_btn_color .. "|size=17|text=" .. choice_lv2_name[i] .. "|link=@show,".. map_lv1_name .. "," .. choice_lv2_name[i] .. ">"
lv2_btn_y = lv2_btn_y + 50
end
end
elseif map_number == 4 then
lv2_btn_y = 205
for i=1, map_number do
if choice_lv2_name[i] == map_lv2_name then --选中按钮颜色
lv2_btn_color = 251
msg = msg .. "<Button|x=404|y=355|width=100|height=36|nimg=custom/npc_map_bg/an1.png|mimg=custom/npc_map_bg/an1.png|pimg=custom/pc_map_bg/an1.png|color=251|size=16|text=进入地图|link=@enter_map," .. map_lv1_name .. "," .. map_lv2_name .. ">"
else
lv2_btn_color = 255
end
if i % 2 == 1 then
msg = msg .. "<Button|x=315|y=" .. lv2_btn_y .. "|width=120|height=34|pimg=custom/pc_map_bg/1900000674.png|outlinecolor=0|nimg=custom/npc_map_bg/1900000673.png|outline=1|color=" .. lv2_btn_color .. "|size=17|text=" .. choice_lv2_name[i] .. "|link=@show,".. map_lv1_name .. "," .. choice_lv2_name[i] .. ">"
else
msg = msg .."<Button|x=475|y=" .. lv2_btn_y .. "|width=120|height=34|pimg=custom/pc_map_bg/1900000674.png|outlinecolor=0|nimg=custom/npc_map_bg/1900000673.png|outline=1|color=" .. lv2_btn_color .. "|size=17|text=" .. choice_lv2_name[i] .. "|link=@show,".. map_lv1_name .. "," .. choice_lv2_name[i] .. ">"
lv2_btn_y = lv2_btn_y + 65
end
end
end
-- 拼接地图介绍
msg = msg .. [[
<Img|x=41|y=311|img=custom/npc_map_bg/title_01.png|esc=0>
<Img|x=41|y=119|img=custom/npc_map_bg/image_02.png|esc=0>
<Img|x=320|y=100|img=custom/npc_map_bg/image_01.png|esc=0>
<Img|x=320|y=130|img=custom/npc_map_bg/image_01.png|esc=0>
<Img|x=320|y=160|img=custom/npc_map_bg/image_01.png|esc=0>
]]
local cur_map_info = map_info[map_lv2_name] --地图介绍信息
msg = msg .. "<Img|x=41|y=91|img=custom/npc_map_bg/" .. cur_map_info["map_title_img"] .. "|esc=0>"
msg = msg .. "<Img|x=51|y=128|width=206|height=171|esc=0|img=/custom/mmap/".. cur_map_info["mmap_img"] .. ">"
msg = msg .. "<RText|x=343|y=100|color=100|size=15|text=<地图简介:/FCOLOR=100>".. cur_map_info["jieshao"] .. ">"
msg = msg .. "<RText|x=343|y=130|color=100|size=15|text=<刷新时间:/FCOLOR=100>".. cur_map_info["mon_time"] .. ">"
msg = msg .. "<RText|x=343|y=160|color=100|size=15|text=<进入条件:/FCOLOR=100>".. cur_map_info["enter_condi"] .. ">"
-- 拼接怪物爆物品展示
local scale = 1
if not getispc(actor) then --移动端缩放比例
scale = 0.7
end
local mon_drop_org_t = mon_item_drop[map_lv2_name] -- 取得地图爆率
local mon_drop_shuffle_t = shuffle(mon_drop_org_t) --随机装备显示
local mon_drop_item_id = "nil"
local start_children = 91
msg = msg .. "<ListView|id=9|x=30|y=329|children={91,92,93,94,95,96,97,98,99,100,101,102}|width=240|height=55|direction=2|bounce=1|margin=-20>"
for i=1, #mon_drop_shuffle_t do
mon_drop_item_id = getidbyname(mon_drop_shuffle_t[i])
if mon_drop_item_id then
msg = msg .. "<ItemShow||id=".. start_children .. "|itemid=".. mon_drop_item_id .. "|itemcount=1|showtips=1|bgtype=1|scale=".. scale ..">"
start_children = start_children + 1
end
end
say(actor, msg)
end
function enter_map(actor, map_group, map_title)
--parm1 map_group 地图分组名称
--parm2 map_title 地图名字
--进入地图条件判断和执行
if not map_title or map_title == "" then
sendmsg9(actor,"请选择要进入的地图")
return false
end
if not map_info[map_title] then
sendmsg9(actor,"请进入的地图条件不存在")
return false
end
local player_lv = getlevel(actor)
local player_gold = getbindgold(actor)
local map_condi_t = map_info[map_title]
if player_lv < map_condi_t["level"] then
sendmsg9(actor,"进入地图需要" .. map_condi_t["level"] .. "级")
return false
end
if player_gold < map_condi_t["gold"] then
sendmsg9(actor,"进入地图需要" .. map_condi_t["gold"] .. "金币")
return false
end
if subbindgold(actor, map_condi_t["gold"], "进入地图消耗") then
local msg = map_enter_sendmsg[map_group][1]
msg = string.format(msg, getname(actor), map_title)
local range = map_condi_t["range"] or 0
if map_condi_t["x"] and map_condi_t["y"] then
-- sendmsg6(actor, map_condi_t["x"])
mapmove(actor, map_condi_t["mapid"], map_condi_t["x"], map_condi_t["y"], range)
else
map(actor, map_condi_t["mapid"])
end
sendmsg0(actor, msg, map_enter_sendmsg[map_group][2], map_enter_sendmsg[map_group][3])
setstr(actor, "进入地图分组", map_group)
setstr(actor, "进入地图名称", map_title)
return true
else
sendmsg9(actor,"进入地图扣除金币失败")
return false
end
end