#### Archived

This topic is now archived and is closed to further replies.

• 0

# Using events to make a skill check and math equation for rate of success

## Question

Hi! I'm working on a game demo or more of a proof of concept to see if it works for a scifi rpg that is similar in a few ways to Fabled Lands for the iPad. If you haven't played it it's basically like a gamebook or visual novel rpg where there's a combo of text describing the scene and location and then uses a menu to tell you what actions you can take in that area. Also the best part is that for each scene or random event you see large and colorful images or paintings of the location or the event. It's a free roaming adventure where you can explore and find adventure do quests and such. I want to do something similar but in a futuristic cyberpunk/space opera setting. Well I've got the basics going. But here's what I'm stuck with so far and I'm hoping for a little advice and input on the best way to handle this.

In Fabled Lands you have several skills that come into play in the game such as Thievery, Scouting, Combat, Charisma, Magic, etc. One thing I want to do is the Skill Test where for example let's say you want to get through a locked door. The choices on the menu allow you to try to pick the lock or try to use a magic power to open it. (I'm doing a scifi so my skills will be different but I haven't settled on them yet so this is just a test case anyway for my demo). Now in Fabled lands if you choose to "Pick the Lock" it would have a screen come up that has a picture of the locked door scene on top and a portrait of your character on bottom. It says "Test your thievery! Difficulty: 9. Your thievery skill: 3. Rate of success: 58%." Something like that. Then the game basically rolls 2d6 (two six sided dice or basically a random number between 2 and 12) and adds that to your thievery skill of 3. If the result is 9 or greater (the difficulty target number) then you succeed and go to the next part in the game. If you fail the roll it goes to the failure part of the event. Does that kind of make sense? Another example of testing your skill might be testing your Scouting skill: 5 against a difficulty of 12 to try and track some villains through a forest, or to find your way through a dark sewer system, etc.

Well the question is what is the best way to do something similar in Ace using events and maybe some ruby code for the math. There's several things I need to figure out. Right now I'm using a text message to tell the player about the difficulty number and what his skill number is and using the \V[x] message code to show the current variable numbers in the message. I'm using game variables to generate the random number between 2-12 to add to the player's skill number (to simulate the die roll). Then I'm using conditional branches and common events to compare the players final roll (the random number plus his skill => to difficulty number) and then it uses a switch "SkillTestSuccess" either On if you succeed or Off if you fail to tell the game in other events whether or not you made the roll successfully or not so that I can actual make things happen based on success or failure.

I figure doing the actual skill checking mechanics in a common event and game variables to tell it what the numbers are will allow me to reuse the same event code for every skill test and easily show the resulting numbers in the games text messages. Well that's all well and good and I can basically do all that with events. But I'm wondering if someone could give me an example of a script snippet to use in the common event to do the skill check as simply as possible.

Also this is the math part I'm having the hardest time with and that's figuring out the percentage of the success rate. So in the above example where it checks my thievery skill of 3 + random number against a difficulty number of 9 the rate of success (according to Fabled Lands) is 58%. I really need a simple script that figures out the rate of success or the percent of the odds of winning the skill check. I'm horrible at math and spent hours last night with google and a scratch pad and couldn't figure out the math formula. I like that it shows the rate of success so that the player has a good idea of her chances of succeeding the test.

The other problem is figuring out how to show the special skill number ratings of player in the Status Screen so she knows what they currently are since they aren't just a renaming of of the players regular attributes and they aren't regular combat skills that the game typically uses. They are mainly used in skill tests to see if a player can successfully do something in the game such as pick a lock, track an enemy, etc. The ratings generally go from 1 to 10 though they can be higher. Some items or equipment might add a bonus to the skill whereas some effects like poison might give a penalty to the skill and lower it.

If there are any scripts that would do something similar or would give me an idea how to do it I'd be really grateful. The success rate percentage calculation is the biggest thing stumping me right now. I'm so bad at math. The current list of skills I'm thinking of using so far are:

Streetwise: The measure of your ability to operate in the shadows and pick locks and get info from the right contacts. Basically I'm using this instead of "Thievery" because I don't want the player to be a thief, though I might change the name later. This also measures your ability to lurk in the shadows and be stealthy.

Piloting: Your skill at operating space craft of all types. Includes your ability to navigate through space, make it safely through asteroid fields, etc.

Scouting: Your ability to track enemies through any type of terrain, scan for things in space (for example scan for pirates and get the jump on them before they get the jump on you), find your way through dense jungles, etc.

Meta-powers: The ability to use super human powers. Basically instead of magic in a sci-fi setting. You can be genetically enhanced or have innate super human powers like the X-Men.

Charisma: How charming you are and your power to influence people. How well you can win over characters and gain their trust. etc.

Prestige: This is your social standing in the game. It's closely tied into your rank and title. A high prestige allows you to gain access to the royal court or to fit in at a diplomatic event.

Diplomacy: Similar to Charisma but used in diplomatic situations where you must be, um, a diplomat. Convince the alien captain to stand down instead of fight and such.

Honor: This rating determines your ability to impress others of your honorable intentions and may be used in skill tests like whether an alien warrior will trust you or whether a military officer will listen to you.

This is just the tentative list for my initial demo but you get the idea. Any help on how to set this up so that I can see the skill values in the status screen would be cool. Especially I’d like to show gauges for each special skill so that it gives visual feedback to the player. Thanks!

## 5 answers to this question

I hope this isn't out of line.. but would you mind paraphrasing all that? I'd be happy to help!

##### Share on other sites

That's a whole lot of words for describing a simple random skill game, such as picking a lock. It will be in your best interest to dumb it down to the bare essentials; that's all the program cares about, and that's all we care about.

That said, you're requesting help on an event system, so post in the event system support, and show some screenshots of your current events instead of writing about it, it will help out tremendously.

##### Share on other sites

Haha, Sorry about that. I was up all night and my mind was focused on the whole project. That and I tend to babble on a lot. I'll post the actual event part in the event system support, though that's not my big difficulty. The biggest problem at the moment is a math equation script. I'll boil it down to that right now. How do I determine the Success Rate percentage of a random skill test?

If my skill score is 3, and I add to that a random number between 1 and 12, and the difficulty number is nine, how do I calculate my odds of success as a percentage? E.g. Success Rate: 58% or something. What's the equation in Ruby script?

Now I know that my roll plus my skill will be anything from 4 to 15. So what are the odds of getting a 9 or greater, as expressed in a fraction first of all. I'm so bad with math. Is it 10/15 odds to get a nine or higher? Is that right? I think to get the success rate once I know the odds is to divide the numerator by the denominator or the top number with the bottom number. That gives me .66. Then multiply that by 100 to get the percentage is 66% success rate. I think.

I'm so bad with math I'm not sure I'm doing it right. Besides I want to boil this down to a single line of ruby script that I can then put in the event. I think if I can even just get the equation for figuring out the success rate, I can figure the rest out from there.

##### Share on other sites

Yes!!! Finally I got the whole Success Rate % issue solved. I ended up having to ask on a really cool programmer question site and they answered and gave me some code to use. So here's a screenshot of the event with the ruby script in it that figures out the success rate of the skill test.

`difficulty_level = \$game_variables[3]skill = \$game_variables[4]random_range = 12delta = difficulty_level - skill# Variable 5 holds the success rate.\$game_variables[5] =[100 - (delta.to_f / random_range * 100),100].min.to_i`

The tricky bit at the end was the part the nice programmer helped me with. This is actually a little longer than it needs to be but I felt it was more readable this way. I'm using game variables for the actual skill and difficulty numbers to make it easy to show them in a text message. But I also declared the three first variables to make the script easier to understand and so it'd be easy to change the actual variable numbers later without getting confused over what variable does what in the actual equation. Basically what this does is take the player's skill level plus a random range of 12, and the difficulty level, and then figures out your chance of success and saves that to game variable 5. Then I can show that later in a text message. Like this:

Anything else on this subject I'll post on the events board since that'll be what I'll be working on next. Btw, I'm using Modern Algebra's (rmrk.net) ATS message script for Ace. That's how I got the fancy message formatting.

##### Share on other sites

Great! Congratulations on figuring it out, but don't double post, thank you.

Since this is solved I guess, I'm closing this.