decaying nanoframes give back too much resources?

decaying nanoframes give back too much resources?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

decaying nanoframes give back too much resources?

Post by knorke »

When canceling a construction in my game, the player gets back too much resources. (metal)
Seems like the payback is the whole unitcost even if the unit was just started a few percent.
How to reproduce:
1) download game (its zipped .sdd)
2) use up some resources so the storage is not filled anymore
(eg build 5 of the 1st unit in buildlist -> you now have 500 metal)
3) make an "Erector" construction vehicle -> you now have 0 metal
4) wait and notice how the resources do not fill up because nothing produces metal
5) start making a factory with the con vehicle, with no metal it will stay at 0% build progress
6) cancel the construction with the stop button -> omg 800 instant metal for canceling a construction only costs 200 metal to make.

How to fix that?
It does not seem to happen in other mods.
Also canceling units in the factory does not have that effect.
self-d the unit during construction does not give back metal.

modrules.lua looks like this:

Code: Select all

return {construction = {
    constructionDecay      = true; -- defaults to true
    constructionDecayTime  = 5;  -- defaults to 6.66
    constructionDecaySpeed = 0.01;  -- defaults to 0.03
  },
}
https://github.com/spring/spring/blob/d ... t.cpp#L911
can't notice anything funny here either.


Image

things that do not solve it:
-adding energycost
-putting negative constructionDecaySpeed (makes autocompleting nanoframes with endless growing health. cool.)
Attachments
springtutorialgame_decyaytest.sdd.7z
zipped .sdd!
(299.48 KiB) Downloaded 33 times
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: decaying nanoframes give back too much resources?

Post by Kloot »

You have:

Code: Select all

simplefactory.lua
    buildTime=25
    buildCostMetal=200
modrules.lua
   constructionDecaySpeed=0.01
When a structure starts decaying, it generates

Code: Select all

metalCost * buildDecay
worth of metal every SlowUpdate tick that its health is still > 0, where

Code: Select all

buildDecay = 1.0f / (buildTime * constructionDecaySpeed);
so in your case buildDecay = (1 / (25 * 0.01)) = 4 --> lots of free metal because all nanoframes start life with 0.1 health.

there was also a minor engine bug wrt. metal refunding, details hardly worth mentioning
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: decaying nanoframes give back too much resources?

Post by knorke »

hm ok, but why does it work in say, xta?
Or does it happen there too but is just more hidden because units also cost energy?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: decaying nanoframes give back too much resources?

Post by Kloot »

It does happen elsewhere, but XTA units have much larger buildtimes so 1.0 / (buildTime * constructionDecaySpeed) is << 1 (even with the default constructionDecaySpeed value of 0.03) and you do not get game-breaking amounts of free metal from them.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: decaying nanoframes give back too much resources?

Post by knorke »

i see. just to make sure, with the change in next spring version player will only get as much metal as they have invested into the construction?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: decaying nanoframes give back too much resources?

Post by knorke »

fedjohn wrote:Oh I see,
With the change in next spring version player will only get a metal as they have invested into the construction?
Yes, dear spammer, that is correct.
Just tested in 84.0 and it works. Thanks Kloot!
Post Reply

Return to “Game Development”