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

Change LowPowerSlowdown to LowPowerModifier #14664

Merged
merged 4 commits into from
Oct 8, 2018

Conversation

MustaphaTR
Copy link
Member

Also removed LowPowerSlowdown:s that were already equal to default value.

Didn't write a upgrade rule, not sure if wanted, as we are gonna rewrite them anyway.

@GraionDilach
Copy link
Contributor

This, along with ProductionQueue->BuildDurationModifier should probably be ripped out to a separate conditional QueueSpeedModifier traits by this point.

@@ -508,7 +508,7 @@ public void Tick(PlayerResources pr)
if (pm.PowerState != PowerState.Normal)
{
if (--Slowdown <= 0)
Slowdown = Queue.Info.LowPowerSlowdown;
Slowdown = Queue.Info.LowPowerModifier;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means that the slowdown is now multiplied by 100. Every tick, the Slowdown will go down by 1, so it will now take 300 ticks to do one build tick on low power. Allowing modifiers that aren't effectively multiple of 100 will require careful work to allow for fractional build ticks. I think it may be possible to do by replacing --Slowdown with Slowdown -= 100, but I'm not 100% sure.

You asked on IRC about the interaction with #14702; I have nothing in principle against allowing a modifier to speed up the build queue (values less than 100). That would require the logic here to allow the build to tick multiple times per game tick.

@MustaphaTR
Copy link
Member Author

Updated, if my calculations are correct, this should do the job. I did a debug message locally with 175 modifier on Armor queue, values looks correct.

openra-2018-01-14t045339580z

@reaperrr
Copy link
Contributor

Didn't write a upgrade rule, not sure if wanted, as we are gonna rewrite them anyway.

There's currently no ETA for this, and the upgrade rule for this PR should be simple (rename and multiply value by 100).

Also needs a rebase.

@MustaphaTR
Copy link
Member Author

Rebased and added a upgrade rule.

abcdefg30
abcdefg30 previously approved these changes Mar 19, 2018
Copy link
Member

@abcdefg30 abcdefg30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me otherwise. Needs a rebase though.

@@ -508,8 +508,8 @@ public void Tick(PlayerResources pr)

if (pm.PowerState != PowerState.Normal)
{
if (--Slowdown <= 0)
Slowdown = Queue.Info.LowPowerSlowdown;
if ((Slowdown -= 100) <= 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks weird, why didn't you use just if (Slowdown - 100 <= 0)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, i haven't answered, because i wasn't sure. But looks like -= is correct. Slowdown needs to tick down, otherwise unit won't be built.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cleaner to split this onto two lines:

Slowdown -= 100;
if (SlowDown < 0)
    ...

@MustaphaTR
Copy link
Member Author

Rebased. Moved the update rule to the new system, but did not test it.

@MustaphaTR
Copy link
Member Author

NTM: Looks like this needs rebase again.

@pchote
Copy link
Member

pchote commented May 20, 2018

Ping @MustaphaTR.

Copy link
Member

@pchote pchote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few thoughts:

@@ -80,8 +80,8 @@ public class ProductionQueueInfo : ITraitInfo

public void RulesetLoaded(Ruleset rules, ActorInfo ai)
{
if (LowPowerSlowdown <= 0)
throw new YamlException("Production queue must have LowPowerSlowdown of at least 1.");
if (LowPowerModifier < 100)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous check was needed because 0 or negative values would break the calculation. IMO there is no reason not to disallow modifiers between 1 and 100 (implying a speed up on low power) here.

@@ -508,8 +508,8 @@ public void Tick(PlayerResources pr)

if (pm.PowerState != PowerState.Normal)
{
if (--Slowdown <= 0)
Slowdown = Queue.Info.LowPowerSlowdown;
if ((Slowdown -= 100) <= 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be cleaner to split this onto two lines:

Slowdown -= 100;
if (SlowDown < 0)
    ...

[Desc("The build time is multiplied with this value on low power.")]
public readonly int LowPowerSlowdown = 3;
[Desc("The build time is multiplied with this percentage on low power.")]
public readonly int LowPowerModifier = 300;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may make sense to take this chance to reset the default to 100? a 3x slowdown is quite arbitrary, and specific to the default C&C mods.

@MustaphaTR MustaphaTR force-pushed the low-power-modifier branch 2 times, most recently from b25c03c to 7697753 Compare September 29, 2018 13:39
@MustaphaTR
Copy link
Member Author

Updated.

@MustaphaTR
Copy link
Member Author

MustaphaTR commented Oct 5, 2018

#15018 is merged. There was no merge conflict, but i still rebased to the lastest bleed. I haven't checked if #15018 added anything i should have edited for this to properly work tho.

@pchote
Copy link
Member

pchote commented Oct 6, 2018

The build palette thinks it takes over an hour to build an APC in low power:

screenshot 2018-10-06 at 17 14 59

@pchote
Copy link
Member

pchote commented Oct 6, 2018

I suspect the issue is that ProductionItem.RemainingTimeActual is missing a division by 100.

@MustaphaTR
Copy link
Member Author

Yeah, that was the issue. Updated.

abcdefg30
abcdefg30 previously approved these changes Oct 7, 2018
Copy link
Member

@abcdefg30 abcdefg30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me now. Needs a rebase however.

Copy link
Member

@pchote pchote left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM and looks fine ingame.

Just one tidy in the update rule, which I will push myself shortly to save you from yet another update cycle.

foreach (var q in actorNode.ChildrenMatching(trait))
queues.Add(q);

foreach (var queue in queues)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can simplify to

foreach (var queue in queueTraits.SelectMany(q => actorNode.ChildrenMatching(q)))

and then the code above removed.

@pchote pchote merged commit 47c4be9 into OpenRA:bleed Oct 8, 2018
@MustaphaTR MustaphaTR deleted the low-power-modifier branch October 9, 2018 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants