View Single Post
  #7838    
Old February 5th, 2013 (02:01 PM).
FBI agent's Avatar
FBI agent
If my PM box is full, VM instead :x
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Quote originally posted by Aryan143:
This is the script I am making. I want that a mankey comes to me and asks to join me when I step on a specific tile and then a Pidgey comes to me immediately and evolves to Pidgeotto and then battles me. Note that 0x2 is because that I replaces no. 2 sprite with Mankey.

Spoiler:
'---------------
#org 0x750000
msgbox 0x8750067 MSG_NORMAL '"Someone's here."
showsprite 0x2
msgbox 0x8750079 MSG_YESNO '"This Mankey looks cute!\nDo you wa..."
compare LASTRESULT 0x1
if 0x1 goto 0x87500B5
compare LASTRESULT 0x0
if 0x0 goto 0x87500D3
hidesprite 0x2
showsprite 0x74
msgbox 0x87500E3 MSG_NORMAL '"This Pidgey forces you to\n a batt..."
msgbox 0x875011F MSG_NORMAL '"Wait!Pidgey is evolving!"
fadescreen 0x1
hidesprite 0x74
fadescreen 0x0
showsprite 0x72
cry 0x17 0x0
msgbox 0x875013A MSG_NORMAL '"PIDGEOTTO: Pidddddge!"
wildbattle 0x11 0xA 0x0
fadescreen 0x1
fadescreen 0x0
hidesprite 0x72
setobedience 0xE1E3
setobedience 0xE1E3
'---------------
#org 0x7500B5
givepokemon 0x38 0x5 0x0 0x0 0x0 0x0
fanfare 0x13E
msgbox 0x8750152 MSG_NORMAL '"It seems happy."
waitfanfare
release
end

'---------------
#org 0x7500D3
msgbox @0x8750153 MSG_NORMAL
release
end

'---------
' Strings
'---------
#org 0x750067
= Someone's here.

#org 0x750079
= This Mankey looks cute!\nDo you want to take\p it with you?

#org 0x7500E3
= This Pidgey forces you to\n a battle.\pBut it's not strong.

#org 0x75011F
= Wait!Pidgey is evolving!

#org 0x75013A
= PIDGEOTTO: Pidddddge!

#org 0x750152
= It seems happy.

#org 0x750153
= Then go home!
If this is one of those green script tiles, you've got a ton of structure errors in the script. The first and most obvious error is that even after the script on this tile is run once, it will keep running everytime you walk into it simple because you haven't used any flags (or variables)!
The second is probably the reason you're having the error you are having. It's the whole "jump" thing. I might make a video or something on jump vs call. People keep getting those messed up and causing their scripts to function incorrectly.

When you are starting out, or are working on a script that is "difficult", you must first identify what you want happening. That sound simple and stupid, but what I mean is you want to evaluate different situations that the event will get you into. For example, this one here allows the player to have a choice to adopt the Mankey. What if the player says no? Does the Mankey go away and the Pidgey/Pideotto still attack? Does the Mankey stay there forever until you feel like adopting it? These are good questions that you should answer first. There are also the yes cases. Say I accepted it's offer to join my team, but my current team is full (what then?). What if I accepted the offer, but then later lost in battle to Pidgeotto?

So then lets, look at the script again. When reviewing it, I'm going to make the following assumptions:
- The player MUST accept the Mankey's offer, or it will keep asking until you say yes.
- The player is allowed to give it a nickname
- If the player doesn't have space in the party, he/she must come back with an open slot


Quote:
#org 0x750000
msgbox 0x8750067 MSG_NORMAL
showsprite 0x2 'First problem, the mankey appears before you instantly (looks bad ingame).
msgbox 0x8750079 MSG_YESNO
compare LASTRESULT 0x1 ' If yes, we jump (go to this jump now and read my comments on it).
if 0x1 goto 0x87500B5
compare LASTRESULT 0x0' If no, we jump (go to this jump now and read my comments on it).
if 0x0 goto 0x87500D3
hidesprite 0x2 'From here down, nothing is run. This is because you checked no and yes.
showsprite 0x74
msgbox 0x87500E3 MSG_NORMAL '"This Pidgey forces you to\n a batt..."
msgbox 0x875011F MSG_NORMAL '"Wait!Pidgey is evolving!"
fadescreen 0x1
hidesprite 0x74
fadescreen 0x0
showsprite 0x72
cry 0x17 0x0
msgbox 0x875013A MSG_NORMAL '"PIDGEOTTO: Pidddddge!"
wildbattle 0x11 0xA 0x0
fadescreen 0x1
fadescreen 0x0
hidesprite 0x72
setobedience 0xE1E3
setobedience 0xE1E3'Forgot release end here, also, you don't need to set obedience at all

'---------------
#org 0x7500B5 ' No checks are made to see if party is full, also not allowed to nickname
givepokemon 0x38 0x5 0x0 0x0 0x0 0x0
fanfare 0x13E
msgbox 0x8750152 MSG_NORMAL '"It seems happy."
waitfanfare
release 'Release and end implies end of the script. We don't fight Pidgey is player says YES.
end 'Now go back to the main body

'---------------
#org 0x7500D3 'Just a simple message, don't need to jump for this, you can put it in main body
msgbox @0x8750153 MSG_NORMAL
release 'Release and end implies end of the script. We don't fight Pidgey if player says YES.
end 'Now go back to the main body
Now we see that you've miss used your jumps and the logic is a little flawed in the script because of it. Here's a template of what it should look like:

Spoiler:

Code:
#dyn 0x740000 ' Firstly this is in PKSV not XSE, compile it in PKSV and Decompile it in XSE to fully understand
#org @start
compare 0x5001 0x2
if == jump @end' If it's 0x2 I assume the full script is completed
compare 0x5001 0x1
if == jump @check_want' If it's 0x1 then I didn't have room for mankey last time I was here
msgbox @appears 'The message you had
callstd MSG_NORMAL
clearflag 0x202 'Set mankey's personID to 202, and set this flag in a green script tile before this script(player's room is a good place)
reappear 0x2 'Mankey appears
setvar 0x5001 0x1 ' I set 5001 to 1, ensuring I've already had mankey appear
jump @check_want ' I jump to the yesno message, you'll see why

#org @check_want
msgbox @want ' Ask if I want mankey
callstd MSG_YESNO
compare LASTRESULT YES ' If yes I jump to @get (yes I jump, not call)
if == jump @get
msgbox @too_cute 'If I said I don't want mankey, it says something like makey's cute though and loops again
callstd MSG_NORMAL
jump @check_want 'Part that makes it loop

#org @get
countpokemon ' Checks the amount of 'mon in my party
copyvar 0x5002 LASTRESULT ' I'm setting 0x5002 to this value for a reason, you'll see why
compare 0x5002 0x6 ' Check if the number of party 'mon are 6
if == jump @makeroom
addpokemon MANKEY 0x5 NONE 0x0 0x0 0x0 ' If less than six give me mankey
storepokemon 0x0 MANKEY ' Equivalent to XSE's bufferpokemon
message @obtain
fanfare 0x101
showmsg 'Shows the message I prepared
waitfanfare
msgbox @give_nick 'Ask if I want to nickname it, I'm not forcing a nickname though
callstd MSG_YESNO
compare LASTRESULT YES 'If yes call @nickname. I'm calling here, not jumping because I will returning to this point later
if == call @nickname
disappear 0x2 'Mankey disappears
setflag 0x202 ' set 202
setvar 0x5001 0x2
jump @battle_section ' I don't need to make the jump, but it makes the script more readable

#org @nickname
copyvar 0x8004 0x5002 ' Now I copy 0x5002's value (1-6) into 0x8004
subtractvar 0x8004 0x1 ' I subtract one, because for nickname special you need to set 0x8004 to pokemon slot number (0-5)
fadescreen FADEOUT_BLACK
special NAME_POKEMON
waitspecial
return 'I return back the where this subroutine was called

#org @battle_section
clearflag 0x201
reappear 0x74 ' Mistake? Or you really have someone's person ID set to 116?
msgbox @force_battle 'The pidgey wants to battle text
callstd MSG_NORMAL
pause 0x40 'Now I create the ingame illusion that it's evolving by quickly flashing the screen white 
fadescreen 0x0
pause 0x40
msgbox @evolving 'pidgey evolving message
callstd MSG_NORMAL
fadescreen 0x0
pause 0x10
fadescreen 0x0
disappear 0x74 ' I don't believe these person IDs you have lol
reappear 0x72
cry 0x17 0x0 'Not sure if right cry, I just copied what you had
msgbox @scream ' Part where it screams "Pidddddddddgey!"
callstd MSG_NORMAL
setflag 0x201 'Set flag 201 to keep the pidgey/pidgeotto disappeared
battle 0x11 0xA 0x0 'Again not sure if right, I just copied what you had
fadescreen 0x1
disappear 0x72'pidgeotto disappears
fadescreen 0x0
releaseall 'FINALLY WE END
end

#org @makeroom
msgbox @full_party'tell the player to come back with less than six, also event is paused for duration
callstd MSG_NOCLOSE
release
end

#org @end
releaseall'script already complete, but player walking in tile anyways
end

#org @force_battle
= Pidgey wants to battle!\nIt's not very strong though[.]

#org @scream
= PIDEOTTO: Pidddddge!

#org @give_nick
= Give MANKEY a nickname?

#org @evolving
= Wait! Pidgey is evolving!

#org @forced_battle
= This pidgey forces you to\na battle.\pBut it's not strong. 

#org @too_cute
= Awww[.]\nIt's eyes gleam with love!\lI can't just leave it.

#org @want
= This Mankey looks cute!\nDo you want to take it with you?

#org @full_party
= I don't have room[.]\nBetter come back for it later!

#org @obtain
= \v\h01 obtained a \v\h02!


REQUIRED TO MAKE THIS WORK:
- Pidgey and Pidgeotto person ids set to 202 in A-MAP
- Mankey person ID set to 201 in A-MAP
- Flags 201, 202 unused, and set before this event (in players room = best place)
- variables 5001, 5002 unused
- Pidgey Person event number in Advance map set to 116
- Pideotto Person event number in Advance map set to 114

Technical Notes:
- This is for FireRed
- This was written in pksv
- I have not tested this, but I planned it out while writing the post so it will work
- I'm using the variable 0x5001 to keep track of how much of the script was complete

General Notes:
- Call is generally used when you want to do little things then come back to the main script
- Jump is used when you don't want the rest of the script to run given a condition
- Also, you can take this 1 step further with the special 0xB4. You can check if it was defeated, and if it was you can do a little "Pidgeotto ran away from further shame" or something

Aside from the few technical issues there, what about the Mankey's relation to the story (I know that this is unrelated to the script, but it's for you own understanding). Why is this random Mankey comming up to me and wanting to join my team? It sounds absurd and doesn't really make sense for it to volunteer itself to a life long commitment.

Well, next time don't expect a reply this detailed. I sorta felt nice on this one, and noticed a lot of people in this thread don't plan things through on bigger scripts (they just dive in). If you don't understand anything about the script I put up feel free to ask questions, I will try to answer them :)
__________________
...

My name forum name is FBI Agent, though you can call me FBI because it's shorter.

Some of my stuff:
ASM request/resource thread
ASM tutorials thread