Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix aspd buffing v1 #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,10 @@ function init()
[4] = {'priest', 'highlander', 'psykino', 'fairy', 'blade', 'plague_doctor', 'cannoneer', 'vulcanist', 'warden', 'corruptor', 'thief'},
}

non_attacking_characters = {'cleric', 'stormweaver', 'squire', 'chronomancer', 'sage', 'psykeeper', 'bane', 'carver', 'fairy', 'priest', 'flagellant', 'merchant', 'miner'}
non_cooldown_characters = {'squire', 'chronomancer', 'psykeeper', 'merchant', 'miner'}

non_attacking_characters = {'cleric', 'stormweaver', 'squire', 'chronomancer', 'sage', 'bane', 'carver', 'fairy', 'priest', 'merchant', 'miner', 'infestor', 'jester', 'silencer', 'warden'}
non_cooldown_characters = {'squire', 'chronomancer', 'psykeeper', 'merchant', 'miner', 'cryomancer', 'pyromancer'}
non_speed_buffable = {'artificer', 'bomber', 'carver', 'chronomancer', 'cleric', 'cryomancer', 'engineer', 'fairy', 'flagellant', 'host', 'merchant', 'miner', 'priest', 'psykeeper', 'pyromancer', 'sentry', 'squire', 'stormweaver', 'vulcanist', 'warden'}

character_tiers = {
['vagrant'] = 1,
['swordsman'] = 1,
Expand Down
51 changes: 24 additions & 27 deletions player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -677,18 +677,11 @@ function Player:init(args)

elseif self.character == 'fairy' then
self.t:every(6, function()
local units = self:get_all_units()
units = table.select(units, function(v) return self:is_attacker(v) end)
if self.level == 3 then
local units = self:get_all_units()
local unit_1 = random:table(units)
local runs = 0
if unit_1 then
while table.any(non_attacking_characters, function(v) return v == unit_1.character end) and runs < 1000 do unit_1 = random:table(units); runs = runs + 1 end
end
local unit_1 = random:table_remove(units)
local unit_2 = random:table(units)
local runs = 0
if unit_2 then
while table.any(non_attacking_characters, function(v) return v == unit_2.character end) and runs < 1000 do unit_2 = random:table(units); runs = runs + 1 end
end
if unit_1 then
unit_1.fairy_aspd_m = 3
unit_1.fairyd = true
Expand Down Expand Up @@ -718,9 +711,7 @@ function Player:init(args)
end

else
local unit = random:table(self:get_all_units())
local runs = 0
while table.any(non_attacking_characters, function(v) return v == unit.character end) and runs < 1000 do unit = random:table(self:get_all_units()); runs = runs + 1 end
local unit = random:table(units)
if unit then
unit.fairyd = true
unit.fairy_aspd_m = 2
Expand Down Expand Up @@ -921,16 +912,9 @@ function Player:init(args)
if self.leader and self.awakening then
main.current.t:after(0.1, function()
local units = self:get_all_units()
local mages = {}
for _, unit in ipairs(units) do
if table.any(unit.classes, function(v) return v == 'mage' end) then
table.insert(mages, unit)
end
end
local mage = random:table(mages)
units = table.select(units, function(v) return self:is_class(v, 'mage') and self:is_attacker(v)end)
local mage = random:table(units)
if mage then
local runs = 0
while table.any(non_attacking_characters, function(v) return v == mage.character end) and runs < 1000 do mage = random:table(mages); runs = runs + 1 end
mage.awakening_aspd_m = (self.awakening == 1 and 1.5) or (self.awakening == 2 and 1.75) or (self.awakening == 3 and 2)
mage.awakening_dmg_m = (self.awakening == 1 and 1.5) or (self.awakening == 2 and 1.75) or (self.awakening == 3 and 2)
end
Expand Down Expand Up @@ -1002,21 +986,24 @@ function Player:init(args)
end)
end

if self.enchanted then
if self.leader and self.enchanted then
main.current.t:after(0.1, function()
local units = self:get_all_units()
local enchanter_amount = 0
for _, unit in ipairs(units) do
if table.any(unit.classes, function(v) return v == 'enchanter' end) then

-- Count sorceror units and filter out non attacking units at the same time.
for i = #units, 1, -1 do
if self:is_class(units[i], 'enchanter') then
enchanter_amount = enchanter_amount + 1
end
if not self:is_attacker(units[i]) then
table.remove(units, i)
end
end

if enchanter_amount >= 2 then
local unit = random:table(units)
local runs = 0
if unit then
while table.any(non_attacking_characters, function(v) return v == unit.character end) and runs < 1000 do unit = random:table(units); runs = runs + 1 end
unit.enchanted_aspd_m = (self.enchanted == 1 and 1.33) or (self.enchanted == 2 and 1.66) or (self.enchanted == 3 and 1.99)
end
end
Expand Down Expand Up @@ -1730,6 +1717,16 @@ function Player:chain_infuse(duration)
end


function Player:is_attacker(unit)
return table.all(non_speed_buffable, function(v) return v ~= unit.character end)
end


function Player:is_class(unit, class)
return table.any(unit.classes, function(v) return v == class end)
end


function Player:get_all_units()
local followers
local leader = (self.leader and self) or self.parent
Expand Down