Zeta's ASM/C Spellbook

you can just set the byte in chapter data for # of enemies left to play victory theme to 0 and it’ll never play can’t you

Probably, but I didn’t actually remember there was a byte for that that would mean I’d have to go change that for every chapter, rather than just changing one opcode and forgetting about it.

Ever wanted a little more 776 in your 8? Or just liked the idea of leadership stars?

This hack brings the ‘leadership stars’ mechanic to FE8. Units with leadership stars grant a (configurable) Hit / Avoid bonus to all units of the same allegiance. It requires the Skill System and Modular Stat Screen. Installation is slightly complicated:

  1. #include the Installer.event - note that it has to be included before Master Skill Installer.event! Edit the LeadershipTable, and other options as desired.
  2. Go into Skill System\Battle Calculations.event, and add

LeadershipHook

after one of the POINs. You should end up with a line that looks similar to this:

POIN LeadershipHook ElbowRoom NaturalCover Gamble FieryBlood LifeAndDeath WindDisciple Perfectionist Puissance Hawkeye LightWeight Trample Opportunist

  1. Take the contents of “put these in your text buildfile.txt” and put it in the top of your text buildfile. If you’ve changed the hit/avoid bonus, you probably want to update the text to match.
  2. Copy the contents of the ‘mss stuff’ folder into your MSS folder (it should overwrite ModularStatScreen.event, and the mss_page1_skill.dmp/s files)
  3. (Optional) If you’re using icon 0xCA already (it’s an unused icon in vanilla), it’s possible to change what icon is used for the star. You’ll have to change it in Installer.event, and in mss_page1_skills.s, StatusScreenEnemy.s and StatusScreenPlayer.s (don’t forget to run Assemble ARM on again after changing the icon number)

By default this replaces the affinity/element icon on page 1. If you don’t like that, it’s not too hard to whip up your own MSS settings. It also replaces the textID for one of the debug menu options (the third, which doesn’t even work anyway).

This changes the unit count on the ‘Status’ screen to instead display the total amount of leadership stars for ally and enemy units, so players can have a quick way to view total leadership.

As usual, this hack (well, LeadershipFunctions.c at least) was written in Stan’s FE-CLIB and converted to EA format by lyn.

14 Likes

And version 2 is out already, adding a few new features (configurable bonuses per faction, leadership stars for opposing factions cancelling each other out, total leadership star display on status screen) and fixing some bugs. If you downloaded the previous version, you should probably update.

1 Like


I’ve updated the Arena Level Limits hack with new functionality.

Now you can set a turn count limit, after which the arena can’t be used.
You can also optionally make arenas nonlethal.

1 Like

I am in trouble because mss is hard to merge.

I want to support Leadership with FEBuilderGBA, but with the current mss spec, it conflicts with SkillSystems.
If the status screen can be represented by a structure like a menu command, it will be easier to merge,
but the current situation is not.
The current mss is a form of compilation using ASM macros, so merging is very difficult.

Or,I expect this Leadership feature to be merged into SkillSystems.
That will solve the merge problem.

I think merging it is a good idea, but that’s up to @circleseverywhere if he’s interested in doing it or not (or anyone else who has access to the skill system git, don’t know who does).

1 Like

I need to do more testing, but as an initial observation, I think the game slows down when about to enter battle if the leadership table is too large (~79 characters from my first test).

I tried with 0xFF entries and am getting half a second or more of lag. At 79 entries, there’s a very tiny amount of lag, but it’s still noticeable.

Thanks for the report. I’ll have to do GetFactionLeadershipCount in a different way (probably should have anyway, since the current method doesn’t support having multiple copies of the same UnitID on the map with leadership stars - you only get the benefit once per unitID).

1 Like

@Blademaster
Okay, I think I have it fixed. It doesn’t lag on my test setup even with 0xFF entries on the leadership table.

Can you try this for me and see if it still lags? Just replace the lyn output at the bottom of Installer.event with this:

Fix

// lyn output of LeadershipFunctions.c
ALIGN 4
PUSH
ORG CURRENTOFFSET+$1;GetFactionLeadershipCount:
ORG CURRENTOFFSET+$70;CalculateHitAvoidBonus:
ORG CURRENTOFFSET+$74;ApplyLeadershipBonus:
ORG CURRENTOFFSET+$40;GetLeadershipStarCount:
POP
SHORT $B5F7 $2880 $D005 $2114 $4B14 $2840 $D003 $4B14 $E001 $2132 $4B13 $2048 $2 $434A $2000 $189A $9201 $4F11 $681D $2D00 $D00F $68DA $490F $400A $D10B $51 $19C9 $780C $2C00 $D006 $792E $42A6 $D10A $784A $1810 $600 $1600 $9A01 $3348 $4293 $D1E8 $BCFE $BC02 $4708 $3201 $E7EA
BYTE $CC $DD $2 $2 $4C $BE $2 $2 $BC $CF $2 $2
POIN LeadershipTable
BYTE $C $0 $1 $0
SHORT $B5F0 $250B $4 $23C0 $5745 $3460 $40F $3062 $401D $8822 $C3F $8803 $2D00 $D10E $4D10 $7829 $D $437D $1952 $8022 $4A0E $7812 $39 $4351 $185B $8003 $BCF0 $BC01 $4700 $4E0B $7831 $E $437E $199B $41B $141B $2D80 $D106 $4D07 $782D $39 $4369 $1852 $8022 $E7EB $4D05 $E7F7 $46C0
POIN AllyStarHitBonus
POIN AllyStarAvoidBonus
POIN NPCStarAvoidBonus
POIN EnemyStarHitBonus
POIN NPCStarHitBonus
SHORT $B5F8 $263F $4 $7AC0 $43B0 $F $F7FF $FF86 $5 $7AF8 $43B0 $F7FF $FF81 $4B08 $781B $2B00 $D002 $1A28 $600 $1605 $2D00 $DD03 $29 $20 $F7FF $FFAC $BCF8 $BC01 $4700 $46C0
POIN CancelOutOpposingLeadership
SHORT $2200 $B530 $4C08 $53 $191B $7819 $2900 $D101 $20FF $E004 $6805 $792D $428D $D103 $7858 $BC30 $BC02 $4708 $3201 $E7EE
POIN LeadershipTable

If that works for you, I’ll roll out a proper new version, since I also found and fixed some bugs in the status screen (wouldn’t show – if a side had no stars, and it wouldn’t show enemy stars in fog of war).

1 Like

I’ll try it later tonight as I’m busy at this time. Thank you for the update and glad I could alert you to the issue!

Looks like it worked just fine on my end!

Update time.

  • Fix the bug where the status screen wouldn’t show enemy leadership star count in fog of war chapters
  • Fix the bug where the status screen would show a side as having 0* instead of –
  • Rewrote GetFactionLeadershipCount to be much more efficient, it shouldn’t lag anymore.
  • Multiple units with the same UnitID now work properly (previously, you would only get the leadership stars once per unitID)
  • Fixed the bug where if your level limit was above 20, it wouldn’t subtract 20 before displaying it.
  • Now supports changing the maximum level via a #define in Installer.event - if you have a hack with a maximum level higher or lower than 20, it now supports this easily.
  • Added many new options: You can now configure the maximum level for units, the maximum luck for units (though you’ll have to use modular stat screen if you want to properly display a different max luck than 30), and the minimum stat increases / minimum stat increase for lords.
  • There is now a ClassLevelLimitTable that allows you to give certain classes a higher or lower level limit than the global maximum. Want level 30 dancers/manaketes/whatever? You got it.
  • Do note that level 31 is the maximum possible level, don’t set it higher. To my knowledge there aren’t any save expansion that support max levels higher than 31, either.
9 Likes

Maybe something else is interfering with it, but if a unit with leadership stars joins you mid chapter, do their leadership stars get counted in the calculation? From my testing, this may not be the case.

Good catch.

I wasn’t checking far enough into the blue unit array, apparently. Now checking the whole thing. I don’t think this will make it lag or anything, but it can’t hurt to double check.

Fix

ALIGN 4
PUSH
ORG CURRENTOFFSET+$1;GetFactionLeadershipCount:
ORG CURRENTOFFSET+$74;CalculateHitAvoidBonus:
ORG CURRENTOFFSET+$74;ApplyLeadershipBonus:
ORG CURRENTOFFSET+$40;GetLeadershipStarCount:
POP
SHORT $B5F7 $2880 $D024 $2840 $D125 $2114 $4B14 $2048 $2 $434A $2000 $189A $9201 $4F12 $681D $2D00 $D00F $68DA $4910 $400A $D10B $51 $19C9 $780C $2C00 $D006 $792E $42A6 $D110 $784A $1810 $600 $1600 $9A01 $3348 $4293 $D1E8 $BCFE $BC02 $4708 $2132 $4B06 $E7DB $213E $4B05 $E7D8 $3201 $E7E4
BYTE $CC $DD $2 $2
POIN LeadershipTable
BYTE $C $0 $1 $0 $BC $CF $2 $2 $4C $BE $2 $2
SHORT $B5F0 $250B $4 $23C0 $5745 $3460 $40F $3062 $401D $8822 $C3F $8803 $2D00 $D10E $4D10 $7829 $D $437D $1952 $8022 $4A0E $7812 $39 $4351 $185B $8003 $BCF0 $BC01 $4700 $4E0B $7831 $E $437E $199B $41B $141B $2D80 $D106 $4D07 $782D $39 $4369 $1852 $8022 $E7EB $4D05 $E7F7 $46C0
POIN AllyStarHitBonus
POIN AllyStarAvoidBonus
POIN NPCStarAvoidBonus
POIN EnemyStarHitBonus
POIN NPCStarHitBonus
SHORT $B5F8 $263F $4 $7AC0 $43B0 $F $F7FF $FF84 $5 $7AF8 $43B0 $F7FF $FF7F $4B08 $781B $2B00 $D002 $1A28 $600 $1605 $2D00 $DD03 $29 $20 $F7FF $FFAC $BCF8 $BC01 $4700 $46C0
POIN CancelOutOpposingLeadership
SHORT $2200 $B530 $4C08 $53 $191B $7819 $2900 $D101 $20FF $E004 $6805 $792D $428D $D103 $7858 $BC30 $BC02 $4708 $3201 $E7EE
POIN LeadershipTable

Looks like it is working. In terms of lag, it feels like there is more sometimes if there are more units with leadership stars on the map? It didn’t come across as bad as it was before.

Number of units with leadership stars shouldn’t matter - what would matter is 1. the number of units on the field and 2. the number of entries on the leadership table. Since the code has to check through every unit in the array, make sure they’re alive and on the field, then check through the leadership table to see if they’re on it.

Anyway, I could add an option to cache the leadership star count. What this would mean is - the first time leadership stars are counted per phase, they’d be saved to a location in RAM. So you’d only get lag the first time you went to attack an enemy (or vice versa) per phase.

However, this would have a downside. If you, say, killed an enemy with leadership stars, the enemy leadership star count wouldn’t go down until the start of the next phase. Or if you recruit a green/red unit with leadership stars to your side, you wouldn’t get the stars until the next phase.

Okay, in that case the lag would be because I had a bunch of units on the map with leadership stars on a map that already had a bunch of units. And even then, it didn’t always seem to happen and wasn’t super noticeable.

Yeah, I don’t think that downside would be worth it. I’m a bit busy tonight, but tomorrow I can send you a patch and .sav of the chapter and maybe you could get a feel for yourself of the lag that’s there, but I’d say it isn’t worth the effort unless you want to come up with a sorting algorithm that speeds up the process of seeing what units are in the list of on the map.

If you do that I’ll take a look, and see if I can think of something. That said, I’m not sure there’s much else I can do at this point that won’t come with some kind of downside. And if the lag is barely noticeable, I’d agree that it’s not going to be worth the downsides.

Oh, and a couple quick things just to be sure. I doubt either of these is the problem, but it can’t hurt to double check so:

  • If you accidentally deleted the SHORT 0x0 at the end of the LeadershipTable, that could be causing lag (and random units having leadership stars that they shouldn’t have).
  • Have you tried disabling HPBars? It can cause lag sometimes, since it has to do a lot of processing for effectiveness weapon warnings/high crit enemy warnings.

Sent patch and reply in a PM.