-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.lua
61 lines (53 loc) · 1.66 KB
/
actions.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
require 'timer';
local util = require 'util';
local mgr = AshitaCore:GetResourceManager();
local numerals = { '', ' ii', ' iii', ' iv', ' v', 'vi' };
local function do_summon(thing)
local target = '<me>';
if (thing:lower() == 'atomos') then
target = '<t>'
end
AshitaCore:GetChatManager():QueueCommand('/ma "' .. thing .. '" ' .. target, -1);
end
local function summon(thing)
local petEnt = util:PetEntity();
if (petEnt ~= nil) then -- already has a pet, release first.
if (petEnt.Name:lower() ~= thing:lower()) then
AshitaCore:GetChatManager():QueueCommand('/pet release <me>', -1);
ashita.timer.once(2, function()
do_summon(thing);
end);
end
else
do_summon(thing);
end;
end
local actions = {};
function actions:Get(thing)
return function()
summon(thing);
end;
end
function actions:GetPetAction(action, ranks, target)
if (action == nil) then print(ranks); return nil end
local player = AshitaCore:GetDataManager():GetPlayer();
local rank = 1;
for rank = ranks, 1, -1 do
local ability = mgr:GetAbilityByName(action .. numerals[rank], 2);
if (ability ~= nil and player:HasAbility(ability.Id)) then
return function()
AshitaCore:GetChatManager():QueueCommand('/pet "' .. action .. numerals[rank] .. '" ' .. target, -1);
end, ability;
end
end
end
function actions:GetJaAction(command, target)
local player = AshitaCore:GetDataManager():GetPlayer();
local ability = mgr:GetAbilityByName(command, 2);
if (ability ~= nil) then
return function()
AshitaCore:GetChatManager():QueueCommand('/ja "' .. command .. '" ' .. target, -1);
end, ability;
end
end
return actions;