Using events to make a skill check and math equation for rate of success
Posted 06 December 2012 - 04:41 PM
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!
Posted 06 December 2012 - 07:29 PM
Posted 06 December 2012 - 08:41 PM
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.
Coming very soon ...
Posted 06 December 2012 - 10:30 PM
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.
Posted 07 December 2012 - 04:07 AM
The script I ended up using in the event was this:
difficulty_level = $game_variables skill = $game_variables random_range = 12 delta = difficulty_level - skill # Variable 5 holds the success rate. $game_variables = [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.
Posted 07 December 2012 - 06:23 AM
Since this is solved I guess, I'm closing this.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.
Coming very soon ...