--[[
Author: SLWS_Gao_Q1968023646
Date: 2024-07-06 10:28:24
Description: 夫妻传送
--]]
require("Envir/Market_Def/NpcLua/zh.lua") --个人封装函数
local fl_map_info = { --夫妻召唤进入条件,费用,等级
-- 初级地图--沃玛寺庙
["d022"] = {level=35, gold=2000, group="沃玛寺庙"}, ["d023"] = {level=35, gold=2000, group="沃玛寺庙"}, ["d024"] = {level=35, gold=2000, group="沃玛寺庙"},
-- 初级地图--石墓洞穴
["d713"] = {level=35, gold=2000, group="石墓洞穴"}, ["d714"] = {level=35, gold=2000, group="石墓洞穴"}, ["d715"] = {level=35, gold=2000, group="石墓洞穴"}, ["d717"] = {level=35, gold=2000, group="石墓洞穴"},
-- 初级地图--蜈蚣洞穴
["d601"] = {level=35, gold=2000, group="蜈蚣洞穴"}, ["d603"] = {level=35, gold=2000, group="蜈蚣洞穴"}, ["d618"] = {level=35, gold=2000, group="蜈蚣洞穴"}, ["d606"] = {level=35, gold=2000, group="蜈蚣洞穴"},
-- 初级地图--祖玛之家
["d505"] = {level=35, gold=2000, group="祖玛之家"}, ["d5071"] = {level=35, gold=2000, group="祖玛之家"}, ["d5072"] = {level=35, gold=2000, group="祖玛之家"}, ["d5073"] = {level=35, gold=2000, group="祖玛之家"}, ["d5074"] = {level=35, gold=2000, group="祖玛之家"}, ["d515"] = {level=35, gold=2000, group="祖玛之家"},
-- 初级地图--赤月峡谷
["d10031"] = {level=35, gold=2000, group="赤月峡谷"}, ["d1004"] = {level=35, gold=2000, group="赤月峡谷"}, ["d10051"] = {level=35, gold=2000, group="赤月峡谷"}, ["d10052"] = {level=35, gold=2000, group="赤月峡谷"}, ["d10061"] = {level=35, gold=2000, group="赤月峡谷"}, ["d10062"] = {level=35, gold=2000, group="赤月峡谷"},
-- 初级地图--幻境之门
["h008"] = {level=35, gold=2000, group="幻境之门"}, ["h009"] = {level=35, gold=2000, group="幻境之门"}, ["h010"] = {level=35, gold=2000, group="幻境之门"},
-- 危险地图--封魔殿堂
["d2008"] = {level=45, gold=5000, group="封魔殿堂"}, ["d2011"] = {level=45, gold=5000, group="封魔殿堂"}, ["d2008a"] = {level=45, gold=5000, group="封魔殿堂"}, ["d2004"] = {level=45, gold=5000, group="封魔殿堂"},
-- 危险地图--牛魔大厅
["d2074"] = {level=45, gold=5000, group="牛魔大厅"}, ["d2077"] = {level=45, gold=5000, group="牛魔大厅"}, ["d2078"] = {level=45, gold=5000, group="牛魔大厅"}, ["d2079"] = {level=45, gold=5000, group="牛魔大厅"},
-- 危险地图--幽冥地府
["d2064"] = {level=45, gold=5000, group="幽冥地府"}, ["d2065"] = {level=45, gold=5000, group="幽冥地府"}, ["d2066"] = {level=45, gold=5000, group="幽冥地府"}, ["d2067"] = {level=45, gold=5000, group="幽冥地府"},
-- 危险地图--蚂蚁巢穴
["e602"] = {level=45, gold=5000, group="蚂蚁巢穴"}, ["e603"] = {level=45, gold=5000, group="蚂蚁巢穴"}, ["e604"] = {level=45, gold=5000, group="蚂蚁巢穴"}, ["e605"] = {level=45, gold=5000, group="蚂蚁巢穴"},
-- 危险地图--玛雅神殿
["maya1"] = {level=45, gold=5000, group="玛雅神殿"}, ["maya2"] = {level=45, gold=5000, group="玛雅神殿"}, ["maya3"] = {level=45, gold=5000, group="玛雅神殿"}, ["maya4"] = {level=45, gold=5000, group="玛雅神殿"}, ["maya5"] = {level=45, gold=5000, group="玛雅神殿"},
--危险地图--桃源之门
["h106"] = {level=45, gold=5000, group="桃源之门"},
-- 高级地图--火龙巢穴
["d2081"] = {level=50, gold=10000, group="火龙巢穴"}, ["d2082"] = {level=50, gold=10000, group="火龙巢穴"}, ["d2083"] = {level=50, gold=10000, group="火龙巢穴"},
-- 高级地图--蛮荒部落
["60"] = {level=50, gold=10000, group="蛮荒部落"}, ["61"] = {level=50, gold=10000, group="蛮荒部落"}, ["62"] = {level=50, gold=10000, group="蛮荒部落"}, ["66"] = {level=50, gold=10000, group="蛮荒部落"},
-- 高级地图--幽灵船
["sj00"] = {level=50, gold=10000, group="幽灵船"}, ["sj03"] = {level=50, gold=10000, group="幽灵船"}, ["sj022"] = {level=50, gold=10000, group="幽灵船"}, ["sj04"] = {level=50, gold=10000, group="幽灵船"},
-- 高级地图--雪域荒原
["90"] = {level=50, gold=10000, group="雪域荒原"}, ["xy1"] = {level=50, gold=10000, group="雪域荒原"}, ["xy2"] = {level=50, gold=10000, group="雪域荒原"}, ["xy3"] = {level=50, gold=10000, group="雪域荒原"}, ["xy4"] = {level=50, gold=10000, group="雪域荒原"}, ["xy5"] = {level=50, gold=10000, group="雪域荒原"},
-- 高级地图--地下城堡
["93a"] = {level=50, gold=10000, group="地下城堡"}, ["dxcity02"] = {level=50, gold=10000, group="地下城堡"}, ["dxcity03"] = {level=50, gold=10000, group="地下城堡"}, ["dxcity04"] = {level=50, gold=10000, group="地下城堡"},
-- 高级地图--迷失之城
["92a"] = {level=50, gold=10000, group="迷失之城"}, ["fox01"] = {level=50, gold=10000, group="迷失之城"}, ["fox03"] = {level=50, gold=10000, group="迷失之城"},
-- 终极地图--弑神殿
["tmd1"] = {level=55, gold=20000, group="弑神殿"}, ["tmd2"] = {level=55, gold=20000, group="弑神殿"},
-- 终极地图--屠魔殿
["tumod01"] = {level=55, gold=20000, group="屠魔殿"}, ["tumod02"] = {level=55, gold=20000, group="屠魔殿"}, ["f011"] = {level=55, gold=20000, group="屠魔殿"},
-- 终极地图--寻龙殿
["lh004"] = {level=55, gold=20000, group="寻龙殿"}, ["lh005"] = {level=55, gold=20000, group="寻龙殿"}, ["lh006"] = {level=55, gold=20000, group="寻龙殿"}, ["lh007"] = {level=55, gold=20000, group="寻龙殿"},
-- 终极地图--龙神殿
["dbfd"] = {level=55, gold=20000, group="龙神殿"}, ["zhuxian"] = {level=55, gold=20000, group="龙神殿"},
-- 活动地图--
["sblq"] = {level=40, gold=2000, group="活动地图"}, ["cfgc"] = {level=40, gold=2000, group="活动地图"}, ["wlzb"] = {level=40, gold=2000, group="活动地图"}, ["hhjqdt"] = {level=40, gold=1000, group="活动地图"}, ["wzzd1"] = {level=40, gold=5000, group="活动地图"},
--不归路--
["t334"] = {level=35, gold=10000, group="不归路"}, ["f005"] = {level=35, gold=10000, group="不归路"}, ["f009"] = {level=35, gold=10000, group="不归路"}, ["f010"] = {level=35, gold=10000, group="不归路"}, ["f002"] = {level=35, gold=10000, group="不归路"}, ["f007"] = {level=35, gold=10000, group="不归路"}, ["f003"] = {level=35, gold=10000, group="不归路"}
}
function couple_cs(actor, dear_name)
local str = (getsex(actor) == 0) and "老婆" or "老公"
-- sendmsg6(actor, "dear_name1=" .. type(dear_name))
if not dear_name or dear_name == "" then
sendmsg9(actor, "你没有结婚!")
return false
end
local dear_player = getplayerbyname(dear_name)
-- sendmsg6(actor, "dear_player2=" ..type(dear_player))
if check_dear_tj(actor, dear_player) then
local n = calc_dear_fee(actor, dear_player) --进图费用
if getbindgold(dear_player) < n then
sendmsg9(actor, "你的" .. str .. "没有" .. n .. "金币进入地图,夫妻传送无法完成!")
return false
end
if subbindgold(actor, 2000) then
if n > 0 and not subbindgold(dear_player, n) then
sendmsg9(actor, "扣除" .. str .. "进入地图费用失败,本次夫妻传送无法完成!")
end
setint(actor, "夫妻传送时间", os.time())
mapmove(dear_player, getmap(actor), getx(actor), gety(actor), 2)
return true
else
sendmsg9(actor, "扣除2000金币失败,本次夫妻传送无法完成!")
return false
end
end
end
--[[
@description: 检测夫妻传送条件
@return {bool}
--]]
function check_dear_tj(actor, dear_player)
local str = (getsex(actor) == 0) and "老婆" or "老公"
if getbindgold(actor) < 2000 then
sendmsg9(actor, "传唤" .. str .. "每次需要2000金币!")
return false
end
local dear_cs_time = getint(actor, "夫妻传送时间") --上次夫妻传送时间
local next_time = dear_cs_time + 5 -- 下次可传送时间
if os.time() < next_time then
sendmsg9(actor, "还需要" .. (next_time - os.time() ) .. "秒才能使用夫妻传送!", "#00FF00")
return false
end
if not dear_player then
sendmsg9(actor, "你的爱人不在线,无法使用夫妻传送")
return false
end
local dear_username = getname(dear_player) --对方名字
if getplaydef(dear_player, "U52") == 1 then
sendmsg9(actor, "【" .. dear_username .. "】不允许使用夫妻传送!")
return false
end
if getbaseinfo(dear_player, 0) then
sendmsg9(actor, "【" .. dear_username .. "】处于死亡状态,无法使用夫妻传送!")
return false
end
if getbaseinfo(dear_player, 61) then
sendmsg9(actor, "【" .. dear_username .. "】处于离线挂机,无法使用夫妻传送!")
return false
end
local mapid = getmap(actor)
local t = fl_map_info[mapid] --获取传送地图条件
if t and getlevel(dear_player) < t["level"] then
sendmsg9(actor, "【" .. dear_username .. "】没有" .. t["level"] .. "级,无法进入!")
return false
end
return true
end
--[[
@description: 计算进地图费用
@return {number 扣除金币数}
--]]
function calc_dear_fee(actor, dear_player)
local mapid = getmap(actor)
local dear_mapid = getmap(dear_player)
local t = fl_map_info[mapid] --获取传送地图条件
if not t or mapid == dear_mapid then -- 在免费地图或者同一地图发起 夫妻传送
return 0
end
local t_dear = fl_map_info[dear_mapid]
if not t_dear then --对方在免费地图,进收费地图一定需要费用
return t["gold"]
end
if (t["group"] ~= t_dear["group"]) then --对方在收费地图,但在不同组里面
return t["gold"]
end
return 0
end