Smooth outcomes/incomes in the game

Started by
6 comments, last by Pleistorm 8 years, 3 months ago

Hi!

I have few buildings that give the player constant income like +1 per 50 steps, other units, that give income depending on some situations and there is ofcourse outcomes for upkeep for each unit and building.

The problem is that resourses are "dancing": 10, 15, 20, 25, 5, 8, 2, 0, 3, 10, 15...

So the player may just wait for the moment when he have enough and to order something (a tank for example). Resourses cant be negative. I want to remove this and when a lot of units/buildings are in use income should be just slower.

I put the outcome upkeep because in a moment the player become too rich with many units and resourses are no more important. For example player build a lot of farms and receives a lot of resourses, now he can spam units for a long period. No need to develop upgrades and technologies...

If you have other ideas...

Advertisement

It sounds like all of your resources and units update their income/cost independently?

If you instead synchronize all updates, it should be smooth.

I mean, Instead of income/cost happening at once, maybe you can delay it so it only happens each every X steps, summed together?

The problem might be those units that give income depending on specific situations, if those are needed to make the total income positive, instead of just being a "bonus".

But if those buildings that give continous income is enough to cover the upkeep, it should be ok I think?

Another problem might be how often the upkeep is taken? instead of taking a big upkeep seldom, take a small upkeep often might be better

Hi, interesting idea. I did some experiments:


//Farm
if (10-(instance_number(Buildings)+instance_number(Units)))+1>0
{
    Base.money +=(10-(instance_number(Buildings)+instance_number(Units)))+1
}


About the continous/constant income - yes, they should be enough but that idea is not usefull in the game because resourse gathering units (not buildings) are dependant on the harvest of resourseX. Controlling that resourse is important the game is based on this controlling. But sometimes resourseX is not acceptable (enemy destroyed it for example) that is why I decided to put constant gathering by some buildings, otherwise the player just can sit and watch his defeat.

I'm not sure I entirely understand what the issue is, but I think it would be better to separate the money coming in from the money being spent. (First add all the money coming in, then in a separate and independent equation subtract all the money being spent.)

In that equation, I'm guessing the 10 represents the number of farms? What happens though if the number of units and buildings is greater than the amount you're getting from farms? It would make sense for the player to be losing money in that case, but that case alone doesn't cover it.

Also, is this a real time game or turn based? If it's real time you can definitely smooth out the income and resource spending over time (spend a percentage of the cost every update based on how much time has passed out of an overall build time) rather than spending up front in chunks.

The problem is that current money is jumping from 0 to say 30. So if you want to buy a unit that costs 25 or 30 you can wait a little, the resourses will become 30 at a moment you buy it and it tries to take its money (taxes :)) but they are gone.

Initial resourse=10

1 min.: Income: +5

1 min. 10 secs: Income: +5

1 min. 20 secs: Income: +5

1 min. 29 secs: You buy unit for 25.

If you miss that in that moment at the next moment:

1 min. 30 secs: Outcome -20. You can't buy anything.

It is RTS, yes. +10 is per farm but in a moment when there are few farms and resourse collecting units and all they are upgraded that is a huge income. Even if they are not upgraded money is too much. The idea is to produce, later upgrade and keep all units not constantly producing and loosing. Which means if there are too much resourses you could make super army at any moment, if there are very low and you loose the army it is done. But the player has some heavy and expensive units and the game has not typical upgrades timeline, you can build such units instead of many cheap and I want with them built to have less money. It doesn't happen, I can take more territory and then more income and the AI is screwed.

Incomes are limited by the number of storages, so yes, resourses over the current limit are lost. Also outcomes are from repairing, building and shooting. No money - no shooting.

So you have to cheat actually because your base can't collect these taxes. And because there are irregular income it becomes worse. I havent enough time to test it fully yesterday but I think it works (the method above).

I am not sure I understand your proposal

Command and Conquer and Supreme Commander for example have a "streaming" or "pay as you go" resource system where you can add units to the production queue without currently having the money to complete them, and the game automatically spends the money over time as long as the player has some. It's also the system I'm using in my game, it's more complicated to implement but there are some advantages to using it. The basic idea is that, unlike games like Starcraft or Age of Empires, you don't have to wait until you have the full value of the unit to tell the game to start building it. So in that example, if a unit costs 30 resources you can tell the game to start building it whether you have 0 or 25 or whatever and it will start building over time as long as the player has money to spend, which means you'll never have to wait for the player resources to hit a certain amount before starting production.

This is the basic form of the equation I use in the production building's update loop:


resourcesSpent = (buildingQueue[0].initialCost) * (timeStep/ (buildingQueue[0].buildTime));

if(resourcesSpent > player.totalResources)
{
  if(player.totalResources < 0)
  {
    resourcesSpent = 0;
  }
  else
  {
    resourcesSpent = player.totalResources;
  }
}

buildingQueue[0].remainingCost -= resourcesSpent;
player.totalResources -= resourcesSpent;

Where:

resourcesSpent = amount of money this production building spends on producing stuff this update loop

buildingQueue[] = a list of data on units to build

buildingQueue[0].initialCost = the total cost of the unit (e.g. 30)

timeStep = how long it's been since the last update loop (probably something like 1/60th of a second)

buildingQueue[0].buildTime = how long the unit would take to build if we didn't run out of resources during building (used along with initialCost to determine the rate at which resources are spent)

player.totalResources = how many resources the player currently has

buildingQueue[0].remainingCost = initially the same as to initialCost, when this reaches 0, the unit is completed and removed from the queue

There's more to it, like dealing with integer rounding, evenly distributing resources when there's a low amount and multiple production buildings, but the above code is the main part.

This is very similar to GaldorPunk's response, however it would seem to be that your looking at upkeep costs over time (eg. 5 swordsman costs 20 resources per 30 seconds) with building new units being a full price purchase instantly (eg. 25 resource when click the create new swordsman button) rather than paying over a period of time (eg. 1 resource per second for 25 seconds and then nothing).

It would seem to me that you are adjusting the player's balance for income and expanses at different times. In your example your doing income every 10 secs, but not doing expenses till 30 secs.

I would suggest that both should be done at the same time and the end result applied to the player's balance. This way the player's balance will gradually go up or down rather than jumping.

For example

Initial resourse=10

1 min.: Income: +5, Expense: -5, Change: 0, Resource: 10

1 min. 10 secs: Income: +5, Expense: -5, Change: 0, Resource: 10

1 min. 20 secs: Income: +5, Expense: -5, Change: 0, Resource: 10

1 min. 30 secs: Income: +5, Expense: -5, Change: 0, Resource: 10

The expenses after 30 seconds is still 20, but it is spread across each step the same as income.

The player isn't earning any income so would not be able to purchase the 25 cost unit. The player is left with two choices 1) increase income (such as by using the moving a unit into the right position for situational income) or 2) Decrease expenses (such as by getting rid of a unit)

Continuing from the previous example, assuming player removed unit to reduce expenses

Initial resourse=10

1 min. 40 secs: Income: +5, Expense: -4, Change: +1, Resource: 11

1 min. 50 secs: Income: +5, Expense: -4, Change: +1, Resource: 12

2 min. : Income: +5, Expense: -4, Change: +1, Resource: 13

2 min. 10 secs: Income: +5, Expense: -4, Change: +1, Resource: 14

The player is now earning again so will be able to a some point purchase the 25 cost unit, but doesn't have to time it just before the expenses get removed from their balance.

Thanks to all of you but I will stick to what I did yesterday. I think it works for now and everything is too complicated. Resourse gathering is much different so I put farms ability to add some resourses too. Otherwise it is too much volatile. The idea I chose has nothing to what is available in other games and for years it become the spin of the game. I changed it to make the game simplified (actually the game design and coding) but that changed the gameplay extremely and it is a new game which I dont like.

This topic is closed to new replies.

Advertisement