-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
18 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,29 @@ | ||
local acutil = require('acutil'); | ||
ui.SysMsg("Load poisonpot auto charge") | ||
ui.SysMsg("Load Poisonpot Auto Charge") | ||
|
||
function POISONPOTAUTOCHARGE_ON_INIT(addon, frame) | ||
POISONPOT_AUTO_CHARGE() | ||
end | ||
|
||
function POISONPOT_AUTO_CHARGE() | ||
|
||
if hasPoisonJob() == nil then | ||
return;end | ||
|
||
local poisonAmount = getPoisonAmount() | ||
if poisonAmount == nil then | ||
return;end | ||
|
||
local poisonpot = GET_POISONPOT_ID(); | ||
|
||
if poisonpot == nil then | ||
return;end | ||
|
||
local cnt = math.floor((1000 - poisonAmount) / 200); | ||
session.AddItemID(poisonpot, cnt); | ||
EXECUTE_POISONPOT_COMMIT() | ||
end | ||
|
||
function hasPoisonJob() | ||
local frame = ui.GetFrame("sysmenu"); | ||
local frame = ui.GetFrame("sysmenu"); | ||
local poisonpot = GET_CHILD(frame, "poisonpot", "ui::CButton"); | ||
if poisonpot == nil then | ||
return nil | ||
end | ||
return true | ||
end | ||
|
||
function getPoisonAmount() | ||
if not poisonpot then | ||
return; | ||
end | ||
|
||
local myEtc = GetMyEtcObject(); | ||
local poisonAmount = myEtc['Wugushi_PoisonAmount']; | ||
if poisonAmount < 700 then | ||
return poisonAmount; | ||
|
||
local cnt = math.floor((1000 - poisonAmount) / 200); | ||
if cnt < 1 then | ||
return | ||
end | ||
return nil | ||
end | ||
|
||
-- 645569 misc_poisonpot | ||
|
||
function GET_POISONPOT_ID() | ||
local inventoryItems = session.GetInvItemList(); | ||
|
||
if inventoryItems == nil then | ||
return nil;end | ||
|
||
local poison = session.GetInvItemByName('misc_poisonpot') | ||
local poisonGUID = poison:GetIESID() | ||
|
||
local index = inventoryItems:Head(); | ||
local itemCount = session.GetInvItemList():Count(); | ||
|
||
for i = 0, itemCount - 1 do | ||
local inventoryItem = inventoryItems:Element(index); | ||
index = inventoryItems:Next(index); | ||
|
||
if inventoryItem == nil then | ||
break;end | ||
|
||
local itemObj = GetIES(inventoryItem:GetObject()); | ||
if itemObj == nil then | ||
break;end | ||
|
||
if string.starts(itemObj.ClassName, "misc_poisonpot") then | ||
return inventoryItem:GetIESID(); | ||
end | ||
end | ||
return nil; | ||
end | ||
session.ResetItemList() | ||
session.AddItemID(poisonGUID, cnt); | ||
EXECUTE_POISONPOT_COMMIT() | ||
end |