-
Notifications
You must be signed in to change notification settings - Fork 5
/
test.lua
173 lines (148 loc) · 5.69 KB
/
test.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
local PLAYER_EVENT_ON_LOGIN = 3
local function OnLogin(event, player)
player:SendBroadcastMessage("Hello world")
end
RegisterPlayerEvent(PLAYER_EVENT_ON_LOGIN, OnLogin)
--
--print(">>Script: TeleportStone loading...OK")
--
----菜单所有者 --默认炉石
--local itemEntry =6948
--local Stone={}
--function Stone.ShowGossip(event, player, item)
-- player:SendBroadcastMessage("ShowGossip")
-- return false
--end
--
--function Stone.SelectGossip(event, player, item, sender, intid, code, menu_id)
-- player:SendBroadcastMessage("SelectGossip")
-- return false
--end
--
--
--RegisterItemGossipEvent(itemEntry, 1, Stone.ShowGossip)
--RegisterItemGossipEvent(itemEntry, 2, Stone.SelectGossip)
local target
local function Chat (event, player, message, type, language)
player:SendBroadcastMessage("Chating")
if (message == "#sex") then --test change model
player:SetDisplayId(1)
player:SendBroadcastMessage("You have been sexed up!")
return 0
end
--get target
if(message == "t") then
target=player:GetSelection()--得到玩家选中对象
player:SendBroadcastMessage("get target:"..target:GetName().." type:"..target:GetTypeId())
end
-- test move
if(message =="a") then
local slave = player:GetSelection()--得到玩家选中对象
if(slave)then
if(slave:GetTypeId()==3)then--目标是生物
--slave:MoveFollow(target)
end
end
end
if(message == "k") then
player:SetHealth(0)
player:KillPlayer()
--player:SetLuaCooldown(0, 3)
--player:RemoveEvents()
player:SendBroadcastMessage("player:"..player:GetName().." killed")
end
if(message == "aura") then
local spellID = 16609
player:AddAura(spellID,player)
end
end
RegisterPlayerEvent(18, Chat)
--RegisterPlayerEvent(42,Chat)
-- 让闪金镇的马克能够对话
-- 先修改马克的 creature_template.npc_flags = 2+1(3) 才能有对话菜单
local creatureEntry = 795
local function OnGossipHello(event, player, unit)
player:GossipMenuAddItem(0, "Test Weather", 1, 1)
player:GossipMenuAddItem(0, "Nevermind..", 1, 2)
player:GossipSendMenu(1, unit)
end
local function OnGossipSelect(event, plr, unit, sender, action, code)
if (action == 1) then
plr:GetMap():SetWeather(plr:GetZoneId(), math.random(0, 3), 1) -- random weather
plr:GossipComplete()
unit:MoveFollow(plr)
elseif (action == 2) then
plr:GossipComplete()
plr:SendBroadcastMessage("player:"..plr:GetName().." hello?")
--unit:MoveTo(0, plr:GetX()+50,plr:GetY(),plr:GetZ())
unit:MoveClear()
end
end
RegisterCreatureGossipEvent(creatureEntry, 1, OnGossipHello)
RegisterCreatureGossipEvent(creatureEntry, 2, OnGossipSelect)
--让闪金镇的布尔797有boss技能 癞皮狼525 暴风城卫兵1423
local npcId = 525
local Therer = {}
function Therer.OnEnterCombat(event, creature, target)
creature:RegisterEvent(Therer.ArcaneBolt, 12000, 0)
creature:RegisterEvent(Therer.DrainLife, 7500, 0)
creature:RegisterEvent(Therer.DigestiveAcid, 18000, 0)
creature:RegisterEvent(Therer.ArcaneExplode, 15000, 0)
end
function Therer.OnLeaveCombat(event, creature)
creature:SendUnitYell("Didn't even stand a chance", 0)
creature:CastSpell(creature, 36393, true)
creature:RemoveEvents()
end
function Therer.OnDied(event, creature, killer)
if (killer:GetObjectType() == "Player") then
killer:SendBroadcastMessage("You killed " .. creature:GetName() .. "!")
end
creature:RemoveEvents()
end
--奥数爆炸
function Therer.ArcaneExplode(event, dely, calls, creature)
local TARGET3 = creature:GetAITarget(4, true, 0, 45)
creature:CastSpell(TARGET3, 34656, true)
creature:SendUnitYell("奥数爆炸!", 0)
end
--奥术箭
function Therer.ArcaneBolt(event, dely, calls, creature)
local TARGET2 = creature:GetAITarget(4, true, 0, 45)
creature:CastSpell(TARGET2, 58456, true)
creature:SendUnitYell("奥术箭!", 0)
end
--吸取生命
function Therer.DrainLife(event, dely, calls, creature)
creature:CastSpell(creature:GetVictim(), 17620, false)
creature:SendUnitYell("吸取生命!", 0)
end
--消化酸液
function Therer.DigestiveAcid(event, dely, calls, creature)
local TARGET1 = creature:GetAITarget(1, true, 0, 45)
creature:CastSpell(TARGET1, 26476, true)
creature:SendUnitYell("消化酸液!", 0)
end
RegisterCreatureEvent(npcId, 1, Therer.OnEnterCombat)
RegisterCreatureEvent(npcId, 2, Therer.OnLeaveCombat)
RegisterCreatureEvent(npcId, 4, Therer.OnDied)
--test RegisterMapEvent
local INSTANCE_EVENT_ON_PLAYER_ENTER = 4 -- (event, instance_data, map
function MapEvent_PlayerEnterMap(event, instance_data, map, player)
player:SendBroadcastMessage("MapEvent:玩家:"..player:GetName().." 进入了死亡矿井。")
end
RegisterMapEvent( 36, INSTANCE_EVENT_ON_PLAYER_ENTER, MapEvent_PlayerEnterMap )
-- only RegisterServerEvent works
local MAP_EVENT_ON_PLAYER_ENTER = 21 -- (event, map, player)
function ServerEvent_PlayerEnterMap(event, map, player)
player:AddAura(22888, player)
player:SendBroadcastMessage("ServerEvent:玩家:"..player:GetName().." 进入了"..map:GetName())
end
RegisterServerEvent(MAP_EVENT_ON_PLAYER_ENTER, ServerEvent_PlayerEnterMap )
--Test PLAYER_EVENT_ON_COMMAND. Type ".myCmd subcmd1" in console to test.
--https://elunaluaengine.github.io/Global/RegisterPlayerEvent.html
local PLAYER_EVENT_ON_COMMAND = 42 -- (event, player, command) - player is nil if command used from console. Can return false
local function Player_Command(event,player,command)
player:SendBroadcastMessage("Player_Command:player:"..player:GetName().." input: "..command)
end
local isCancel = RegisterPlayerEvent( PLAYER_EVENT_ON_COMMAND, Player_Command )