Skeetendo

’Cause all games were better on the GBC

You are not logged in.

  • Index
  • → Help/Question
  • → Create new trainers? [And other scripts] // updated: [2013-01-24]

#1 2012-12-16 16:21:42

Skurbert
Member
Registered: 2012-12-16
Post 1/95

Create new trainers? [And other scripts] // updated: [2013-01-24]

This is the situation: I want to edit Pokemon Silver. A game I have played for 12 years. I have always been annoyed by the fact that the game is not "complete", in the sense that the other world, KANTO, is lacking and very empty.

I have done some editing to spice the worlds up. But there is one thing that still is missing:

Trainers. I need to add a lot of trainers. And i don't have a clue how to do this.

I'm gonna be strict with you:


* I SUCK at hex editing. It impossible for me.
* I don't want to be a "SUPERHACKER". I just want my Pokemon Silver to be more enjoyable.
* I have read a lot of tutorials, hints and searched the web - To no avail.

This is what I'm trying to achieve:

* Add lot of trainers all around the map of Kanto.
* If possible: Able to meet trainers again (without phone call)
* BONUS: Able to carry more money than 999 999


I am using JohtoMap. Since HexEditing seems impossible and scripting at least is mostly "copy-paste" I thought
it would be much more simple. SO WRONG I WAS!

Now If you can help this poor fella' to get some sort of progress on this would be highly appreciated.

This is what has happened so far:

* Game Freezes, then restarting with odd colors
* Game Freezes before battle, must be reseted
* "ERROR OPCODE"
* Random text and the battle start with a glitched pokemon named "????". Game not freezing this time




I even tried to use this code used for another trainer:

#org 0x12D991
'-----------------------------------
moveperson 0x4 0x17 0x6
writevarcode 0x42
wildon
locationtotext 0x0
2call 0x404A ' 0x13C04A
talkaftercancel
loadfont
2writetext 0x4255 ' 0x13C255
closetext
loadmovesprites
end

#org 0x13C04A
'-----------------------------------
talkaftercancel
loadfont
2writetext 0x4255 ' 0x13C255
closetext
loadmovesprites
end

#org 0x13C255
= Sayonara! I just\nlearned that in my\lJapanese class.\e


But somehow, it just f**ks up and "resets" when I go to file->SAVE in "JohtoMap". Something I must be doing wrong. I don't care if I am just able to... copy trainers or whatever, I ONLY WANT TO ADD MORE TRAINERS TO THAT BLOODY MAP. Is that too much to ask for? Is it IMPOSSIBLE?

I have tried every code, tried every way, and it WONT WORK. It glitches up, it crashes, or the code resets in JohtoMap.

I am so frustrated....
I have tried everything. I don't know what I'm doing wrong or why the codes are "reseting" in JohtoMap. I don't know how to stop it or what "0xFFFFFFFF" is for. 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF Everywhere!!

If you have any questions regarding this or want some specific screenshots or codes to solve this out: Don't hesitate to ask. Give me something to work with. I MUST fix this. At ALL cost.

Last edited by Skurbert (2013-01-24 11:36:51)

Offline

#2 2012-12-16 19:51:59

Miksy91
Member
Registered: 2010-10-16
Post 1,323/2,311

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

You can't copy --> paste scripts used by existing trainers to form new ones.
This would work with GBA games but not with G/S/C (because of things called flags and rom banks).

You don't have to become "superhacker" to be able to add more trainers to the game but you do need to know quite a lot to accomplish doing that (and learning hex editing is still way below that knowledge, not trying to make you not do that but knowing basics of hex editing isn't just enough).

Personally, I would have no trouble doing this and I wouldn't call myself that "super". If you want to learn, start reading and experimenting (with anything, it doesn't necessarily have to do anything with this you want to accomplish).

Offline

#3 2012-12-17 04:45:19

Skurbert
Member
Registered: 2012-12-16
Post 2/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

I guess my dream crashes instantly then.. :(

I actually tried to make a hack for Zelda earlier, and since that involved hex editing and whatever it quickly got hairy and annoying and I was totally exhausted before giving up. One thing is for sure; I'm never gonna be a scripter/hacker/hex-user. I have done many things with map-editors in my life, for example Duke Nuken or Jedi Knight, and that was quite possible to learn, bc at least you could copy/paste codes and stuff. But this is ALL but confusing and it seems I can't handle it this time either (as was the case with Zelda).

After reading "need to know quite a lot", i realise that was the nail in the coffin. lol. I will NOT be able to complete this. Or am I?

Edit, my bad, I found this helpful thread. God bless!
http://hax.iimarck.us/topic/1696/


But this then? In JohtoMap, when you click on a trainer. The list goes:

Selected: (I guess it's the object number object on screen?)
Picture: (something with the sprite. I don't know?)
Face/Type: (change the sprite object, however this "rarely" works because there are like 200 numbers but 15 different sprites or whatever..)
Movement: (If the object moves)
Time Type: (What is this?)
Time Value: (What is this?)
Sight Range: (What distance before he see you)
Palette: (Color of the guy)

Now to the more confusing ones:

Type: (I guess "2" is a trainer. Right? it should ALWAYS be that?)
Script: (yeye.. this is where i aaaaaaaaaaaaaalways fail)
Flag Index: (What is this? Should it always be FF?)
Flag Bit: (What is this? Should it also be FF?)

And in "Edit Map Properties", there are more alternatives like:

Level data.
Event data.
Event/Script bank.
Map script.

Should i fiddle with them or just leave them alone? It sounds tempting.. "Event Data".. ah... adding more trainers. ;) But when it seems fun and possible, it turns out to be the opposite.

I guess an "Adding trainers Guide" is a much needed thing! :D

Last edited by Skurbert (2012-12-17 04:54:06)

Offline

#4 2012-12-17 05:59:47

Miksy91
Member
Registered: 2010-10-16
Post 1,326/2,311

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

First of all, Mateo has made a tutorial for adding a new person event to a map. Try to understand how it works out and check what Global FAQ and Resource thread has to offer.

And yeah, you've got it right that every trainer has its type set to 2 (this isn't the case for example with gym leaders though because their script isn't the same as with other trainers).

This also ought to explain some of your questions: http://hax.iimarck.us/files/scriptingco … ventaufbau

Offline

#5 2012-12-17 06:25:30

Skurbert
Member
Registered: 2012-12-16
Post 4/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Thanks! I will check that out!

Offline

#6 2012-12-17 07:06:30

Skurbert
Member
Registered: 2012-12-16
Post 5/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Allright.. I was brave enough to try the hex editor "Gold Finger", but when i opened the Rom, all I see is this:

############################################
############################################
############################################
############################################
############################################

Not. A. Single. Line. Of. Text.
Well, I guess you understand why I hate Hex Editors, Yet, Im stupid enough to return to them.


But I think this thread helped somewhat:

http://www.pokecommunity.com/showthread.php?p=6603752

And there we have a screenshot which is my biggest inspiration for my project so far:

73061894.png

And that one worked. So something you must have done right? I should be able to copy that code, tweak it somewhat and use it on a trainer. There are some codes that is missing or whatever. But from i've seen on this forums NOTHING says anything about these script, every thread talks about hex editing. I don't wanna do hex editing. I want to SCRIPT using the utility of the picture above (I don't wanna battle a shiny pokemon, but that was just an example).

Every thread on this forum confuses me, even the most basic Tutorials. I feel stupid. :P There are just numbers numbers numbers everywhere. I want a simple code, like that one on the picture. Because your code worked, then it SHOULD work for me. Then why fiddling with hex-editors. And screenshots are also good to use than trying to memorize a lot of numbers. Reading a wall of text with numbers of numbers of codes won't help when im trying to understand the basics. I want an example code, something to work with. And things like "change X1 to X5 by clicking there and there".

Sorry my bad english. I'm just frustrated because i know i do something like 95 % right and that 5 % missing is some shitty code somewhere that I can't find or figure out for whatever reason.

I will post a screenshot later with a better example code.

Last edited by Skurbert (2012-12-17 07:15:17)

Offline

#7 2012-12-17 07:50:04

Skurbert
Member
Registered: 2012-12-16
Post 7/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

kkj1116 wrote:

I'd like to chime in and say that I know exactly how you feel (but I feel that way with most data structures and Assembly language, I get some very basic things so far). A year ago I struggled with grasping hex editing too but it's really really simple if you think about it. Even now ASM codes seem very ominous. But time and familiarity seems to be the best way to learn difficult concepts to me at least..

I don't know how helpful I am but I'd like to try so give me a chance:

  • The #'s you see on a Hex Editor (I'm assuming you're using Gold Finger) are just visual representations of the data on the left. For example, you'll see a ton of random bunch of letters like FA, 2E, 10, BD, and such.

  • To deciper these #'s, you need a table file. A Table File is basically like a translation file that translates some of these FA, DE's and other random-looking jargon into actual letters. I'm not too sure where you can get your hands on one, but if you can't find one I can upload.

  • Those random-looking combinations are actually numbers. From 00 to FF, these can represent the numbers 0 to 255. 0 can be represented by "00" and 255 can be represented by "FF". It's called a hexadecimal counting system and is called that because you count with 16 digits, not 10. For example:

    0, 1, 2, 3, 4, 5, 6, 7, 8, 9 that you are used to, as opposed to
    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

    So then, number 10 in hex system would be A.

  • Hex editing is much simpler than scripting, IMO. Scripting codes are actually hex bytes arranged in such ways. I know for a fact that Mateo's Scripting Tutorial talks about how he learned scripting from looking at hex bytes. The scripting compendium Miksy linked shows that all the scripting commands can be represented by hex digits.

  • Again, hex editing is very simple! If you wanted to change what Pokemon trainer RED had, you could change one "byte" (a single box in the hex editor) and instead get Starmie as opposed to Snorlax. Or, you could change what graphics appear on a map, what music plays on a map, what kind of lighting it shows, and all that good stuff. All by changing two letters in a game file.

* As for your script, I'm avoiding helping people with scripting as I haven't even done it in a while myself.

Thank you for your understanding. I'm taking a break from all of this for the moment, but your text gives a little hope at least. :) When I tried hex editing before when trying to edit "The legend of Zelda" i thought it would be simple. I stopped that for one reason: One person on a forum told another one to "Search for text j90j099jwef90j in the hex-editor". I tried to do that to no avail. Since my patience was zero, and it didnt find anything i quited it. Now I'm sitting here, 4 years later, trying to understand how it works again.

It would be very nice if you can upload one of those "Table Files". That could be the reason for all of my frustration. Why didnt they include it in the utility? Stupid basterds! :P

But to be short: You CAN insert new trainers into the game by using the hex editor? And u can do it by "repointing" (or whatever it's called..) from JohtoMap to that specific number(s) in Gold Finger? Am I on the right track here?

(Someone said something about "find some free space 00 00 00 00 00 00 00 and point the trainer to that space".)

Last edited by Skurbert (2012-12-17 07:52:27)

Offline

#8 2012-12-17 07:53:28

Miksy91
Member
Registered: 2010-10-16
Post 1,327/2,311

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

The reason why this set of scripting codes in that picture work is because you can write script data of type 00 (0 in Type box) with PKSV. As you found out earlier, the Type byte for each trainer is set to 02 (2 in that box). Because of that reason, PKSV won't be that helpful when editing trainers, it can only edit the "last part" of their script.

As shown in that compendium I linked you,

02 = Trainer: scriptpointer points to this structure:

[Bit no. (2byte)][Trainer Group][Trainer Number][2byte pointer to Text when seen][2byte pointer to text when trainer beaten][2byte pointer to script when lost (0000=Blackout)][2byte pointer to script if won/talked to again]

This whole structure is formed with bytes and it would make no sense trying to decompile this set of bytes with PKSV, all you can see is "garbage" if you do that. However, how this byte structure works is actually quite simple!

The first two bytes represent the Bit Number/Flag of this trainer. Basically, this is used to store data (0 = "still fightable", 1 = "already beaten") while playing the game whether you can challenge this trainer or not. When the trainer is beaten, this bit (bits can be 0 or 1) is changed to 1 and the trainer cannot be challenged again.
The next two bytes, Trainer Group and Trainer Number, define the class of this trainer and if Trainer Number is set to 06 for instance, the data of 6th trainer in this Trainer Group (or class) is loaded. The data that is loaded consists basically of the name of the trainer and its pokemon data.

The following 4 bytes are "text pointers". These are used for loading the text data displayed when the trainer challenges you and when you beat him after the battle (but before price money is given). The next two bytes are somewhat "unused" data because after losing to any trainer during the gameplay, a "blackout" occurs and sends you in front of the last Pokecenter you've been. But these are just set to 00 00 for every trainer, no particular reason why (or actually there is but the stuff is kinda complicated here so I won't bother explaining, and yet I'm not even sure if my assumption about that is true).
And after all these bytes is a Script Pointer. This thing here actually leads to a normal script of Type 0 and you could open it properly with PKSV if you wanted to. The script data is normally like this:

talkaftercancel
loadfont
2writetext @text
closetext
loadmovesprites
end

@text
I was no match for you...

talkaftercancel is a script code that is used for making the trainer not talk to you after he is defeated. If he is talked to by the player, this command "does nothing". And the rest of the script data looks pretty much the same as the first script example in that pokecommunity tutorial.


Skurbert wrote:

It would be very nice if you can upload one of those "Table Files". That could be the reason for all of my frustration. Why didnt they include it in the utility? Stupid basterds! :P

This is because the table file for every game can be different (or normally is). Pokemon RBY and GSC share mostly the one and same table file though.

Skurbert wrote:

But to be short: You CAN insert new trainers into the game by using the hex editor? And u can do it by "repointing" (or whatever it's called..) from JohtoMap to that specific number(s) in Gold Finger? Am I on the right track here?

(Someone said something about "find some free space 00 00 00 00 00 00 00 and point the trainer to that space".)

Yes you can.
The only thing making the stuff a bit difficult is understanding how to use right Bit Numbers/Flags for the trainer because most of the possible ones are already used. But if you're not going to aim for doing anything else but adding new trainers, you can use unused part of RAM (DEC0-DEFF) for this. I can help you out with that later, won't be difficult at all :)

Last edited by Miksy91 (2012-12-17 08:03:01)

Offline

#9 2012-12-17 08:45:10

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 2,038/3,474

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Skurbert wrote:
Mateo wrote:

Helpfull text

Oh, that makes sense. Thank you for that answer!

Sadly I'm exhausted at the moment and VERY confused. I'm jumping from thread to thread trying to figure out what to do, trying to read guides and tutorials, but atm everything is just a mess and numbers  everywhere and I dont understand anything at all. What I do understand is that a scripting text is telling what to do in an event. Which one can code through the PKSV scripting utility. Its a shame that you say now that PKSV don't work for this. Is that correct? Let me hear you say it: "YOU CANT USE PKSV TO ADD NEW TRAINERS!". Because if that's true then it would go straight down the recycle bin and I will never more bother with it.

Hex-editing is not my thing simply because I dont understand it at all. For example: I only manage to see "##############" everywhere in "Gold Finger", no numbers whatsoever. So I give up on hex editing. Did u see my thread I started before? I have som serious trouble with this.

I only want to add new trainers. I don't want to create a new game, I don't want to be a "SUPERHACKER", I want to complete the game called "Pokemon Silver" in the sense that you can face many more trainers in the game. And I'm a complete noob on both scripting and hex-editing. That's why I love utilities like these because they make it less frustrating for idiots like me to edit the game to one's liking.

Thank you very much for this utility. And thank you for "MartEd", "Wild Pokemon editor", etc.

You can add trainers with PKSV, but you would have to talk to them to battle them, they wouldn't be able to "See" you on the map, if my memory is correct.

An example of a trainer you have to talk to in order to battle:

#org 0x11D780
'-----------------------------------
faceplayer
loadfont
2writetext 0x57B0 ' 0x11D7B0
closetext
loadmovesprites
winlosstext 0x57F3 0x582E ' 0x11D7F3,0x11D82E
loadtrainer 0xA 0x1
startbattle
returnafterbattle
loadfont
2writetext 0x5853 ' 0x11D853
closetext
loadmovesprites
special 0x2F
special 0x32
disappear 0x2
setbit1 0x691
pause 0xF
special 0x31
pause 0x1E
special 0x1B
refreshscreen 0x0
credits
end


#org 0x11D7B0
= Looks like I can't\nget to BRICK TOWN\pbecause of all the\nboulders.\e


#org 0x11D7F3
= If I had a MIST\nSTONE to use, I\pprobably would\nhave won!\e


#org 0x11D82E
= Well, that's how\nit goes sometimes.\e


#org 0x11D853
= The journey is\nnever really over.\pAlways new places\nto explore!\e

That code came from where you battle Leaf in Pokémon Christmas, so it does a few extra things you wouldn't have to do for a normal trainer. For example, she goes away after the battle and a normal trainer would stay there. I could come up with an example script tomorrow that doesn't do anything fancy. But you would still have to use a hex editor at some point just to find free space to add your new trainer scripts at.

Also, going by your post, you are making a very simple mistake when looking at Goldfinger and that is confusing you.

18295210.png

The side with all of the "######"s is the side where it would show the text if you had a table file loaded. The side on the left with values like FC C3 00 01 etc. are the actual hex values we talk about editing. To find free space to insert a script, like we were talking about, you would select Edit -> Goto from the menu at the top, and type in the offset where the event data started for that map. Then you would scroll down until you find a long run of 00 bytes. That would look something like this:

gf2.png

Then you would find the pointer for that offset either by manually calculating it or using a pointer calculator program (you'll want to use a pointer calculator). When you know the pointer, you can tell your event to load from there. Then you could use PKSV to put your new script at that offset and go to town. I'll explain that a little more when I post a script that would just be a "normal" trainer.

I know this sounds complicated, but it doesn't take very long at all once you've done it the first time and know what you're doing.



EDIT: Side note about Miksy's comment: I usually don't put the talkaftercancel command in my custom trainers, but that's just because I want to make sure people read the text if I took the time to write it. Haha!

Last edited by Mateo (2012-12-17 08:47:43)

Offline

#10 2012-12-17 09:04:07

Skurbert
Member
Registered: 2012-12-16
Post 8/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Thank you all for all your help so far. I'm starting to get a hang of this now. I'm gonna take some time and read what you have written again, later on, and really try to start editing again. Also, again, thank you Mateo for that piece of code, splendid! I will try it out. If you could post another code later that would also be very appreciated. Those screenshots above with "###" everywhere: That's EXACTLY what it look like.

Now there's much information for me to take in, but I guess I have to do my homework, lol. kkj1116, I used that "table" and reopened "Gold Finger" but it still looks kinda weird. There are text, but the letters are very random and in different colors like purple/yellow and white. I will post a screenshot later. Could the reason for it to be that it's IPS-patched? (I used a IPS-hack as a base, because the guy who had done it added so you can fight the legendary birds and catch all pokemons, etc.). Maybe I can't Hex-edit it now because I have used IPS on it? Might be wrong.

Miksy91: That piece of code is a great example of what confuses me. Where do i find it? How do I change it and how do i add one of my own? But that makes sense to me, it points to something that tells it what to do, like level of pokemon, trainer name, etc. Right?

"02 = Trainer: scriptpointer points to this structure:

[Bit no. (2byte)][Trainer Group][Trainer Number][2byte pointer to Text when seen][2byte pointer to text when trainer beaten][2byte pointer to script when lost (0000=Blackout)][2byte pointer to script if won/talked to again]" Tha

Offline

#11 2012-12-17 11:59:33

Skurbert
Member
Registered: 2012-12-16
Post 9/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

I made some progress:

* I figured out a way to place items on the map. Yay! I can now fill both Kanto and Johto with stuff. I didnt even needed to touch the script. Very easy, for once! However, seems like copy/paste invisible items (signs) freezes the game. Gotta take some look into that.

* The code Mateo showed us was VERY glitchy, BUT, I was thrown into battle against a trainer named "????" which had a pokemon with a close resemble to MissingNo. I can't say it was beautiful. The only move it could do was "struggle". I tried to fight it down, but then it FLEED! Then the game freezed. When I looked at the script again in "Johto Map" it had reseted some lines like the letters in blue (like "faceplayer") and the lines at the bottom ("Looks like I can't\nget to BRICK TOWN\pbecause of all the\nboulders.\e", etc.) I will wait for the other code. You can trust me, I'm gonna try it out! :D

* I downloaded the "Pointer Calculator" and did (like u said):

1. Opened "Johto Map" -> ROUTE 29 -> Edit Map properties -> Event Data ------> 12A349 <-------
2. Opened Gold Finger. Did what you told me and -> Goto -> 12A349
3. Scrolled down, found a lot of empty lines -> 00 00 00 00 00
4. Clicked the first 00 on the first totally empty line -> OFFSET : 12a400
5. Opened Pointer Calculator: Writing -> 12a400 ($12a400 because you can't remove "$", i guess that's the point, just to make clear.. lol.)
6. UN-CHECKED "3 byte?" - Was that correct done?
7.  The result -> $12a400 = $0064

Is that correct? And what am I gonna do now?

Last edited by Skurbert (2012-12-17 12:01:51)

Offline

#12 2012-12-17 16:00:24

Miksy91
Member
Registered: 2010-10-16
Post 1,331/2,311

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Skurbert wrote:

Now there's much information for me to take in, but I guess I have to do my homework, lol. kkj1116, I used that "table" and reopened "Gold Finger" but it still looks kinda weird. There are text, but the letters are very random and in different colors like purple/yellow and white. I will post a screenshot later. Could the reason for it to be that it's IPS-patched? (I used a IPS-hack as a base, because the guy who had done it added so you can fight the legendary birds and catch all pokemons, etc.). Maybe I can't Hex-edit it now because I have used IPS on it? Might be wrong.

An ips-patch being applied to the rom has nothing to do with the problem. Most likely, you just have to change some settings with GoldFinger there, that's all.

Skurbert wrote:

Miksy91: That piece of code is a great example of what confuses me. Where do i find it? How do I change it and how do i add one of my own? But that makes sense to me, it points to something that tells it what to do, like level of pokemon, trainer name, etc. Right?

"02 = Trainer: scriptpointer points to this structure:

[Bit no. (2byte)][Trainer Group][Trainer Number][2byte pointer to Text when seen][2byte pointer to text when trainer beaten][2byte pointer to script when lost (0000=Blackout)][2byte pointer to script if won/talked to again]" Tha

As explained with the type bytes, the script pointer of every person event using Type 02 (or 2 like Johtomap displays it) should point to this kind of a structure for the script (or "trainer battle") to be displayed properly in game.

For reference, Mateo made an example of how to make a "trainer battle script" gym leaders use. He showed there that trainers can be also loaded with scripts of Type 00 (0) and the script pointer of person events using this Type points to "normal" script data. But the main problem with this format is the fact none of the trainers will challenge you unless they're talked to (while normal trainers can see, and come to you).

But back to scripts of Type 02. To find this sort of a code for every trainer in the game, you have to calculate the script data by using the script pointer Johtomap shows in the "Script" box there. And beneath the box Johtomap actually shows where the script data is located (because it's programmed to calculate the offsets with the pointers).
So for any existing trainer out there, you can edit their script data simply by opening up the offset Johtomap shows under the "Script" box with a hex editor.

To be able to add a new trainer to any existing map, you have to find blank space (00 00 00 00...) in the same rom bank where the Event Data is located (there should be a tutorial explaining how this is done somewhere), repoint the Event Data there, and add a new person event in the end of the data (make sure you remember to add 1 to the value defining how many person events there are in this map). Next, you have to choose where you're going to add the script of this new person event (close by to the Event Data is just fine, even to the next 00 following it). Now, calculate the pointer to this offset you chose to write the script data of this person and change that new person event's script pointer to point to this offset.
Finally, you have to write the data to this trainer accordingly to how scripts of Type 02 work.

Try working this out by for example creating a new trainer, using its Bit Number as 07 00, Trainer Group as 11 and Trainer Number as 01. You should run into fighting Brock if everything goes according to the plan. For the 2-byte pointers to text data there, you could for example use the values of any other trainer in this same map and that way, this person event (using Brock's trainer data) would display all the text data that person does.


Mateo wrote:

EDIT: Side note about Miksy's comment: I usually don't put the talkaftercancel command in my custom trainers, but that's just because I want to make sure people read the text if I took the time to write it. Haha!

I was thinking of making no trainer have that command in their scripts at first too but most of the new trainers simply say nothing important so they do have that command in their scripts. However, when I actually want to execute something after a battle or make the battled trainer give the player useful information, they do talk after the battle and the trainers itself are often unavoidable as well.

Last edited by Miksy91 (2012-12-17 16:09:32)

Offline

#13 2012-12-17 20:23:15

Mateo
Member
From: The Sims 4
Registered: 2009-11-25
Post 2,039/3,474

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Skurbert wrote:

* The code Mateo showed us was VERY glitchy, BUT, I was thrown into battle against a trainer named "????" which had a pokemon with a close resemble to MissingNo. I can't say it was beautiful. The only move it could do was "struggle". I tried to fight it down, but then it FLEED! Then the game freezed. When I looked at the script again in "Johto Map" it had reseted some lines like the letters in blue (like "faceplayer") and the lines at the bottom ("Looks like I can't\nget to BRICK TOWN\pbecause of all the\nboulders.\e", etc.) I will wait for the other code. You can trust me, I'm gonna try it out! :D

Miksy91 wrote:

For reference, Mateo made an example of how to make a "trainer battle script" gym leaders use. He showed there that trainers can be also loaded with scripts of Type 00 (0) and the script pointer of person events using this Type points to "normal" script data. But the main problem with this format is the fact none of the trainers will challenge you unless they're talked to (while normal trainers can see, and come to you).

In addition to what Miksy91 said, if you inserted everything in the offsets those were listed at, it would only work if it was called from that same rom bank. Also, if you do get it working, it will start a battle with Prof Oak in a rom that isn't Pokemon Christmas (actually it will look like Oak, and load Will's data. The reason it loads Leaf in Christmas is because I repointed trainer data and changed the unused Oak trainer class).


EDIT: Wow, sorry, I just realized that I got distracted today and never put up another sample script like I was going to. I'll get one up soon though.

Last edited by Mateo (2012-12-18 08:06:39)

Offline

#14 2012-12-19 06:20:52

Skurbert
Member
Registered: 2012-12-16
Post 10/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

I'm still alive! And I havent given up just yet! At the moment I'm trying to get a better understanding of the Hex-Editor. One thing I don't really get is the "Rom Bank". "In the same rom bank" What do you mean with that and how do I know it is the same "Rom Bank"? Just a quick and simple explanation of that would be to very good help.

"EDIT CURRENT TABLE". ONE table is a pair of numbers like "00", "FF", Right? Is trainer information stored in ONE or is it stored in SEVERAL "Tables"? For example, If I click a trainer in "Johto Map" and the Script is "D780", that would point it to "0x131780". But I don't want to point it there since that is user by another trainer.. another info.. or whatever. So What I do Is using the closest free space "00 00 00 00". OFFSET NR 12a400 in GoldFinger is a freespace (like 40+ lines ) and gives the number "$0064" by the calculator. Am I gonna fill the space here with hexnumbers? Am I making any sense whatsoever? :D Because you told me to "tell the event to load from there".

Because I have to do SOMETHING right when I'm actually facing a trainer. It is glitchy. It is named "???" but at least I'm facing some sort of trainer (even if it fleed. lol). But for the moment I see numbers numbers numbers everywhere and it's like a large djungle were you don't have a clue what to do or which direction to take. My solution to this was to flatten the hole Djungle. So I will be a pain in the a** and ask a lot of questions, and that is the only way for me to learn. I hope you guys dont get too mad, because I'm learning small bits at the time.

Last edited by Skurbert (2012-12-19 06:31:40)

Offline

#15 2012-12-19 06:40:20

Skurbert
Member
Registered: 2012-12-16
Post 11/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

kkj1116 wrote:

I wrote a little section about banks on the Global FAQ thing, and I'm wondering if it's any helpful. Be my guinea pig please?

To be more direct however: ROM banks divide up the rom in x4000 number of bytes. This means that there are 16384 bytes in each ROM bank.

I'm not sure if you're referring to the Table File option in Gold Finger or data tables. Table files simply contain a translation-like code for the user to see text data.
The second describes an array of pointers (usually). So, for example, a trainer table would list all the pointers to individual trainer data, and you could repoint a specific pointer and put the new individual trainer data in a blank space.

As for your example I'm not too sure if you necessarily use the closest free space. Some pointers, that are two bytes long, point within a bank (so it is limited). Some pointers are three bytes long, and that extra byte defines an outside bank it can point to. If a pointer in bank 2 pointed to a space, it points to a different part in bank 2. If it has a byte to point to bank 4, then it points to a space outside of bank 2, some part in bank 4.

You don't have to fill up blank spaces with any hex numbers! As long as you repoint correctly, any empty or 00'd out space in the bank should do.

I actually don't know if I'm making any sense.


Well, what I refering to was: Gold Finger - > OPTIONS -> Edit Current Table
And then something called "Table Editor" shows up. I don't know what's it for but I guess I'm gonna need it later on in some way.

Ah! So I DONT have to fill with hex-numbers. Phew. That was a relief. But at the same time I wonder: Why not? Shouldnt the game have some information for the trainer? (Start pokemon, levels, trainernamne, etc). Remember that I just took the first empty space I could find. I have not told the game these informations (Because I don't know how!) So for example, If I want to face "Bugcatcher, Cooltrainer", etc. Then how do I tell the game to do it?

I didnt flatten the jungle in the HEX-EDITOR hehe! :D I was flatten it in my brain.

BTW: I must have done something wrong again because when i put (In JohtoMap):
"0064" in the box "Script" it reverts to "64" and the text writes "Script Location: 0x64". Is that really correct?
Offset in GoldFinger: $12a400
Pointer: $0064 (Calculated through Point Calculator)

EDIT: PICTURE:

bvQvs.png

Last edited by Skurbert (2012-12-19 07:02:22)

Offline

#16 2012-12-19 07:33:15

Miksy91
Member
Registered: 2010-10-16
Post 1,337/2,311

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

To make more sense to what kkkj1116 said before,

Actually, it's possible that one game could be using several different one-byte (all values from 00 to FF, two byte would be all from 0000 to FFFF) table files for different things. These pokemon games don't do that though so you don't worry about that, you can use the one and same table file for everything.
As a reference, I made a small hack of DBZ Buu's Fury in the past and it used both ASCII code, and a in-game table file for displaying text.

Skurbert wrote:

If I click a trainer in "Johto Map" and the Script is "D780", that would point it to "0x131780".

You actually wrote this wrongly here because D780 points to $D780 in RAM. 5780 (Johtomap form, would be written as 80 57 in rom) would point to 0x131780.

But to rest of the stuff...

Skurbert wrote:

So What I do Is using the closest free space "00 00 00 00". OFFSET NR 12a400 in GoldFinger is a freespace (like 40+ lines ) and gives the number "$0064" by the calculator. Am I gonna fill the space here with hexnumbers? Am I making any sense whatsoever? :D Because you told me to "tell the event to load from there".

Yeah, that's what you gotta do. But you can actually start replacing those 00's in the part where the actual code in that rom banks ends, let's say, already at the 5th 00 after all the other code. (01 97 04 00 00 00 00 (and you can write your own hex code here)).
Basically, it's not a bad thing you leave plenty of free space before your own code but just personally, I like creating everything as rationally as possible and not write data in random places.

Skurbert wrote:

[Well, what I refering to was: Gold Finger - > OPTIONS -> Edit Current Table
And then something called "Table Editor" shows up. I don't know what's it for but I guess I'm gonna need it later on in some way.

That there is just a menu showing what the table file is used for, it's simply a "replacement" for Notepad which you can use for editing table files easily.

Skurbert wrote:

Ah! So I DONT have to fill with hex-numbers. Phew. That was a relief. But at the same time I wonder: Why not? Shouldnt the game have some information for the trainer? (Start pokemon, levels, trainernamne, etc). Remember that I just took the first empty space I could find. I have not told the game these informations (Because I don't know how!) So for example, If I want to face "Bugcatcher, Cooltrainer", etc. Then how do I tell the game to do it?

You repoint the script data of a person event using its script Type as 2 to free space and write its script data there. [Trainer Group] is the byte that determines
which trainer class the trainer you encounter will be of. And [Trainer Number] then again tells which trainer you're going to face from that [Trainer Group].

Skurbert wrote:

BTW: I must have done something wrong again because when i put (In JohtoMap):
"0064" in the box "Script" it reverts to "64" and the text writes "Script Location: 0x64". Is that really correct?
Offset in GoldFinger: $12a400
Pointer: $0064 (Calculated through Point Calculator)

EDIT: PICTURE:

http://i.imgur.com/bvQvs.png

Yes, that's correct. No it's not.
This is how you'd do it manually:

1) Find the start of the rom bank

Because the offset you're repointing to is at 0x12A400, the start of this rom bank is at 0x128000.
This is because every rom bank is a list of 0x4000 bytes starting at:
$0000, $4000, $8000, $C000, ..., $120000, $124000, $128000, $12C000, ... (and 80 < A4 < C0)

2) Find the pointer

It is so that 00 40 (4000 in Johtomap form) points to start of a rom bank, in this case 0x128000.
If you want to point to 0x12A400, you've to increase that pointer (00 40) by the difference of these two.

0x12A400 - 0x128000 = 0x2400 --> 24 00

Rotate those two around --> 00 24

And this is what you add to 00 40 --> "00 40 + 00 24 = 00 64"
And this 00 64 here is 6400 in Johtomap form.

Last edited by Miksy91 (2012-12-19 07:42:05)

Offline

#17 2012-12-19 08:33:02

Skurbert
Member
Registered: 2012-12-16
Post 12/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Miksy91 wrote:

Yeah, that's what you gotta do. But you can actually start replacing those 00's in the part where the actual code in that rom banks ends, let's say, already at the 5th 00 after all the other code. (01 97 04 00 00 00 00 (and you can write your own hex code here)).
Basically, it's not a bad thing you leave plenty of free space before your own code but just personally, I like creating everything as rationally as possible and not write data in random places.

Alright, I get it. Nice to know I'm doing something right! :D I will write it more tighter later, but as for now when I'm still learning, I will do it this way.

Miksy91 wrote:

That there is just a menu showing what the table file is used for

Alright, then I won't bother with that.

Miksy91 wrote:

And this is what you add to 00 40 --> "00 40 + 00 24 = 00 64"
And this 00 64 here is 6400 in Johtomap form.

Wow, It works! Thanks! :D

Miksy91 wrote:

You repoint the script data of a person event using its script Type as 2 to free space and write its script data there. [Trainer Group] is the byte that determines
which trainer class the trainer you encounter will be of. And [Trainer Number] then again tells which trainer you're going to face from that [Trainer Group].

Hmm. Ok. And I'm doing this in Gold Finger, right? Could you write an example code? Like, cooltrainer? I just want to try it out and see if it works.

This is how it looks for me:

S23Vf.png

Last edited by Skurbert (2012-12-19 08:43:55)

Offline

#18 2012-12-19 10:15:48

Miksy91
Member
Registered: 2010-10-16
Post 1,338/2,311

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

The trainer group of Cooltrainer (M) is 1B.
You can use any trainer number you like so let's for example use 02 for that.

The first trainer of list "Cooltrainer" is at 0x3A0DF (and is called "NICK"). This is what the trainer data of "NICK" is like. It starts with its name, has some stuff there and ends with "FF" (displayed as 9 with the table file). After this FF, is the trainer data of the second trainer of this trainer group (or the one with Trainer Number 02), AARON.

So let's make it so you'll battle AARON when talking to this guy here.
Let's set the Bit Number to 07 00 leading to an effect, the guy can be challenged again every time you return to the map (affecting nothing unwanted in ram).

So this way, the script data has to start with 07 00 1B 02 (like stated with, how Type 02 works). The next four bytes are 2-byte script pointers to text.
Let's put this guy's text it offsets 0x12A415 and 0x12A425.

$12A415
00 80 7F A1 A0 B3 B3 AB A4 F4 7F B8 A4 B2 E6 57

$12A425
00 8C B8 7F 54 8C 8E 8D 7F A5 AE B4 A6 A7 B3 4F B6 A4 AB AB E8 57

And by looking for the pointers leading to these offsets, you should get 15 64 and 25 64 (this way you'll have to write them in rom, and this is also how Johtomap stores them). And after these, you'll write to 00 00. After the 00 00, you'll have to input the pointer to the script loaded after the battle, let's just make it so the script data for this starts straight after all this other stuff (00 00 "Pointer"). That way, the pointer has to be set to 0C 64.

And in 0C 64 you can either write the data with PKSV for with a hex editor, I'll just show a simple way of ending the script in hex:

65 47 4C XX YY 53 49 90

This thing here is in byte form what I wrote earlier:

talkaftercancel (65)
loadfont (47)
2writetext @text (4C XX YY)
closetext (53)
loadmovesprites (49)
end (90)

@text
I was no match for you...

Let's just write that text string "I was no match for you..." in offset 0x12A43B, straight behind "My POKEMON fought well." string.
So in here you'll simply write:

$12A43B
00 88 7F B6 A0 B2 7F AD AE 7F AC A0 B3 A2 A7 4F A5 AE B1 7F B8 AE B4 75 57

And instead of XX YY, set the pointer to 3B 64.

And finally what it should look like in rom:

nimetnsu.png

Last edited by Miksy91 (2012-12-19 10:17:12)

Offline

#19 2012-12-19 11:10:59

Skurbert
Member
Registered: 2012-12-16
Post 13/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Miksy91 wrote:

Helpful text..

I did everything you said and pointed in all the text in the Hex-Editor. Seems like copy/paste doesnt work in the hex-editors so I painstakingly changed every bite, one-by-one and now I'm finaly finished.

This is how the text/script looks at the moment, i changed it many times to get it work, but i seem to write something wrong yet again:

#org 0x12A40C
'-----------------------------------

talkaftercancel
loadfont
2writetext @text
closetext
loadmovesprites
end

@text
I was no match for you...

This is how it looked by default after hex-editing:

#org 0x12A400
'-----------------------------------
if != 0x0 0x21B ' 0xFFFFFFFF
loadvar 0x64
givecoins 0x64
2call 0x640C ' 0x12A40C
talkaftercancel
loadfont
2writetext 0x5364 ' 0x129364
loadmovesprites
end

#org 0x12A40C
'-----------------------------------
talkaftercancel
loadfont
2writetext 0x5364 ' 0x129364
loadmovesprites
end


#org 0x129364
#raw 0xAC
#raw 0x7F
#raw 0xB3
#raw 0xA7
#raw 0xA4
#raw 0x7F
#raw 0xB2
#raw 0xA4
#raw 0xA2
#raw 0xAE
#raw 0xAD
#raw 0xA3
#raw 0x7F
#raw 0xAE
#raw 0xA5
#raw 0x4F
#raw 0xB2
#raw 0xA4
#raw 0xB5
#raw 0xA4
#raw 0xAD
#raw 0x7F
#raw 0xA2
#raw 0xA7
#raw 0xA8
#raw 0xAB
#raw 0xA3
#raw 0xB1
#raw 0xA4
#raw 0xAD
#raw 0xE8
#raw 0x57
= TUSCANY: Today is\nnot Tuesday. That\lis unfortunate[.]\e



Can you please write the hole text the way it should look like because I just can't get it to work. The Trainer shows the question mark and then the game freezes/restarts before he has a chance to say something.

Thank you!

Last edited by Skurbert (2012-12-19 11:13:58)

Offline

#20 2012-12-19 11:33:07

Miksy91
Member
Registered: 2010-10-16
Post 1,339/2,311

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

You'll have to adjust the text pointers to point to "00" like I've done in that example.
Text data (for "normal text") starts with 00 and ends with 57.

Also at the way the script currently ends, it should freeze just after loading font to ram. "2writetext 0x5364" is displaying nonsense (not pointing to 00) as you can see by opening offset 0x129364 with a hex editor. On the other hand, this here is looking just like it should:

#org 0x12A400
'-----------------------------------
if != 0x0 0x21B ' 0xFFFFFFFF (translates to: 07 00 1B 02)
loadvar 0x64 (translates to 15 64)
givecoins 0x64 (translates to 25 64 00)
2call 0x640C ' 0x12A40C (translates to 00 0C 64)

--> 07 00 1B 02 15 64 25 64 00 00 0C 64

Last edited by Miksy91 (2012-12-19 11:35:47)

Offline

#21 2012-12-19 11:55:03

Skurbert
Member
Registered: 2012-12-16
Post 14/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Miksy91 wrote:

You'll have to adjust the text pointers to point to "00" like I've done in that example.
Text data (for "normal text") starts with 00 and ends with 57.

Also at the way the script currently ends, it should freeze just after loading font to ram. "2writetext 0x5364" is displaying nonsense (not pointing to 00) as you can see by opening offset 0x129364 with a hex editor. On the other hand, this here is looking just like it should:

#org 0x12A400
'-----------------------------------
if != 0x0 0x21B ' 0xFFFFFFFF (translates to: 07 00 1B 02)
loadvar 0x64 (translates to 15 64)
givecoins 0x64 (translates to 25 64 00)
2call 0x640C ' 0x12A40C (translates to 00 0C 64)

--> 07 00 1B 02 15 64 25 64 00 00 0C 64

Thanks! That code/line is exactly as in the hex-editor. But everytime i try to change the script through PKSV it reverts back to the ugly unworking script before. (I'm using the "Decompile Script"-button). For example: This one:

#org 0x129364
#raw 0xAC
#raw 0x7F
#raw 0xB3
#raw 0xA7
#raw 0xA4
#raw 0x7F
#raw 0xB2
#raw 0xA4
#raw 0xA2
#raw 0xAE
#raw 0xAD
#raw 0xA3
#raw 0x7F
#raw 0xAE
#raw 0xA5
#raw 0x4F
#raw 0xB2
#raw 0xA4
#raw 0xB5
#raw 0xA4
#raw 0xAD
#raw 0x7F
#raw 0xA2
#raw 0xA7
#raw 0xA8
#raw 0xAB
#raw 0xA3
#raw 0xB1
#raw 0xA4
#raw 0xAD
#raw 0xE8
#raw 0x57
= TUSCANY: Today is\nnot Tuesday. That\lis unfortunate[.]\e

You want to see another screenshot?

Offline

#22 2012-12-19 11:59:26

Miksy91
Member
Registered: 2010-10-16
Post 1,342/2,311

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

You shouldn't be editing the trainer's script with PKSV in the first place.
You may only do that for the latter part of it, starting at $12A40C but as in this case we're not trying to do anything complicated, a hex editor is all you really need.

What you've got there wrong are the text pointers. Write those text strings in the rom offsets I described there, make the pointers point to them (with those offsets, 15 64 and 25 64) work and everything should work fine until the battle ends. After the end of the battle, you still need to have the script loaded after the battle right (at $12A40C).

Last edited by Miksy91 (2012-12-19 11:59:39)

Offline

#23 2012-12-19 12:09:27

Skurbert
Member
Registered: 2012-12-16
Post 15/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Miksy91 wrote:

You shouldn't be editing the trainer's script with PKSV in the first place.
You may only do that for the latter part of it, starting at $12A40C but as in this case we're not trying to do anything complicated, a hex editor is all you really need.

What you've got there wrong are the text pointers. Write those text strings in the rom offsets I described there, make the pointers point to them (with those offsets, 15 64 and 25 64) work and everything should work fine until the battle ends. After the end of the battle, you still need to have the script loaded after the battle right (at $12A40C).

Hmm.. I'm really confused at the moment. Overload, lol!

But havent I already done it? Or have I missunderstood this completely? Take a look:

TN123.png

Compared:

nimetnsu.png

Maybe I was right about the table doesnt show it up propely.

Last edited by Skurbert (2012-12-19 12:21:06)

Offline

#24 2012-12-19 13:08:04

Miksy91
Member
Registered: 2010-10-16
Post 1,343/2,311

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

No, you've written your code wrong there. The problem with the picture of mine is that it doesn't show one "row" on the right...

Now your final text pointer is set to 64 53 instead of 3B 64 like I showed in my example (the byte 3B is actually the one you can't see in that picture because it's hidden in that not-shown row).

And just for the same reason, the text doesn't look right in your picture either;
fught <--> fought, ws <--> was

And again for the same reason, the first two text data pointers don't point to the text data because the two text datas in your picture start at $12A414 and $12A423 (instead of $12A415 and $12A425).

Last edited by Miksy91 (2012-12-19 13:11:02)

Offline

#25 2012-12-19 13:21:16

Skurbert
Member
Registered: 2012-12-16
Post 16/95

Re: Create new trainers? [And other scripts] // updated: [2013-01-24]

Miksy91 wrote:

No, you've written your code wrong there. The problem with the picture of mine is that it doesn't show one "row" on the right.
Now your final text pointer is set to 64 53 instead of 3B 64 like I showed in my example (the byte 3B is actually the one you can't see in that picture because it's hidden in that not-shown row).

And just for the same reason, the text doesn't look right in your picture either;
fught <--> fought, ws <--> was

And again for the same reason, the first two text data pointers don't point to the text data because the two text datas in your picture start at $12A414 and $12A423 (instead of $12A415 and $12A425).

Oh, I missed that totally.

Über-fail then! Because I looked at your picture and then wrote it exactly like it was shown on your picture. Darn it! Now I have to start it all over from the beginning! Jippie! :D

Still I'm getting paranoid about the fact that yours is showing Blue "/" while mine is showing Cyan "##"'s everywhere. Maybe I shouldn't worry too much.

If you want to post another screenshot that shows all the numbers I will try and redo it all.

Offline

  • Index
  • → Help/Question
  • → Create new trainers? [And other scripts] // updated: [2013-01-24]

Board footer

Powered by FluxBB