TUTORIAL: HOW TO STEAL LIKE A HERO
Posts
Pages:
1
Steal like a Hero
A tutorial on Hero's Realm Steal command by kentona
This tutorial outlines the steps you need to take to implement a Steal command similar to the one found in Hero's Realm. That is, a Steal command that targets a single monster, and has a chance to steal a common item (a chest), where that chance depends on the relative agilities of the Hero and the targetted monster.
Prerequisites
10 Switches
Steal_GO The steal command has been issued
StealTarget1_DONE Monster 1 has been successfully stolen from
StartTarget2_DONE Monster 2 has been successfully stolen from
StartTarget3_DONE Monster 3 has been successfully stolen from
StartTarget4_DONE Monster 4 has been successfully stolen from
StartTarget5_DONE Monster 5 has been successfully stolen from
StartTarget6_DONE Monster 6 has been successfully stolen from
StartTarget7_DONE Monster 7 has been successfully stolen from
StartTarget8_DONE Monster 8 has been successfully stolen from
Chest_OPENED Switch thrown when a chest is opened
4 Variables
RandomNumber Variable used to hold a randomly generated number
AGL_Hero Variable used to hold a hero's agility value
AGL_Monster Variable used to hold a monster's agility value
StealRnd Variable used to hold the Steal random number
1 special item
Chest The item that you steal from monsters
1 Skill
Steal The skill selected when you want to steal
1 Battle Command
Steal The battle command that contains the Steal skill
1 Condition
No Item The condition inflicted upon enemies when Steal is used, in order to avoid the "Missed" message.
1 Attribute
StealAttr The steal attribute - just something to check for your Steal skill
1 Battle Event
Steal The single battle event that holds all your stealing code
2 Common Events
Chest A common event that is run when you open a chest
AfterBattle This common event is to run after battle to turn off the StealTarget_DONE switches
4 Battle Animations
Steal Animation A little anim played when a character attempts to steal
Steal Successful! Anim played when a steal attempt is successful
Couldn't Steal! Anim played when a steal attempt is unsuccessful
Has no item! Anim played when a steal attempt is performed on a monster with no item left
Set Up
This section describes the steps you need to take to set up the Steal command.
The idea is to have a single target Skill under a Steal battle command that steals a common item called Chest, which itself will call a common event that gives you a random item. I used the Chest concept to ease the burden of working with Battle Events - I didn't have to worry about giving each monster it's own item in each and evey one of the battles, which is tedious and time consuming. I'm a copy & paste kinda guy.
1. The Steal skill
Basically, you set up a Battle Command of type Skill Subset, a skill called Steal that targets a single enemy that inflicts a No Item status that uses a StealAttr attribute.
a. Under the Battle Layout tab, set a new Battle Command
b. Add a new command called Steal and make it of the Skill Subset type.
c. Under the Conditions tab, add a new condition called No Item
i) Ends after Battle
ii) Priority 1
iii) Susceptibility at 100% to A B C D and E
iv) Abates after 1 turns
v) 100% chance of recovery
vi) 100% chance of recovery after hit
vii) No Restriction
d. Under the Attributes tab, add a new attribute called StealAttr of type Magic. % are irrelevant.
e. Under the Skill tab, add a new skill called Steal:
i) Type Steal (battle command)
ii) MP = 0
iii) Single Enemy
iv) Effect rating 0
v) 100 % Success rate
vi) Animation Movement: Move to Target (in a crouch stance, if possible)
vii) Animation: Steal Animation - A little anim played when a character attempts to steal
viii) 0 to all the stats, 0 influence
ix) Condition: Inflict No Item
x) Attribute: StealAttr
The condition is inflicted in order to avert the "Missed!" message coming up after the Steal skill is used. Since the skill inflicts "No Item" 100% of the time, with a 100% A B C D E, it always inflicts and "Missed!" doesn't come up. The No Item condition always ends immediately after the next turn, so your players won't notice it.
2. The Chest item
You add a Switch item that turns on a switch that activates a autostart common event which in turn adds a random item to your inventory
a. Under the Item tab, add a new item called Chest
i) Type: Switch
ii) Price: 0 (or whatever you want, if you would like to be able to sell unopened chests)
iii) Number of uses: 1
iv) "Something is hidden inside..."
v) Turn ON switch; Chest_OPENED
vi) Use: Field only.
b. Under the Common Events tab, add a new common event Chest
i) Trigger: Auto-Start
ii) Trigger Switch: Chest_OPENED
Now, the common event should be tailored for your game, but I'll describe what I did for Hero's Realm:
3. The Battle Event
There are actually 8 different types of battle events, but only 1 would be in any particular battle. It depends on how many monsters appear in the battle. I will describe a 1 monster battle, but indicate where you have to duplicate code for multiple monsters.
a. Add a new blank Page to the Battle Events
b. Trigger: Turns Elapsed
c. Now, for each character that can Steal, add this:\
Save the hero's agility (used later) and turn on a switch so we know Steal was enacted. Repeat for each hero.
d. After all that, within the same battle event, add this code:
Now, this might be a little confusing, but let me explain my reasoning.
The formula I am implementing is this:
( * Rnd) / ( + )
or in english:
The Hero's agility, plus or minus 20%, divided by the sum of Hero's Agility and the targetted monster's agilty, all multiplied by 100.
The result of this will (almost) never be greater than 100. The +/- 20% just adds a little randomness to the equation, and the Multiply by 100 thing is used since RM2k3 can't handle fractions. After calculating the formula, I generate a number between 1 and 100 and if the formula's result is greater than the random number, the Steal is successful. But let's go through some examples to test the results.
Let's say the Hero and the Monster have the same agility (ie- 25), and let's ignore the +/- 20%. Plugging in the numbers, we get this:
(25 * 100)/(25 + 25) = 2500/50 = 50
So, this indicates that we have a 50% success rate (when we compare it against a randomly generated number between 1 and 100). Which seems reasonable considering the hero's agility is the same as the monster's.
Now let's say the Hero has 4x the agility than the monster (ie- 100 vs 25). Again, ignoring the 20%...
(100 * 100)/(25 + 100) = 10000/125 = 80
So, this indicates that we have a 80% success rate, which, too, seems reasonable considering the hero's agility vastly outranks the monster's.
Flip the situation and let's say the Hero has 1/4 the agility of the monster (ie- 25 vs 100). Again, ignoring the 20%...
(25 * 100)/(100 + 25) = 2500/125 = 20
So, this indicates that we have a 20% success rate. Neat, eh?
The beauty of this formula is that the actual values of the agilities is completely irrelevant - it's the relative values that matter. Now, working in the +/- 20%, it just affects the final result, really. So, without the +/-, if it is 50%, then after applying the +/- 20%, your result would range between 40% to 60%. For base 80%, it'd range between 64% and 96%. On a side note, only if you have a base greater than 83% and were lucky enough to get a +20% would you have a Steal % > 100%.
NOTE:
For multiple monsters, you would copy the code contained in the "Branch if 1:Greywolf Targetted" block and replace 1:Greywolf with 2:Leafer, and StealTarget1_DONE with StealTarget2_DONE. Rinse and repeat for more monsters. Make sure that the number of blocks match the number of monsters in the battle or you get "Target not defined" crashes. To save work, I make 8 different battles, for monster groups containing 1, 2, 3...8 monsters, and customize my Steal battle event to 1 thru 8 monsters. Then, when I want a new monster group, I copy the appropriate base group, and replace those monsters with the desired ones for my new monster group.
NOTE 2:
For those of you with a lot of time on your hands, you could just ignore the Chest idea and customize FOR EACH BATTLE and FOR EACH MONSTER what item they have for you to steal. I would not recommend this.
4. The Clean Up
After every battle, you need to turn off the StealTarget( 1 thru 8 )_DONE switches. Otherwise, you'd only ever be able to steal once per game, which would suck.
Now, I have a common event that runs after every battle, that handles all of my after battle clean up, which happens to include StealTarget1_DONE: OFF etc.. stuff. How you handle this is up to you.
5. Applying the skill
To use the Steal skill, give a Character (or Class) the Steal battle command and the Steal skill. Voila.
To use it in a battle, choose the Steal command, "cast" the Steal skill and select the monster you wish to steal from. If you are lucky, you'll steal an item. After the battle, you can go to your inventory and open the Chest you stole and get a random item! Yay!
Conclusion
This concludes the tutorial on Steal like a Hero.
For questions or comments, email kentona at kenton007@hotmail.com or PM me in the RMN forums. Thanks for reading!
A tutorial on Hero's Realm Steal command by kentona
This tutorial outlines the steps you need to take to implement a Steal command similar to the one found in Hero's Realm. That is, a Steal command that targets a single monster, and has a chance to steal a common item (a chest), where that chance depends on the relative agilities of the Hero and the targetted monster.
Prerequisites
10 Switches
Steal_GO The steal command has been issued
StealTarget1_DONE Monster 1 has been successfully stolen from
StartTarget2_DONE Monster 2 has been successfully stolen from
StartTarget3_DONE Monster 3 has been successfully stolen from
StartTarget4_DONE Monster 4 has been successfully stolen from
StartTarget5_DONE Monster 5 has been successfully stolen from
StartTarget6_DONE Monster 6 has been successfully stolen from
StartTarget7_DONE Monster 7 has been successfully stolen from
StartTarget8_DONE Monster 8 has been successfully stolen from
Chest_OPENED Switch thrown when a chest is opened
4 Variables
RandomNumber Variable used to hold a randomly generated number
AGL_Hero Variable used to hold a hero's agility value
AGL_Monster Variable used to hold a monster's agility value
StealRnd Variable used to hold the Steal random number
1 special item
Chest The item that you steal from monsters
1 Skill
Steal The skill selected when you want to steal
1 Battle Command
Steal The battle command that contains the Steal skill
1 Condition
No Item The condition inflicted upon enemies when Steal is used, in order to avoid the "Missed" message.
1 Attribute
StealAttr The steal attribute - just something to check for your Steal skill
1 Battle Event
Steal The single battle event that holds all your stealing code
2 Common Events
Chest A common event that is run when you open a chest
AfterBattle This common event is to run after battle to turn off the StealTarget_DONE switches
4 Battle Animations
Steal Animation A little anim played when a character attempts to steal
Steal Successful! Anim played when a steal attempt is successful
Couldn't Steal! Anim played when a steal attempt is unsuccessful
Has no item! Anim played when a steal attempt is performed on a monster with no item left
Set Up
This section describes the steps you need to take to set up the Steal command.
The idea is to have a single target Skill under a Steal battle command that steals a common item called Chest, which itself will call a common event that gives you a random item. I used the Chest concept to ease the burden of working with Battle Events - I didn't have to worry about giving each monster it's own item in each and evey one of the battles, which is tedious and time consuming. I'm a copy & paste kinda guy.
1. The Steal skill
Basically, you set up a Battle Command of type Skill Subset, a skill called Steal that targets a single enemy that inflicts a No Item status that uses a StealAttr attribute.
a. Under the Battle Layout tab, set a new Battle Command
b. Add a new command called Steal and make it of the Skill Subset type.
c. Under the Conditions tab, add a new condition called No Item
i) Ends after Battle
ii) Priority 1
iii) Susceptibility at 100% to A B C D and E
iv) Abates after 1 turns
v) 100% chance of recovery
vi) 100% chance of recovery after hit
vii) No Restriction
d. Under the Attributes tab, add a new attribute called StealAttr of type Magic. % are irrelevant.
e. Under the Skill tab, add a new skill called Steal:
i) Type Steal (battle command)
ii) MP = 0
iii) Single Enemy
iv) Effect rating 0
v) 100 % Success rate
vi) Animation Movement: Move to Target (in a crouch stance, if possible)
vii) Animation: Steal Animation - A little anim played when a character attempts to steal
viii) 0 to all the stats, 0 influence
ix) Condition: Inflict No Item
x) Attribute: StealAttr
The condition is inflicted in order to avert the "Missed!" message coming up after the Steal skill is used. Since the skill inflicts "No Item" 100% of the time, with a 100% A B C D E, it always inflicts and "Missed!" doesn't come up. The No Item condition always ends immediately after the next turn, so your players won't notice it.
2. The Chest item
You add a Switch item that turns on a switch that activates a autostart common event which in turn adds a random item to your inventory
a. Under the Item tab, add a new item called Chest
i) Type: Switch
ii) Price: 0 (or whatever you want, if you would like to be able to sell unopened chests)
iii) Number of uses: 1
iv) "Something is hidden inside..."
v) Turn ON switch; Chest_OPENED
vi) Use: Field only.
b. Under the Common Events tab, add a new common event Chest
i) Trigger: Auto-Start
ii) Trigger Switch: Chest_OPENED
Now, the common event should be tailored for your game, but I'll describe what I did for Hero's Realm:
<> Message: \N[0] opens the chest...
<> Variable: [XXXX: RandomNumber], set Rnd[0-7]
<> Branch if Var [XXXX: RandomNumber] is 0
<> Variable: [XXXX: RandomNumber] Set Holdana Level
<> Variable: [XXXX: RandomNumber] * Party Size
<> Change Money: [XXXX: RandomNumber] Add
<> Message: Found \V[XXXX] gold!
: End
<> Branch if Var [XXXX: RandomNumber] is 1
<> Change Items: [Medicinal Herb] Add
<> Message: Found Medicinal Herb!
: End
[i]....etc etc for each item...[/i]
<> Switch Operation: [Chest_OPENED] OFF
3. The Battle Event
There are actually 8 different types of battle events, but only 1 would be in any particular battle. It depends on how many monsters appear in the battle. I will describe a 1 monster battle, but indicate where you have to duplicate code for multiple monsters.
a. Add a new blank Page to the Battle Events
b. Trigger: Turns Elapsed
c. Now, for each character that can Steal, add this:\
<> Branch if [Bob] [Steal battle command] Used
<> Switch Operations: [Steal_GO] ON
<> Variable Operations: [XXXX: AGL_Hero] Set, [Bob] Agility
: End
d. After all that, within the same battle event, add this code:
<> Branch if Switch [Steal_GO] is ON
<> Switch Operation: [Steal_GO] OFF
<> Comment: Steal was called, check to see if monster 1 was targetted
<> Branch if 1:Greywolf Targetted
<> Comment: Has monster 1 been stolen from already?
<> Branch if [StealTarget1_DONE] is ON
<> Comment: Show the Has no item animation
<> Show Battle Animation: [Has no item!], 1:Greywolf
: Else Handler
<> Comment: This is the actual Steal code
<> Variable Operation: [XXXX: AGL_Monster] Set 1:Greywolf Agility
<> Variable Operation: [XXXX: AGL_Monster] + Var[XXXX: AGL_Hero]'s value
<> Variable Operation: [XXXX: StealRnd] Set, Rnd [80-120]
<> Variable Operation: [XXXX: AGL_Hero] * Var[XXXX: StealRnd]'s value
<> Variable Operation: [XXXX: AGL_Hero] / Var[XXXX: AGL_Monster]'s value
<> Variable Operation: [XXXX: RandomNumber] Set, Rnd[1-100]
<> Branch if [XXXX: RandomNumber] is [XXXX: AGL_Hero] Less/Equal
<> Comment: Steal Attempt was successful!!
<> Change Items: Chest 1 Add
<> Switch Operations: [StealTarget1_DONE] ON
<> Show Battle Animation: Steal Successful!
: Else Handler
<> Show Battle Animation: Couldn't Steal!
: End
: End
: End
<> Comment: If there was more than one monster, the code for that monster would go here.
<> Comment: ...Starting with "Branch if 2:Leafer Targetted ...etc...
: End
Now, this might be a little confusing, but let me explain my reasoning.
The formula I am implementing is this:
( * Rnd) / ( + )
or in english:
The Hero's agility, plus or minus 20%, divided by the sum of Hero's Agility and the targetted monster's agilty, all multiplied by 100.
The result of this will (almost) never be greater than 100. The +/- 20% just adds a little randomness to the equation, and the Multiply by 100 thing is used since RM2k3 can't handle fractions. After calculating the formula, I generate a number between 1 and 100 and if the formula's result is greater than the random number, the Steal is successful. But let's go through some examples to test the results.
Let's say the Hero and the Monster have the same agility (ie- 25), and let's ignore the +/- 20%. Plugging in the numbers, we get this:
(25 * 100)/(25 + 25) = 2500/50 = 50
So, this indicates that we have a 50% success rate (when we compare it against a randomly generated number between 1 and 100). Which seems reasonable considering the hero's agility is the same as the monster's.
Now let's say the Hero has 4x the agility than the monster (ie- 100 vs 25). Again, ignoring the 20%...
(100 * 100)/(25 + 100) = 10000/125 = 80
So, this indicates that we have a 80% success rate, which, too, seems reasonable considering the hero's agility vastly outranks the monster's.
Flip the situation and let's say the Hero has 1/4 the agility of the monster (ie- 25 vs 100). Again, ignoring the 20%...
(25 * 100)/(100 + 25) = 2500/125 = 20
So, this indicates that we have a 20% success rate. Neat, eh?
The beauty of this formula is that the actual values of the agilities is completely irrelevant - it's the relative values that matter. Now, working in the +/- 20%, it just affects the final result, really. So, without the +/-, if it is 50%, then after applying the +/- 20%, your result would range between 40% to 60%. For base 80%, it'd range between 64% and 96%. On a side note, only if you have a base greater than 83% and were lucky enough to get a +20% would you have a Steal % > 100%.
NOTE:
For multiple monsters, you would copy the code contained in the "Branch if 1:Greywolf Targetted" block and replace 1:Greywolf with 2:Leafer, and StealTarget1_DONE with StealTarget2_DONE. Rinse and repeat for more monsters. Make sure that the number of blocks match the number of monsters in the battle or you get "Target not defined" crashes. To save work, I make 8 different battles, for monster groups containing 1, 2, 3...8 monsters, and customize my Steal battle event to 1 thru 8 monsters. Then, when I want a new monster group, I copy the appropriate base group, and replace those monsters with the desired ones for my new monster group.
NOTE 2:
For those of you with a lot of time on your hands, you could just ignore the Chest idea and customize FOR EACH BATTLE and FOR EACH MONSTER what item they have for you to steal. I would not recommend this.
4. The Clean Up
After every battle, you need to turn off the StealTarget( 1 thru 8 )_DONE switches. Otherwise, you'd only ever be able to steal once per game, which would suck.
Now, I have a common event that runs after every battle, that handles all of my after battle clean up, which happens to include StealTarget1_DONE: OFF etc.. stuff. How you handle this is up to you.
5. Applying the skill
To use the Steal skill, give a Character (or Class) the Steal battle command and the Steal skill. Voila.
To use it in a battle, choose the Steal command, "cast" the Steal skill and select the monster you wish to steal from. If you are lucky, you'll steal an item. After the battle, you can go to your inventory and open the Chest you stole and get a random item! Yay!
Conclusion
This concludes the tutorial on Steal like a Hero.
For questions or comments, email kentona at kenton007@hotmail.com or PM me in the RMN forums. Thanks for reading!
Be careful about using conditions (status ailments) for things like this. The way Rm2k3 handles ailments, some will overwrite others. If the "can't steal" ailment can be overwritten with another one, the player can exploit it by stealing, inflicting the ailment, waiting until it wears off, then stealing again.
author=The Real Brickroad link=topic=64.msg839#msg839 date=1182284347Ah, but I can't check if a monster has a condition in a Battle Event. That's why I use the switches.
Be careful about using conditions (status ailments) for things like this. The way Rm2k3 handles ailments, some will overwrite others. If the "can't steal" ailment can be overwritten with another one, the player can exploit it by stealing, inflicting the ailment, waiting until it wears off, then stealing again.
The condition (which I failed to explain) is used so that the Steal skill doesn't result in a "Missed!" message coming up after the skill is used. Since the skill inflicts "No Item" 100% of the time, with a 100% A B C D E, it always inflicts and "Missed!" doesn't come up.
I'll add this to the tutorial.
If you have 4x the agility of an enemy then the steal rate is almost pointless. Over four attempts the chance of nabbing an item at 80% chance is 99.84%, while at 50% its 93.75%. The sheer number of turns you get will make certain that you can steal the item, and if you have 4x the agility then it isn't like any enemy can pose a threat to your party so when the 6.25% chance of failure kicks in there's no point in not making it five turns (~97%) to steal. Nevermind when the enemy has 4x the speed since you are going straight to Murdertown if you get one turn out of the enemy's four.
I think having 1.5x the opponent's speed would be a good value of getting max stealing rates. Its a value possible without being grossly overlevelled the enemy and you don't get successful steals out of sheer number of turns but out of having a good steal modifier. The equation: (60 * UserAGI)/TargetAGI - 10 will have Steal hit 80% steal rate at 1.5x agility (or 20% at 0.5x agility) for example. Using the 25 AGI for both targets if a Thief gets 3 AGI on level up then on your scale his odds go from 50%->52%, while on mine it goes from 50%->57%.
Of course it all isn't peaches. Since the steal % raises much quicker, it also drops quicker. Thieves who don't have a good AGI/EnemyAGI are terrible stealers. Plus it could make agility even more overpowered than it already is since not only can you pump out more turns but you can also steal an item sooner and get back to murdering! (although my thief was never good on the murdering stuff in Hero's Realm, but I also had a Champion as a damage dealer so _maybe_ that's just me :v)
Looking back at this now its probably more effort than its worth (if its worth it at all) and no players would notice but damn I'm not going to erase this post and waste the time I spent writing it by jingo!
I think having 1.5x the opponent's speed would be a good value of getting max stealing rates. Its a value possible without being grossly overlevelled the enemy and you don't get successful steals out of sheer number of turns but out of having a good steal modifier. The equation: (60 * UserAGI)/TargetAGI - 10 will have Steal hit 80% steal rate at 1.5x agility (or 20% at 0.5x agility) for example. Using the 25 AGI for both targets if a Thief gets 3 AGI on level up then on your scale his odds go from 50%->52%, while on mine it goes from 50%->57%.
Of course it all isn't peaches. Since the steal % raises much quicker, it also drops quicker. Thieves who don't have a good AGI/EnemyAGI are terrible stealers. Plus it could make agility even more overpowered than it already is since not only can you pump out more turns but you can also steal an item sooner and get back to murdering! (although my thief was never good on the murdering stuff in Hero's Realm, but I also had a Champion as a damage dealer so _maybe_ that's just me :v)
Looking back at this now its probably more effort than its worth (if its worth it at all) and no players would notice but damn I'm not going to erase this post and waste the time I spent writing it by jingo!
I remember reading this a while back but didn't want to necropost so thanks Klox for doing it for me. Well written article Kentona. :)
I was most excited about the fact that the formula relies on the relative agilities. It's true that the formula could've used some tweaking, but the whole package is pretty sweet.
If I ever make a new project in RM2k3 (or a steal script in VX), I'll take your notes into consideration.
Also, holy necropost Batman!
If I ever make a new project in RM2k3 (or a steal script in VX), I'll take your notes into consideration.
Also, holy necropost Batman!
There is already a fantastic steal script out there, kentona, that you can customize to have set percents of steal rate, use a relative AGI formula, a mixture of both, and increase/decrease steal rates with equipment.
If you're still using rm2k3, though, this is an excellent script! I love opening chests in Hero's Realm. =D
If you're still using rm2k3, though, this is an excellent script! I love opening chests in Hero's Realm. =D
Pages:
1




















