Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,431,591
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-18-24 02:20 AM
Guest: Register | Login

0 users currently in Super Mario RPG Hacking | 1 guest

Main - Super Mario RPG Hacking - Battle Scripting Tutorial New thread | New reply


Waddler-D
Posted on 01-27-09 04:20 AM (rev. 9 of 02-28-09 07:56 PM) Link | Quote | ID: 99559


Paragoomba
Level: 21

Posts: 6/71
EXP: 44618
Next: 5325

Since: 01-24-09

Last post: 4804 days
Last view: 4771 days
Battle Scripting Tutorial

1  An overview


2. The battle scripting commands
A. Basic Commands (Very basic)
a. Do 1 attack [xx]
b. Do 1 of 3 attacks [E0 xx xx xx]
c. Do 1 spell [EF xx]
d. Do 1 of 3 spells [F0 xx xx xx]
e. If only one alive [FC 14 00 00]
f. Wait 1 turn [FD]
g. Wait 1 turn, restart script [FE]
h. Use battle dialogue [E3 xx]
i. Exit battle [EC]
B. Intermediate Commands (Middle-of-the-road)
a. If target alive [FC 10 00 aa]
b. If target dead [FC 10 01 aa]
c. If HP is below [FC 07 xx xx]
d. If target HP is below [FC 06 aa xx]
e. If target affected by [FC 08 aa bb]
f. If target not affected by [FC 09 aa bb]
g. If attack phase = [FC 0A xx 00]
h. Target remove [EA 00 00 aa]
i. Target disable [F2 00 cc]
j. Target enable [F2 01 cc]
k. Target call [EA 01 00 dd]
l. Target set [E2 aa]
m. Target set invincibility [EB 00 aa]
n. Target null invincibility [EB 01 aa]
C. Advanced Commands (The good stuff)
a. Memory Addresses
i. If memory >= [FC 0D ee xx]
ii. If memory < [FC 0C ee xx]
iii. If memory bits set [FC 11 ee bb]
iv. If memory bits clear [FC 12 ee bb]
v. Memory set bits [E7 00 ee bb]
vi. Memory clear bits [E7 01 ee bb]
vii. Memory increment [E6 00 ee]
viii. Memory decrement [E6 01 ee]
ix. Generate random # [ED xx]
x. Memory clear [E8 xx]
b. Attack clauses
i. If attacked [FC 05 00 00]
ii. If attacked with command [FC 01 bb bb]
iii. If attacked with element [FC 04 bb bb]
iv. If attacked with spell [FC 02 xx xx]
v. If attacked with item [FC 03 xx xx]
c. Miscellaneous
i. Use battle event [E5 xx]
ii. Use object sequence [F1 xx]
iii. Set items [F4 00 ff 00]
iv. Command enable [F3 00 bb]
v. Command disable [F3 01 bb]
vi. If in formation [FC 13 xx xx]

3. The battle scripting itself
A. The layout
a. The actions by the enemy [Blah blah FF]
b. the counter actions by the enemy [FF Blah Blah FF]
B. Examples
a. Simplistic script
b. Turn-based action
c. Basic Memory
d. Advanced Memory
e. Object sequence?
f. Saving Space
g. Multiple attacks
h. Target Enabling/Disabling
i. Invincibilty Enabling/Disabling
j. Special cases with certain attacks and actions.
...and more

4. Final Comments
A. Top 5 things to save you trouble
B. Credits
C. Questions and Comments?

5. It's over, go get started!


---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


1. An overview

With the release of the Lazy Shell editor and the introduction of SMRPG hacking to everybody. I felt it would be a good idea to make a tutorial of the Battle Script edtior (in battle scripting for SMRPG in general). To start, I really enjoy how this battle script is composed. I feel with some experimentation, one can gain a grasp of the Battle Script editor and easily make some interesting enemies and bosses. Though, before we go into battle scripting, we must look at what you can do for starters, and that would mean... a look over on the commands.

2. The battle scripting commands

There are quite a few commands available to you as you might have noticed either from the editor itself or this tutorial. For this game, these commands are quite flexible in what you can do (Hell, it's basically one of the reasons why I enjoyed making the battle scripts for the enemies and bosses in my hack). While there are limitations, you can be rather creative and usually find some way to get that idea out of your mind (or from paper) and into SMRPG. I separated the commands into three categories. You got the very simplistic commands or basic comands. Then you have the intermediate commands, something that will be useful for more complex enemies and bosses. Then you got the cream of the crop advanced commands, which will allow for the full creative potential of the way enemies and bosses will try to attack (or help) you out.

A. Basic Commands


Yes, I'm even questioning why I'm doing this because these commands are pretty self-explanatory. However, most of the commands are the bare bones of any battle script. You can't have an enemy without an attack, otherwise, that fight is just gonna be a waste of time. In any case, let's go over the basics.


a. Do 1 attack [xx]

b. Do 1 of 3 attacks [E0 xx xx xx]


Yes, I have to, it's the law. Basically, in the hex editor, you type 2 acceptable values and... you get an attack. The thing is, you have to know what the value will make the enemy do. I will supply a list of attacks, but if you wanna go one step beyond, you can probably figure out how to edit the enemy attack animations and make your own list, but for now, here's the basic list:

00/00 - Attack from Place
01/01 - Standard Normal Attack
02/02 - Big Jump Attack 1
03/03 - Normal Attack 1
04/04 - Ditto of #01
05/05 - Warping Attack
06/06 - Hopping Attack
07/07 - No Anim Attack
08/08 - Burrowing Attack
09/09 - Charging Attack
0A/10 - Flying Attack
0B/11 - Big Jump Attack 2
0C/12 - Teleport Attack
0D/13 - Bouncing Attack
0E/14 - Croco Attack
0F/15 - Normal Attack 2
10/16 - Spikey Needle
11/17 - Thornet (Poison)
12/18 - Huge spike
13/19 - Funguspike (Mushroom)
14/20 - Throws Knife
15/21 - Throws Shuriken
16/22 - Full House
17/23 - Wild Card
18/24 - Royal Flush
19/25 - One Bomb
1A/26 - Spritz Bomb
1B/27 - Kicking Rock Throw Attack
1C/28 - Rock Throw Attack
1D/29 - Blaster Attack
1E/30 - Blazer (Death)
1F/31 - Ball of Light
20/32 - (Mack Jump?) (Final Smithy's Machine Gun)
21/33 - Echofinder (Mute)
22/34 - Scarecrow Bell (Scarecrow)
23/35 - Doom Reverb (Mute)
24/36 - Spore Chimes (Mushroom)
25/37 - Ink Blast
26/38 - Gunk Ball (Mute)
27/39 - Endobubble (Fear)
28/40 - Bubble Attack
29/41 - Sleep-Sauce (Sleep)
2A/42 - Venom Drool (Poison)
2B/43 - Mush Funk (Mushroom)
2C/44 - S'Crow Funk (Scarecrow)
2D/45 - Stench (Poison)
2E/46 - Normal Hammer Throw
2F/47 - Fear Hammer Throw (Fear)
30/48 - Viro Plasm (Poison)
31/49 - Psycho Plasm (Fear)
32/50 - Small Mute Bubble (Mute)
33/51 - Small Sleep Bubble (Sleep)
34/52 - Pollen Nap (Sleep)
35/53 - S'Crow Dust (Scarecrow)
36/54 - Sporocyst (Mushroom)
37/55 - Toxicyst (Poison)
38/56 - Bone Throw w/ Attack Anim
39/57 - Bone Throw w/o Attack Anim
3A/58 - Lulla-bye (Sleep)
3B/59 - Elegy (Mute)
3C/60 - Backfire
3D/61 - Va Va Voom
3E/62 - Fun & Run
3F/63 - Body Slam
40/64 - Howl (Fear)
41/65 - Scream (Fear)
42/66 - Iron Maiden (Fear)
43/67 - Fangs
44/68 - Poison (Poison)
45/69 - Carni-Kiss
46/70 - Claw
47/71 - Grinder
48/72 - Dark Claw (Poison)
49/73 - Scythe (Death)
4A/74 - Sickle (Scarecrow)
4B/75 - Deathsickle (Fear)
4C/76 - Eerie Jig (Scarecrow)
4D/77 - Somnus Waltz (Sleep)
4E/78 - Dahlia Dance (Convert to Mushroom)
4F/79 - Skewer
50/80 - Pierce
51/81 - (Tank's Bullet Bill)
52/82 - Magnum (Final Smithy's)
53/83 - Psyche
54/84 - Migraine
55/85 - Self-Destruct
56/86 - Stronger Self-Destruct
57/87 - Multistrike
58/88 - Flutter Hush
59/89 - Terrapin Attack, No Sound
5A/90 - Mario Attack
5B/91 - Toadstool Heart Attack

5C/92 - Fear Roulette
5D/93 - Smithy Hammer
5E/94 - Attack from Place, walks backwards
5F/95 - (Final Smithy's Hammer)
60/96 - Hammer Time!
61/97 - Valor Up
62/98 - Terrapin Attack
63/99 - Last Shot!, Buggy
64/100 - Bowser Claw
65/101 - Bowser Spike
66/102 - Shut off A Attack (Bowyer's)
67/103 - Shut off Y Attack (Bowyer's)
68/104 - Shut off X Attack (Bowyer's)
69/105 - Arrow Attack (Bowyer's)
6A/106 - G'Night (Bowyer's)
6B/107 - Sling Shy Attack
6C/108 - Bounding Bounces Attack (Think Heavy Troopa)
6D/109 - Chomp
6E/110 - Get Tough!
6F/111 - Mukumuku Attack
70/112 - Missed Me! (Mukumuku's)
71/113 - Mukumuku Chomp Attack
72/114 - Loco Express (Booster's)
73/115 - Trio of Eggs Attack
74/116 - Explosive Egg Attack
75/117 - Bomb Attack
76/118 - Exploded in Place
77/119 - Jinxed (Jinx's)
78/120 - Triple Kick (Jinx's)
79/121 - Quicksilver (Jinx's)
7A/122 - Bombs Away (Jinx's)
7B/123 - Vigor Up
7C/124 - Normal Attack
7D/125 - Silver Bullet (Death) (Jinx's)
7E/126 - Terrapunch
7F/127 - Scarecrow Fangs (Scarecrow)
80/128 - Shaker (Death)

Enemy attack list

While those descriptions are basic, they will give you a good idea of what's what. However, I must mention about some attacks:

- Any attacks that cause the enemy to self-destruct (Anything with "self-destruct" in it, Last Shot!, Psyche!, Migraine!) require some extra work, such as removing the enemy from battle (addressed later).
- Be wary of using attacks that are assigned to a certain enemy on any enemy (Loco Express and Jinx's attacks also count in all of this) other than the one mentioned. You'll run into problems otherwise. Even then if you use it on the correct enemy, there could be some issues.
- Vigor and Valor Up will be used incorrectly (it will target your party members, but it's usually meant to assist your enemies) if all by itself and requires some extra work.
- Refrain from using attacks Fear Roulette (5C/92) and more importantly, Birdo's Explosive egg attack (74/116). Using those without some knowledge of memory addresses can make the attack look odd, or possibly freeze the game.


(For information on these attacks I mentioned, look at the "Special cases with certain attacks and actions" part of the tutorial)

Now, with that out of the way, I grouped "Do 1 of 3 attacks" with "Do 1 attack" for a obvious reason. Though, about Do 1 of 3 attacks, you can make it so that the enemy can possibly take no action instead. In a hex editor, its value is "FB", but in Lazy Shell, it's made simple for you.

Now, with that seemingly simple topic out of the way...


c. Do 1 spell [EF xx]

d. Do 1 of 3 spells [F0 xx xx xx]


Spells in SMRPG are different from normal attacks for a couple reasons. They use up the monster's FP and they are calculated with the enemy's MATK and Magic Power of the spell against the target's MDEF. Thankfully, this section is short and sweet. Just know the list of spells and a few key things, as well as the information from the past subject and you can get this in a snap. The things that you need to know:

- Don't use characters' spells (The ones with @ in front of them) with the enemies, terrible things will happen.
- Big Bang is another case of self-destruct, so remember that extra code at the end when using it.
- The "Escape" spell should be only used on enemies, otherwise... again, terrible things will happen.
- Recover and Mega Recover requires some targeting. If you don't do this, the enemy will become your new friend and will probably heal Mario or his allies.
- All the spells from Drain, to the 5 spells after Big Bang can be used by the enemies. Though, the last 4 can be glitchy graphically (Treasure Head Smithy spells) and the last one... well, that's just an unused spell (along with Knock Out).

Spell list

This is all you need to know about these two commands, "Do 1 of 3 spells" plays out much like "Do 1 of 3 attacks" and with that, you know how to make your enemies attack you and cast spells.


e. If only one alive [FC 14 00 00]


An easy one to explain, this just means, "If I am the only monster alive and/or targetable". If it's true, then this conditional statement will be executed. Otherwise, the game will pass over it.


f. Wait 1 turn [FD]


Basically, your enemy imitates a brick. He waits off a turn. He just is thinking too hard, etc. But this can be fun for enemies making a mindgame out of those waits...


g. Wait 1 turn, restart script [FE]


This is used when you are with a command that starts with an "If...". If you're a coding genius, then it's like "End If" or "Else". Otherwise, you always want to have a block of script after a "If..." finishing up with this. If you do not do this, this can really do a number on that enemy script, and possibly others. Basically, just make sure you use this when you use an "If..."


h. Use battle dialogue [E3 xx]


Simple. Even more so on Lazy Shell, just use this and pick the quote you want. If you're hex editing, just figure out the quotes and write them down somewhere.

i. Exit battle [EC]


The world ends... Oh wait, wrong function. It just ends the battle. That's it.


Intermediate Commands


Intermediate Commands have a little more to them, but they are not too hard to understand compared to Advanced Commands, but they are still rather important to consider and they can truly help a battle be more interesting in the end. For instance, you could have a boss change its attack pattern upon reaching a certain amount of HP (which is simple coding, but if it gets complex, it can be a bit difficult to read. Anyway, on with the commands.


a. If target alive [FC 10 00 aa]

b. If target dead [FC 10 01 aa]


These two commands are conditional ones, as you can tell. However, the first of the two is probably gonna be used more often and usually in conjunction with some other commands. However, it basically checks if the target that you select, which is the "aa" byte of the hex display, is alive or not. Depending on the condition, if it's true, it will of course, run the code after. While Lazy Shell editors will have no problem figuring out what's what with the "aa", hex editing individuals will probably have a rougher time. Here are the valid "aa" values (Lazy Shell users, just take note of the words in parentheses):

00 - Mario
01 - Toadstool
02 - Bowser
03 - Geno
04 - Mallow
05-0F - Unknown, best not to use
10 - Character in Slot 1 (In a party of three, the character on the far right)
11 - Character in Slot 2 (In a party of three, the character in the middle)
12 - Character in Slot 3 (In a party of three, this will be Mario again, as he always occupies the far left)
13 - Monster 1 in a formation
14 - Monster 2 in a formation
15 - Monster 3 in a formation
16 - Monster 4 in a formation
17 - Monster 5 in a formation
18 - Monster 6 in a formation
19 - Monster 7 in a formation
1A - Monster 8 in a formation
1B - The enemy using this battle script, or self.
1C - All monsters in formation, excluding self
1D - Randomly selected monster in formation, excluding self
1E - All monsters in formation, including self
1F - Randomly selected monster in formation, including self
20-22 - Unknown, best not to use
23 - All opponents (Mario's party)
24 - At least one opponent (At least one person of Mario's party; basically if one person is alive or dead, it counts as true depending on the condition)
25 - Random opponent (One person of Mario's party)
26 - Unknown, best not to use
27 - at least one monster

Knowing these values and what they do will make the process a little easier in battle scripting. Mainly because of the reason that all commands with the word "target" in them with abide by this list (except for Target call, a slight difference with that). But these two commands are useful for adding some unique to your enemies, such as allowing an enemy to make sure he has allies to heal with a recovery spell, or if there's a player character that he hates seeing in a party and will respond differently (Remember revisiting Bowser's Castle and noticing enemies running around when Bowser is fighting with you? That's a good example of such usage). This command also will be important for allowing enemies to do multiple attacks correctly.


c. If HP is below [FC 07 xx xx]

d. If target HP is below [FC 06 aa xx]


This is a very useful command for bosses and enemies that do not die immediately upon reaching 0 HP. It is also good for setting new attack phases for bosses and enemies if desired. The first one is primarly for just the enemy itself. Again, Lazy Shell will make the value entry easier, but hex editing... you need to know a little bit about that.

Note: Lazy Shell users can skip this, as well as hexadecimal seasoned individuals
Basically, the first xx value (Which will take anything by the way, since it's basically a numerical value you're entering) is for 0-255 HP, the second xx value, however is needed for 256 HP and above. Some hex editors might detail the information, but the idea is that each number in the second xx value represents 256. So if you have say, "FC 07 00 05" in there, it's 256 * 5 = 1280. The first xx value then becomes an additional value to the second, so if you have "FC 07 14 05", it would be asking "If HP is below 1300" (20 [14 in hex] + 256 * 5 = 1300).

For the second command, you need to know that the first value is for assigning a target, while the second value is the HP. The second value isn't going to be precise as the "If HP is below" command. Lazy Shell users will notice that the value will only go up by 16. So basically, 01 = 16 in hexadecimal for this command in the xx value. This command's usefulness is allowing for a monster to know about the HP of his allies and possibly his enemies. I'd suggest to be creative with it.


e. If target affected by [FC 08 aa bb]

f. If target not affected by [FC 09 aa bb]


These next two commands deals with the matter of status ailments. This will tell the enemy to check and see if an ally monster(s), or his enemy or enemies, are affected with a certain status effect. If so, it will act according to what's after it. These might rarely be used in the course of battle scripting, but I feel that they could lead to some interesting responses. For instance, an enemy could be a wise one and respond to an enemy using Red Essence and use recovery spells, aside from other things.

It could also be used for the opposite, like if an enemy uses an attack that is meant to instill everybody with the Fear status, and ends up missing somebody, they could respond differently. These two conditional commands have the potential to be a lot of fun and really help to make a boss unpredictable or seem like a smartass.

Finally, here are the bit values of those status effects for the hex editor users (the "bb" value, which you'll get more familiar with in the Advanced commands).

01 - Mute
02 - Sleep
04 - Poison
08 - Fear
20 - Mushroom
40 - Scarecrow
80 - Red Essence effect/Invincibility

If you want to mix effects together... Just add their values together, but most hex editor users probably know this already, so I'll leave it at that.

g. If attack phase = [FC 0A xx 00]


A simple command, but it has some ties with advanced commands, which is why it's not completely basic. This command checks and sees how many rounds (basically how many times everyone has attacked at least once, or in this case, how many times the enemy has made a intentional action) and if it is equal to or above that number, it will utilize the pattern under this conditional command. As I said pretty simple, but the interesting thing about this command is that it can be replicated with another, more advanced command.

h. Target remove [EA 00 00 aa]


A command that should probably be in advanced commands, but has uses with basic ones as well. This is the command you want to use with attacks that make an enemy self-destruct. This will officially remove the opponent from the battlefield and will not give you the problem of fighting the ghost of an invisible enemy. Also, because I feel it should be addressed now, since this is an important feature for all enemies that you plan to have defeated by script. The command in hex is "F1 03 EA 00 00 1B", and in Lazy Shell, it's the Use object sequence and the value 03, and then after that, you use Target remove with the value self. This will be explained further in the Advanced Commands, but for now, this is how you get the spoils of a scriptedly-killed enemy.

i. Target disable [F2 00 cc]

j. Target enable [F2 01 cc]


Interesting commands, but both can be very tricky to use. These commands can allow or disallow the player to attack a monster on the field. For the value cc, this is well established by Lazy Shell already. For the hex editors, you'll need to know those values, but they are extremely simple.

00 - self
01 - Monster 1 in formation
02 - Monster 2 in formation
03 - Monster 3 in formation
04 - Monster 4 in formation
05 - Monster 5 in formation
06 - Monster 6 in formation
07 - Monster 7 in formation
08 - Monster 8 in formation

While the values are simple, these commands can be tricky to use. For instance, target disabling is used and there are some loose ends, it could result in your battle ending prematurely as the condition for the battle system is simple: The battle ends if the player has no valid enemy targets or the enemy has no player characters to target. Target enabling can also be a problem in that you'll have to make sure that the enemy will be alive when you enable it as a target. Otherwise, you'll get a silly error message in regards to that mistake, but nothing game-breaking. I will go more in detail with tricks on how to avoid either of these occurrences from happening.

k. Target call [EA 01 00 dd]


If you fought Mack in the original Super Mario RPG, this command certainly is the main principle behind him calling back those Bodyguards. Basically, with this command, you can not only bring back previously defeated enemies, but also bring back enemies that are hidden from the player at the start of the battle. If used correctly, it can be a very interesting command to spruce up your battles. If used incorrectly, you'll get that error message again. A simple way to avoid this, is to check if that enemy target is available. Usually in most cases, if an enemy is alone, this would be a viable time to use the command for logical reasons if desired. Basic rule is, ALWAYS have some sort of conditional command with this one. Otherwise, you're gonna get an error message every turn until the enemy that was called to battle is defeated.

One last thing you should know about this command is that while it does use the same set of values as the targeting, there are different values that it uses for it to work properly. Lazy Shell users should look for values with the word call in parentheses while hex editing users can refer to this list:

28 - Monster 1 in formation called
29 - Monster 2 in formation called
2A - Monster 3 in formation called
2B - Monster 4 in formation called
2C - Monster 5 in formation called
2D - Monster 6 in formation called
2E - Monster 7 in formation called
2F - Monster 8 in formation called

l. Target set [E2 aa]


This is a very fun command, but can be a tricky one as well. However, this allows the enemy to rebel against the general targeting scheme of the game and allows you to set the target for the attack afterwards. This command is, 99% of the time, used with an attack or spell and is crucial for a few attacks and spells. Such spells that come into mind are the "Escape" and "Recover" spells. The idea of this is that this command is always executed before the attack, that way the game will then tell the enemy to attack this target with this attack or spell. Also, in many cases, be wary using "at least one..." or "all..." values for targeting to attacks and spells unless you know what you're doing with it. Otherwise, you could have an enemy move to attack one person and somehow hitting everybody. While it looks neat, most attacks will look a bit goofy that way. Try it out and see if you're that curious.

m. Target set invincibility [EB 00 aa]

n. Target null invincibility [EB 01 aa]


The final two commands in the intermediate category are double-edged in their usefulness. While it's interesting for allowing an enemy to become invinciblity or to remove it (Exor and Bowser for examples), the command has a hidden feature about it that might want you to use something else for bosses. This factor is that when invinciblity is made null for an enemy, any special immunities they might have had, such as not taking 9999 damage from Geno Whirl, is removed. This is VERY bad news for bosses because players can and will exploit things like that. However, normal enemies and bosses that lack the special immunity (or not having to deal with Geno's awesomeness) can set and remove invinciblity with little risk. Though, don't be cruel (unless you really WANT to) and make a boss set with this and not have a way for the player to get out of the battle.

C. Advanced Commands


The big boys of the battle scripting process, these are the commands that can make or break battles. And yes, they can literally break your battles too. This part of the guide will explain these commands in the best detail that I possibly can. I'm sure the information will be more than enough to gain a solid grasp on the battle scripting system of Super Mario RPG.

a. Memory Addresses


Memory addresses are easily one of the best things about this battle scripting system. It definitely allows for the creativity to really get going, along with many other commands (usually the advanced ones). For starters, I feel it's very important to detail the addresses you have available. Some are free to use, some aren't, but all will be really helpful in making some very nice battles. To get started, I will point out how some of the addresses function...

Lazy Shell users, you will probably see a list of addresses in a pull-down box with 7EE000. The numbers you should focus on are the last two, hex editor users have no choice to focus on the last two anyway. Before you begin thinking that each memory address works the same and they're just for storing stuff, you will sadly be mistaken. While some addresses are similar to one another, others have different uses as I stated earlier. Here are the ones that I know of and can tell you about:

00-03 - These memory addresses are for free storage that can used for the battle that the monster is in. These addresses can be used for either bit setting/clearing or as a numerical variable, but this is apparently all the enemies in the group. These memory address can carry the stored information over connected battles (Example: Cloaker & Domino with Earthlink & Mad Adder, Smithy's 2 forms).

04 - This I KNOW for sure what it is used for. This is the scripted enemy's personal memory address, meaning that one single enemy's memory will not conflict with another's. For example, say you want just one enemy to do an attack when a memory address is above a certain number. With the 00-03 variables, if there is more than one enemy in a formation that has this same conditional command that is met in doing a certain attack, you may end up with ALL the enemies doing that special attack. With the 04 memory address, this gives that one enemy a personal variable. So if something occurs that activates a command that would store something to the 04 memory address, only THAT one enemy would be affected by it. If it is not clear to you now, I will certainly address this and the other memory addresses to the best of my knowledge. But the basic idea, 04 is an individual enemy memory address, while 00-03 are enemy group memory addresses.

05 - This memory address is an unique one, as it is used with another command. That command is the "Generate random #" command, basically making the classification of this memory address simple. This stores a random number and can be used for conditional commands. However, I would refrain from using this memory address with conditional commands that check upon bits.

06 - This memory address is one that you've actually already ran into before. While I could let you guess upon this mystery, it's a memory address that stores the number of rounds an enemy has taken an action scripted. So basically, now knowing that this memory address controls the number of turns an enemy has made an action, you are able to manipulate this variable and can do more in terms of creativity.

07 - I have a small understanding of this memory address, but unfortunately not a great one. However, from what I've learned this is used primarily for a few battles. It is an important feature for the Birdo battle, as it is a control and a way to check how many Eggberts are on the screen. THIS is why I advised not using those explosive eggs yet. If things aren't properly set up, such as someone defending an explosive egg attack and not having an Eggbert enemy hidden in the formation, the game will freeze afterwards. From my understanding, this memory address seems to be one used changed by the battle system itself and keeps track of enemies by both variable format (Look at Bundt in an unhacked rom, its used for the candles) and bit format (Again, Eggbert is the best example).

0D - This memory address, from my experience, seems much like the 00-02 and 03 variable. It can be used to store information, and it seems to linger over battle transitions (like Cloaker & Domino again). So for the most part, consider it as an enemy group memory address.

0E - This memory address has only one known use to me so far. Apparently, it seems to manipulate some attack animations that otherwise doesn't correspond with the targeting system. The ultimate example of this is Fear Roulette. You HAVE to use this memory address if you are to have this attack work as it did in the game. Otherwise, you're gonna have this circumstance where the attack will look like it'll hit one character, but another ends up dying from it instead.

0F - This memory address is another strange one, but its use is fairly clear to me. Basically, it's apparently a flag-like memory address for monsters, and it's an individually-based one. I will be sure to give the data in which you will probably use, but the main idea is that the memory address is primarily used for allowing the enemy to do certain attacks in place. For instance, you probably are wondering how King Calamari does not move for Gunk Ball, when other enemies do. This memory address is the reason why he doesn't move, it required the setting of a bit and from that, King Calamari learned that "Hey, I should not move for this attack" and will do as planned. However, while it may work for some attacks, other attacks will have the enemy ignore this memory address and do what it wants anyway. I will give a list of attacks that will work along with this memory address, but otherwise, I suggest experimenting to fully see what works and what does not.

The rest - Though I'm not sure off, I think I've noticed the 08 memory address being used a few times in the original game, but the others aren't put to use or in this case, referred to in the original battle scripts. However, for the curious individuals, I'd suggest to play with them and test them out, see what they do. You might end up finding a gold mine of interesting things from it. Now with memory adddresses explained and out of the way, we'll now get to the commands.

One last important note, when you are messing around with memory addresses, you have to make a mental note in your head that you can only mess with a memory address in one way or another. Like you can't have a memory address be a numerical variable and also have bits set, it'll conflict with one another and can cause a mess of battle bugs.

i. If memory >= [FC 0D ee xx]

ii. If memory < [FC 0C ee xx]


A great conditional command, and with little risk in freezing your game usually (again, depends on which memory address you use]. The memory address you will use most with this is the 05 memory address, as you will have to check the random number and where it was placed. However, this command definitely has other uses and they are best reserved for bosses, due to the many group-based memory addresses and very very few individual ones, but of course, nothing is off-limits in that respect.

While Lazy Shell users will have it easy, again, it's best to also show how it is done in hexadecimal too. The ee stands for the last two digits of the memory address, so if you wanted to check 7EE005's memory address, you just put in "05". The xx can be any number between 0 and 255. However, I highly doubt you'll have to concern yourself with anything going to 255 or even past 100. Then again, it all depends on how it is manipulated.

iii. If memory bits set [FC 11 ee bb]

iv. If memory bits clear [FC 12 ee bb]


Another conditional command, but unfortunately, these aren't as simple as the ones mentioned before. However, they are just as important and useful as "If memory >=" and "If memory <". The way they work is like this, these are in a sense, switches. Like for instance, if a bit is set, we can say that it is "ON", or if a bit is clear, it would be "OFF". Furthermore, memory addresses all have 8 bits to utilize, so you can store an array of information if needed, as long as it's just two values.

Also, a very important thing to note. While you can check that a group of bits are available, if the game finds that one bit out of many is set, the conditional command will find it to be true. So if you have it checking that the first 4 bits are set, and one actually is, they ALL will be considered set. Same case for the second of these two conditonal commands.

Another thing I must stress is that you should refrain from using these conditional commands on the 05 and 06 memory addresses. I'm not sure what it could do, but these are more or less seen as a numerical variable considering that they store a random number and the number of rounds one takes action in respectfully. However, the rest are fair game.

v. Memory set bits [E7 00 ee bb]

vi. Memory clear bits [E7 01 ee bb]


Finally, some commands with action. These are commands that allow you to switch off or on memory address's bits. The "set" is kind of like turning "ON" a bit, while the "clear" is much like turning it "OFF". In most cases, memory addresses will have all the bits primarily turn "OFF" except for ones that are being manipulated by battle events and the battle system.

For Lazy Shell users, this process is again simplified, just pick a memory address and the bits you want to set or clear and voila, it's done. For hex editor users, just know about the ee value being for the memory address you want to set or clear and the bb value being the bits. Since the bb value pertains to bits, just keep this list in mind.

01 - Bit 0
02 - Bit 1
04 - Bit 2
08 - Bit 3
10 - Bit 4
20 - Bit 5
40 - Bit 6
80 - Bit 7

Mixing these bits together in one command is quite possible if you ever need to do so. Again, Lazy Shell users will have it easy here, but hex editor users will just need to add values together once more. Later on, I will explain of the major uses of these commands with certain memory addresses.

vii. Memory increment [E6 00 ee]

viii. Memory decrement [E6 01 ee]


These commands are probably the easiest to understand of all the advanced commands, but they too can be tricky to deal with at times. However, they are definitely the least of your worries. These are intertwined with the "If memory >=" and "If memory <" commands, and are also important to use with the "Generate Random #" command.

These commands work like this, you just have to choose what memory address that the game will add up by one. So if you want to add to a memory address like 04, just choose the memory address in Lazy Shell, or with hex editing, put in "04" in place of ee. The exact same works for the Memory decrement. So as I said, very simple commands, but their usefulness is great. They can also make for cheap switches as well, because with setting and clearing bits, you have to use 4 bytes, but with memory increment, you would only use three. I will go more into detail on this idea later on, but it's best to have it in mind for starters.

ix. Generate random # [ED xx]


Okay, so I lie earlier. THIS command and the next is the easiest to understand. However, it is one of the most common of all the Advanced commands and also very useful. Basically, the reason why it is advanced is because on its own, it is useless, but with the "If memory >=" or "If memory <", it is easily the ONLY way you're gonna have any randomization with your enemies' attacks (besides doing 1 of 3 attacks/spells).

Basically, the idea is that this function will generate a number from 0 up to the value you enter in place of xx. Very simple concept, but it's one of the most useful advanced commands.

x. Memory clear [E8 ee]


This command is straightforward, and can be rather helpful in saving space in the long run. However, the difficulty of it arises on when it is best to use this seemingly simple command. The idea is that the command will clear ALL information of the memory address. Meaning, the numerical variable with be reset to 0 and all the bits of the memory address will be clear and it'll be fresh for usage afterwards. While it's simple with the numerical variable, the bits can provide some trouble. Basically, you have to make sure that other bits should be kept set or not. If there are no other bits you need at one point, feel free to clear the whole thing, but if you NEED one of those bits set for a certain condition, it is important to just clear the bit that you want to clear.


b. Attack Clauses


These conditional commands all have to deal with how an enemy is attacked. The thing that makes them advanced is these will primarly be used in the counterattack section of an enemy's battle script. Using them in the first section is possible, but you might run into problems as the enemy was act as if it is always true after it happens. With this bit of information out of the way, onto the commands!


i. If attacked [FC 05 00 00]


The easiest of the attack clause commands. The basic understanding is that an enemy will react (if placed in the counter attack section) to all of your attacks with the script placed after this. While this might satisfy some, the problem with this is that not only will the enemy react to your attacks, it will also react to any other targeted actions. For instance, if the enemy is set to attack you with every attack, and he decided to heal himself; he would heal himself and because he was targeted by some "attack", he will attack you right after that recovery spell. Basically, this command, while basic for an advanced command, carries a broad range when it comes to being attacked. Use this in enemy groups where you KNOW that the enemies will not target themselves if you don't plan to have those surprises placed upon the player. However, if you do want to do it, it can work out just as well.


ii. If attacked with command [FC 01 bb bb]


This is probably one of the best attack clause conditional commands. It keeps things relatively simple, but it eliminates the broadness that "If attacked" carries. Basically, if the enemy is attacked, it will check to see what command was used by a player character to do damage to it. If the player used the "Attack" command, and the conditional command is checking for this, it'll be true and the enemy will respond accordingly. What's also great about this command is that you can have it check for TWO commands. For instance, you have an enemy counterattack if they are damaged by an "Attack" or a "Special" command. For the sake of hex editor users, I will provide the list this command uses for the bb value.

01 - Attack
02 - Special
04 - Items

Very small list, but I would not suggest trying to add these values in one byte. I haven't tried it, but if you're desperate for space, go for it and see what happens.


iii. If attacked with element [FC 04 bb 00]


Another very fun attack clause command. This one refers to what element (Fire, Ice, Thunder or Jump) you hit the enemy with. For Lazy Shell users, you have checkboxes but again, the hex editors will need another list of values to put in. Here is the list:

10 - Ice
20 - Thunder
40 - Fire
80 - Jump

Of course, adding up all the values will allow you to check for multiple elements in this conditional statement. But it is safe to note that you should probably use this conditional command with a "If attacked with command". Just having this alone can be a bit problematic at times and will cause it to run off on its own. Otherwise, it is a very good command to use.


iv. If attacked with spell [FC 02 xx xx]


An attack command that is rather specific and those who hav played Final Fantasy games can understand what it could be used for. Basically, you can make an enemy react based on the use of a certain spell or two. Like if a character used one of the strongest specials in the game against a certain boss and the boss didn't like that one bit, you can have that boss counter the spell with something of his own. It's rather useful but the thing is, the enemy has to be struck by it, not just observe it being used on your party. Therefore, that's the one minor problem of this attack clause, but it would be a little unfair if some enemy countered you using a healing spell. For those using Lazy Shell, you know the drill. Hex editors should just refer to the spell list and work from there.


v. If attacked with item [FC 03 xx xx]


The final attack clause refers to an item you use on a boss. One main use that was gotten out of this is when someone used Pure Water on a ghost or undead enemy. You remember them dying, right? Well, if you don't, the idea is that the enemy had this in their counterattack system, if you used Pure Water on them, they would make themselves die basically. It can also be used to prevent players from using a certain item on a boss through coercion (such as countering with a nasty attack). For hex editors, follow this link for a list of items that can be put into the xx values. However, the same thing with spells needs to be considered here, the enemy must be targeted by the item for it to work. Using this command for checking if the player uses a Mushroom to heal themselves, not very effective.


c. Miscellaneous


These are the advanced commands that what's left. Of course, a couple of these are either hard to understand or can downright break the battle/freeze the game/etc.
However, they can do well to put the finishing touches in your battles or give them the unique spark that raises them above the rest. Now with that out of the way, onto these last commands.


i. Use battle event [E5 xx]


This command can be the one that will freeze your game or just make a really bad glitch. They are very specific and can be problematic if not considering all the matters on the playing field. However, they are very useful if you mix them into your battles and create interesting situations. Just be wary of events with lines in front of them when selecting one of them and to also refrain from using event 5F. That will just freeze your game right after destroying the bombs, which is rather annoying. Other than that, it's best to test them out and see what works and what doesn't. For hex editors, here's yet another list to utilize:

Battle event list


ii. Use object sequence [F1 xx]


This, hands down, can be the most confusing command for people that are new to battle scripting. Most of the time, it will do nothing for enemies, but other times, it can bring out a lot of animations. However, the most important command that you need to know out of this object sequence is F1 03 and sometimes F1 04, but it's mainly the former. With these two values in place, these basically have the enemy convincingly removed out of battle, and they are almost always used for bosses, usually the ones that fade away and give you a fountain of coins. While this is not the only use for it and there are other features to be gotten from it (such as Boomer's changing of colors), I will go into further detail on that.


iii. Set items [F4 00 ff 00]


This command is advanced because of how rare it is and that it's only best when used with another event. Nine times out of ten, this command probably won't be used. But for a reference, if you recall the 2nd Croco battle in the original, he ends up stealing all your items halfway through and then at the end, returns them to you. It's a pretty simple command otherwise, ff can be 00 for removing your items or it can be 01 for returning them if they are removed. I wouldn't advise doing 01 if you have items to begin with or 00 if you have them removed. Other than that, it's a simple, but rare command.


iv. Command enable [F3 00 bb]

v. Command disable [F3 01 bb]


These two commands are more useful than the last. If you remember the Bowyer battle in the original, these commands are used to disable the Attack, Special, or Item commands. There are only three values for bb mainly for the three commands that you have available for doing attacks, healing, etc. Those values are: 01 for Attack, 02 for Special, and 04 for Items. Hex editor users can add up the values, while Lazy Shell users get the checkboxes. Now it would be most convincing if you used this command with an attack or a spell. One that would let the player know that there is a reason why he can't use specials on the enemy now.


vi. If in formation [FC 13 xx xx]


This final command is the last command I learned about in my days of battle scripting. While it was rarely used in the original (Snifits were the only enemy to use them in fact), it could be a little more useful for future hacks as you can effectively make multiple battle scripts for one enemy with it. You just have to know what formation that enemy is in or will be in, and that can be a little tricky. It's not the only command that refers to something outside of battle scripts however, object sequences are actually another command that has to refer somewhere else for its different effects. In the end, this command can be very useful and could create some rather interesting enemies.

3. The Battle Scripting Itself

Finally, the Battle scripting system and the ideas behind it. It is quite simple, yet can yield to rather interesting results. Combining all the commands up above will create some interesting enemies, but before you get to that, we will have to run over the basic aspects of the two parts of the system.

A. The layout


a. The actions by the enemy [Blah Blah FF]


The battle script runs much like any other computer program, if you have had experience with C++, Java and the likes. Basically, the script runs from top to bottom. With each conditional statement, it will check and see if the conditions are met. If so, it focuses on that section of the script, if not, it will move on to the next condition. If there is no conditional and just actions, the enemy will always do these actions. After reaching the end of the script, it will then move onto the counterattack script.

b. The counter attacks by the enemy [FF Blah Blah FF]


The second part of the battle script is an interesting one, it can sometimes be filled with commands or it can be empty. However, it is an important component to the script and WILL be needed to create some interesting fights. Basically, this dictates how your enemy will react to certain attacks or situations that the enemy is hit with. Bosses that are defeated by a matter of script should always have checks that are performed to indicate if their HP is 0 or not, otherwise, they are going to live forever and that's no fun for the player. Afterwhich, then you can focus on other events.

B. Examples


c. Simplistic script


With this script, it will address something that is fairly basic, but a good starting point on what to do. Here's a picture to provide details on what the simplistic script will accomplish.



First off, you can see that the Crippo's command is quite small. Basically, the simplistic script covers... simple stuff. In this case, simple randomization of attacks. From what the current script translates out, the Crippo 50% of the time will use Blizzard, Blast, or Electroshock; the other 50% he will use physical attacks.

The idea of how to do it is to clear the 7EE005 address, the one that is used for the random number, then generate a random number, say from 00 to 07 will give you eight possible selections. Afterwards, you set a “If memory <” command, in which if it is true, the enemy will use that script and then start over when it is done. Same case if the random number is over what you suggest for the memory. And you can assign whatever happens if the number is less than the one under “If memory <” and what happens if it is over. Very simple but very important to remember.

I will also convert the script to hexadecimal, so that the hex editor users can get an idea of how it works.

E8 05 ED 07 FC 0C 05 04 F0 54 49 4A FE E0 01 43 1C FF FF

With all that out of the way, you can now take in the idea of this simplistic script and how to randomize your enemy's attacks. And also, you can have multiple checks within the random numbers. Feel free to experiment a bit with that.

d. Turn-based action


Turn-based action, from what I'm referring to, is the idea of having enemies go along their attacks by turns. For instance, take the Goomba's battle script.



Notice how the goomba's actions are separated by a “Wait 1 Turn” command, and that each action is different from the last. With this understanding, you can have an enemy follow a set of actions with each turn. However, there is a downside to this. While the enemy will follow it, it may follow it TOO well. Say, for instance, you have an enemy that will use some different attacks at 50% HP, but currently is in a script that following a lineup of “Wait 1 Turn”, it has to reach a “Wait 1 Turn, restart script” to actually get to the 50% HP script. If the boss or enemy were easy enough to beat, it could totally pass over this script and you'd be missing out on a bit there. Otherwise, it is a fairly nice concept to consider for your enemies and bosses.

03 FD E0 03 10 03 FD 03 FF FF

(A small idea, just letting you guys know I'm alive and committed to finishing this tutorial. I apologize for the LONG LONG delay. I thank those for reading the tutorial so far and feel free to leave any comments and questions either in this thread or via PM, e-mail, or possibly IM if I'm around and not terribly busy.)


____________________
AIM: WaddlerD 85

PressAdob
Posted on 01-28-09 07:19 PM Link | Quote | ID: 99671


Red Goomba
Level: 15

Posts: 13/36
EXP: 16264
Next: 120

Since: 10-09-08

Last post: 3820 days
Last view: 3817 days
Nice! Very useful!

Should be a default document with the editor!

Waddler-D
Posted on 01-28-09 07:25 PM Link | Quote | ID: 99672


Paragoomba
Level: 21

Posts: 12/71
EXP: 44618
Next: 5325

Since: 01-24-09

Last post: 4804 days
Last view: 4771 days
I've talked with Omega and he plans to have it as a help document with the next version of the editor, so we'll definitely have it placed in there soon.

____________________
AIM: WaddlerD 85

Mecakoto
Posted on 01-29-09 12:43 AM Link | Quote | ID: 99693


Shyguy
Level: 23

Posts: 9/93
EXP: 66868
Next: 855

Since: 01-28-09
From: A computer.

Last post: 3453 days
Last view: 3348 days
Very good and extremely informative!

Has certainly helped me understand how things work. =D

____________________
http://www.youtube.com/user/mecakoto

PressAdob
Posted on 02-01-09 05:22 PM Link | Quote | ID: 99911


Red Goomba
Level: 15

Posts: 16/36
EXP: 16264
Next: 120

Since: 10-09-08

Last post: 3820 days
Last view: 3817 days
Very nice work on those newer commands!

Waddler-D
Posted on 02-09-09 10:40 PM Link | Quote | ID: 100443


Paragoomba
Level: 21

Posts: 24/71
EXP: 44618
Next: 5325

Since: 01-24-09

Last post: 4804 days
Last view: 4771 days
I apologize for the lack of updates on the tutorial. I've been rather busy with school work and had to cool off after this week. I should have some more stuff up and ready by tonight or at least this week.

____________________
AIM: WaddlerD 85

Mecakoto
Posted on 02-10-09 03:05 AM Link | Quote | ID: 100479


Shyguy
Level: 23

Posts: 30/93
EXP: 66868
Next: 855

Since: 01-28-09
From: A computer.

Last post: 3453 days
Last view: 3348 days
Posted by Waddler-D
I apologize for the lack of updates on the tutorial. I've been rather busy with school work and had to cool off after this week. I should have some more stuff up and ready by tonight or at least this week.


It's all right. We can wait for the awesomeness that this will being. =p

____________________
http://www.youtube.com/user/mecakoto

Mecakoto
Posted on 02-24-09 06:43 AM Link | Quote | ID: 101760


Shyguy
Level: 23

Posts: 47/93
EXP: 66868
Next: 855

Since: 01-28-09
From: A computer.

Last post: 3453 days
Last view: 3348 days
Possibly against my better judgement, as I am not sure if I should do this, I am bumping this thread to keep it off of page 2 for the people who use the default (I think) setting for topics viewable per page per section of these boards.

Also, it can be a reminder to Waddler-D to finish it when he is not to busy. =p (sorry if I bump this pointlessly, either because you are to busy to continue it at this time or of some other circumstance that are unbeknownst to me)

____________________
http://www.youtube.com/user/mecakoto

Waddler-D
Posted on 02-28-09 07:57 PM Link | Quote | ID: 101953


Paragoomba
Level: 21

Posts: 26/71
EXP: 44618
Next: 5325

Since: 01-24-09

Last post: 4804 days
Last view: 4771 days
Alright, just posting to say that the battle scripting tutorial is finally updated and that I'll try to finish it up tonight or tomorrow. No promises, but I WILL finish this eventually.

____________________
AIM: WaddlerD 85

Mecakoto
Posted on 08-15-09 01:38 AM Link | Quote | ID: 113453


Shyguy
Level: 23

Posts: 51/93
EXP: 66868
Next: 855

Since: 01-28-09
From: A computer.

Last post: 3453 days
Last view: 3348 days
I'm bumping this back up because it's just so good and useful. =p

____________________
http://www.youtube.com/user/mecakoto

Main - Super Mario RPG Hacking - Battle Scripting Tutorial New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.026 seconds. (391KB of memory used)
MySQL - queries: 82, rows: 111/112, time: 0.017 seconds.