A dumb question regarding skills code

Hey please you’re not bad. Everyone is bad at assembly when they start out. There are so many conventions and whatnot that make it seem overwhelming, but you’re doing pretty well!

Ah sorry I should have included this macro in the function writeup:

.macro blh to, reg
    ldr \reg, =\to
    mov lr, \reg
    .short 0xF800
.endm

This can go anywhere near the top of your file.

You can use what I wrote or the aura skill checker. Use whatever you think is best. It’s your code!

Just remember that you need to decide on the intended behavior of your code. You can either have the effect apply to within a single allegiance (requiring you to selectively loop through a single allegiance pool) or have the effect be allegiance-independent (just requiring changing the limits of the loop to cover all units and not just player units).

1 Like

Right now I don’t know what I’m going to use, but, a big but, I am grateful to you for helping me solve the problem in an alternative way, because I believe that whatever I learn will always be useful in the endeven though i completed the goal of creating a new skill i didn’t complete the main quest, learn as much as possible about assembly.
I don’t know if I made myself clear, I hope this is just a start, I would like to try to do different things, right now I’m starting to recreate the mount unit system like Tellius game

Ah, great, now i see if it works
now when I assemble the code, it does not report any errors, but when I am in play, and I try to open the least of the units, to see skills, statistics, name etc …but the game crashes with a simple black screen for safety I also did a test on a clean buildfile but it always seems to
I would not like it if it was for how I entered the new library

.thumb
.equ AuraSkillCheck, SkillTester+4
.equ ForLadyID, AuraSkillCheck+4
push { r4, r5, lr }
mov r4, r0 @ We only need to store one battle struct pointer.
.macro blh to, reg
    ldr \reg, =\to
    mov lr, \reg
    .short 0xF800
.endm

I also tried to put it on top, line after the

> .thumb

but same thing

I’d put the macro right below the .thumb, but it shouldn’t matter.
Make sure you’re writing to free space! Can we see how you’re installing the skill in your EA script?

I don’t think I was wrong about this because by inserting the other version nothing happened
(for scruple I check again after this too)

no problem
i try to rebuild how it is i am installing the skill, just a couple of minutes

EDIT: Then


I put the folder of the skill (ForLady) in the AuraSkill folder, in the Auraskill.event I wrote this:

> ALIGN 4
> ForLady:
> #incbin "ForLady/ForLady.dmp"
> POIN SkillTester
> POIN AuraSkillCheck
> WORD ForLadyID

right after the spur skills but I don’t think it has much to do with it
EDIT (2):I checked, assembling the old code, everything works, i think i got something wrong when i insert the .dmp file

Well for organization’s sake, this shouldn’t go in aura skills. This should really go with PreBattleSkills. Be sure you’re correctly adding a pointer to your routine to the PreBattleCalcLoop as well!

thanks for the advice

I added it on the same line where there are Demoiselle Gentilhomme MaleficAura etc… could this be the mistake?
with the other code, everything works fine
was I wrong to rewrite the code?

> .thumb
> .equ AuraSkillCheck, SkillTester+4
> .equ ForLadyID, AuraSkillCheck+4
> .macro blh to, reg
>     ldr \reg, =\to
>     mov lr, \reg
>     .short 0xF800
> .endm
> push { r4, r5, lr }
> mov r4, r0 @ We only need to store one battle struct pointer.
> 
> @ Does this unit have the skill
> ldr r0, ForLadyID
> mov r1, r4
> blh SkillTester, r2
> cmp r0, #0x00
> beq Done
> 
> @ Now we need to start looping through player units.
> mov r5, #0x00
> StartLoop:
> add r5, r5, #0x01
> cmp r5, #0x63
> beq Done
>     mov r0, r5
>     blh GetUnit, r1 @ Unit we want to test is in r0.
>     cmp r0, #0x00
>     beq StartLoop
>     ldr r1, [ r0 ]
>     cmp r0, #0x00
>     beq StartLoop @ Does this unit exist?
>     ldr r1, [ r1, #0x28 ] @ Character abilities.
>     ldr r2, [ r0, #0x04 ]
>     ldr r2, [ r2, #0x28 ] @ Class abilities.
>     orr r1, r1, r2
>     mov r2, #0x40
>     lsl r2, r2, #0x08 @ IsFemale.
>     tst r1, r2
>     beq LoopStart @ Reiterate if this unit is male.
>     
>     @ We should probably check if this unit is dead too.
>     ldr r1, [ r0, #0x0C ]
>     lsr r1, r1, #2
>     lsl r1, r1, #31
>     cmp r1, #0x00
>     bne StartLoop @ Reiterate if this unit is dead.
> 
>     @ Now let's check the ranges.
>     ldrb r1, [ r4, #0x10 ] @ Main unit X.
>     ldrb r2, [ r0, #0x10 ] @ This unit X.
>     sub r1, r1, r2
>     cmp r1, #0x00
>     bge NotNegativeX @ Aaaaa we have to account for the differences being negative.
>         mov r2, #0x01
>         neg r2, r2
>         mul r1, r2 @ Multiply by -1. There may be a more efficient way to do this but eh.
>     NotNegativeX:
>     ldrb r2, [ r4, #0x11 ] @ Main unit Y.
>     ldrb r3, [ r4, #0x11 ] @ This unit Y.
>     sub r2, r2, r3
>     cmp r2, #0x00
>     bge NotNegativeY
>         mov r3, #0x01
>         neg r3, r3
>         mul r2, r3
>     NotNegativeY:
>     @ r1 has |XDifference|, and r2 has |YDifference|.
>     add r1, r1, r2 @ Total distance between these units.
>     cmp r1, #0x03 @ I think 3 is your range?
>     bgt StartLoop @ This unit is outside the range.
> 
> @ We've passed all of the conditions.  Let's apply the bonus!
> mov r1, #0x5A
> ldrh r2, [ r4, r1 ] @ Attacker's damage.
> add r2, r2, #2 @ Add 2 damage.
> strh r2, [ r4, r1 ]
> 
> mov r1, #0x60
> ldrh r2, [ r4, r1 ] @ Attacker's hit.
> add r2, r2, #10 @ Add 10 hit.
> strh r2, [ r4, r1 ]
> 
> Done:
> pop { r4, r5 }
> pop { r0 }
> bx r0
> 
> .align
> .ltorg
> CharData:
> .long 0x202be4c
> MovementPoin:
> .long 0x880bb96
> SkillTester:
> @POIN SkillTester
> @ POIN AuraSkillCheck
> @ WORD ForLadyID

Reading this, I just realized that cmp r5, #0x63 should be cmp r5, #63. We want 63 in decimal, not hex.

That should be fine if you wrote it there in the PreBattleCalcLoop, though yeah.

1 Like

I applied the fix, but the ids of a unit are not in hexadecimal? seeing from FEbuilderGBA they look like hexadecimal to me, or we are seeing the number of units passing?

for safety now I will show how I insert the poin

> #include "BattleCalcDefinitions.event"
> 
> 	/* Pre-battle calculation loop */
> 
> PUSH
> ORG 0x2a95c
> jumpToHack(BtlLoopParent)
> 
> // ORG 0x2AFFE //make 0xc = cannot double
> // SHORT 0x280C 0xD005
> POP
> 
> ALIGN 4
> BtlLoopParent:
> #incbin "FE8_battle_calc_loop.dmp"
> BtlLoopTable:
> POIN BC_DefRes BC_Power BC_ASpd BC_Hit BC_Avo BC_Crit CritUpSkill BC_Dodge BC_Support BC_WRank BC_Status //these are the existing battle calculation routines
> POIN Lull //This is effectively a stat modifier routine, so it has to go first
> POIN FaireCheck HolyAura
> POIN BreakerCheck MageSlayer
> POIN BlowCheck
> POIN DefendingCheck
> #ifdef LEADERSHIP_STARS
>   POIN LeadershipHook
> #endif //LEADERSHIP_STARS
> #ifdef BIORHYTHM
>   POIN BiorhythmFunc
> #endif //BIORHYTHM
> POIN Wrath SpurStr SpurMag SpurSpd SpurDef SpurRes
> POIN DriveStr DriveMag DriveSpd DriveDef DriveRes
> POIN LuckySeven OddRhythm EvenRhythm QuickBurn SlowBurn
>*Check this line!* POIN Demoiselle Gentilhomme MaleficAura Intimidate Tantivy Focus Inspiration Charm Solidarity VoiceOfPeace Anathema LilysPoise Charisma Hex Loyalty Infiltrator ***ForLady***
> POIN ElbowRoom NaturalCover Gamble FieryBlood LifeAndDeath WindDisciple Perfectionist Puissance Hawkeye LightWeight Trample Opportunist BattleVeteran SilentPride Thunderstorm Outrider HeavyStrikes Charge Vanity KnightAspirant AssassinateDamageBonus ArcaneBlade
> POIN Daunt BloodTide WhitePool NightTide Insight Prescience Vigilance DefiantAvo DefiantCrit TowerShield ShortShield IndoorFighter OutdoorFighter Deadeye Fortune
> POIN BlueFlame BlueFlameAura DoubleLion Cultured Thighdeology Thotslayer KeepUp Armorboost Horseguard Skyguard
> POIN Frenzy // This was moved here because Str/Mag Split conflict, and... I'm not sure why it wouldn't be here in the first place.
> POIN UpWithArch
> POIN AxefaithHit
> POIN StancesASM
> #ifdef ENABLE_GBA_LETHALITY
> POIN LethalitySkill Bane
> #else
> POIN LethalitySkill NonGBALethalitySkill Bane
> #endif
> 
> //add any new ones before here
> 
> //tower shield plus needs to go after every other skill that may affect defender's attack
> POIN TowerShieldPlus
> // Because of how killing machine works, critical check should always be done last
> POIN CriticalCheck
> #ifdef CANNOT_CRIT
> 	POIN NegateCritWeapons //This goes last, so that crit will always be set to 0 if set and never modified from there
> #endif // CANNOT_CRIT
> POIN 0
> 
> PUSH
> ORG 0x2a3f8
> //rewrite range map
> jumpToHack(rewriteRangeMap)
> POP
> 
> ALIGN 4
> rewriteRangeMap:
> #incbin "rewriteRangeMap.dmp"
> 
> PROTECT 0x2A95C 0x2A968

That looks fine yeah. And… you say that it still crashes on startup?

yes, very strange, I don’t think I did something wrong during the installation