-
Notifications
You must be signed in to change notification settings - Fork 308
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
#3959 Refactored stockpile limits into unit custom params #3994
base: master
Are you sure you want to change the base?
#3959 Refactored stockpile limits into unit custom params #3994
Conversation
Refactored these too |
…All-Reason into 3959-refactor-stockpile-limits
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this again, the stockpile limit should be on the weapon def, not the unit def, as that is what it applies to.
That might explain why I've been having trouble testing these changes... |
Caveat beyond-all-reason/spring#1817 (but it's still good to apply it to weapons) |
OK so I moved ['legcom'] = 2, into legcom.lua but none of the weapons are marked as stockpile=true, so which one does it apply to? Is this an error? |
Also similarly armcomlvl2 has ['armcomlvl2'] = 3, but none of its weapons are marked stockpile=true. armcomlvl3 has a backlauncher with stockpile=true but armcomlvl2 does not have this weapon, so remove its stockpile limit? |
…All-Reason into 3959-refactor-stockpile-limits-4
Refactored and commented out the inconsistencies e.g. stockpile limits on non-stockpile weapons... |
@@ -136,6 +136,9 @@ return { | |||
weapontimer = 14, | |||
weapontype = "Cannon", | |||
weaponvelocity = 900, | |||
--customparams = { | |||
-- stockpilelimit = 1, | |||
--}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stockpile limit was defined but this weapon does not have stockpile configuration
@@ -371,6 +371,9 @@ return { | |||
weapontimer = 5, | |||
weapontype = "MissileLauncher", | |||
weaponvelocity = 650, | |||
customparams = { | |||
stockpilelimit = 3, | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused weapon but has stockpile configuration so should have limit, or could be deleted entirely
@@ -363,6 +363,9 @@ return { | |||
weapontimer = 5, | |||
weapontype = "MissileLauncher", | |||
weaponvelocity = 650, | |||
customparams = { | |||
stockpilelimit = 3, | |||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused weapon but has stockpile configuration so should have limit, or could be deleted entirely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be safe to remove the napalmmissile from the legion comms, it probably won't be needed in the future and wouldn't be difficult to remake.
@@ -13,6 +13,8 @@ unitsTable['legdecomlvl3'].decoyfor = "legcomlvl3" | |||
unitsTable['legdecomlvl3'].customparams.decoyfor = "legcomlvl3" | |||
unitsTable['legdecomlvl3'].health = math.ceil(unitsTable['legdecomlvl3'].health*0.5) | |||
unitsTable['legdecomlvl3'].weapondefs.disintegrator.damage.default = 40 | |||
--unitsTable['legdecomlvl3'].weapondefs.napalmmissile.customparams.stockpilelimit = 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused weapon but has stockpile configuration so should have limit, or could be deleted entirely
@@ -103,6 +103,7 @@ return { | |||
normaltex = "unittextures/leg_normal.dds", | |||
paralyzemultiplier = 0.025, | |||
subfolder = "", | |||
--stockpilelimit = 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stockpile limit defined but no stockpile configuration on weapon
@@ -124,6 +124,7 @@ return { | |||
minimum_respawn_stun = 5, | |||
distance_stun_multiplier = 1, | |||
fall_damage_multiplier = 5,--this ensures commander dies when it hits the ground so effigies can trigger respawn. | |||
--stockpilelimit = 3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stockpile limit defined but no stockpile configuration on weapon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SethDGamre Is this supposed to be a stockpiling weapon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Zecrus2 Can you please review the Legion units that ryanbennitt commented on?
@@ -124,6 +124,7 @@ return { | |||
minimum_respawn_stun = 5, | |||
distance_stun_multiplier = 1, | |||
fall_damage_multiplier = 5,--this ensures commander dies when it hits the ground so effigies can trigger respawn. | |||
--stockpilelimit = 3, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SethDGamre Is this supposed to be a stockpiling weapon?
@@ -28,14 +28,19 @@ if gadgetHandler:IsSyncedCode() then | |||
local GiveOrderToUnit = Spring.GiveOrderToUnit | |||
|
|||
local canStockpile = {} | |||
Spring.Log(gadget:GetInfo().name, LOG.WARNING, "Check all stockpiles "..#UnitDefs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a warning, this should be LOG.INFO
, but should really just be removed, it adds noise to the log.
for i = 1, #ud.weapons do | ||
local weaponDef = WeaponDefs[ud.weapons[i].weaponDef] | ||
if weaponDef.stockpile and weaponDef.customParams and weaponDef.customParams.stockpilelimit then | ||
Spring.Log(gadget:GetInfo().name, LOG.INFO, "Stockpile "..ud.name.." - "..weaponDef.name.." limit "..weaponDef.customParams.stockpilelimit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logging is not needed, it adds a lot of noise to the log.
for i = 1, #ud.weapons do | ||
local weaponDef = WeaponDefs[ud.weapons[i].weaponDef] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't weaponDef
already the weapon def?
for i = 1, #ud.weapons do | |
local weaponDef = WeaponDefs[ud.weapons[i].weaponDef] | |
for _, weaponDef in ipairs(ud.weapons) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC it's just the ID.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
weaponDef.weaponDef
is the weapon def ID. From the wiki example, it looks like weapons
table is an array where each value is the weapon def.
https://springrts.com/wiki/Lua_UnitDefs
local weaponDef = WeaponDefs[ud.weapons[i].weaponDef] | ||
if weaponDef.stockpile and weaponDef.customParams and weaponDef.customParams.stockpilelimit then | ||
Spring.Log(gadget:GetInfo().name, LOG.INFO, "Stockpile "..ud.name.." - "..weaponDef.name.." limit "..weaponDef.customParams.stockpilelimit) | ||
isStockpilingUnit[udid] = tonumber(weaponDef.customParams.stockpilelimit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Table name should represent what it contains. Shouldn't the table be indexed by weapon def ID, not unit def ID?
isStockpilingUnit[udid] = tonumber(weaponDef.customParams.stockpilelimit) | |
weaponStockpileLimits[weaponDef.weaponDef] = tonumber(weaponDef.customParams.stockpilelimit) |
I have no idea why the engine calls the weapon def ID weaponDef
instead of weaponDefID
....
Work done
Refactored stockpile limits into each unit's custom params section instead.
Some values remain as cannot find these unit defs here, are they stored elsewhere or are they vestigial and can be removed?
Addresses Issue(s)
Move default stockpile limits to customparams #3959
#3959
Setup
Just a regular game, some units changed require evolved commanders, legion, raptors
Test steps
Construct any unit containing a limited stockpile of e.g. missiles, confirm that it stops building when its stockpile limit is reached