forked from Keristero/ezlibs-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
266 lines (239 loc) · 8.18 KB
/
main.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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
local eznpcs = require('scripts/ezlibs-scripts/eznpcs/eznpcs')
local ezmemory = require('scripts/ezlibs-scripts/ezmemory')
local ezmystery = require('scripts/ezlibs-scripts/ezmystery')
local ezweather = require('scripts/ezlibs-scripts/ezweather')
local ezwarps = require('scripts/ezlibs-scripts/ezwarps/main')
--local ezfarms = require('scripts/ezlibs-scripts/ezfarms')
--local ezencounters = require('scripts/ezlibs-scripts/ezencounters/main')
--local plugins = {ezweather,eznpcs,ezmemory,ezmystery,ezfarms,ezwarps,ezencounters}
local plugins = {ezweather,eznpcs,ezmemory,ezmystery,ezwarps}
local sfx = {
hurt='/server/assets/ezlibs-assets/sfx/hurt.ogg',
item_get='/server/assets/ezlibs-assets/sfx/item_get.ogg',
recover='/server/assets/ezlibs-assets/sfx/recover.ogg',
card_error='/server/assets/ezlibs-assets/ezfarms/card_error.ogg'
}
eznpcs.load_npcs()
function handle_battle_results(player_id, stats)
for i,plugin in ipairs(plugins)do
if plugin.handle_battle_results then
plugin.handle_battle_results(player_id, stats)
end
end
end
function handle_custom_warp(player_id, object_id)
for i,plugin in ipairs(plugins)do
if plugin.handle_custom_warp then
plugin.handle_custom_warp(player_id, object_id)
end
end
end
function handle_player_move(player_id, x, y, z)
for i,plugin in ipairs(plugins)do
if plugin.handle_player_move then
plugin.handle_player_move(player_id, x, y, z)
end
end
end
function handle_player_request(player_id, data)
for i,plugin in ipairs(plugins)do
if plugin.handle_player_request then
plugin.handle_player_request(player_id, data)
end
end
end
--Pass handlers on to all the libraries we are using
function handle_tile_interaction(player_id, x, y, z, button)
for i,plugin in ipairs(plugins)do
if plugin.handle_tile_interaction then
plugin.handle_tile_interaction(player_id, x, y, z, button)
end
end
end
function handle_post_selection(player_id, post_id)
for i,plugin in ipairs(plugins)do
if plugin.handle_post_selection then
plugin.handle_post_selection(player_id, post_id)
end
end
end
function handle_board_close(player_id)
for i,plugin in ipairs(plugins)do
if plugin.handle_board_close then
plugin.handle_board_close(player_id)
end
end
end
function handle_player_avatar_change(player_id, details)
for i,plugin in ipairs(plugins)do
if plugin.handle_player_avatar_change then
plugin.handle_player_avatar_change(player_id, details)
end
end
end
function handle_player_join(player_id)
for i,plugin in ipairs(plugins)do
if plugin.handle_player_join then
plugin.handle_player_join(player_id)
end
end
--Provide assets for custom events
for name,path in pairs(sfx) do
Net.provide_asset_for_player(player_id, path)
end
end
function handle_actor_interaction(player_id, actor_id)
for i,plugin in ipairs(plugins)do
if plugin.handle_actor_interaction then
plugin.handle_actor_interaction(player_id,actor_id)
end
end
end
function tick(delta_time)
for i,plugin in ipairs(plugins)do
if plugin.on_tick then
plugin.on_tick(delta_time)
end
end
end
function handle_player_disconnect(player_id)
for i,plugin in ipairs(plugins)do
if plugin.handle_player_disconnect then
plugin.handle_player_disconnect(player_id)
end
end
end
function handle_object_interaction(player_id, object_id)
for i,plugin in ipairs(plugins)do
if plugin.handle_object_interaction then
plugin.handle_object_interaction(player_id,object_id)
end
end
end
function handle_player_transfer(player_id)
for i,plugin in ipairs(plugins)do
if plugin.handle_player_transfer then
plugin.handle_player_transfer(player_id)
end
end
end
function handle_textbox_response(player_id, response)
for i,plugin in ipairs(plugins)do
if plugin.handle_textbox_response then
plugin.handle_textbox_response(player_id,response)
end
end
end
--custom events, remove them if you dont want them.
local event1 = {
name="Punch",
action=function (npc,player_id,dialogue,relay_object)
local player_mugshot = Net.get_player_mugshot(player_id)
Net.play_sound_for_player(player_id,sfx.hurt)
Net.message_player(player_id,"owchie!",player_mugshot.texture_path,player_mugshot.animation_path)
end
}
eznpcs.add_event(event1)
local event_snow = {
name="Snow",
action=function (npc,player_id,dialogue,relay_object)
local area_id = Net.get_player_area(player_id)
ezweather.start_snow_in_area(area_id)
local next_dialouge_options = {
id=dialogue.custom_properties["Next 1"],
wait_for_response=false
}
return next_dialouge_options
end
}
eznpcs.add_event(event_snow)
local event2 = {
name="Buy Gravy",
action=function (npc,player_id,dialogue)
if ezmemory.spend_player_money(player_id,300) then
Net.play_sound_for_player(player_id,sfx.item_get)
Net.message_player(player_id,"Got net gravy!")
local next_dialouge_options = {
id=dialogue.custom_properties["Got Gravy"],
wait_for_response=true
}
return next_dialouge_options
else
local next_dialouge_options = {
id=dialogue.custom_properties["No Gravy"],
wait_for_response=false
}
return next_dialouge_options
end
end
}
eznpcs.add_event(event2)
local event3 = {
name="Drink Gravy",
action=function (npc,player_id,dialogue,relay_object)
local player_mugshot = Net.get_player_mugshot(player_id)
Net.play_sound_for_player(player_id,sfx.recover)
Net.message_player(player_id,"\x01...\x01mmm gravy yum",player_mugshot.texture_path,player_mugshot.animation_path)
local next_dialouge_options = {
wait_for_response=true,
id=dialogue.custom_properties["Next 1"]
}
return next_dialouge_options
end
}
eznpcs.add_event(event3)
local event4 = {
name="Cafe Counter Check",
action=function (npc,player_id,dialogue,relay_object)
local next_dialouge_options = nil
if relay_object then
next_dialouge_options = {
wait_for_response=false,
id=dialogue.custom_properties["Counter Chat"]
}
else
next_dialouge_options = {
wait_for_response=false,
id=dialogue.custom_properties["Direct Chat"]
}
end
return next_dialouge_options
end
}
eznpcs.add_event(event4)
local gift_zenny = {
name="Gift Monies",
action=function (npc,player_id,dialogue)
local zenny_amount = tonumber(dialogue.custom_properties["Amount"])
ezmemory.spend_player_money(player_id,-zenny_amount)
Net.play_sound_for_player(player_id,sfx.item_get)
Net.message_player(player_id,"Got "..zenny_amount.. "$!")
if dialogue.custom_properties["Next 1"] then
local next_dialouge_options = {
wait_for_response=true,
id=dialogue.custom_properties["Next 1"]
}
return next_dialouge_options
end
end
}
eznpcs.add_event(gift_zenny)
local deal_damage = {
name="Damage",
action=function (npc,player_id,dialogue)
local damage_amount = tonumber(dialogue.custom_properties["Amount"])
local player_hp = tonumber(Net.get_player_health(player_id))
local new_hp = player_hp-damage_amount
Net.play_sound_for_player(player_id,sfx.hurt)
Net.message_player(player_id,"Took "..damage_amount.. " damage!\n new hp ="..new_hp)
Net.set_player_health(player_id, new_hp)
if dialogue.custom_properties["Next 1"] then
local next_dialouge_options = {
wait_for_response=true,
id=dialogue.custom_properties["Next 1"]
}
return next_dialouge_options
end
end
}
eznpcs.add_event(deal_damage)