Author Topic: Javascript FF4 Event Scripter  (Read 2886 times)

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Javascript FF4 Event Scripter
« on: August 12, 2008, 05:16:27 PM »
I converted and updated my Applescript event scripter to a Javascript version. It can be found here:

http://phoenix.hacks.googlepages.com/FF4EventScripter.html

You can change either the hex data or the hex values within the text data. There's a few quirks with hitting return in the text data -- basically, to add another line you have to hit return between the hex values and the text. Other than, it works pretty well I think. I even got instantaneous updating to work, which I wasn't sure was possible. Along with my event offsets document (hosted by bond697 here) you can script any of the events by copying and pasting the hex data. I'm planning on using it for writing my own events, too.

bond697: I noticed the line values on the event offsets document you have posted is messed up after event 3D. Do you need a new copy of it, or can you fix it?

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: Javascript FF4 Event Scripter
« Reply #1 on: August 12, 2008, 05:24:25 PM »
Hey, this is pretty cool. I was planning on making some modifications to a few events soon so this will come in really handy.

This is a bit of a stupid question but what determines where events appear? For example, if I wanted to change Baron's item shop so it used a different shop list, what determines what event the shopkeeper calls?

Phoenix

  • FF4 Hacker
  • *
  • Posts: 456
    • View Profile
    • Phoenix Hacks
Re: Javascript FF4 Event Scripter
« Reply #2 on: August 12, 2008, 06:03:10 PM »
To warn you, you're much better off changing the event itself. The events loaded by speaking to people are a bit of a hassle to mess with. I'm sure you can decide for yourself which is better, though, so here's the explanation:

The events when speaking to people are determined by the speech data. The pointers for this are 99A00-99DFF (2 bytes, reverse and add 0x99E00) and the speech data is 99E00-9A4FF (variable length). It took me a long while to figure out what the bytes meant, but I believe I have a clear understanding of how it's coded:

Code: [Select]
FFxx = Load event xx
FEaa = If event flag aa is set...
aa = If event flag aa is clear...

Examples:
aaFFxxFFyy = If event flag aa is clear, then load event xx, else load event yy
FEaabbFFxxFEccFFyyFFzz = If event flag aa is set and bb is clear, then load event xx,
else if event flag cc is set, load event yy, else load event zz

The speech data utilizes events numbers 01-03, which are EE message calls:
"Show message [hex data xx following event call] (from bank 2)"
For example, the Old Man wandering in the town of Baron has the following data (at 99EDE-99EEA):
FE 06 FF 03 FE 0B FF 02 FF 01 03 04 05
This translates to:
Data Meaning
FE 06 If event flag 06 is set,
FF 03 load event 03 (i.e. message call EE 02 = message 05 of bank 2)
FE 0B (else) If event flag 0B is set,
FF 02 load event 02 (i.e. message call EE 01 = message 04 of bank 2)
FF 01 (else) load event 01 (i.e. message call EE 00 = message 03 of bank 2)
03 04 05 Hex data following event call

So you see, it's a pain to change, because you need to keep track of the person/object index and the event flags. Shops aren't conditional, so they would be a simple "FFxx" string. For example, I checked on the Baron Item shop man, and he is person/object number 44. You look that up in the speech data, and the data is "FF 26." Event 26 is "Bring up shop 13." And shop 13 is the item shop that you want. Much easier to just change event 26 to bring up a different shop.

Just a heads up: when writing this out I did notice that person 44 is used by the Baron, Kaipo, and Toroia item shops. That means they all load the same item shop, and if you change the event it'll change all the shops. You'd have to create three different person/object instances to have three different shops.

Dragonsbrethren

  • Forum Overlord
  • *
  • Posts: 1,820
    • View Profile
    • Dragonsbrethren Industries
Re: Javascript FF4 Event Scripter
« Reply #3 on: August 12, 2008, 06:11:03 PM »
Just a heads up: when writing this out I did notice that person 44 is used by the Baron, Kaipo, and Toroia item shops. That means they all load the same item shop, and if you change the event it'll change all the shops. You'd have to create three different person/object instances to have three different shops.

Ack, so not only do those sprites share the same event, the maps share the same sprite...makes it a lot more annoying to change than I was expecting.

bond697

  • FF4 Archivist
  • *
  • Posts: 624
  • Gender: Male
  • is NOT a spoony bard!
    • View Profile
    • The FF4 Reference Book
Re: Javascript FF4 Event Scripter
« Reply #4 on: August 12, 2008, 06:31:41 PM »

bond697: I noticed the line values on the event offsets document you have posted is messed up after event 3D. Do you need a new copy of it, or can you fix it?

can you send me a new copy? the one i have from last time has the events messed up in the same manner. if that doesn't work, i'll fix each one manually.
The FF4 Reference Book - Now with new hosting!

bond697

  • FF4 Archivist
  • *
  • Posts: 624
  • Gender: Male
  • is NOT a spoony bard!
    • View Profile
    • The FF4 Reference Book
Re: Javascript FF4 Event Scripter
« Reply #5 on: August 13, 2008, 11:07:27 PM »
that new copy fixed the problem nicely. :happy:
The FF4 Reference Book - Now with new hosting!