• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Balance of Power Bar

S

samyak

Guest
How to make a "Balance of Power" variable bar like in Total War Series?
 
D

DekuNut

Guest
I've never played any of the Total War games, but I found this answer to what the Total War 'Balance of Power' bar is:

In the campaign it is supposed to reflect the strength of each army and the odds of winning. It doesn't do a good job of refelcting the counters of each army and other factors though.

In battle it is just a straight up how many men on each side with some factors taken into account for leaders, heroes, monsters. When units shatter, the bar shifts.


What is basically sounds like you need to do is give each unit in that army a value. Add up all the values for the entire army, then compare it to the other army and you should be able to make a bar that visually represents which army has the bigger value.
 
S

samyak

Guest
I've never played any of the Total War games, but I found this answer to what the Total War 'Balance of Power' bar is:

In the campaign it is supposed to reflect the strength of each army and the odds of winning. It doesn't do a good job of refelcting the counters of each army and other factors though.

In battle it is just a straight up how many men on each side with some factors taken into account for leaders, heroes, monsters. When units shatter, the bar shifts.


What is basically sounds like you need to do is give each unit in that army a value. Add up all the values for the entire army, then compare it to the other army and you should be able to make a bar that visually represents which army has the bigger value.
I understand that, but the coding part is problematic, especially when you have to do calculate the sum in every step
 
D

DarthTenebris

Guest
I understand that, but the coding part is problematic, especially when you have to do calculate the sum in every step
Unless it's fast paced, updating it only when a unit dies might be a better choice.

Hope I helped.
 

Relic

Member
yes, your problem so far is too vague to provide code for, but something like:

Code:
Var Player_one_power=0
With team one units{
    Player_one_power+=unit_power
}

//repeat for player two

Total_power=Player_one_power+Player_two_power;

Player_one_power_fraction=Player_one_power/Total_power
From there you can draw a bar, and colour a fraction of its width based on player one power (and player two if you want)
 
S

samyak

Guest
I
yes, your problem so far is too vague to provide code for, but something like:

Code:
Var Player_one_power=0
With team one units{
    Player_one_power+=unit_power
}

//repeat for player two

Total_power=Player_one_power+Player_two_power;

Player_one_power_fraction=Player_one_power/Total_power
From there you can draw a bar, and colour a fraction of its width based on player one power (and player two if you want)
Unless it's fast paced, updating it only when a unit dies might be a better choice.

Hope I helped.
@Fat_Man3468800 I want it to be a bit more complicated. There are many other factors associated in the formula for power of a unit.

(Btw, does somebody know how to delete a message here)
 
Last edited by a moderator:
S

samyak

Guest
@Relic Earlier I did something like this-

var i;

{
for ( i= 0; i< instance_number(team1); i++)
{
w[i[=instance_find(team1,i);
team1power+=w[i[.pow;

}
}

But here the the team1power continued increasing without limits

EDIT: w[i[ is an array. The forum isn't somehow not saving the square brackets
 
Last edited by a moderator:
T

teamrocketboyz

Guest
im a total newbie to anything like this but willing to chuck in my 2 cents.

what i would do if i was to implement such a thing is to set a string called "army_strength" i would then issue a value to each of the army roles, for example.

infantryman = 1
tank = 3
tower = 5

each time an instance dies you could minus the number set for each role

you could then set up a draw event on the draw gui to draw a healthbar and set the healthbar to the "army strength" string, the bar would be full when the army value hits 100 as its supposed to be a health bar and im to new here to figure out how to set it past 100 without the bar looking odd.

this way the "healthbar" would actually be drawing the army strength.

I may get a backlash for this advice but im sorry guys thats all i have.
 
S

samyak

Guest
im a total newbie to anything like this but willing to chuck in my 2 cents.

what i would do if i was to implement such a thing is to set a string called "army_strength" i would then issue a value to each of the army roles, for example.

infantryman = 1
tank = 3
tower = 5

each time an instance dies you could minus the number set for each role

you could then set up a draw event on the draw gui to draw a healthbar and set the healthbar to the "army strength" string, the bar would be full when the army value hits 100 as its supposed to be a health bar and im to new here to figure out how to set it past 100 without the bar looking odd.

this way the "healthbar" would actually be drawing the army strength.

I may get a backlash for this advice but im sorry guys thats all i have.
As I mentioned earlier, this is insufficient, there are other factors in the 'strength' formula too, which may change in-game, even if all units are alive
 

Relic

Member
As I mentioned earlier, this is insufficient, there are other factors in the 'strength' formula too, which may change in-game, even if all units are alive
We can't help you with these "complicated factors" because we don't know what these are. How you calculate a team's total power is entirely up to you.

But here the the team1power continued increasing without limits
If this code ran each step, you would have to also reset team1power to zero each step before running this code. Otherwise it will add to this variable every step, yes.
 
S

samyak

Guest
We can't help you with these "complicated factors" because we don't know what these are. How you calculate a team's total power is entirely up to you.


If this code ran each step, you would have to also reset team1power to zero each step before running this code. Otherwise it will add to this variable every step, yes.
I tried this-

var i;

team1power=0;
for ( i= 0; i< instance_number(team1); i++)
{
w[i[=instance_find(team1,i);
team1power+=w[i[.pow;

}

But the value isn't updating when there is a second instance.
 
Top