-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #132 from gamrguy/master
Fix apexRageBonus, utility changes
- Loading branch information
Showing
4 changed files
with
79 additions
and
15 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
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require("/scripts/vec2.lua") | ||
require("/scripts/util.lua") | ||
|
||
--[[ | ||
This script gives a scaling status effect based on health lost. | ||
The effects increase starting from healthRange[1] and reach their maximum at healthRange[2]. | ||
Arguments: | ||
"args" : { | ||
"healthRange" : [0.8, 0.1] -- % of health when this effect starts and stops increasing | ||
"stats" : [ -- Which stats this applies, and their maximum values | ||
{ "stat" : "maxEnergy", "effectiveMultiplier" : 0.3 }, | ||
{ "stat" : "powerMultiplier", "effectiveMultiplier" : 1.3 }, | ||
... | ||
] | ||
} | ||
]] | ||
|
||
function FRHelper:call(args, ...) | ||
if not args or not args.healthRange then return end | ||
|
||
local healthRange = args.healthRange | ||
local health = status.resourcePercentage("health") | ||
if health > healthRange[1] then return end | ||
|
||
-- Scale the current health % to the area of interest | ||
local healthRelative = math.max(0, (health - healthRange[2]) / (healthRange[1] - healthRange[2])) | ||
local scale = 1 - healthRelative | ||
|
||
local scaleMultiplier = function (mult, scaleThing) | ||
if mult >= 1 then | ||
return 1 + (mult - 1) * scaleThing | ||
elseif mult < 1 then | ||
return mult + (1 - mult) * healthRelative | ||
end | ||
end | ||
|
||
local stats = util.map(args.stats, | ||
function (v) | ||
return { | ||
stat = v.stat, | ||
amount = v.amount and v.amount * scale, | ||
baseMultiplier = v.baseMultiplier and scaleMultiplier(v.baseMultiplier, scale), | ||
effectiveMultiplier = v.effectiveMultiplier and scaleMultiplier(v.effectiveMultiplier, scale) | ||
} | ||
end | ||
) | ||
|
||
self:applyPersistent(stats, "FR_speciesRageBonus") | ||
end |
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
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