Skip to content

Commit

Permalink
Merge branch 'beyond-all-reason:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSilverHornet authored Mar 28, 2024
2 parents 35c3c7a + 1760d8d commit e3dc770
Show file tree
Hide file tree
Showing 72 changed files with 3,703 additions and 3,623 deletions.
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# March 2024
• [Proposed Units Rework Modoption] Rework to Whistler and Lasher added to modoption, which has the units switch between longer range tracking aa missiles and non-tracking ground missiles. Mauser, Quaker, Stiletto changes removed from modoption.
• [Mauser + Quaker] Rework from proposed_unit_reworks modoption moved to main game with a few additional changes. This rework aims to give these units a more mobile and aggressive role, which reduces the role overlap with the heavier T2 veh artillery options. Their ranges are reduced by 120, speed increased by 20%, acceleration increased 50%, health increased 20%, and accuracy is improved.
• [Stiletto] Rework from proposed_unit_reworks modoption moved to main game. This rework aims to give the stiletto a more specialized role for disabling specific targets while being less efficient as a defensive option against groups. The unit's metal and energy costs are doubled, buildpower cost increased 50%, health increased by 30%, paralyze time increased from 10s->20s, bomb count reduced from 5->3, aoe reduced from 240->200, emp damage per bomb increased 4000->6000
• [Banshee] Reloadtime reduced by 10% (DPS 34->38)
• [Dragon Claw] DPS reduced by 14% (185->159)
• [Razorback] Laser damage vs air reduced from 75% to 50%
• [Demon] Health reduced from 20000->18000
• [Crocodile and Cayman (T1 hovertanks)] Crocodile cost reduced 290m2600E->270m2400E, Cayman cost reduced 320m3300E->300m3100E
• [Salamander] EMP resist reduced from 95%->90%
• [Epoch and Black Hydra] Projectiles for main cannons increased in size, damage, and aoe, with a reduced fire rate
Expand Down
99 changes: 99 additions & 0 deletions common/tablefunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,105 @@ if not table.shuffle then
end
end

if not table.map then
--- Applies a function to all elements of a table and returns a new table with the results.
---@generic K, V, R
---@param tbl table<K, V> The input table.
---@param callback fun(value: V, key: K, tbl: table<K, V>): R The function to apply to each element. It receives three arguments: the element's value, its key, and the original table.
---@return R[] A new table containing the results of applying the callback to each element.
function table.map(tbl, callback)
local result = {}
for k, v in pairs(tbl) do
result[k] = callback(v, k, tbl)
end
return result
end
end

if not table.reduce then
--- Reduces a table to a single value by applying a function to each element in order.
---@generic K, V, R
---@param tbl table<K, V> The input table.
---@param callback fun(acc: R, value: V, key: K, tbl: table<K, V>): R The function to apply to each element. It receives four arguments: the accumulator, the element's value, its key, and the original table.
---@param initial R The initial value of the accumulator. If no value is specified, the first callback will receive nil as the accumulator value.
---@return R The final value of the accumulator after applying the callback to all elements.
function table.reduce(tbl, callback, initial)
local accumulator = initial

for k, v in pairs(tbl) do
accumulator = callback(accumulator, v, k, tbl)
end

return accumulator
end
end

if not table.filterArray then
--- Creates a new (array-style) table containing only the elements that satisfy a given condition.
---@generic V
---@param tbl V[] The input table.
---@param callback fun(value: V, index: number, tbl: V[]): boolean The condition to check for each element. It receives three arguments: the element's value, its key, and the original table. It should return true if the element satisfies the condition, false otherwise.
---@return V[] A new table containing only the elements that satisfy the condition.
function table.filterArray(tbl, callback)
local result = {}
for i, v in ipairs(tbl) do
if callback(v, i, tbl) then
result[#result + 1] = v
end
end
return result
end
end

if not table.filterTable then
--- Creates a new (dictionary-style) table containing only the elements that satisfy a given condition.
---@generic K, V, R
---@param tbl table<K, V> The input table.
---@param callback fun(value: V, key: K, tbl: table<K, V>): boolean The condition to check for each element. It receives three arguments: the element's value, its index, and the original table. It should return true if the element satisfies the condition, false otherwise.
---@return table<K, V> A new table containing only the elements that satisfy the condition.
function table.filterTable(tbl, callback)
local result = {}
for k, v in pairs(tbl) do
if callback(v, k, tbl) then
result[k] = v
end
end
return result
end
end

if not table.all then
--- Checks if all elements of a table satisfy a condition.
---@generic K, V, R
---@param tbl table<K, V> The input table.
---@param callback fun(value: V, key: K, tbl: table<K, V>): boolean The condition to check for each element. It receives three arguments: the element's value, its key, and the original table. It should return true if the element satisfies the condition, false otherwise.
---@return boolean True if all elements satisfy the condition, false otherwise.
function table.all(tbl, callback)
for k, v in pairs(tbl) do
if not callback(v, k, tbl) then
return false
end
end
return true
end
end

if not table.any then
--- Checks if at least one element of a table satisfies a condition.
---@generic K, V, R
---@param tbl table<K, V> The input table.
---@param callback fun(value: V, key: K, tbl: table<K, V>): boolean The condition to check for each element. It receives three arguments: the element's value, its key, and the original table. It should return true if the element satisfies the condition, false otherwise.
---@return boolean True if at least one element satisfies the condition, false otherwise.
function table.any(tbl, callback)
for k, v in pairs(tbl) do
if callback(v, k, tbl) then
return true
end
end
return false
end
end

if not pairsByKeys then
---pairs-like iterator function traversing the table in the order of its keys.
---Natural sort order will be used by default, optionally pass a comparator
Expand Down
Loading

0 comments on commit e3dc770

Please sign in to comment.