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

#3959 Refactored stockpile limits into unit custom params #3994

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

ryanbennitt
Copy link

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

@sprunk
Copy link
Collaborator

sprunk commented Dec 4, 2024

@ryanbennitt
Copy link
Author

Refactored these too

Copy link
Member

@WatchTheFort WatchTheFort left a 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.

@ryanbennitt
Copy link
Author

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...

@sprunk
Copy link
Collaborator

sprunk commented Dec 13, 2024

Caveat beyond-all-reason/spring#1817 (but it's still good to apply it to weapons)

@ryanbennitt
Copy link
Author

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?

@ryanbennitt
Copy link
Author

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?

@ryanbennitt
Copy link
Author

Looking at this again, the stockpile limit should be on the weapon def, not the unit def, as that is what it applies to.

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,
--},
Copy link
Author

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,
},
Copy link
Author

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,
},
Copy link
Author

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

Copy link
Collaborator

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
Copy link
Author

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,
Copy link
Author

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,
Copy link
Author

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

Copy link
Member

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?

Copy link
Member

@WatchTheFort WatchTheFort left a 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,
Copy link
Member

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)
Copy link
Member

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)
Copy link
Member

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.

Comment on lines +37 to +38
for i = 1, #ud.weapons do
local weaponDef = WeaponDefs[ud.weapons[i].weaponDef]
Copy link
Member

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?

Suggested change
for i = 1, #ud.weapons do
local weaponDef = WeaponDefs[ud.weapons[i].weaponDef]
for _, weaponDef in ipairs(ud.weapons) do

Copy link
Collaborator

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.

Copy link
Member

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)
Copy link
Member

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?

Suggested change
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....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants