Working with percent

I have never really work worked with the percent in *stat_chart. So I have it working just fine but not sure how to keep it from exceeding 100% here is the code I am using, with the four stats involved. Any ideas would be great thanks.

*label player
*comment keep these temps
*temp lead_1 0
*temp lead_2 0
*temp lead_3 0
*temp lead_4 0
*temp lead_5 0

Team views of your leadership

*comment remove theses temps
*temp tm_1_con 100
*temp tm_1_intrest 18
*temp tm_1_anger 30
*temp tm_1_fear 19

*comment keep tm_1
*set lead_1 tm_1_con
*set lead_1 + tm_1_intrest
*set lead_1 - tm_1_anger
*set lead_1 - tm_1_fear

*comment do not want this to exceed 100%
 percent lead_1 ${tm_1_name}

 percent heart Health
 percent willpower Will 
 percent nerve Nerve

I’m not sure but I think the code is this:

*if strength >100
 *set strength 100

Again I’m not sure.

Thank you, lol feel silly was thinking I would need a formula. This is simple and can change around as needed. :slight_smile:

It’s OK. c:

Sometimes I forget to



Might also be worth checking out “fair math” on the wiki or in COG’s guides.

@CJW I did, but was undecided if I really wanted to use it. I am so far into the story code that making a change to fair math might be a whole lot of work.

If I had started with the stats first I would have seen fair math as a good option. :slight_smile:

@lordirishdas FWIW, I also found that the use of fairmath was causing me problems with the way randomtest works for Vendetta. In essence, it was treating some percentile values as potentially zero (even though that situation is impossible in the actual game) so it refused to apply a fairmath change during testing (because it doesn’t work on zero?), which meant that Vendetta could never pass randomtest (ergo: would never be published!). I therefore scrapped all use of fairmath, and it passed randomtest with no trouble. I now do precisely what @Aquos_Boost suggested there, to cap percentile stats.

It’s also worth noting that with the latest version of ChoiceScript it no longer breaks the game if a percentile value exceeds 100 (IIRC it used to error the instant that happened), and indeed, the *stat_chart bars themselves will now happily exceed 100 without problem.

Thanks for the heads up on the fair math. I did see while testing that it did handle over 100 just fine. But to have 153% belief in the players ability to lead was a little unrealistic. ^^

@lordirishdas True enough. In Vendetta I cap all the bars except one, since in that particular case 153% (or whatever) actually serves a useful purpose. :wink:

@Vendetta :wink:

The nice thing is now I can quickly add modifers. Such as Davis is a female hater, so will have a big drop in leadership if you choose to play as female.

@lordirishdas One thing worth considering is using a *gosub / *return after any significant changes, and jump to a section for capping stats (either end of the scale), especially if that stat will soon after be checked for something else. It depends precisely how you use these values in your game, but in some cases it may not be a good idea to rely on the stats screen alone for capping as some players can play through an entire game without bothering to look at their stats at all.

Further to my earlier comment re: problems with fairmath & randomtest, I suppose I should also point out that these are unlikely to affect most games. This is not the first time Vendetta’s behind-the-scenes complexity has proven to be its own worst enemy, and it won’t be the last… Most games probably wouldn’t have the same problems and I’d actually recommend the use of fairmath for anyone starting their first game.

1 Like

I rarely play using stats myself, but relize for some it is all about the stats. In game I am using another method for leadership. Just want to give those that play by stats something simple to use. If I were to use the system in game for stats display I would leave everyone with a headache lol.

Like you, my game is far to complex for its own good at times. So far now will avoid fair math.

I use fairmath in Unnatural to get it to pass randomtest you need to have each stat start at 1 not 0.

@Nocrurnal_Stillness there is the possibility for a number of 0’s due to the nature of the game. I can see where fair math is usefull, just not for this particular game. ^^

I’m resurecting this thread because you gave a link to it in the An Office Adventure thread. I thought I’d point out that switching to fairmath wouldn’t be very hard if you just used “find and replace” in your text editor.

uses his awesome necromantic powers to necro this thread RISE!!!

I have been working with a few codes today in a test game, and I wanted to display the character’s health as a number and as a percentage. Here is how I accomplished this:

*comment Variables below are used for character health and health gain.

*set hp_from_level 10
*comment This variable defines how much HP the character has from their character_level.
*set character_health_total (hp_from_level + (character_level * ability_con_modifier))
*comment This variable defines the character's maximum HP.
*set hp_damage 2
*comment This variable defines how much damage the character has taken.
*set character_health (character_health_total - hp_damage)
*comment This variable defines how many hit points, referred to as HP, the character currently has.
*set character_hp_percent ((character_health / character_health_total) * 100)
1 Like