Melanogaster Posted September 20, 2014 Posted September 20, 2014 I tried to make an NPC that gives you a Tyrogue if you talk with him, the problem is I can't find a tutorial for this or any instructions for this specific type of script. I've looked into what NPCs in the game give you a pokemon, I found Amanita gives an Eevee, located her in Castelia City and found out she uses Script 988. I tried to look into script 988 but couldn't make out much of it. In the header it says there are 5 scripts, which is consistent with what NPRE says, but that's it, as NPRE shows 5 scripts and 28 function which I don't know what they do, and I can't pinpoint the exact part of the script responsible with giving the player a pokemon, as NPRE says it's Function 13 (I think?). It's one of the pictures. Meanwhile running scrparse.lua in desmume says there are 22 scripts in script file 988, as in one of the pictures. Can anyone help me? I really don't know what to make of this.
Melanogaster Posted September 20, 2014 Author Posted September 20, 2014 I've decided to try to find the script used to give off the Deerling on the route 6 weather institute. But I've got a few questions that maybe someone can answer as there's a problem I can't understand. In the overworld I'm trying to add the NPC, the NPCs already there have scripts assigned to them that have erratic numbers, instead of being assigned lower numbers like 08 00, 02 00 etc. they have numbers like 5A 1B or D0 07 as the number of their script. But in the script file for that overworld there are only 10 scripts, getting to that number seems irrational, does anyone know what this means?
Kaphotics Posted September 20, 2014 Posted September 20, 2014 That'd be calling another script in another script file. 0x1B5A = 7002 0x07D0 = 2000
Melanogaster Posted September 20, 2014 Author Posted September 20, 2014 That'd be calling another script in another script file.0x1B5A = 7002 0x07D0 = 2000 Does this mean that if I give my NPC the script number 0B 00, as there's 10 addresses in the header of the script file, it should execute normally (After I add the script and edit the header to accommodate the increase of course)?
Kaphotics Posted September 20, 2014 Posted September 20, 2014 Does this mean that if I give my NPC the script number 0B 00, as there's 10 addresses in the header of the script file, it should execute normally (After I add the script and edit the header to accommodate the increase of course)? Correct. The script number an overworld will use is then used with the Script's Header to start execution at the desired offset. OW Script# -> fetch Script File (for map/zone) if < 255, else load external (undocumented, really) Script File Header -> get offset of Script# -> start new script @ offset.
Melanogaster Posted September 21, 2014 Author Posted September 21, 2014 The script works ingame, it give the player the Deerling. But there are 2 problems I'm not sure how to fix, the first being why am I asked 2 times instead of just once like the original NPC does, and the second is the NPC will give me Deerlings ad Infinitum. This is the code I've taken from that NPC and am using on the current NPC: 2F 00 02 00 2E 00 A6 00 47 05 74 00 3D 00 00 04 06 00 00 00 00 00 32 00 3E 00 30 00 2F 00 02 00 2E 00 A6 00 47 05 74 00 10 00 AA 01 08 00 00 00 11 00 01 00 1F 00 FF 45 00 00 00 3C 00 00 04 07 00 08 00 00 00 00 00 47 00 10 80 09 00 10 80 08 00 00 00 11 00 01 00 1F 00 FF 0C 00 00 00 04 00 32 00 00 00 1E 00 10 00 00 00 3C 00 00 04 0C 00 08 00 00 00 00 00 32 00 3F 00 1E 00 10 00 00 00 3C 00 00 04 0D 00 08 00 00 00 00 00 32 00 3F 00 30 00 2F 00 02 00 28 00 24 80 00 00 28 00 25 80 00 00 28 00 26 80 00 00 03 01 24 80 00 00 09 00 24 80 08 00 06 00 11 00 01 00 1F 00 FF 16 00 00 00 3C 00 00 04 0B 00 08 00 00 00 00 00 32 00 3F 00 1E 00 14 01 00 00 3C 00 00 04 08 00 08 00 00 00 00 00 3F 00 D2 00 25 80 09 00 25 80 08 00 00 00 11 00 01 00 1F 00 FF 1A 00 00 00 0E 01 10 80 49 02 00 00 1E 00 03 00 02 00 00 00 00 00 04 00 1E 00 81 00 00 00 09 00 25 80 08 00 01 00 11 00 01 00 1F 00 FF 1A 00 00 00 0E 01 10 80 49 02 01 00 1E 00 03 00 02 00 00 00 00 00 04 00 1E 00 54 00 00 00 09 00 25 80 08 00 02 00 11 00 01 00 1F 00 FF 1A 00 00 00 0E 01 10 80 49 02 02 00 1E 00 03 00 02 00 00 00 00 00 04 00 1E 00 27 00 00 00 09 00 25 80 08 00 03 00 11 00 01 00 1F 00 FF 14 00 00 00 0E 01 10 80 49 02 03 00 1E 00 03 00 02 00 00 00 00 00 04 00 4C 00 00 A9 00 18 05 34 00 09 00 00 00 AA 00 4B 00 34 00 0A 00 00 00 47 00 10 80 09 00 10 80 08 00 00 00 11 00 01 00 1F 00 FF 10 00 00 00 3F 00 05 01 26 80 24 80 01 00 1E 00 02 00 00 00 3F 00 3C 00 00 04 And this is what I've tried to decipher from the code, can anyone tell me if I did it wrong? It's just that some parts make no sense. 2F 00 - Unlock All 02 00 - (????) 2E 00 - Lock All A6 00 47 05 - Play Sound Clink 74 00 - Face Player 3D 00 00 04 06 00 00 00 00 00 - Text Message 32 00 - Wait Button (?) 3E 00 - Close Message Key Press (?) 30 00 - Wait Moment (?) 2F 00 - Unlock All 02 00 - (????) 2E 00 - Lock All A6 00 47 05 - Play Sound Clink 74 00 - Face Player 10 00 AA 01 - Store Flag (?) 08 00 00 00 - Compare to (it's empty, is it wrong (?)) 11 00 01 00 - Condition (?) 1F 00 FF 45 00 00 00 3C 00 00 04 07 00 08 00 00 00 00 00 47 00 10 80 - Yes or No 09 00 10 80 - Store Var (? stores the Yes or No?) 08 00 00 00 - Compare to (?) 11 00 01 00 - Condition (?) 1F 00 FF 0C 00 00 00 - If (?) 04 00 32 00 00 00 - Call Routine (?) 1E 00 10 00 00 00 - Jump (?) 3C 00 00 04 0C 00 08 00 00 00 00 00 - Message 32 00 - Wait Button (?) 3F 00 - Close Message Key Press 2 1E 00 10 00 00 00 - Jump (?) 3C 00 00 04 0D 00 08 00 00 00 00 00 - Message 32 00 - Wait Button 3F 00 - Close Message Keypress 30 00 - Wait Moment 2F 00 - Unlock All 02 00 28 00 24 80 00 00 28 00 25 80 00 00 28 00 26 80 00 00 03 01 24 80 00 00 09 00 24 80 08 00 06 00 11 00 01 00 1F 00 FF 16 00 00 00 - If (?) 3C 00 00 04 0B 00 08 00 00 00 00 00 - Message 32 00 - Wait Button 3F 00 - Close Message Key Press 2 1E 00 14 01 00 00 - Jump (?) 3C 00 00 04 08 00 08 00 00 00 00 00 - Message 3F 00 - Close Mesage Key Press 2 D2 00 25 80 - Store (? Store What?) 09 00 25 80 - Store Var (? Store the numbers from the function above?) 08 00 00 00 - Compare to (? To what?) 11 00 01 00 - Condition (?) 1F 00 FF 1A 00 00 - If (?) 00 0E 01 10 80 49 02 00 00 1E 00 03 00 02 00 00 00 00 00 04 00 1E 00 81 00 00 00 09 00 25 80 08 00 01 00 11 00 01 00 1F 00 FF 1A 00 00 00 0E 01 10 80 49 02 01 00 1E 00 03 00 02 00 00 00 00 00 04 00 1E 00 54 00 00 00 09 00 25 80 08 00 02 00 11 00 01 00 1F 00 FF 1A 00 00 00 0E 01 10 80 49 02 02 00 1E 00 03 00 02 00 00 00 00 00 04 00 1E 00 27 00 00 00 09 00 25 80 08 00 03 00 11 00 01 00 1F 00 FF 14 00 00 00 0E 01 10 80 49 02 03 00 1E 00 03 00 02 00 00 00 00 00 04 00 4C 00 00 A9 00 18 05 34 00 09 00 00 00 AA 00 4B 00 34 00 0A 00 00 00 47 00 10 80 - Yes or No 09 00 10 80 - Store Var (?) 08 00 00 00 - Compare to (?) 11 00 01 00 - Condition (?) 1F 00 FF 10 00 00 00 - If (?) 3F 00 - Close Message Key Press 2 05 01 26 80 24 80 01 00 1E 00 02 00 00 00 - Jump (?) 3F 00 - Close Message Key Press 2 3C 00 00 04 - Message (? Bytes are missing?)
Kaphotics Posted September 21, 2014 Posted September 21, 2014 02 00 is "EndScript" 10 00 AA 01 = CheckFlag 0x01AA 08 00 00 00 = Logical Comparison 11 00 01 00 = Value 1 1F 00 FF 45 00 00 00 = IfResult (False 0xFF = -1) then jump to 0x00000045 ... Can always try Spiky's DS Map Editor (SDSME) which should have script editing support; also my edited version of NPRE should show most of the script names (including give pokemon)
Melanogaster Posted September 22, 2014 Author Posted September 22, 2014 02 00 is "EndScript"10 00 AA 01 = CheckFlag 0x01AA 08 00 00 00 = Logical Comparison 11 00 01 00 = Value 1 1F 00 FF 45 00 00 00 = IfResult (False 0xFF = -1) then jump to 0x00000045 ... Can always try Spiky's DS Map Editor (SDSME) which should have script editing support; also my edited version of NPRE should show most of the script names (including give pokemon) My first question regards the Jump and If, is the 0x00000045 the point in the script at which it will jump, as in the 45th byte in the script? NPRE for some reason crashes when I try to view my script. I think because it's broken at the end I believe, but that's how it was in the original script so I'm not sure what's wrong. I've managed to decrypt the whole script using http://pastebin.com/raw.php?i=vrkp0SN8 , but there's some things I can't understand. For example, why is the function for give pokemon called 4 times? This is the finished decrypted script I believe: 2F 00 - Unlock All 02 00 - End 2E 00 - Lock All A6 00 47 05 - Play Sound Clink 74 00 - Face Player 3D 00 00 04 06 00 00 00 00 00 - Text Message 32 00 - Wait Button 3E 00 - Close Message Key Press 30 00 - Wait Moment 2F 00 - Unlock All 02 00 - End 2E 00 - Lock All A6 00 47 05 - Play Sound Clink 74 00 - Face Player 10 00 AA 01 - Store Flag 08 00 00 00 - Compare to 11 00 01 00 - Condition 1F 00 FF 45 00 00 00 3C 00 00 04 07 00 08 00 00 00 00 00 47 00 10 80 - Yes or No 09 00 10 80 - Store Var 08 00 00 00 - Compare to 11 00 01 00 - Condition 1F 00 FF 0C 00 00 00 - If 04 00 32 00 00 00 - Call Routine 1E 00 10 00 00 00 - Jump 3C 00 00 04 0C 00 08 00 00 00 00 00 - Message 32 00 - Wait Button 3F 00 - Close Message Key Press 2 1E 00 10 00 00 00 - Jump 3C 00 00 04 0D 00 08 00 00 00 00 00 - Message 32 00 - Wait Button 3F 00 - Close Message Keypress 30 00 - Wait Moment 2F 00 - Unlock All 02 00 - End 28 00 24 80 00 00 - Set Var Equal Var 28 00 25 80 00 00 - Set Var Equal Var 28 00 26 80 00 00 - Set Var Equal Var 03 01 24 80 00 00 - Store Party Count More 09 00 24 80 - Store Var 08 00 06 00 - Compare to 11 00 01 00 - Condition 1F 00 FF 16 00 00 00 - If 3C 00 00 04 0B 00 08 00 00 00 00 00 - Message 32 00 - Wait Button 3F 00 - Close Message Key Press 2 1E 00 14 01 00 00 - Jump 3C 00 00 04 08 00 08 00 00 00 00 00 - Message 3F 00 - Close Mesage Key Press 2 D2 00 25 80 - Store (? Store What?) 09 00 25 80 - Store Var 08 00 00 00 - Compare to 11 00 01 00 - Condition 1F 00 FF 1A 00 00 00 - If 0E 01 10 80 49 02 00 00 1E 00 03 00 02 00 00 00 00 00 04 00 - Give Pokemon 1E 00 81 00 00 00 - Jump 09 00 25 80 - Store Var 08 00 01 00 - Compare to 11 00 01 00 - Condition 1F 00 FF 1A 00 00 00 - If 0E 01 10 80 49 02 01 00 1E 00 03 00 02 00 00 00 00 00 04 00 - Give Pokemon 1E 00 54 00 00 00 - Jump 09 00 25 80 - Store Var 08 00 02 00 - Compare to 11 00 01 00 - Condition 1F 00 FF 1A 00 00 00 - If 0E 01 10 80 49 02 02 00 1E 00 03 00 02 00 00 00 00 00 04 00 - Give Pokemon 1E 00 27 00 00 00 - Jump 09 00 25 80 - Store Var 08 00 03 00 - Compare to 11 00 01 00 - Condition 1F 00 FF 14 00 00 00 - If 0E 01 10 80 49 02 03 00 1E 00 03 00 02 00 00 00 00 00 04 00 - Give Pokemon 4C 00 00 - Set Var Hero A9 00 18 05 - Play Fanfare 34 00 09 00 00 00 - Event Gray Message AA 00 - Wait Fanfare 4B 00 - Close Angry Message (Why Angry?) 34 00 0A 00 00 00 - Event Grey Message 47 00 10 80 - Yes or No 09 00 10 80 - Store Var 08 00 00 00 - Compare to 11 00 01 00 - Condition 1F 00 FF 10 00 00 00 - If 3F 00 - Close Message Key Press 2 05 01 26 80 24 80 01 00 - ???? 1E 00 02 00 00 00 - Jump 3F 00 - Close Message Key Press 2 3C 00 00 04 - Message (? Bytes are missing?) Is there a place I can see a more detailed explanation of some functions, like for example D2 00 XX XX or 4C 00 XX - Set Var Hero?
Kaphotics Posted September 23, 2014 Posted September 23, 2014 repeats 4 times as it is giving 4 different forms (seasonal). 00D2 = SetVar Season jump statements are "bytes forward from current position", which is at the end of the (if-then)jump statement.
Melanogaster Posted September 23, 2014 Author Posted September 23, 2014 repeats 4 times as it is giving 4 different forms (seasonal).00D2 = SetVar Season jump statements are "bytes forward from current position", which is at the end of the (if-then)jump statement. Ok, I managed to make it work properly, text and everything. But the guy who gives the pokemon keeps giving it every time you ask for it, how do I change it? 10 00 AA 01 - Store Flag or 4C 00 00 - Set Var Hero have any relevance to my issue?
Kaphotics Posted September 24, 2014 Posted September 24, 2014 You'd have to check the flag at the start of the script. Check Flag -> Branch to 2 results (flag vs no flag) and handle it. Store Flag -> Compare ~= 1 -> if false goto A... else... B 004C 00 is used for text lines, as text-line variables load from stored variables. I'd check the gift pokemon scripts (probably the Eevee would be best) to learn from.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now