[FE7] Getting a third faction working for 1 chapter


#1

As most of you know by now, there’s a method of making green units hostile to players and enemies (skips the allegiance check). This is done by editing a byte on the ROM, but what I’m trying to do is make the green units only hostile for a specific chapter.

Technically I can do this by using the VBA to memory hack the byte from RAM during that chapter. But obviously that’s not a permanent solution. So what I’m asking is: How do I get a third faction working for a specific chapter? I know Bloodlines does this (albeit in a different manner) so I know it must be possible.


#2

Find the routine that checks this byte, hook your own routine to it and return a different value depending on the ID of the chapter

so: do asm


#3

I guess I should be more clear: I presumed out that you could use some sort of conditional to get this working, as you said. I’m just not sure where to start on such a thing.


#4

If you have access to a debugger (no$debugger is a good start), you can break-on-read the relevant value in ROM to do what Leonarth said.


#5

The allegiance check is done by comparing ID’s of the unit.
If the 0x40 bit is set it’s an NPC
If 0x80 is set it’s an enemy
If neither it’s a player unit
The game checks if the 2 units in question are equal after clearing all the bits except 0x80(AND 0x80). Equal means they’re allies, not equal means enemies (tribalism at its finest). What I did in bloodlines was AND 0xC0 then checking for equivalencies meaning for units to be allies they have to be in the same faction. I incorporated my checked for this indiscriminate hostility with an AI value, it wouldn’t be difficult to change the condition to just a chapter ID. If you’re stepping through the code yourself that’s what you’d want to do; AND 0xC0 instead of 0x80. I can’t remember the function address offhand and I’m away from my computer this week. I can just give you the code if you want to wait or you can use no$ to find the function and write a little bit of code. Good luck :+1:t2:


#6

For example, if you modify it as follows, NPC will hostile if local flag 0x27 is enabled.

NPC_uragiri.s

@ローカルフラグ0x27をONにするとNPCが敵対する。
@When local flag 0x27 is turned on, NPC is hostile.
@Call 080238B0

.thumb
.macro blh to, reg=r3
  ldr \reg, =\to
  mov lr, \reg
  .short 0xf800
.endm

PUSH  {r0,r1,lr}

mov   r0, #0x27
blh   0x080798F8       @FE7U  CheckFlag
cmp   r0, #0x00
bne   Uragiri
mov   r2, #0x80        @ 仲間 (゚∀゚)人(゚∀゚) 
b     Join

Uragiri:
mov r2, #0xC0          @ 裏切り (・∀・) 

Join:
POP  {r1,r0}
and r1 ,r2
mov r3, #0x0
and r2 ,r0
cmp r2 ,r1
bne NotNPC

mov r3, #0x1

NotNPC:
mov r0 ,r3
POP  {pc}

NPC_uragiri.event

#ifdef _FE7_

#include "EAstdlib.event"
#include "Extensions/Hack Installation.txt"


PUSH
ORG $238B0		//FE7U
jumpToHack(NPC_uragiri)
POP

NPC_uragiri:
#incbin "NPC_uragiri.dmp"

#else
    ERROR This version of Selection Quotes is for FE7!
#endif

Since FEU can not attach zip, compile (assembly) by yourself.