I made a macro for custom Talk-To AI.
#define SeekAndTalkThenOtherwise(convoChars, target, startLabel, thenLabel, otherwiseLabel) "MoveTowardsIfOutOfRange(target); ConditionalGoto(4,EQ,otherwiseLabel); ConditionalGoto(2,NE,startLabel); InitiateTalk(convoChars); Goto(thenLabel)"
//convoChars is a list of 2 bytes of the characters. First the initiator, then the talk-to person.
//target is the actual targetted character
//startLabel is a label right before this command.
//thenLabel is a label number to GOTO after they talk.
//otherwiseLabel is a label number to GOTO if the one to look for is not deployed.
With these being the definitions of the macros inside the macro:
#define MoveTowardsIfOutOfRange(charID) "BYTE 0x0D 0x00 0xFF 0x00; WORD charID; WORD 0x00000000; WORD 0x00000000"
#define ConditionalGoto(constant, comparator, label) "BYTE 0x00 comparator 0xFF label; WORD constant; WORD 0x0203A972; WORD 0x00000000"
#define Label(label) "BYTE 0x1B 0x00 0xFF label; WORD 0x00000000; WORD 0x00000000; WORD 0x00000000"
#define Goto(label) "BYTE 0x03 0x00 0xFF label; WORD 0x00000000; WORD 0x00000000; WORD 0x00000000"
#define Routine_AI(routine, paramPointer) "BYTE 0x01 0x64 0xFF 0x00; WORD 0x00000000; POIN routine; POIN paramPointer"
#define InitiateTalk(charsPointer) "Routine_AI(0x0803A58D, charsPointer)"
And here’s a demo of it in action:
AI1PointerTable(0x01, TalkToLyn)
...
UNIT Sain Cavalier 0x00 Level(1,NPC,False) [14,9] [14,9] [IronSword] [0x1, 0x3, 0x0, 0x0]
...
TurnEvents:
TURN 0x00 OpeningScene [01,00] 0x0 0x00
AFEV 0x0B SainJoins 0x0A
TURN
CharacterEvents:
CHAR 0x0A SainLyn Sain Lyn $00000000
CHAR 0x0A SainLyn Lyn Sain $00000000
CHAR
...
SainJoins:
CUSI Sain $47
ENDA
SainLyn:
TEX1 0x838
REMA
ENDA
...
TalkToLyn:
SeekAndTalkThenOtherwise(TalkCharacters, Lyn, 0, 1, 1)
Label(1)
DefaultAction //AttackInRange... I'm trying to find a better, untaken name for it. Or free up the name.
Goto(1)
...
TalkCharacters:
BYTE Sain Lyn 0x00 0x00
I’ll probably make a Tech Demo of this eventually.
What this does is that Sain seeks out and talks to Lyn. Once he does, he turns into an Other Unit and will attack enemies in his range.