Qhimm.com Forums

Miscellaneous Forums => Scripting and Reverse Engineering => Topic started by: Girl next door on 2016-09-17 15:30:05

Title: [ff8] Edit the encounters on the world map
Post by: Girl next door on 2016-09-17 15:30:05
Hi!

I want to edit the encounters on the world map. With Cactilio, I can change the scenes but not their location. The idea is to put some rare encounters on special places. I can do that with Deling on fields but not on the world map. Any idea how I can do this ?
Title: Re: [ff8] Edit the encounters on the world map
Post by: Maki on 2016-09-17 16:14:15
I discovered it's in one of wmsetus section. We found the worldmap regions but no encounters. It's somewhere near section 2 to 9. Currently- no one have found where exactly. Search somewhere in sections 1 to 9 in wmsetus file. Here's the notes I collected:
http://wiki.qhimm.com/view/Talk:FF8/WorldMap_wmsetxx
Title: Re: [ff8] Edit the encounters on the world map
Post by: Girl next door on 2016-09-17 20:30:06
Well, that's quite a heavy thing, I will wait for someone more skilled than me. ^^'
Title: Re: [ff8] Edit the encounters on the world map
Post by: Maki on 2016-10-14 16:24:16
wmsetus.section2:
(https://s19.postimg.org/rq9lxryfn/getpubthumb.png)
Does it look similar to you? :)
I have not found the encounter data, but it's a map of world map regions for encounters. I'll be trying to reverse it.

EDIT: I found function that returns world map block ID based on Squall's position. 0x553760 for me
then:
mov     al, [edx+edi] (where EDX is world segment and EDI is LEA of section 2 start)

All six first wmset sections are tied to one function. I already found the one that gets the region ID when character is moving and have no enc-none equipped. This is clearly all encounters.
Title: Re: [ff8] Edit the encounters on the world map
Post by: Girl next door on 2016-10-14 20:35:37
Yes, it's the same thing for the wmsetfr:

(http://image.noelshack.com/fichiers/2016/41/1476477084-capture.png)

That's a weird code no ? You should find somewhere the encounter's ID no ? But here, it's just the map if you have the ability No encounters no ?
Title: Re: [ff8] Edit the encounters on the world map
Post by: Maki on 2016-10-15 16:47:33
Good news! I found it!
wmsetus.section4 structure:

uint16 - encounter ID

It's as simple as that

0x541CF1 is mov     dx, [ecx+eax*2]
ECX - section4 pointer; eax is unknown so far...
Balamb garden uses:
0x6
0x8
0xC
0xE

It uses the same encounter IDs as normal scene.out file

also treat section 5 as leftover/null

I haven't localized the ECX yet (the pointer that tells which position from section4 to read encounter from)
Title: Re: [ff8] Edit the encounters on the world map
Post by: Girl next door on 2016-10-15 20:03:10
That's good news ! ;D

But well, it's hard to understand for me. At which offset the sector 4 begins please ?
Title: Re: [ff8] Edit the encounters on the world map
Post by: Maki on 2016-10-15 20:43:52
That's good news ! ;D

But well, it's hard to understand for me. At which offset the sector 4 begins please ?

If you use my Rinoas Toolset you can unpack wmset file. I'm working now on repacker and editor for section 4 and 2, so fear not. :3
Title: Re: [ff8] Edit the encounters on the world map
Post by: Girl next door on 2016-10-15 21:22:35
Great ! Looking forward to its released ! ;D
Title: Re: [ff8] Edit the encounters on the world map
Post by: Girl next door on 2016-10-17 02:24:24
About the world map, do you know where is the draw points data please ?
Title: Re: [ff8] Edit the encounters on the world map
Post by: Maki on 2016-10-19 08:13:14
About the world map, do you know where is the draw points data please ?

Hm, the only function associated with draw points is kind of giant function of event processing probably (I called it draw point related, but I see now there are references to text and world map quests, so that's not this). Game calls "GetDrawMagic" from EAX that is dword_204400C.
dword_204400C however is set as return by sub_54F770
sub_54F770 in fact loads wmsetS35 pointer, so... Looks like section 35 is managing world map draw magic. That's all for now, I need to finish the editor for wmset 2 and 4 first.
Title: Re: [ff8] Edit the encounters on the world map
Post by: Girl next door on 2016-10-20 04:57:41
Of course, one thing after the other. :) Will you put this editor in your Rinoa's toolset ?
Title: Re: [ff8] Edit the encounters on the world map
Post by: Maki on 2016-10-23 11:36:01
Of course, one thing after the other. :) Will you put this editor in your Rinoa's toolset ?
Okay, it's done:
https://github.com/MaKiPL/FF8-Rinoa-s-Toolset/releases/tag/1.1.2

First open, unpack, open section you want to edit and finally click on compile. File saving prompt should appear if no errors. Remember to have backup of your files!
Compile/unpack/editor works on all language versions (wmsetus, wmsetit, wmsetfr etc...)

Now the draw points...
Title: Re: [ff8] Edit the encounters on the world map
Post by: volvania on 2016-10-24 00:16:03
WMSET : not enough WMSET section! can't build file...
thats the message appear when i compile is that a normal error or i did something wrong maki?
Title: Re: [ff8] Edit the encounters on the world map
Post by: Maki on 2016-10-24 06:29:29
WMSET : not enough WMSET section! can't build file...
thats the message appear when i compile is that a normal error or i did something wrong maki?
Rebuild function automatically finds all possible language versions. Normally, you should have one success and four errors like this.
Title: Re: [ff8] Edit the encounters on the world map
Post by: Maki on 2016-11-09 11:07:38
About the world map, do you know where is the draw points data please ?

Section35:
OffsetSizeDescription
0x000x2CUnused - skipped in ASM
0x2C + (drawID * 4)4DrawPointVariable

DrawPointVariable:
OffsetSizeDescription
0x00shortProbably X
0x02shortProbably Y

The X and Y calculation example (FF8 2000 english):
ECX: 020409FC
ESI:  020400AC
EDX: 0204095C

X == EDX
Y == ((*ECX - *ESI) - 4 ) >> 4  [just gets pointer variable from ECX and substracts it from ESI, then substracts 4 and shifts right 4, pretty simple]

I'm still not sure how to calculate it to world map position. Magic IDs are probably coded inside EXE as field draw points are http://forums.qhimm.com/index.php?topic=16980.0

EDIT:
Yes, it gets data from the same DrawMagicArray as fields, just adds 0x80 to drawID. Therefore every drawmagic bigger than 0x80 is world-map only I think.
The magicID to draw is simple counted as draw entry. So, the first draw magic entry is magic ID = 0, second is magicID=1 and etc... [like autoincrement database]

EDIT2:
Okay, EDX = 0 if top left corner on map and 2FFF if bottom right corner.
but X makes no sense...
(https://i.gyazo.com/e720d46f474a3350021a38d1d232873b.gif)
Zoom in if you don't see variables
Title: Re: [ff8] Edit the encounters on the world map
Post by: Halfer on 2016-11-09 19:04:49

EDIT2:
Okay, EDX = 0 if top left corner on map and 2FFF if bottom right corner.
but X makes no sense...

Yo!

The "0-2FFF" format is actually 2 bytes

In Big-Endian format:
 First byte is X location in width counted from blocks (0x20 * 4 or 32 * 4), where 0x20/32 is blocks from "left edge" to "right edge" in world map.
 Second byte being Y location in height counted from blocks (0x18 * 2 or 24 * 2), where 0x18/24 is blocks from "top edge" to "bottom edge" in world map.

In short:
Code: [Select]
First byte = Block in world map row
Second byte = Block in world map column * 2 (Only for every other column block)

Hope that was clear in anyway :)
Title: Re: [ff8] Edit the encounters on the world map
Post by: resinate on 2016-11-19 01:51:18
ok soo someone went around and completely deleted all encounter IDS of ff8 from all the wikis does anyone have this list on backup?
Title: Re: [ff8] Edit the encounters on the world map
Post by: Maki on 2016-11-19 08:40:53
http://wiki.qhimm.com/view/FF8/Encounter_Codes
It's still there.
Title: Re: [ff8] Edit the encounters on the world map
Post by: Maki on 2016-11-23 15:01:30
In short:
Code: [Select]
First byte = Block in world map row
Second byte = Block in world map column * 2 (Only for every other column block)

Thanks!
I don't know if it happens everywhere, but the X variable should be ANDed to 7 bits (0x7F). Do you know for what this one bit is responsible for?
Title: Re: [ff8] Edit the encounters on the world map
Post by: Halfer on 2016-11-23 16:54:20
Thanks!
I don't know if it happens everywhere, but the X variable should be ANDed to 7 bits (0x7F). Do you know for what this one bit is responsible for?

My bad... The value is calculated from block positions.

the X is treated as two sequential rows so the math goes:

Code: [Select]

X = rowBlockAmount, which is 4 times segment amount so 4 * 32 = 128 or 0x80. The last bit tells which row of the two we are on, first or second. The range of top row is from 0x00 - 0x7F and second row's 0x80 - 0xFF.

Y is incremented whenever X goes over 0xFF.


Hope this image helps more than my blather :D (Open in new tab for seeing text)

(https://s14.postimg.org/kuuj96azj/Explanation.png)