News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

[sm] enemy e8ff (ROBO) location where room state check occurs

Started by Moehr, September 12, 2017, 03:40:41 PM

Previous topic - Next topic

Moehr

If possible, I would like to edit Robo's AI so it checks for an event flag to turn on/off, as opposed to an area boss. From what I can gather from testing, the AI checks to see if the boss of its current area has been defeated before switching from active to inactive. It won't make or break my hack if I can't get robo running before the boss dead flag for a given area is set, but it will help keep the theme going.

Ideally I am looking to clone Robo so there are two sets; an autonomous aggressive one that operates under its own direction, and one controlled by the hub which, once the hub goes down, all hub-controlled Robos also shut off.

I have a workaround in mind if this isn't feasible; I imagine one of the bits in the ROBO AI routine is checking for the boss dead bitflag, but I'm not sure if I can figure out which bit to change on my own and didn't have luck finding it.

Again, thanks for the assist; I'm about 40 rooms in with another 160 to go (maybe less with a bit of luck!). I'll post something once there's enough to make it worth checking out.

edit - I can't think of a good reason why it bothers checking for the boss bit in the first place since the only time it's active is once the room has performed the state check, and since you can swap enemy sets with a state check, and there is a separate enemy for the powered-down ROBO... (shrugs).

PHOSPHOTiDYL

There's only $0C bytes to work with, perhaps jsr to freespace first & cmp enemy index to the clone's index.
If it's the clone, assuming it's the aggressive one, skip the event check.

LDA #event : JSL $808233 will check for an event as happened, clc if not, sec if happened.

Just an untested idea, I haven't touched robo yet...




Moehr

I don't know how to properly use ASM yet but I will come back to this post once I start mucking around with it. The plan would be to change the boss state check to an event state check in the original AI; then, in the clone, skip the event state check. I am assuming the 0C bytes means that's what's free in the enemy AI rather than the bank where the AI is located, correct? I don't think that'll impact the plan I want to go with but I can see how that would leave precious little space to add anything new.

PHOSPHOTiDYL

From the INIT AI, the very first code it runs...

$A8CB77 AE 9F 07    LDX $079F  [$7E:079F]
$A8CB7A BF 28 D8 7E LDA $7ED828,x[$7E:D82B]
$A8CB7E 89 01 00    BIT #$0001
$A8CB81 F0 49       BEQ $49    [$CBCC]


There's also $0642 bytes free space in this bank, plenty of room to work with.
This is untested, but it'd be something like JSR clonecheck : LDA #event : JSL $808233 : BEQ $49.

clonecheck:
LDX numberofenemies : LDA currentenemyindex : CMP cloneheader : BNE $03 : JMP $CB83/$CBCC : RTS

If it's not a clone, rts & eventcheck.
If it's a clone, jmp to which of the two jumps don't deactivate robo.

As for clonecheck, I know LDA : CMP works for bosses, just haven't tried with multiple enemies in a room...

Moehr

I hope to learn how to implement that change once I've got the main stuff in place.

In the meantime, the workaround I am using is
-setting the Wrecked Ship Boss value bit to 01 "Boss Dead" with a plm encountered upon entering the area
-rooms that have a Robo that needs to shut off later in the game do so via an event state, rather than a boss state