-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmagic.lua
53 lines (45 loc) · 1.37 KB
/
magic.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
local util = require('util');
local packets = require('packets');
local spells = packets.spells;
local status = packets.status;
local magic = {};
local ranks = {'', 'II', 'III', 'IV', 'V', 'VI', 'VII'};
function magic:cast(spell, target)
AshitaCore:GetChatManager():QueueCommand('/magic ' .. spell .. ' ' .. target, 0);
end
function magic:highest(names, levels, maxrank)
if (type(names) == 'string') then
names = {names};
end
if (maxrank == nil or maxrank > 7) then
maxrank = #ranks;
end
for i = #ranks, 1, -1 do
local rank = ranks[i];
for j, name in ipairs(names) do
local key = name;
local spell = name:gsub("_", " ");
if (strength ~= '') then
key = key .. '_' .. rank;
spell = spell .. ' ' .. rank;
end
if (spells[key] and magic:can(spells[key], levels)) then
return spell, i, spells[key];
end
end
end
end
-- Can the player cast this spell?
-- @param the spell id
-- @param the spell level table
-- @param true/false on checking for SUBJOB
function magic:can(spell, levels, isSub)
local iparty = AshitaCore:GetDataManager():GetParty();
local player = AshitaCore:GetDataManager():GetPlayer();
local lvl = util:JobLvlCheck(isSub);
if (isSub) then
lvl = ipary:GetMemberSubJobLevel(0);
end
return player:HasSpell(spell) and levels[spell] ~= nil and lvl >= levels[spell];
end
return magic;