print(">>Script: Teleport stone.")
--54844
--菜单所有者 --默认炉石
local itemEntry =6948
--阵营
local TEAM_ALLIANCE=0
local TEAM_HORDE=1
--菜单号
local MMENU=1
local TPMENU=2
local GMMENU=3
local ENCMENU=4
--菜单类型
local FUNC=1
local MENU=2
local TP=3
local ENC=4
--GOSSIP_ICON 菜单图标
local GOSSIP_ICON_CHAT = 0 -- 对话
local GOSSIP_ICON_VENDOR = 1 -- 货物
local GOSSIP_ICON_TAXI = 2 -- 传送
local GOSSIP_ICON_TRAINER = 3 -- 训练(书)
local GOSSIP_ICON_INTERACT_1 = 4 -- 复活
local GOSSIP_ICON_INTERACT_2 = 5 -- 设为我的家
local GOSSIP_ICON_MONEY_BAG = 6 -- 钱袋
local GOSSIP_ICON_TALK = 7 -- 申请 说话+黑色点
local GOSSIP_ICON_TABARD = 8 -- 工会(战袍)
local GOSSIP_ICON_BATTLE = 9 -- 加入战场 双剑交叉
local GOSSIP_ICON_DOT = 10 -- 加入战场
--装备位置
local EQUIPMENT_SLOT_HEAD = 0--头部
local EQUIPMENT_SLOT_NECK = 1--颈部
local EQUIPMENT_SLOT_SHOULDERS = 2--肩部
local EQUIPMENT_SLOT_BODY = 3--身体
local EQUIPMENT_SLOT_CHEST = 4--胸甲
local EQUIPMENT_SLOT_WAIST = 5--腰部
local EQUIPMENT_SLOT_LEGS = 6--腿部
local EQUIPMENT_SLOT_FEET = 7--脚部
local EQUIPMENT_SLOT_WRISTS = 8--手腕
local EQUIPMENT_SLOT_HANDS = 9--手套
local EQUIPMENT_SLOT_FINGER1 = 10--手指1
local EQUIPMENT_SLOT_FINGER2 = 11--手指2
local EQUIPMENT_SLOT_TRINKET1 = 12--饰品1
local EQUIPMENT_SLOT_TRINKET2 = 13--饰品2
local EQUIPMENT_SLOT_BACK = 14--背部
local EQUIPMENT_SLOT_MAINHAND = 15--主手
local EQUIPMENT_SLOT_OFFHAND = 16--副手
local EQUIPMENT_SLOT_RANGED = 17--远程
local EQUIPMENT_SLOT_TABARD = 18--徽章
function ST.SummonNPC(player, entry)
local guid=player:GetGUIDLow()
local lastTime,nowTime=(ST[guid] or 0),os.time()
if(player:IsInCombat())then
player:SendAreaTriggerMessage("不能在战斗中召唤。")
else
if(nowTime>lastTime)then
local map=player:GetMap()
if(map)then
player:SendAreaTriggerMessage(map:GetName())
local x,y,z=player:GetX()+1,player:GetY(),player:GetZ()
local nz=map:GetHeight(x,y)
if(nz>z and nz<(z+5))then
z=nz
end
local NPC=player:SpawnCreature(entry,x,y,z,0, 3,ST.TIME*1000)
if(NPC)then
player:SendAreaTriggerMessage("召唤随身商人成功。")
NPC:SetFacingToObject(player)
NPC:SendUnitSay(string.format("%s,你好,需要点什么?",player:GetName()),0)
lastTime=os.time()+ST.TIME
else
player:SendAreaTriggerMessage("召唤随身商人失败。")
end
end
else
player:SendAreaTriggerMessage("召唤NPC不能太频繁。")
end
end
ST[guid]=lastTime
end
function ST.SummonGNPC(player)--召唤商人
ST.SummonNPC(player, ST.NPCID2)
end
function ST.SummonENPC(player)--召唤附魔
ST.SummonNPC(player, ST.NPCID1)
end
local function ResetPlayer(player, flag, text)
player:SetAtLoginFlag(flag)
player:SendAreaTriggerMessage("你需要重新登录角色,才能修改"..text.."。")
player:SendAreaTriggerMessage("正在返回选择角色菜单")
player:LogoutPlayer(true)
end
local Stone={
GetTimeASString=function(player)
local inGameTime=player:GetTotalPlayedTime()
local days=math.modf(inGameTime/(24*3600))
local hours=math.modf((inGameTime-(days*24*3600))/3600)
local mins=math.modf((inGameTime-(days*24*3600+hours*3600))/60)
return days.."天"..hours.."时"..mins.."分"
end,
GoHome=function(player)--回到家
player:CastSpell(player,8690,true)
player:ResetSpellCooldown(8690, true)
player:SendBroadcastMessage("已经回到家")
end,
SetHome=function(player)--设置当前位置为家
local x,y,z,mapId,areaId=player:GetX(),player:GetY(),player:GetZ(),player:GetMapId(),player:GetAreaId()
player:SetBindPoint(x,y,z,mapId,areaId)
player:SendBroadcastMessage("已经设置当前位置为家")
end,
local function Enchanting(player, EncSpell, Eid, money) --附魔 (玩家,附魔效果,附魔位置)
local ID=Eid
local Nowitem = player:GetEquippedItemBySlot(ID)--得到相应位置物品
if (Nowitem and Eid ) then--存在物品
--local WType = Nowitem:GetSubClass()--物品类型
local WName = Nowitem:GetItemLink()--物品链接
for solt=0,1 do
local espellid=Nowitem:GetEnchantmentId(solt)
if(espellid and espellid>0)then
Nowitem:ClearEnchantment(solt)
if(EncSpell<=0)then
player:SendBroadcastMessage(WName.."已经清除附魔("..espellid..")")
elseif(solt < 1 )then
Nowitem:SetEnchantment(espellid, solt+1)
break
end
end
end
if(EncSpell>0)then
Nowitem:SetEnchantment(EncSpell, 0)
player:CastSpell(player, 36937)
player:SendBroadcastMessage(WName.."已经附魔。")
player:SetHealth(player:GetMaxHealth())--回复生命
return true
end
else
player:SendNotification("你身上没有装备相应的物品")
end
return false
end
function Stone.AddGossip(player, item, id)
player:GossipClearMenu()--清除菜单
local Rows=Menu[id] or {}
local Pteam=player:GetTeam()
local teamStr,team="",player:GetTeam()
if(team==TEAM_ALLIANCE)then
teamStr ="[|cFF0070d0联盟|r]"
elseif(team==TEAM_HORDE)then
teamStr ="[|cFFF000A0部落|r]"
end
for k, v in pairs(Rows) do
local mtype,text,icon,intid=v[1],( v[2] or "???" ), (v[4] or GOSSIP_ICON_CHAT), (id*0x100+k)
if(mtype==MENU)then
player:GossipMenuAddItem(icon, text, 0, (v[3] or id )*0x100)
elseif(mtype==FUNC or mtype==ENC)then
local code,msg,money=v[5],(v[6]or ""), (v[7] or 0)
if(mtype==ENC)then
icon=GOSSIP_ICON_TABARD
end
if((code==true or code ==false))then
player:GossipMenuAddItem(icon, text, money, intid, code, msg, money)
else
player:GossipMenuAddItem(icon, text, 0, intid)
end
elseif(mtype==TP)then
local mteam=v[8] or TEAM_NONE
if(mteam==Pteam)then
player:GossipMenuAddItem(GOSSIP_ICON_TAXI, teamStr..text, 0, intid, false,"是否传送到 |cFFFFFF00"..text.."|r ?",0)
elseif(mteam ==TEAM_NONE)then
player:GossipMenuAddItem(GOSSIP_ICON_TAXI, text, 0, intid, false,"是否传送到 |cFFFFFF00"..text.."|r ?",0)
end
else
player:GossipMenuAddItem(icon, text, 0, intid)
end
end
if(id > 0)then--添加返回上一页菜单
local length=string.len(string.format("%x",id))
if(length>1)then
local temp=bit_and(id,2^((length-1)*4)-1)
if(temp ~= MMENU)then
player:GossipMenuAddItem(GOSSIP_ICON_CHAT,"上一页", 0,temp*0x100)
end
end
end
if(id ~= MMENU)then--添加返回主菜单
player:GossipMenuAddItem(GOSSIP_ICON_CHAT,"主菜单", 0, MMENU*0x100)
else
if(player:GetGMRank()>=3)then--是GM
player:GossipMenuAddItem(GOSSIP_ICON_CHAT,"GM功能", 0, GMMENU*0x100)
end
player:GossipMenuAddItem(GOSSIP_ICON_CHAT, "在线总时间:|cFF000080"..Stone.GetTimeASString(player).."|r", 0, MMENU*0x100)
end
player:GossipSendMenu(1, item)--发送菜单
end
function Stone.ShowGossip(event, player, item)
player:MoveTo(0,player:GetX(),player:GetY(),player:GetZ()+0.01)--移动就停止当前施法
Stone.AddGossip(player, item, MMENU)
end
function Stone.SelectGossip(event, player, item, sender, intid, code, menu_id)
local menuid=math.modf(intid/0x100) --菜单组
local rowid =intid-menuid*0x100 --第几项
if(rowid== 0)then
Stone.AddGossip(player, item, menuid)
else
player:GossipComplete() --关闭菜单
local v=Menu[menuid] and Menu[menuid][rowid]
if(v)then --如果找到菜单项
local mtype=v[1] or MENU
if(mtype==MENU)then
Stone.AddGossip(player, item, (v[3] or MMENU))
elseif(mtype==FUNC)then --功能
local f=v[3]
if(f)then
player:ModifyMoney(-sender) --扣费
f(player, code)
end
elseif(mtype==ENC)then
local spellId,equipId=v[3],v[4]
Enchanting(player, spellId, equipId, 0)
Stone.AddGossip(player, item, menuid)
elseif(mtype==TP)then --传送
local map,mapid,x,y,z,o=v[2],v[3],v[4], v[5], v[6],v[7] or 0
local pname=player:GetName()--得到玩家名
if(player:Teleport(mapid,x,y,z,o,TELE_TO_GM_MODE))then--传送
Nplayer=GetPlayerByName(pname)--根据玩家名得到玩家
if(Nplayer)then
Nplayer:SendBroadcastMessage("已经到达 "..map)
Nplayer:ModifyMoney(-sender)--扣费
end
else
print(">>Eluna Error: Teleport Stone : Teleport To "..mapid)
end
end
end
end
end