S
samyak
Guest
How to make a "Balance of Power" variable bar like in Total War Series?
I understand that, but the coding part is problematic, especially when you have to do calculate the sum in every stepI'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.
Unless it's fast paced, updating it only when a unit dies might be a better choice.I understand that, but the coding part is problematic, especially when you have to do calculate the sum in every step
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
yes, your problem so far is too vague to provide code for, but something like:
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)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
@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.Unless it's fast paced, updating it only when a unit dies might be a better choice.
Hope I helped.
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 aliveim 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.
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.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
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.But here the the team1power continued increasing without limits
I tried this-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.