How to Steal like a Hero
Article
A tutorial on Hero's Realm Steal command (RM2k3)
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 steals 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 stolen from enemies
1 Attibute
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
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:
(( +/- 20%) * 100) / ( + )
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 steals 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 stolen from enemies
1 Attibute
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
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 opens the chest...
Variable: , set Rnd
Branch if Var is 0
Variable: Set Holdana Level
Variable: * Party Size
Change Money: Add
Message: Found \V gold!
: End
Branch if Var is 1
Change Items: Add
Message: Found Medicinal Herb!
: End
....etc etc for each item...
Switch Operation: 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 Used
Switch Operations: ON
Variable Operations: Set, Agility
: End
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:
Branch if Switch is ON
Switch Operation: 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 is ON
? ? Comment: Show the Has no item animation
? ? Show Battle Animation: , 1:Greywolf
? : Else Handler
? ? Comment: This is the actual Steal code
? ? Variable Operation: Set 1:Greywolf Agility
? ? Variable Operation: + Var's value
? ? Variable Operation: Set, Rnd
? ? Variable Operation: * Var's value
? ? Variable Operation: / Var's value
? ? Variable Operation: Set, Rnd
? ? Branch if is Less/Equal
? ? Comment: Steal Attempt was successful!!
? ? Change Items: Chest 1 Add
? ? Switch Operations: 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:
(( +/- 20%) * 100) / ( + )
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!
Comments
Roguemetal 07/04/08 11:25 PM
This is all very impressive. Not going to use it myself, but I had to at least try it out.
Feldschlacht IV 05/10/08 02:18 PM
Complex, but more than worth it. Thanks for sharing your trade secrets with us, Kentona!
Add Comment
You must be logged in to comment.
Home
