-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
commands.lua
177 lines (159 loc) · 5.8 KB
/
commands.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
local packets = require('packets');
local actions = require('actions');
local combat = require('combat');
local config = require('config');
local fov = require('fov');
local jbrd = require('jobs.brd');
local jcor = require('jobs.cor');
local jsmn = require('jobs.smn');
local jgeo = require('jobs.geo');
local queue = {};
local start = 0;
local last = 0;
return {
following = false,
process = function(self, id, size, packet)
local chatType = struct.unpack('b', packet, 0x4 + 1);
if (chatType ~= packets.CHAT_TYPE_LINKSHELL2) then return end
local player = AshitaCore:GetDataManager():GetPlayer();
local actor = struct.unpack('s', packet, 0x8 + 1);
local idSize = struct.unpack('H', packet, 0x00 + 1);
local msgSize = (4 * (bit.rshift(idSize, 9)) - 0x18) + 1;
local msg = struct.unpack(string.format('c%d', msgSize), packet, 0x17 + 1);
local args = msg:args();
if (args[1] == 'leader') then
actions:leader(actor);
config:save();
end
-- If we're the leader... then don't listen.
if (config:get().leader == GetPlayerEntity().Name) then return end
if (args[1] == 'follow') then
self:follow(actor);
elseif (args[1] == 'stay') then
self:stay();
elseif (args[1] == 'reload') then
self:reload();
elseif (args[1] == 'echo') then
AshitaCore:GetChatManager():QueueCommand(msg:sub(6):gsub('<self>','<me>'), 0);
elseif (args[1] == 'gov' or args[1] == 'fov') then
if (args[4] == 'cancel') then
fov:cancel(args[1], args[2], args[3]);
elseif(args[4] == 'buffs') then
fov:buffs(args[1], args[2], args[3]);
elseif(args[4] == 'home') then
self:stay();
fov:home(args[1], args[2], args[3]);
elseif(args[4] == 'sneak') then
fov:sneak(args[1], args[2], args[3]);
else
fov:page(args[1], args[2], args[3], args[4]);
end
elseif (args[1] == 'debuff') then
combat:debuff(tonumber(args[2]));
elseif (args[1] == 'nuke') then
combat:nuke(tonumber(args[2]));
elseif (args[1] == 'sleep') then
combat:sleep(tonumber(args[2]));
elseif (args[1] == 'sleepga') then
combat:sleep(tonumber(args[2]), true);
elseif (args[1] == 'attack') then
combat:attack(tonumber(args[2]));
elseif (args[1] == 'signet') then
actions:signet(args[2], args[3]);
elseif (args[1] == 'warpscroll') then
if (args[3] ~= '0') then
actions:warp_scroll(args[2], args[3]);
else
AshitaCore:GetChatManager():QueueCommand('/item "Instant Warp" <me>', -1);
end
elseif (args[1] == 'idlebuffs') then
self:SetIdleBuffs(args[2]);
elseif (args[1] == 'sneakytime') then
self:SetSneakyTime(args[2]);
elseif (args[1] == 'talk') then
actions:queue(actions:InteractNpc(args[2], args[3]));
elseif (args[1] == 'setweaponskill') then
self:SetWeaponSkill(args[2], args[3]);
elseif (args[1] == 'bard' and (Jobs.Bard == player:GetMainJob() or Jobs.Bard == player:GetSubJob())) then
jbrd:bard(unpack(args));
elseif (args[1] == 'corsair' and (Jobs.Corsair == player:GetMainJob() or Jobs.Corsair == player:GetSubJob())) then
jcor:corsair(unpack(args));
elseif (args[1] == 'summoner' and (Jobs.Summoner == player:GetMainJob() or Jobs.Summoner == player:GetSubJob())) then
jsmn:summoner(unpack(args));
elseif (args[1] == 'geo' and (Jobs.Geomancer == player:GetMainJob() or Jobs.Geomancer == player:GetSubJob())) then
jgeo:geo(unpack(args));
elseif (args[1] == 'corn') then
actions:corn(args[2], args[3]);
end
end,
SetIdleBuffs = function(self, value)
local cnf = config:get();
cnf['IdleBuffs'] = value == 'true' or value == 'on';
if (cnf['IdleBuffs']) then
cnf['SneakyTime'] = false;
end
config:save();
end,
SetSneakyTime = function(self, value)
local cnf = config:get();
cnf['SneakyTime'] = value == 'true' or value == 'on';
if (cnf['SneakyTime']) then
cnf['IdleBuffs'] = false;
end
config:save();
end,
SetWeaponSkill = function(self, player, value)
--split out player and value
local pv = { };
if (tonumber(value) ~= nil and player == GetPlayerEntity().Name) then
local cnf = config:get();
cnf['WeaponSkillID'] = tonumber(value);
config:save();
end
end,
SearchWeaponSkill = function(self, value)
local list = {};
if (value~=nil) then
local searchme = string.upper(value.."");
print('Weaponskills containing '..searchme..':');
for k, v in pairs(packets.weaponskills) do
if (string.find(k,searchme) ~= nil or string.find(v,searchme) ~= nil) then
print(k.." "..v);
end
end
-- No search argument provided
else
print('To narrow your search, provide text to be searched for');
print('EXAMPLE - "/seven searchweaponskill co" yields the following result:');
for k, v in pairs(packets.weaponskills) do
if (string.find(k,'CO') ~= nil or string.find(v,'CO') ~= nil) then
print(k.." "..v);
end
end
end
end,
follow = function(self, player)
if (player ~= GetPlayerEntity().Name) then
AshitaCore:GetChatManager():QueueCommand("/follow " .. player, 1);
end
end,
stay = function(self)
local cnf = config:get();
if (cnf['stay'] == nil) then
cnf['stay'] = true;
AshitaCore:GetChatManager():QueueCommand("/sendkey numpad7 down", -1);
elseif (cnf['stay'] == true) then
cnf['stay'] = nil;
AshitaCore:GetChatManager():QueueCommand("/sendkey numpad7 up", -1);
end
end,
reload = function(self)
AshitaCore:GetChatManager():QueueCommand("/addon reload seven", -1);
end,
shutdown = function(self)
AshitaCore:GetChatManager():QueueCommand("/shutdown", -1);
end,
rest = function(self)
AshitaCore:GetChatManager():QueueCommand('/heal', -1);
end
};