-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathevents.lua
150 lines (131 loc) · 4.05 KB
/
events.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
Events = {
autoHealEvent,
autoHealthItemEvent,
autoManaItemEvent,
autoHasteEvent,
autoParalyzeHealEvent,
creatureAlertEvent,
autoEatEvent,
antiKickEvent,
autoFishingEvent,
runeMakeEvent,
autoReplaceWeaponEvent,
magicTrainEvent
}
local pnProtection
local pnAfk
function Events.init()
connect(LocalPlayer, { onHealthChange = Events.onHealthChange})
pnProtection = ProtectionModule.getPanel()
pnAfk = AfkModule.getPanel()
pnCreatureList = CreatureList.getPanel()
end
function Events.changeOption(key, status, loading)
loading = loading or false
if Bot.defaultOptions[key] == nil then
Bot.options[key] = nil
return
end
if g_game.isOnline() then
Events.setEvents(key, status, Loading)
local tab
if loading then
if pnProtection:getChildById(key) ~= nil then
tab = pnProtection
elseif pnAfk:getChildById(key) ~= nil then
tab = pnAfk
elseif pnCreatureList.getChildById(key) ~= nil then
tab = pnCreatureList
end
local widget = tab:getChildById(key)
if not widget then
return
end
local style = widget:getStyle().__class
if style == 'UITextEdit' or style == 'UIComboBox' then
tab:getChildById(key):setText(status)
elseif style == 'UICheckBox' then
tab:getChildById(key):setChecked(status)
elseif style == 'UIItem' then
tab:getChildById(key):setItemId(status)
end
end
if Bot.options[g_game.getCharacterName()] == nil then
Bot.options[g_game.getCharacterName()] = {}
end
Bot.options[g_game.getCharacterName()][key] = status
end
end
function Events.setEvents(key, status, loading)
if key == 'AutoHeal' then
-- removeEvent(Events.autoHealEvent)
if status then
-- Events.autoHealEvent = addEvent(ProtectionModule.autoHeal)
end
elseif key == 'AutoHealthItem' then
removeEvent(Events.autoHealthItemEvent)
if status then
Events.autoHealthItemEvent = addEvent(ProtectionModule.autoHealthItem)
end
elseif key == 'AutoManaItem' then
removeEvent(Events.autoManaItemEvent)
if status then
Events.autoManaItemEvent = addEvent(ProtectionModule.autoManaItem)
end
elseif key == 'AutoHaste' then
removeEvent(Events.autoHasteEvent)
if status then
Events.autoHasteEvent = addEvent(ProtectionModule.autoHaste)
end
elseif key == 'AutoParalyzeHeal' then
removeEvent(Events.autoParalyzeHealEvent)
if status then
Events.autoParalyzeHealEvent = addEvent(ProtectionModule.autoParalyzeHeal)
end
elseif key == 'AutoManaShield' then
removeEvent(Events.autoManaShieldEvent)
if status then
Events.autoManaShieldEvent = addEvent(ProtectionModule.autoManaShield)
end
elseif key == 'CreatureAlert' then
removeEvent(Events.creatureAlertEvent)
if status then
Events.creatureAlertEvent = addEvent(AfkModule.creatureAlert)
end
elseif key == 'AutoEat' then
removeEvent(Events.autoEatEvent)
if status then
Events.autoEatEvent = addEvent(AfkModule.autoEat)
end
elseif key == 'AntiKick' then
removeEvent(Events.antiKickEvent)
if status then
Events.antiKickEvent = addEvent(AfkModule.antiKick)
end
elseif key == 'AutoFishing' then
removeEvent(Events.autoFishingEvent)
if status then
Events.autoFishingEvent = addEvent(AfkModule.autoFishing)
end
elseif key == 'RuneMake' then
removeEvent(Events.runeMakeEvent)
if status then
Events.runeMakeEvent = addEvent(AfkModule.runeMake)
end
elseif key == 'AutoReplaceWeapon' then
removeEvent(Events.autoReplaceWeaponEvent)
if status then
Events.autoReplaceWeaponEvent = addEvent(AfkModule.autoReplaceWeapon)
end
elseif key == 'MagicTrain' then
removeEvent(Events.magicTrainEvent)
if status then
Events.magicTrainEvent = addEvent(AfkModule.magicTrain)
end
end
end
function Events.onHealthChange(localPlayer, health, maxHealth)
if pnProtection:getChildById('AutoHeal'):isChecked() == true then
Events.autoHealEvent = addEvent(ProtectionModule.autoHeal)
end
end