Stat help?

Allright so iv been gone a well so my codeings a bit rusty but i this isn’t really a codeing problem.

im heaving trouble keeping track of what the max of the stats is. i have no idea how high your magic or intelligence can get. :confused: How do you recommend i go about this?

@appleduck28 not quite sure what you mean. could you perhaps clarify this? to my knowledge, the stat is worked as a percentage and by default is set to a maximum of 100. however, you might be able to edit one of the .js files to change this. i’m not entirely sure on this.

Im not sure about there being a cap on how high the stat can go but i am asking for advice on how to keep track of how high the stats can currently get in as far as i have written for example i know that max strength is around 37.

@appleduck28 when you say how they can get in as far as you’ve written, do you mean you have set a cap yourself within your own game? if so, if you could give a sample of your code (or perhaps pastebin the entire thing), that would be quite helpful.

It’ll go as high as you’ve let it in your code…?

:confused: Im seeing confusion im not worried about how high it can go but what the player can actually get well playing.

At the end have a recap of scores that the player can give you feedback.

i like that idea alot. I mite try something like that

percentage stats are basically integers that vary from a minimum of 1 to a maximum of 99. You are not required to use percentage stats however. The advantage of using them is that you can make the gains bigger for lower stats and smaller for higher stats, ie.

10+10=20
10 %+10= 19 (gain of 9)

80+10= 90
80 %+10 = 82 (gain of 2)

Oh, I should also add that when using percentage stats, reductions are the opposite. The losses are larger for higher stats, and smaller for lower stats. This is because smaller stats have more to gain and less to lose while higher stats have more to lose and less to gain.

@appleduck28 The best solution to your problem I’ve found is to playtest it myself–a lot–and then go through that route in the code itself and tweak things accordingly for better balance. In theory you should know your own game well enough to easily follow the “most rewarding” paths for particular stat gains, without having to do much more than skim through the text & options. The game’s own stats screen should then tell you what you want to know.

Besides, playtesting your own game is also a great way finding most of those niggling little bugs before updating online. :smiley:

@appleduck28 I’m guessing you mean that after coming back to your code after a while away, you are lost as to how high each stat can get but don’t want the player to be able to exceed 100?

If so, there are two ways to correct it.
The quick fix would be to add some checks whenever you increase or decrease the stat. For example:

You eat the magic apple.
*set magic +15
*if magic>99
*set magic 100
It tastes great.

With this, your magic score (or whatever stat) will never exceed the limit you set.

The alternative way to correct it would be to use fairmath and percentages, however this would mean a full overview of all your code so far. To know more about fairmath, have a look here: http://www.choiceofgames.com/make-your-own-games/choicescript-advanced/

Boy this is going to be some task. Thank for your help andymwhy

@appleduck28, if you want to get an idea of the max value your stats can reach in the game, you can hack the randomtest.js file to help you out. Let’s say you want to compute max values for 3 stats: strength, health, and magic. I’ll show you how to hack the randomtest.js file to give you that info. You can modify what I show you below to work for the exact stats you want to examine. Caveat: The CS interpreter and related JS code is complex enough that I can’t be sure that what I’m about to tell you is 100% precise, but I’m confident it will get you in the ballpark. So here goes…

First, make a copy of the randomtest.js file and store it somewhere so you can return to using it if you mess up the code you’re going to edit.

There are three areas of the code in the randomtest.js file where you’ll enter additional JS code. The first area is near the top of the file. Find this line:


var gameName = "mygame";

Just above that line, copy and paste the following code:


// Start code mod
var stat_names = [
   "strength"
  ,"health"
  ,"magic"
];
var num_stats = stat_names.length;
var max_stats = [];
var stat_idx;
for (stat_idx = 0; stat_idx < num_stats; ++stat_idx) {
	max_stats[stat_idx] = 0;
}
// End code mod

(If you want to determine max values for a different set of stats, you would change the strings in the stat_names array; see example of this at the bottom of this post.)

The second area of the code to modify is towards the bottom of the file. Find this line:


sceneCoverage = coverage[this.name];

Just below that line, copy and paste the following code:


// Start code mod
	for (stat_idx = 0; stat_idx < num_stats; ++stat_idx) {
		var stat_idx_name = stat_names[stat_idx];
		var stat_idx_value = this.stats[stat_idx_name];
		if (max_stats[stat_idx] < stat_idx_value) {
			max_stats[stat_idx] = stat_idx_value;
		}
	}
// End code mod

This code is keeping track of the max stat values. Note that this block of code is executed more often than it would actually be executed during a real game, but since you’re looking for a max and not an average, the values should be accurate.

The final area of code to modify is at the very end of the file, where you will enter the code to output the results. Go to the very end of the file and copy and paste the following block of code:


// Start code mod
for (stat_idx = 0; stat_idx < num_stats; ++stat_idx) {
	log("Max " + stat_names[stat_idx] + " = " + max_stats[stat_idx]);
}
// End code mod

After you have finished making those mods, save the randomtest.js file and then run the test. I’d recommend using only one iteration at first, just to get some quick feedback. Then you can increase the number of iterations to see how it effects the results.

The output for the max stats will be at the end of the randomtest-output.txt file.

Whatever the set of stats you want to examine, you only have to initialize the stat_names array to hold the names of the stats you are interested in. For instance, if the names of the stats you are interested in are strength, reflexes, wounds, magic, and dollars, then you’d set up your stat_names array like this instead:


var stat_names = [
   "strength"
  ,"reflexes"
  ,"wounds"
  ,"magic"
  ,"dollars"
];

Just make sure that the names of the stats you enter here match exactly to what you put in the stats array in mygame.js, with the same spelling and case. Also make sure to put quotes around the stat names in this array.

There you have it. Because of the random nature of randomtest.js, it’s always possible that some path through your game will produce higher stats than what’s uncovered by this method, but like I said, this method should get you in the ballpark. Hope it helps.

I’ll make this short and quick.

*if reputation
[b]Reputation[b]
*stat_chart
percent Wishful
percent Infinity
percent Survivors

This is what I have in my choicescript_stats file
My question is. Is it possible to have one percent variable show up and have the others show up later? While all being under the Reputation section? Thanks in advance

TITLE
   *if got_wishful = "true"
      *stat_chart
         percent wishful $!{wishful_name}
   *if got_infinity = "true"
      *stat_chart
         percent infinity $!{infinity_name}
  etc

You’ll need to put the “other stats that show up later” under individual checks.

And then, all you need to do is to “turn on” the required variables so these stats can trigger the check, thus appear later.

The code example is already presented by :point_up_2:t4: @MeltingPenguins, but the gist is

*if chapterone
   *stat_chart
      percent ohwowastatforchapterone
*if chaptertwo
   *stat_chart
      percent omgstatchaptertwo
*if chapterthree
   *stat_chart
      percent statchapterthreesendhelp
1 Like

I’ve seen games like Zombie Exodus: Safe Haven Where in the Stats screen at the bottom there are options to choose. Where clicking one choice would bring you somewhere else in the Stats screen.

I was hoping someone could help me understand how to implement this mechanism into my game. Thanks in advance.

This is on CoG’s web page.


*redirect_scene: This command behaves kinda like *goto_scene, but you can only use it on the stats screen. On the stats screen, the game is in “stats mode,” and so the button at the top of the screen says “Return to the game” instead of “Stats.” Stats mode is like the Matrix; it’s not the real world. In stats mode, *goto_scene stays in stats mode, and it doesn’t affect the main game. If you “Return to the game,” you’ll be right back in “game mode” in the chapter where you left off, like waking from a dream. Use *redirect_scene on the stats screen to *goto_scene in the main game.
1 Like

You basically do what you would in the actual story. Though, it shouldn’t be within a stats_chart. It should be either below or over it. You use a *choice command and then set out the options. Then you create the labels. :smiley: