/
lua_general.cpp
1808 lines (1530 loc) · 58.9 KB
/
lua_general.cpp
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifdef LUA_EQEMU
#include "lua.hpp"
#include <luabind/luabind.hpp>
#include <sstream>
#include <list>
#include <map>
#include "lua_parser.h"
#include "lua_item.h"
#include "lua_iteminst.h"
#include "lua_client.h"
#include "lua_npc.h"
#include "lua_entity_list.h"
#include "quest_parser_collection.h"
#include "questmgr.h"
#include "qglobals.h"
#include "../common/timer.h"
#include "../common/eqemu_logsys.h"
struct Events { };
struct Factions { };
struct Slots { };
struct Materials { };
struct ClientVersions { };
struct Appearances { };
struct lua_registered_event {
std::string encounter_name;
luabind::adl::object lua_reference;
QuestEventID event_id;
};
extern std::map<std::string, std::list<lua_registered_event>> lua_encounter_events_registered;
extern std::map<std::string, bool> lua_encounters_loaded;
extern void MapOpcodes();
extern void ClearMappedOpcode(EmuOpcode op);
void unregister_event(std::string package_name, std::string name, int evt);
void load_encounter(std::string name) {
if(lua_encounters_loaded.count(name) > 0)
return;
lua_encounters_loaded[name] = true;
parse->EventEncounter(EVENT_ENCOUNTER_LOAD, name, 0);
}
void load_encounter_with_data(std::string name, std::string info_str) {
if(lua_encounters_loaded.count(name) > 0)
return;
lua_encounters_loaded[name] = true;
std::vector<EQEmu::Any> info_ptrs;
info_ptrs.push_back(&info_str);
parse->EventEncounter(EVENT_ENCOUNTER_LOAD, name, 0, &info_ptrs);
}
void unload_encounter(std::string name) {
if(lua_encounters_loaded.count(name) == 0)
return;
auto liter = lua_encounter_events_registered.begin();
while(liter != lua_encounter_events_registered.end()) {
std::list<lua_registered_event> &elist = liter->second;
auto iter = elist.begin();
while(iter != elist.end()) {
if((*iter).encounter_name.compare(name) == 0) {
iter = elist.erase(iter);
} else {
++iter;
}
}
if(elist.size() == 0) {
lua_encounter_events_registered.erase(liter++);
} else {
++liter;
}
}
lua_encounters_loaded.erase(name);
parse->EventEncounter(EVENT_ENCOUNTER_UNLOAD, name, 0);
}
void unload_encounter_with_data(std::string name, std::string info_str) {
if(lua_encounters_loaded.count(name) == 0)
return;
auto liter = lua_encounter_events_registered.begin();
while(liter != lua_encounter_events_registered.end()) {
std::list<lua_registered_event> &elist = liter->second;
auto iter = elist.begin();
while(iter != elist.end()) {
if((*iter).encounter_name.compare(name) == 0) {
iter = elist.erase(iter);
}
else {
++iter;
}
}
if(elist.size() == 0) {
lua_encounter_events_registered.erase(liter++);
}
else {
++liter;
}
}
lua_encounters_loaded.erase(name);
std::vector<EQEmu::Any> info_ptrs;
info_ptrs.push_back(&info_str);
parse->EventEncounter(EVENT_ENCOUNTER_UNLOAD, name, 0, &info_ptrs);
}
void register_event(std::string package_name, std::string name, int evt, luabind::adl::object func) {
if(lua_encounters_loaded.count(name) == 0)
return;
unregister_event(package_name, name, evt);
lua_registered_event e;
e.encounter_name = name;
e.lua_reference = func;
e.event_id = static_cast<QuestEventID>(evt);
auto liter = lua_encounter_events_registered.find(package_name);
if(liter == lua_encounter_events_registered.end()) {
std::list<lua_registered_event> elist;
elist.push_back(e);
lua_encounter_events_registered[package_name] = elist;
} else {
std::list<lua_registered_event> &elist = liter->second;
elist.push_back(e);
}
}
void unregister_event(std::string package_name, std::string name, int evt) {
auto liter = lua_encounter_events_registered.find(package_name);
if(liter != lua_encounter_events_registered.end()) {
std::list<lua_registered_event> elist = liter->second;
auto iter = elist.begin();
while(iter != elist.end()) {
if(iter->event_id == evt && iter->encounter_name.compare(name) == 0) {
iter = elist.erase(iter);
break;
}
++iter;
}
lua_encounter_events_registered[package_name] = elist;
}
}
void register_npc_event(std::string name, int evt, int npc_id, luabind::adl::object func) {
if(luabind::type(func) == LUA_TFUNCTION) {
std::stringstream package_name;
package_name << "npc_" << npc_id;
register_event(package_name.str(), name, evt, func);
}
}
void register_npc_event(int evt, int npc_id, luabind::adl::object func) {
std::string name = quest_manager.GetEncounter();
register_npc_event(name, evt, npc_id, func);
}
void unregister_npc_event(std::string name, int evt, int npc_id) {
std::stringstream package_name;
package_name << "npc_" << npc_id;
unregister_event(package_name.str(), name, evt);
}
void unregister_npc_event(int evt, int npc_id) {
std::string name = quest_manager.GetEncounter();
unregister_npc_event(name, evt, npc_id);
}
void register_player_event(std::string name, int evt, luabind::adl::object func) {
if(luabind::type(func) == LUA_TFUNCTION) {
register_event("player", name, evt, func);
}
}
void register_player_event(int evt, luabind::adl::object func) {
std::string name = quest_manager.GetEncounter();
register_player_event(name, evt, func);
}
void unregister_player_event(std::string name, int evt) {
unregister_event("player", name, evt);
}
void unregister_player_event(int evt) {
std::string name = quest_manager.GetEncounter();
unregister_player_event(name, evt);
}
void register_item_event(std::string name, int evt, int item_id, luabind::adl::object func) {
std::string package_name = "item_";
package_name += std::to_string(item_id);
if(luabind::type(func) == LUA_TFUNCTION) {
register_event(package_name, name, evt, func);
}
}
void register_item_event(int evt, int item_id, luabind::adl::object func) {
std::string name = quest_manager.GetEncounter();
register_item_event(name, evt, item_id, func);
}
void unregister_item_event(std::string name, int evt, int item_id) {
std::string package_name = "item_";
package_name += std::to_string(item_id);
unregister_event(package_name, name, evt);
}
void unregister_item_event(int evt, int item_id) {
std::string name = quest_manager.GetEncounter();
unregister_item_event(name, evt, item_id);
}
void register_spell_event(std::string name, int evt, int spell_id, luabind::adl::object func) {
if(luabind::type(func) == LUA_TFUNCTION) {
std::stringstream package_name;
package_name << "spell_" << spell_id;
register_event(package_name.str(), name, evt, func);
}
}
void register_spell_event(int evt, int spell_id, luabind::adl::object func) {
std::string name = quest_manager.GetEncounter();
register_spell_event(name, evt, spell_id, func);
}
void unregister_spell_event(std::string name, int evt, int spell_id) {
std::stringstream package_name;
package_name << "spell_" << spell_id;
unregister_event(package_name.str(), name, evt);
}
void unregister_spell_event(int evt, int spell_id) {
std::string name = quest_manager.GetEncounter();
unregister_spell_event(name, evt, spell_id);
}
Lua_Mob lua_spawn2(int npc_type, int grid, int unused, double x, double y, double z, double heading) {
auto position = glm::vec4(x, y, z, heading);
return Lua_Mob(quest_manager.spawn2(npc_type, grid, unused, position));
}
Lua_Mob lua_unique_spawn(int npc_type, int grid, int unused, double x, double y, double z, double heading = 0.0) {
auto position = glm::vec4(x, y, z, heading);
return Lua_Mob(quest_manager.unique_spawn(npc_type, grid, unused, position));
}
Lua_Mob lua_spawn_from_spawn2(uint32 spawn2_id) {
return Lua_Mob(quest_manager.spawn_from_spawn2(spawn2_id));
}
void lua_enable_spawn2(int spawn2_id) {
quest_manager.enable_spawn2(spawn2_id);
}
void lua_disable_spawn2(int spawn2_id) {
quest_manager.disable_spawn2(spawn2_id);
}
void lua_set_timer(const char *timer, int time_ms) {
quest_manager.settimerMS(timer, time_ms);
}
void lua_set_timer(const char *timer, int time_ms, Lua_ItemInst inst) {
quest_manager.settimerMS(timer, time_ms, inst);
}
void lua_set_timer(const char *timer, int time_ms, Lua_Mob mob) {
quest_manager.settimerMS(timer, time_ms, mob);
}
void lua_stop_timer(const char *timer) {
quest_manager.stoptimer(timer);
}
void lua_stop_timer(const char *timer, Lua_ItemInst inst) {
quest_manager.stoptimer(timer, inst);
}
void lua_stop_timer(const char *timer, Lua_Mob mob) {
quest_manager.stoptimer(timer, mob);
}
void lua_stop_all_timers() {
quest_manager.stopalltimers();
}
void lua_stop_all_timers(Lua_ItemInst inst) {
quest_manager.stopalltimers(inst);
}
void lua_stop_all_timers(Lua_Mob mob) {
quest_manager.stopalltimers(mob);
}
void lua_depop() {
quest_manager.depop(0);
}
void lua_depop(int npc_type) {
quest_manager.depop(npc_type);
}
void lua_depop_with_timer() {
quest_manager.depop_withtimer(0);
}
void lua_depop_with_timer(int npc_type) {
quest_manager.depop_withtimer(npc_type);
}
void lua_depop_all() {
quest_manager.depopall(0);
}
void lua_depop_all(int npc_type) {
quest_manager.depopall(npc_type);
}
void lua_depop_zone(bool start_spawn_status) {
quest_manager.depopzone(start_spawn_status);
}
void lua_repop_zone() {
quest_manager.repopzone();
}
bool lua_is_disc_tome(int item_id) {
return quest_manager.isdisctome(item_id);
}
void lua_safe_move() {
quest_manager.safemove();
}
void lua_rain(int weather) {
quest_manager.rain(weather);
}
void lua_snow(int weather) {
quest_manager.rain(weather);
}
int lua_scribe_spells(int max) {
return quest_manager.scribespells(max);
}
int lua_scribe_spells(int max, int min) {
return quest_manager.scribespells(max, min);
}
int lua_train_discs(int max) {
return quest_manager.traindiscs(max);
}
int lua_train_discs(int max, int min) {
return quest_manager.traindiscs(max, min);
}
void lua_set_sky(int sky) {
quest_manager.setsky(sky);
}
void lua_set_guild(int guild_id, int rank) {
quest_manager.setguild(guild_id, rank);
}
void lua_create_guild(const char *name, const char *leader) {
quest_manager.CreateGuild(name, leader);
}
void lua_set_time(int hour, int min) {
quest_manager.settime(hour, min, true);
}
void lua_set_time(int hour, int min, bool update_world) {
quest_manager.settime(hour, min, update_world);
}
void lua_signal(int npc_id, int signal_id) {
quest_manager.signalwith(npc_id, signal_id);
}
void lua_signal(int npc_id, int signal_id, int wait) {
quest_manager.signalwith(npc_id, signal_id, wait);
}
void lua_set_global(const char *name, const char *value, int options, const char *duration) {
quest_manager.setglobal(name, value, options, duration);
}
void lua_target_global(const char *name, const char *value, const char *duration, int npc_id, int char_id, int zone_id) {
quest_manager.targlobal(name, value, duration, npc_id, char_id, zone_id);
}
void lua_delete_global(const char *name) {
quest_manager.delglobal(name);
}
void lua_start(int wp) {
quest_manager.start(wp);
}
void lua_stop() {
quest_manager.stop();
}
void lua_pause(int duration) {
quest_manager.pause(duration);
}
void lua_move_to(float x, float y, float z) {
quest_manager.moveto(glm::vec4(x, y, z, 0.0f), false);
}
void lua_move_to(float x, float y, float z, float h) {
quest_manager.moveto(glm::vec4(x, y, z, h), false);
}
void lua_move_to(float x, float y, float z, float h, bool save_guard_spot) {
quest_manager.moveto(glm::vec4(x, y, z, h), save_guard_spot);
}
void lua_path_resume() {
quest_manager.resume();
}
void lua_set_next_hp_event(int hp) {
quest_manager.setnexthpevent(hp);
}
void lua_set_next_inc_hp_event(int hp) {
quest_manager.setnextinchpevent(hp);
}
void lua_respawn(int npc_type, int grid) {
quest_manager.respawn(npc_type, grid);
}
void lua_set_proximity(float min_x, float max_x, float min_y, float max_y) {
quest_manager.set_proximity(min_x, max_x, min_y, max_y);
}
void lua_set_proximity(float min_x, float max_x, float min_y, float max_y, float min_z, float max_z) {
quest_manager.set_proximity(min_x, max_x, min_y, max_y, min_z, max_z);
}
void lua_clear_proximity() {
quest_manager.clear_proximity();
}
void lua_enable_proximity_say() {
quest_manager.enable_proximity_say();
}
void lua_disable_proximity_say() {
quest_manager.disable_proximity_say();
}
void lua_set_anim(int npc_type, int anim_num) {
quest_manager.setanim(npc_type, anim_num);
}
void lua_spawn_condition(const char *zone, uint32 instance_id, int condition_id, int value) {
quest_manager.spawn_condition(zone, instance_id, condition_id, value);
}
int lua_get_spawn_condition(const char *zone, uint32 instance_id, int condition_id) {
return quest_manager.get_spawn_condition(zone, instance_id, condition_id);
}
void lua_toggle_spawn_event(int event_id, bool enable, bool strict, bool reset) {
quest_manager.toggle_spawn_event(event_id, enable, strict, reset);
}
void lua_summon_burried_player_corpse(uint32 char_id, float x, float y, float z, float h) {
quest_manager.summonburriedplayercorpse(char_id, glm::vec4(x, y, z, h));
}
void lua_summon_all_player_corpses(uint32 char_id, float x, float y, float z, float h) {
quest_manager.summonallplayercorpses(char_id, glm::vec4(x, y, z, h));
}
int lua_get_player_burried_corpse_count(uint32 char_id) {
return quest_manager.getplayerburriedcorpsecount(char_id);
}
bool lua_bury_player_corpse(uint32 char_id) {
return quest_manager.buryplayercorpse(char_id);
}
void lua_task_selector(luabind::adl::object table) {
if(luabind::type(table) != LUA_TTABLE) {
return;
}
int tasks[MAXCHOOSERENTRIES] = { 0 };
int count = 0;
for(int i = 1; i <= MAXCHOOSERENTRIES; ++i) {
auto cur = table[i];
int cur_value = 0;
if(luabind::type(cur) != LUA_TNIL) {
try {
cur_value = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed) {
}
} else {
count = i - 1;
break;
}
tasks[i - 1] = cur_value;
}
quest_manager.taskselector(count, tasks);
}
void lua_task_set_selector(int task_set) {
quest_manager.tasksetselector(task_set);
}
void lua_enable_task(luabind::adl::object table) {
if(luabind::type(table) != LUA_TTABLE) {
return;
}
int tasks[MAXCHOOSERENTRIES] = { 0 };
int count = 0;
for(int i = 1; i <= MAXCHOOSERENTRIES; ++i) {
auto cur = table[i];
int cur_value = 0;
if(luabind::type(cur) != LUA_TNIL) {
try {
cur_value = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed) {
}
} else {
count = i - 1;
break;
}
tasks[i - 1] = cur_value;
}
quest_manager.enabletask(count, tasks);
}
void lua_disable_task(luabind::adl::object table) {
if(luabind::type(table) != LUA_TTABLE) {
return;
}
int tasks[MAXCHOOSERENTRIES] = { 0 };
int count = 0;
for(int i = 1; i <= MAXCHOOSERENTRIES; ++i) {
auto cur = table[i];
int cur_value = 0;
if(luabind::type(cur) != LUA_TNIL) {
try {
cur_value = luabind::object_cast<int>(cur);
} catch(luabind::cast_failed) {
}
} else {
count = i - 1;
break;
}
tasks[i - 1] = cur_value;
}
quest_manager.disabletask(count, tasks);
}
bool lua_is_task_enabled(int task) {
return quest_manager.istaskenabled(task);
}
bool lua_is_task_active(int task) {
return quest_manager.istaskactive(task);
}
bool lua_is_task_activity_active(int task, int activity) {
return quest_manager.istaskactivityactive(task, activity);
}
int lua_get_task_activity_done_count(int task, int activity) {
return quest_manager.gettaskactivitydonecount(task, activity);
}
void lua_update_task_activity(int task, int activity, int count) {
quest_manager.updatetaskactivity(task, activity, count);
}
void lua_reset_task_activity(int task, int activity) {
quest_manager.resettaskactivity(task, activity);
}
void lua_task_explored_area(int explore_id) {
quest_manager.taskexploredarea(explore_id);
}
void lua_assign_task(int task_id) {
quest_manager.assigntask(task_id);
}
void lua_fail_task(int task_id) {
quest_manager.failtask(task_id);
}
int lua_task_time_left(int task_id) {
return quest_manager.tasktimeleft(task_id);
}
int lua_is_task_completed(int task_id) {
return quest_manager.istaskcompleted(task_id);
}
int lua_enabled_task_count(int task_set) {
return quest_manager.enabledtaskcount(task_set);
}
int lua_first_task_in_set(int task_set) {
return quest_manager.firsttaskinset(task_set);
}
int lua_last_task_in_set(int task_set) {
return quest_manager.lasttaskinset(task_set);
}
int lua_next_task_in_set(int task_set, int task_id) {
return quest_manager.nexttaskinset(task_set, task_id);
}
int lua_active_speak_task() {
return quest_manager.activespeaktask();
}
int lua_active_speak_activity(int task_id) {
return quest_manager.activespeakactivity(task_id);
}
int lua_active_tasks_in_set(int task_set) {
return quest_manager.activetasksinset(task_set);
}
int lua_completed_tasks_in_set(int task_set) {
return quest_manager.completedtasksinset(task_set);
}
bool lua_is_task_appropriate(int task) {
return quest_manager.istaskappropriate(task);
}
void lua_popup(const char *title, const char *text, uint32 id, uint32 buttons, uint32 duration) {
quest_manager.popup(title, text, id, buttons, duration);
}
void lua_clear_spawn_timers() {
quest_manager.clearspawntimers();
}
void lua_zone_emote(int type, const char *str) {
quest_manager.ze(type, str);
}
void lua_world_emote(int type, const char *str) {
quest_manager.we(type, str);
}
int lua_get_level(int type) {
return quest_manager.getlevel(type);
}
void lua_create_ground_object(uint32 item_id, float x, float y, float z, float h) {
quest_manager.CreateGroundObject(item_id, glm::vec4(x, y, z, h));
}
void lua_create_ground_object(uint32 item_id, float x, float y, float z, float h, uint32 decay_time) {
quest_manager.CreateGroundObject(item_id, glm::vec4(x, y, z, h), decay_time);
}
void lua_create_ground_object_from_model(const char *model, float x, float y, float z, float h) {
quest_manager.CreateGroundObjectFromModel(model, glm::vec4(x, y, z, h));
}
void lua_create_ground_object_from_model(const char *model, float x, float y, float z, float h, int type) {
quest_manager.CreateGroundObjectFromModel(model, glm::vec4(x, y, z, h), type);
}
void lua_create_ground_object_from_model(const char *model, float x, float y, float z, float h, int type, uint32 decay_time) {
quest_manager.CreateGroundObjectFromModel(model, glm::vec4(x, y, z, h), type, decay_time);
}
void lua_create_door(const char *model, float x, float y, float z, float h, int open_type, int size) {
quest_manager.CreateDoor(model, x, y, z, h, open_type, size);
}
void lua_modify_npc_stat(const char *id, const char *value) {
quest_manager.ModifyNPCStat(id, value);
}
int lua_collect_items(uint32 item_id, bool remove) {
return quest_manager.collectitems(item_id, remove);
}
void lua_update_spawn_timer(uint32 id, uint32 new_time) {
quest_manager.UpdateSpawnTimer(id, new_time);
}
void lua_merchant_set_item(uint32 npc_id, uint32 item_id) {
quest_manager.MerchantSetItem(npc_id, item_id);
}
void lua_merchant_set_item(uint32 npc_id, uint32 item_id, uint32 quantity) {
quest_manager.MerchantSetItem(npc_id, item_id, quantity);
}
int lua_merchant_count_item(uint32 npc_id, uint32 item_id) {
return quest_manager.MerchantCountItem(npc_id, item_id);
}
std::string lua_item_link(int item_id) {
char text[250] = { 0 };
quest_manager.varlink(text, item_id);
return std::string(text);
}
std::string lua_say_link(const char *phrase, bool silent, const char *link_name) {
char text[256] = { 0 };
strncpy(text, phrase, 255);
quest_manager.saylink(text, silent, link_name);
return std::string(text);
}
std::string lua_say_link(const char *phrase, bool silent) {
char text[256] = { 0 };
strncpy(text, phrase, 255);
quest_manager.saylink(text, silent, text);
return std::string(text);
}
std::string lua_say_link(const char *phrase) {
char text[256] = { 0 };
strncpy(text, phrase, 255);
quest_manager.saylink(text, false, text);
return std::string(text);
}
const char *lua_get_guild_name_by_id(uint32 guild_id) {
return quest_manager.getguildnamebyid(guild_id);
}
uint32 lua_create_instance(const char *zone, uint32 version, uint32 duration) {
return quest_manager.CreateInstance(zone, version, duration);
}
void lua_destroy_instance(uint32 instance_id) {
quest_manager.DestroyInstance(instance_id);
}
int lua_get_instance_id(const char *zone, uint32 version) {
return quest_manager.GetInstanceID(zone, version);
}
void lua_assign_to_instance(uint32 instance_id) {
quest_manager.AssignToInstance(instance_id);
}
void lua_assign_group_to_instance(uint32 instance_id) {
quest_manager.AssignGroupToInstance(instance_id);
}
void lua_assign_raid_to_instance(uint32 instance_id) {
quest_manager.AssignRaidToInstance(instance_id);
}
void lua_remove_from_instance(uint32 instance_id) {
quest_manager.RemoveFromInstance(instance_id);
}
void lua_remove_all_from_instance(uint32 instance_id) {
quest_manager.RemoveAllFromInstance(instance_id);
}
void lua_flag_instance_by_group_leader(uint32 zone, uint32 version) {
quest_manager.FlagInstanceByGroupLeader(zone, version);
}
void lua_flag_instance_by_raid_leader(uint32 zone, uint32 version) {
quest_manager.FlagInstanceByRaidLeader(zone, version);
}
void lua_fly_mode(int flymode) {
quest_manager.FlyMode(flymode);
}
int lua_faction_value() {
return quest_manager.FactionValue();
}
void lua_check_title(uint32 title_set) {
quest_manager.checktitle(title_set);
}
void lua_enable_title(uint32 title_set) {
quest_manager.enabletitle(title_set);
}
void lua_remove_title(uint32 title_set) {
quest_manager.removetitle(title_set);
}
void lua_wear_change(uint32 slot, uint32 texture) {
quest_manager.wearchange(slot, texture);
}
void lua_voice_tell(const char *str, uint32 macro_num, uint32 race_num, uint32 gender_num) {
quest_manager.voicetell(str, macro_num, race_num, gender_num);
}
void lua_send_mail(const char *to, const char *from, const char *subject, const char *message) {
quest_manager.SendMail(to, from, subject, message);
}
void lua_cross_zone_signal_client_by_char_id(uint32 player_id, int signal) {
quest_manager.CrossZoneSignalPlayerByCharID(player_id, signal);
}
void lua_cross_zone_signal_client_by_name(const char *player, int signal) {
quest_manager.CrossZoneSignalPlayerByName(player, signal);
}
void lua_cross_zone_message_player_by_name(uint32 type, const char *player, const char *message) {
quest_manager.CrossZoneMessagePlayerByName(type, player, message);
}
luabind::adl::object lua_get_qglobals(lua_State *L, Lua_NPC npc, Lua_Client client) {
luabind::adl::object ret = luabind::newtable(L);
NPC *n = npc;
Client *c = client;
std::list<QGlobal> global_map;
QGlobalCache::GetQGlobals(global_map, n, c, zone);
auto iter = global_map.begin();
while(iter != global_map.end()) {
ret[(*iter).name] = (*iter).value;
++iter;
}
return ret;
}
luabind::adl::object lua_get_qglobals(lua_State *L, Lua_Client client) {
luabind::adl::object ret = luabind::newtable(L);
NPC *n = nullptr;
Client *c = client;
std::list<QGlobal> global_map;
QGlobalCache::GetQGlobals(global_map, n, c, zone);
auto iter = global_map.begin();
while (iter != global_map.end()) {
ret[(*iter).name] = (*iter).value;
++iter;
}
return ret;
}
luabind::adl::object lua_get_qglobals(lua_State *L, Lua_NPC npc) {
luabind::adl::object ret = luabind::newtable(L);
NPC *n = npc;
Client *c = nullptr;
std::list<QGlobal> global_map;
QGlobalCache::GetQGlobals(global_map, n, c, zone);
auto iter = global_map.begin();
while (iter != global_map.end()) {
ret[(*iter).name] = (*iter).value;
++iter;
}
return ret;
}
luabind::adl::object lua_get_qglobals(lua_State *L) {
luabind::adl::object ret = luabind::newtable(L);
NPC *n = nullptr;
Client *c = nullptr;
std::list<QGlobal> global_map;
QGlobalCache::GetQGlobals(global_map, n, c, zone);
auto iter = global_map.begin();
while (iter != global_map.end()) {
ret[(*iter).name] = (*iter).value;
++iter;
}
return ret;
}
Lua_EntityList lua_get_entity_list() {
return Lua_EntityList(&entity_list);
}
int lua_get_zone_id() {
if(!zone)
return 0;
return zone->GetZoneID();
}
const char *lua_get_zone_long_name() {
if(!zone)
return "";
return zone->GetLongName();
}
const char *lua_get_zone_short_name() {
if(!zone)
return "";
return zone->GetShortName();
}
int lua_get_zone_instance_id() {
if(!zone)
return 0;
return zone->GetInstanceID();
}
int lua_get_zone_instance_version() {
if(!zone)
return 0;
return zone->GetInstanceVersion();
}
luabind::adl::object lua_get_characters_in_instance(lua_State *L, uint16 instance_id) {
luabind::adl::object ret = luabind::newtable(L);
std::list<uint32> charid_list;
uint16 i = 1;
database.GetCharactersInInstance(instance_id,charid_list);
auto iter = charid_list.begin();
while(iter != charid_list.end()) {
ret[i] = *iter;
++i;
++iter;
}
return ret;
}
int lua_get_zone_weather() {
if(!zone)
return 0;
return zone->zone_weather;
}
luabind::adl::object lua_get_zone_time(lua_State *L) {
TimeOfDay_Struct eqTime;
zone->zone_time.GetCurrentEQTimeOfDay(time(0), &eqTime);
luabind::adl::object ret = luabind::newtable(L);
ret["zone_hour"] = eqTime.hour - 1;
ret["zone_minute"] = eqTime.minute;
ret["zone_time"] = (eqTime.hour - 1) * 100 + eqTime.minute;
return ret;
}
void lua_add_area(int id, int type, float min_x, float max_x, float min_y, float max_y, float min_z, float max_z) {
entity_list.AddArea(id, type, min_x, max_x, min_y, max_y, min_z, max_z);
}
void lua_remove_area(int id) {
entity_list.RemoveArea(id);