• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Help with Check-Item Script

  • 68
    Posts
    9
    Years
    Hello,

    I have a problem with a script, that checks if the player has a certain item.

    Here's a description:
    The script shall check if the Player has a certain item. If TRUE -> Set Alarm = Set a fanfare, move a sprite, display a text and set a flag, then end.
    If WRONG -> Display a text, that the player has to obtain the key by beating an ennemy, then end.
    If the alarm is already activated -> Check if Player has item, if true then checkflag. If the flag is set, then display a text and end the script.

    I want that this script is activated by stepping on a teleport-field (which will not be connected to another one). But by testing the script out, the player gets stuck in the script with no way out to escape.

    I have absolutely no idea, what caused this to happen and how to fix it.

    Here's the code:
    [DIV]
    #dynamic 0xA00000 'I use the 807 Patch version'

    #org @start
    lock
    checkitem 0x15F 0x1
    if 0x1 goto @setalarm
    msgbox @needkey 0x6
    release
    end

    #org @needkey
    = I need to get the key from Snorlax

    #org @setalarm
    checkflag 0x1201
    if 0x1 goto @alreadyactivated
    fanfare 0x0152
    applymovement 0x3 @moveflemmli
    waitmovement 0x0
    msgbox @alarmtext 0x6
    setflag 0x1201
    release
    end

    #org @alarmtext
    = Perfect!!! Now let's escape !!!

    #org @moveflemmli
    #raw 0xA
    #raw 0x0
    #raw 0xFE

    #org @alreadyactivated
    = We've already activated the alarm.\nNow let's hurry and escape!!!
    release
    end
    [/DIV]

    Thank you for the help :) !
     
    Hello,

    I have a problem with a script, that checks if the player has a certain item.

    Here's a description:
    The script shall check if the Player has a certain item. If TRUE -> Set Alarm = Set a fanfare, move a sprite, display a text and set a flag, then end.
    If WRONG -> Display a text, that the player has to obtain the key by beating an ennemy, then end.
    If the alarm is already activated -> Check if Player has item, if true then checkflag. If the flag is set, then display a text and end the script.

    I want that this script is activated by stepping on a teleport-field (which will not be connected to another one). But by testing the script out, the player gets stuck in the script with no way out to escape.

    I have absolutely no idea, what caused this to happen and how to fix it.

    Here's the code:
    [DIV]
    #dynamic 0xA00000 'I use the 807 Patch version'

    #org @start
    lock
    checkitem 0x15F 0x1
    if 0x1 goto @setalarm
    msgbox @needkey 0x6
    release
    end

    #org @needkey
    = I need to get the key from Snorlax

    #org @setalarm
    checkflag 0x1201
    if 0x1 goto @alreadyactivated
    fanfare 0x0152
    applymovement 0x3 @moveflemmli
    waitmovement 0x0
    msgbox @alarmtext 0x6
    setflag 0x1201
    release
    end

    #org @alarmtext
    = Perfect!!! Now let's escape !!!

    #org @moveflemmli
    #raw 0xA
    #raw 0x0
    #raw 0xFE

    #org @alreadyactivated
    = We've already activated the alarm.\nNow let's hurry and escape!!!
    release
    end
    [/DIV]

    Thank you for the help :) !

    The checkitem has to be like this:
    "checkitem 0x15F 0x1
    compare LASRESULT 0x1
    if 0x1 goto @setalarm"

    The general syntax of the checkitem command is like this:
    checkitem 0x(item ID) 0x(quantity)
    compare LASTRESULT 0x1
    if (condition) goto @there

    I dont know why the compare LASTRESULT needs to be done but apparently it is needed.
    You can check out Sierra's XSE guide for things like this.

    Another thing: Flag 0x1201 should be unsafe to use iirc. You might wanna change that to a safe flag value.
    Here is a list of safe flags (and vars) that you can use.
    Here is how you can make the other flags safe to use.
     
    The checkitem has to be like this:
    "checkitem 0x15F 0x1
    compare LASRESULT 0x1
    if 0x1 goto @setalarm"

    The general syntax of the checkitem command is like this:
    checkitem 0x(item ID) 0x(quantity)
    compare LASTRESULT 0x1
    if (condition) goto @there

    I dont know why the compare LASTRESULT needs to be done but apparently it is needed.
    You can check out Sierra's XSE guide for things like this.

    Another thing: Flag 0x1201 should be unsafe to use iirc. You might wanna change that to a safe flag value.
    Here is a list of safe flags (and vars) that you can use.
    Here is how you can make the other flags safe to use.

    Thank you so much :)!!! The script now works, when you first activate it. If you don't have the item, you get the text that you'll need the item. It's still a bit buggy though, as it freezes, when you step on the script, after you have activated it and when you return to the map, the Sprite on which I applied a movement, will be at the initial position, not in the changed position, which in my case causes the player to walk through the sprite.

    The links you've send me are also very helpful, I have to read through them in more detail. Yes, I know Sierra's Tutorial, I watched some of his videos on his YT-Channel.
    As for the checkflag 0x1200, this Youtuber said, that those are safe to use, but maybe bc he extended the Memory already? https://www.youtube.com/watch?v=AnaiyYY1rWo&list=PL79F5101F6BEAE673&index=5&t=0s

    I had some trouble to unsertand the compare-Line, but I guess it's that "compare LASTRESULT 0x1" sets the 0x1 to true, when the checkitem-condition is met. And the 0x1 can then be used in an if-statement for non-flags.

    Yeah, but thank you so much for the help :D
     
    Thank you so much :)!!! The script now works, when you first activate it. If you don't have the item, you get the text that you'll need the item. It's still a bit buggy though, as it freezes, when you step on the script, after you have activated it and when you return to the map, the Sprite on which I applied a movement, will be at the initial position, not in the changed position, which in my case causes the player to walk through the sprite.

    The links you've send me are also very helpful, I have to read through them in more detail. Yes, I know Sierra's Tutorial, I watched some of his videos on his YT-Channel.
    As for the checkflag 0x1200, this Youtuber said, that those are safe to use, but maybe bc he extended the Memory already? https://www.youtube.com/watch?v=AnaiyYY1rWo&list=PL79F5101F6BEAE673&index=5&t=0s

    I had some trouble to unsertand the compare-Line, but I guess it's that "compare LASTRESULT 0x1" sets the 0x1 to true, when the checkitem-condition is met. And the 0x1 can then be used in an if-statement for non-flags.

    Yeah, but thank you so much for the help :D

    By any chance, are you using one of the green script tiles for this script? If yes, then you need to associate a variable with it. Without a variable, those tiles can freeze the game (but it executes the script as expected) when you step on it.

    What I mean by associating a variable (putting it in a spoiler so that you can skip if you already know these):
    Spoiler:


    Additionally, here is a tip that I use for script tiles: If I am checking a condition for script tiles like how you are checking if the player has a certain item or, I use an applymovement to make the player move out of the tile if the condition is false. This way, the player can activate the tile again by stepping on it.

    Another thing I noticed was with the @alreadyactivated part of the script. I don't think you can use "goto @alreadyactivated" where @alreadyactivated is a pointer to a text and not a normal part of the script. Compiling the program won't show any errors but it actually messes up the game. Do something like this:
    Spoiler:


    For the person who isn't moving to a changed position: Use a level script like this:
    #org @start
    checkflag 0x1201
    if 0x1 call @changedpos 'this checks if the position has changed or not. You can replace this condition check as per you wish.
    release
    end

    #org @changedpos
    movesprite2 0x(Person event no. in Advanced Map) 0x(X-coordinate) 0x(Y-coordinate)
    spritebehave 0x(Person event no. in Advanced Map) 0x(behavior number you want it to be)
    return

    Place the level script as a type 03 (On entering the map/not on menu close) in the Map script part of the Header tab in Advanced Map. Sierra also has a level script tutorial that you can see if you want.

    Sorry for the long reply! And you're welcome! Feel free to ask if you have any more query!
     
    Wow, your such an help :) !

    Yes I did use a green script tile and I placed a var, but it was at the wrong place in the code 😅.

    Yes, to make a levelscript for Torchic blocking the door, is something I also considered to make.

    But some questions regarding the movement syntax:
    1. I copied the X- & Y-Coordinates from Advance Map. Do those values have to be like '0008' or just '8' ?
    2. And I'm not sure what you mean by 'Behaviour number'. Are these the values from the 'Movement-Type'-Tab in A-Map? If so, I would need '08' for making the person look down after he made a step to the left.
     
    Wow, your such an help :) !

    Yes I did use a green script tile and I placed a var, but it was at the wrong place in the code 😅.

    Yes, to make a levelscript for Torchic blocking the door, is something I also considered to make.

    But some questions regarding the movement syntax:
    1. I copied the X- & Y-Coordinates from Advance Map. Do those values have to be like '0008' or just '8' ?
    2. And I'm not sure what you mean by 'Behaviour number'. Are these the values from the 'Movement-Type'-Tab in A-Map? If so, I would need '08' for making the person look down after he made a step to the left.

    Glad to help! ^_^

    About X and Y coordinates: I don't think the zeroes in the front really matters. You can just use the numbers directly shown in the lower left corner of Advanced-Map.

    About behavior number: The behavior number can be found from the "Movement Type" box in Advanced map. No Movement is behavior no 0, Look Around is 1, Walk Around is 2 and so on. Counting them is painful. So you can instead find the list by going to Advance map's folder -> Ini -> Sprachen and then open the English.ini in a notepad or any text editor. Then search for the word 'Bewegung' there and you'll find all the corresponding behavior number for each movement type.

    Here they are to save you some hassle.
    Spoiler:


    Just be careful that these numbers are in decimal and you need to change them to hexadecimal before using in XSE!
     
    Back
    Top