ladyabaxa: (Default)
On occasion I have to adjust the table for a battle's terrain type map. This is what tells the game whether tiles in that battle are passable and if they are what type of terrain that tile is, who can pass through it, what movement penalty they incur doing so, and finally what the tile's land effect is. The table's boundaries are set by the map's camera boundary coordinates so any time those are changed the table gets automatically shifted around.

Anyway I was resetting the base X & Y coordinates in the fight with Geshp (because I don't feel like act script hacking when I get there) and I took this screenshot of the Caravan since it was a good opportunity to show off how this works.

desktop screenshot of the Caravan's terrain table editor

The top window open in the Caravan is the battle editor. Terrain editing is a sub-tab. The bottom window is the map definitions file this battle takes place on. Its number is visible in the column on the left (66, Overworld - Grans). I have this open because the Caravan doesn't display battle maps on Grans post-earthquake with the updated tileset. I have to manually compare the two layouts to figure out which tiles need the High Sky setting.

The 8 terrain types are, in order as they appear in the editor: low sky, grass, road, bush (terrain between grass and forest in terms of foliage cover), forest, hills, desert, high sky, and water. The table lists all the different movetypes. The numbers are the land effect per terrain and the movement penalty per terrain is color-coded. These values cannot be edited in the Caravan.

Editing the table is simple. Click the icon above the table you want to change tiles to then click on the tile on the map next to it that you wish to change. That tile will then be set to whatever terrain type you previously selected.
ladyabaxa: (Default)
I've been meaning to put together in in-depth post for Shining Force 2's AI systems. This has been slow going primarily because November each year means I put aside all other work to concentrate on NaNoWriMo. This post will eventually be amended as I learn more about the game's AI but for now here are some notes.

1.) If an enemy unit is placed on an impassable tile they cannot leave said tile despite their movement range flashing on their turn. May be useful for perma-rooting specific units. (exception: when a unit who has a Healing Rain is triggered to use said item)

2.) Agility of 128+ results in roll-over and two turns. The game uses BASE Agility when calculating the agility bonus from Boost causing units with 128+ AGI to gain no speed benefit from the spell because their AGI has already been modified for their in battle speed. (To figure out this value take the base agility and subtract 127.)

This is probably the reason why the AI cannot use Boost in Shining Force 2 and Shining Force CD.

3.) Giving a player character enough of an AGI boost off of equipped items to push them over 128 causes their turn order calculation to bug dropping them out of many successive rotations. The root cause of this bug is not understood but it eventually corrects itself as units on the field die and drop out of the rotation.

4.) When the AI is doing damage checks to see what it should use to attack with, when seeking to destroy a unit, the target's resistances are NOT taken into account. The AI can thus be tricked into using magic on a highly resistant target and effectively wasting turns and MP.

5.) If the battle condition is set kill Monster Unit #0 and said monster is a triggered spawn the battle will end on the first enemy turn because the game can't tell the difference between 'dead' and 'waiting to spawn.'

6.) The AI can only parse one entry in its spell list when searching for a spell of a certain type to use. This means if several direct-damage spells are in its list it only uses whatever is listed first. The same is true for healing spells. Thus the AI cannot benefit from knowing both Heal and Aura.

7.) Related to entry 6 above, the AI will not use the spell effect for an item in its inventory unless the item is equipped and then it is limited to what it could use as spells. (For example, if an enemy had an item with the effect of Boost it can't use that effect because Boost is not something the AI understands how to cast.)

8.) AI 15 seems to trigger automatically once it detects enemies within 1.5x to 2.0x its movement range irrespective of other triggers. For example, Cameela on the Nazca Plain would consistently switch from patrol to seek mode once a Force member got within 2x her movement range despite her trigger region remaining un-breached. Got this sorted out, disregard.

9.) When the AI is trying to heal itself and has multiple levels of a heal spell available to it, the first thing it checks is the amount of health the intended recipient has lost which it then compares to each successive effectiveness value for the spell it intends to cast starting with the highest level. The AI will then try to cast the most powerful spell it can - the one that most closely matches the health loss without going over (provided the healer has enough MP). The range of the spell is only considered after power and then only if the caster is not adjacent to the intended target. This means that if the target has lost enough health that the AI tries to cast a Heal with sufficient power but not enough range healing can be prevented by blocking the healer from moving into range. The AI will never consider that it could cast a weaker heal with longer range. It would only do so if it didn't have enough MP to cast the stronger spell.

10.) As a corollary with point 9 above, the AI only ever considers one target at a time when trying to heal. Monster #0 is the highest priority recipient of healing. If multiple targets are healed in one casting it is a function solely of being close enough to the intended target and not because the AI makes any consideration of heal efficiency.

11.) Healing Rains are the only healing item the AI can use. One will be used only if one of two conditions are met. It will be used if the unit carrying the Rain detects that Monster #0 is at half health or less. It will also be used if the unit carrying it is at half health or less and has completely depleted their MP. Using it moves the user one step to the right as a hardcoded action that bypasses collision checks. The unit may step out of bounds or into another unit. Doing so disables collision with said enemy unit until they move into a valid space.
ladyabaxa: (idiot skeletor)
I figured I could explain a little bit about how things work in Shining Force 2. This is all stuff I've figured out through trial and error playing the game over and over again so asking me nitty gritty programming questions is useless because I can't answer them.

Ahem, moving right along.

the Caravan screenshot 1

This is what the battle window looks like in the Caravan (well, there's technically more but it wasn't important for this post and got cropped). I have Zeon himself selected and he shows up in the editor as Rohde's sprite facing up. This isn't important because we know what his unit number is: 98. The Item window is a feature that hasn't been implemented yet and shows up greyed out for all units. X and Y are the unit's coordinates. It can be hacked in using a hex editor by someone knowledgeable in ASM but requires supporting event flags to work. The item is byte 6 in the character's data table with byte 5 being the item's state.

Order Sets determine special AI functions. Use special move order tells the unit to follow a specific unit on the map. If set a Force Member the unit will attempt to seek and attack that person. In the default game this is always set to Bowie probably because he is the only player character whose death ends the battle. Move to Point commands the unit to move to a point specified under AI Zones. Follow Ally tells the unit to follow the numbered ally until said ally dies or enemies come into range.

The AI number specifies which general routine will be run when that unit's turn comes up. There are 16 in all, listed as 0-15, but some are empty routines that make a unit stand around (not that having at least one of those is a bad thing).

Zeon Guards and Prism Flowers have a root AI exception and ignore whatever is set here for their own subroutines. Neither of those can be added to a map unless you are able to ASM hack the battle AI to add the supporting scripts they need. Otherwise the game might freeze once the flower's turn comes up. Don't try this unless you've got a good idea of what you're doing.

That said, the AI number can, in a general sense, be equated to an increasing aggressiveness scale. I'll go into much greater depth about AI in a later post. It doesn't have the patrol routines from Shining Force 1, unfortunately, so that isn't an option.

Region-triggered Spawn is precisely what it sounds like. Regions are sections of the map defined under AI Zones. Checking this box produces two results based on what other options are enabled. 1.) Ticking the box and selecting a region causes the unit to spawn once a player character enters the linked zone. 2.) Ticking just the box makes the game wait until a secondary trigger fires to spawn the monster. Right now there is only one secondary trigger and that is opening a treasure chest in battle - only treasure chests, other tiles don't work! This is what makes monsters-in-a-box work. Please note that if you want the monster to drop whatever is in the chest when slain that item has to be added as the unit's extra item.

Continually Respawn should be pretty obvious. This means the unit respawns on its starting coordinates when slain as long as no other unit occupies that spot. ??? cuts the experience awards given to player characters who attack that monster in half. This means a tough, badass monster can be placed earlier then it would normally while restraining how much experience it gives out.

the Caravan screenshot 2

Okay enough text. It's time to actually show some of this stuff off! I've got the AI Zones tab open now to show off regions and points. The region is the green box. The point is the little blue box. I've mentioned before how trigger regions control triggered spawns but they also tell specific units whether to be active or not. There are some variables dependent on specific AI settings but the basic gist is untriggered units patrol around their starting point (always moving 1 tile vertical and 1 tile horizontal) doing a whole lot of nothing until a force member enters the trigger region and activates them (activated units remain active for the rest of the battle). Untriggered units can and will heal allies.

A unit can have 2 trigger regions associated with it. Entering either works.

the Caravan screenshot 3

In my viddler WIP videos I had one curious Pyrohydra who sat around doing nothing. I've got that particular unit selected in the above screenshot to show how that is done. This devil's only job is to stop intrepid player characters from running up the walkway to Zeon and trigger the reserve units too soon. It doesn't move because the trigger region its attached to is behind it and there isn't enough space to allow it to move the 2 steps it would each turn. This is a less-then-optimal solution until I can edit the tilemap and remove that walkway.

the Caravan screenshot 4

Points are used to tether specific units to one part of the map. This example is a shugenja who has been programmed to move north and remain close to the point in blue. There will be more on using points in the AI post.

the Caravan screenshot 5

This is to show a point that has been moved. Just adjust the X and Y coordinates as needed. Points exist in all battles that have a pre-battle cutscene but the cutscenes don't require (or just doesn't read) the battle script points because I've edited almost all of them and they've had no effect on the cutscenes themselves.

That's all for this installment. This has been an introduction to editing battles in the Caravan. Later!