Modular Battle Routine ~ Demo Released, Currently Needs Ease Of Installation

(Is released with the most recent incarnation of fire shell. Display component a bit hacked together/staved could use some work with alignment. Should be functional, but installing it is a pain.)

PATCHES FOR DEMO

[Easy Mode Patch here][1]
[1]:https://dl.dropboxusercontent.com/u/92273434/Modular_Battle_Demo_Easy_Mode_v1.0.1.ups
[Normal Mode Patch here][2]
[2]:https://dl.dropboxusercontent.com/u/92273434/Modular_Battle_Demo_v1.0.6.ups

Old text:

From what I posted in the communal wishlist:
“”“A complete rewrite/repoint of the main battle engine to stick it somewhere more accessable/expandable. With careful bookkeeping of what routines are where and such. While we’re at it, why not make a table and have them be optional pointers(0x00000000 being no routine) to asm routines to modify battle in some way(such that the nth item calls up the nth pointer and sees if there’s an asm routine to alter the battle data with)? It would seem really cool for people to make their own asm routines for weapons and easily insert and integrate it with the battle system. I mean, of course we’ll have API – like, r0 is attacker hit, r1 is attacker damage, etc etc. ~ @Crazycolorz5"”"

The plan is, instead of each “Check for effect – apply effect” I’m going to have it loop over each bit in certain weapon abilities, and if it is present, call an asm routine pointed to in a table(Or just already in the code). Then, we can make a nightmare module that allows you to rewrite how the built-in effects work, or change them altogether.
Lastly, there’s another table, in case the weapon effects weren’t enough, where you can point to more asm routines(optionally) that can be applied on a PER-WEAPON basis.

Oh this sounds interesting(assuming understand it properly), but for the sake of making sure I actually follow what you’re saying; could you give an example of what you’d be able to do with a weapon?

Uhm, in a table, point to an asm routine that has a nosferatu effect but only gives you half HP. Or a weapon where criticals are x5 instead of x3. (Or whose criticals are insta-kill)

Oh ho, okay so it was similar to what I was thinking about, that’s pretty neat.
Do you think it’d be possible to even have a weapon that calculates it’s criticals differently from the norm(like a weapon that has FE4/5 criticals as opposed to the FE6 and beyond critical)?

Not sure how FE4/5 criticals are calculated.
I’m thinking of hacking two routines at this point, the actual battle calculations(that gets passed whether the attack hit/crited and is responsible for writing the buffer based on that)(I’m working on that now)
And the thing that passes it its calculations(So you can set an alternate hit/crit formula; of course 0x0 in a table will be default)
As well as allowing customization of the Weapon effect byte

… on that topic, does anyone know off the top of their head whether
push {pc} will push the pc BEFORE it’s incremented to the next instruction or AFTER?

FE4/5 criticals are calculated by (Attack x 2) - Enemy Def = Might as opposed (Attack - Enemy Def) x 3 = might for typical criticals.

Yeah, you should be able to change the way damage is calculated. The routine is passed whether a hit will hit or crit though so the other routine I want to change would ideally allow the programmer to change the way those are calculated.

Edit: That sounds fun, acutally.
“Dimensional Sword – 6 Mt, 45 Hit, 1 Wt, 0 Crit
If this sword were to miss, it criticals instead. Can not critical normally.” Or something like that should be possible.

That would be broken, it’s basically a sword that either hits or crits, it cannot miss.

I’m digging the project though. I’m looking forward to what you can do with it! Especially because I want moar cool and unique weaponsss

FE8 support for this one would be pretty difficult. But if its calculations work similarly to FE7’s, then I might be able to just ctrl+f for the code that calculates something. If we’re lucky.

Edit: The simple CTRL+F failed. Maybe I’ll be able to find it with a break-on-write? I’ll try it out after I finish the FE7 version.

1 Like

I’ve made some headway! You can now edit Hit after all game calculations have taken place(i.e. after all w-triangle, tactician, terrain, etc etc). This is due to the way the game calcs hit and avoid. I pass in plenty of variables to work with – attacker’s hit, defender’s avoid, the different(aka default hit), and the pointers to the characters’ battle data, which has more info like weapons and weapon levels and what not. Feasibly, you can make something like a superior sword like in FE13 or something. I leave you here with two proof-of-concept screenies, the source code for my mod, and the source code for the asm routine I used to make Iron Bows have 100% accuracy:

Edit: To-Do, allow the enemy’s weapon affect your hit

Edit2: Changed source; you don’t actually have to skip any bytes. In fact, please don’t.

Edit3: The links are in a different folder and I don’t care to repost them until I finish Modular Hit. They were just showing Rebecca and an enemy archer having 100 hit with iron bows, anyhow.

Changing the plans of this a bit.
From a PM from me to @CT075

  • Allow customizable hit calculation – i.e, final hit is still hit-avoid but you can make the “hit” part of that be 2*str+weapon hit or something
  • Allow customizable crit, like the above,
  • Allow customizable might, like the above
  • If you need more flexibility, allow the hacker to customize based on all of the above and the enemy stats, as written to the battle data; So like, if you want a weapon with 50 hit but ignores the enemy’s avoid, for example.
  • Customizable weapon effects; up to 240-some of them(I’m going to just base this off of your status swords since that handily does some stuff already

So as an example of a weapon I can make
“l33t sword: hit: 20, might: 0, crit: 20, wt: 20
“The amount the unit is weighed down becomes the power of this sword,
hit = 20+5*might,
Criticals are determined solely by luk, not skl/2
Halves enemy avoid and critical dodge
Devil effect”” … or something like that.

This makes mine(any everyone using my extension’s) job easier. The values loaded into the character’s battle data like strength and such are already considered boosted from equipped weapon boost and such. On that topic, it reads the strength at 08028B56 and 58. I’ll add that to documentation…

Things to install into a ROM to use this, still in planning:
-in place might mod
-out of place might mod
-custom might routine pointer table
-in place hit
-out of place hit
-custom hit table
-in place crit
-out of place crit
-custom crit table
-weapon effects mod

-default calculations table
-entry 0: might
-entry 1: hit
-entry 2: crit
-Tentative extra entries:
-e3: avoid
-e4: dodge
-default calculations(from vanilla rom)

-custom routine calculation table

-custom weapon effects table(sans the first few that go toward supporting built-in effects)

I finished the part that allows for custom might calculations

Links obsoleted; look at edit to OP

If you can’t tell what’s going on, I changed the calculation for the might of the Durandal to be Str/2 + Skl/2. (In retrospect, I probably should have made it (Str+Skl)/2 so you don’t get floor’d twice, but, eh, didn’t matter for the demo. I’ll fix it in the source)

I’m removing tactician bonus on hit by default. No one cares about it anyway/it’s not in FE8. I’ll make another patch to remove it from avoid.

Edit: I might be able to rewrite it so that it gets passed as a parameter.

Edit2: I’m so good at this the assembler doesn’t have a thing on me.
I rewrite my power routine to be more succinct and split up the arguments, but I still wrote the original power routine in 4 lines. So I’m just including it; no default calculation table to install!

Edit3: So the power routine is rewritten to fit in place! My version: 0x58 bytes. Original version: 0x58 bytes. Sweet.
Edit: I somehow changed nothing and it expanded to 0x60 bytes O.o

Edit: Did some optimizations and is once again 0x58 bytes

THUMB mode push does not allow pc in its register list

Thanks. I got around it my moving it to a register, and it gives the value the pc would be after the next command, which is quite handy.

Finished the Hit section; it’s SO ugly. But it works. Go look at my screenies! I’m on to crit next. Then one composite-thingy-a-ma-jigger. Then Weapon effects, likely. Then I’ll be done. Maybe. Then I’ll work on modding avoid; or rather; making a template to mod avoid. I won’t make avoid calcs based on like class or something; that’d be god awful. Then again… (So many pointer tables I’d have to keep around though, lol.)

Made the crit part for this; check the OP for details. No screenie this time; but I will take one if requested.

At the sake of sounding like an idiot, how exactly do you apply any of these hacks?
The “Instructions” for them are a bit hard to understand(at least for me, maybe other people aren’t having any issues). Does this need to be used in conjuncture with something else or can it be applied to a base FE7 rom?
The damage routine[(Str+skl)/2] is what I’m trying to implement if that makes the explanation any easier.

Edit: I got help from @Venno regarding this, ignore me