View Single Post
Old February 25th, 2012 (5:13 AM).
metapod23's Avatar
metapod23 metapod23 is offline
Hardened Trainer
    Join Date: Mar 2009
    Gender: Male
    Nature: Timid
    Posts: 673
    Originally Posted by Masterchief1755 View Post
    I had a question about the one in Pallet Town when you step on a certain tile near the grass and Oak comes over and stops you. What is it that causes that and what type of script to you use? From what I'm reading, it looks like Variables? I've been looking at tutorials or videos and there's really no definitive answers on what exactly is used and what it would look like

    For example....walking on the event, Oak appears and walks up to you. That's the sort of thing I'm looking to be able to create. Up until now I've been using PKSV, but if this isn't the recommended program for this I can switch. I just want to know how to do things like this so I can edit or create some new events to spice the game up a bit for friends etc. Not really getting into the making an entirely new game scene, but I would like to know how to do small things like this. Doing well up until this. Thanks for any help.
    XSE (Extreme Script Editor) is recommended over PKSV.

    In A-Map, the script you step on will have a Var number and a Var value. The Variable # is the number of the variable, and the value is what the value of that number is set to.

    So if you look at Oak's script, you see that it is activated when Var # 4050 is set to 0000. By default, all variables are set to the value of 0, which means that script will activate the first time you step on it no matter what, because the value of that script is 0 when the game begins.

    Now, in order to prevent the script from glitching once you step on it, you must do one of two things - either move the player off the script tile in the script, or deactivate the script by setting its var value to something other than 0 (because that is the value it is set to in A-Map for it to be activated).

    There are some scripts that are blocks, and don't deactivate, but only move the player back so they can't leave the town. Likely this script will be deactivated by changing the variable's value later in a future script.

    If you want to deactivate the script as soon as you step on it, though, you can simply change the variable's value. To do this, you would use this command setvar.

    Take a look at Oak's script. There are a few setvar commands used:

    #org 0x1655F9
    setvar 0x4001 0x1
    goto 0x8165605
    #org 0x165605
    setvar 0x8004 0x0
    setvar 0x8005 0x2
    special 0x174
    textcolor 0x0
    pause 0x1E
    playsong 0x12E 0x0
    preparemsg 0x817D72C '"OAK: Hey! Wait!\nDon't go out!"
    pause 0x55
    applymovement MOVE_PLAYER 0x81A75ED
    waitmovement 0x0
    sound 0x15
    applymovement MOVE_PLAYER 0x81A75DB
    waitmovement 0x0
    pause 0x1E
    showsprite 0x3
    compare 0x4001 0x0
    if 0x1 call 0x81656B8
    compare 0x4001 0x1
    if 0x1 call 0x81656C3
    pause 0x1E
    msgbox 0x817D74A MSG_KEEPOPEN '"OAK: It's unsafe!\nWild POKéMON li..."
    pause 0x1E
    compare 0x4001 0x0
    if 0x1 call 0x81656CE
    compare 0x4001 0x1
    if 0x1 call 0x81656E0
    setdooropened 0x10 0xD
    applymovement 0x3 0x816572E
    applymovement MOVE_PLAYER 0x8165758
    waitmovement 0x0
    setdoorclosed 0x10 0xD
    setvar 0x4055 0x1
    clearflag 0x2B
    setvar 0x4050 0x1
    setflag 0x2C
    setflag 0x4001
    warp 0x4 0x3 0xFF 0x6 0xC
    ^ I bolded the one that actually deactivated the script, though. By using setvar, the script has changed the value of variable 4050 to 0001. Now that it is changed to 1 instead of 0, that script will not activate again, unless you were to change the value of 4050 back to 0 in a separate script.

    Be cautious of the variable you use. There's a supposed safe range. Refer to XSE's guide to know which ones are best to use (I don't recall at the moment), or just use variables already used by the game, if you do not need those scripts that the game uses.