The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Script [Emerald] Items as HMs: Checkitem doesn't seem to work

Notices
For all updates, view the main page.

Binary ROM Hacking Need a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.

Ad Content
Reply
 
Thread Tools
  #1   Link to this post, but load the entire thread.  
Old March 29th, 2019 (8:11 AM). Edited March 30th, 2019 by McPaul.
McPaul's Avatar
McPaul McPaul is offline
On my way to become a controversial and hated member.
 
Join Date: Mar 2018
Location: Switzerland
Gender: Male
Posts: 286
Here is the first script I made:

'---------------
#org 0xE3CFBC
lockall
checkflag 0x867
if 0x0 goto 0x8290721
checkitem 0x167 0x1
compare LASTRESULT 0x6
if 0x1 goto 0x8290721
setanimation 0x0 LASTRESULT
bufferitem 0x0 0x167
checkitem 0x167 0x1
msgbox 0x829072E MSG_YESNO '"This tree looks like it can be\ncu..."
compare LASTRESULT 0x0
if 0x1 goto 0x829072B
msgbox 0x8290771 MSG_KEEPOPEN '"[player] used [buffer1]!"
closeonkeypress
doanimation 0x2
waitstate
goto 0x8290710

'---------------
#org 0x290721
msgbox 0x829077D MSG_KEEPOPEN '"This tree looks like it can be\ncu..."
releaseall
end

'---------------
#org 0x29072B
closeonkeypress
releaseall
end

'---------------
#org 0x290710
applymovement LASTTALKED 0x829071F
waitmovement 0x0
hidesprite LASTTALKED
releaseall
end


'---------
' Strings
'---------
#org 0x29072E
= This tree looks like it can be\ncut down!\pWould you like to use [buffer1]?

#org 0x290771
= [player] used [buffer1]!

#org 0x29077D
= This tree looks like it can be\ncut down!


'-----------
' Movements
'-----------
#org 0x29071F
#raw 0x5B 'mov5B
#raw 0xFE 'End of Movements


The problem is that I can cut trees even if I don't have the item 0x167 in my bag despite using the checkitem command. Why is this happening? Did I do wrong somewhere?

Thanks for your answers.
Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old March 30th, 2019 (2:52 AM).
DrFuji's Avatar
DrFuji DrFuji is offline
Heiki Hecchara‌‌
 
Join Date: Sep 2009
Location: Aussie
Age: 30
Gender: Male
Nature: Jolly
Posts: 1,693
Here's a version of your script that will work:

Spoiler:
#dynamic 0x9C0B20

#org @start
lockall
checkflag 0x867
if 0x0 goto @CantCut
checkitem 0x167 0x1
compare 0x800D 0x1
if 0x0 goto @CantCut
setanimation 0x0 0x800D
bufferitem 0x0 0x167
checkitem 0x167 0x1
msgbox @CanBeCut 0x5
compare 0x800D 0x0
if 0x1 goto @DontCut
msgbox @UseCut 0x6
closeonkeypress
doanimation 0x2
waitstate
goto @Continue

#org @CantCut
msgbox @CutDown 0x6
releaseall
end

#org @DontCut
closeonkeypress
releaseall
end

#org @Continue
applymovement 0x800F @Cut
waitmovement 0x0
hidesprite 0x800F
releaseall
end

#org @CanBeCut
= This tree looks like it can be\ncut down!\pWould you like to use [buffer1]?

#org @UseCut
= [player] used [buffer1]!

#org @CutDown
= This tree looks like it can be\ncut down!

#org @Cut
#raw 0x5B
#raw 0xFE


Your issue stemmed these three lines in your original script:
Quote:
checkitem 0x167 0x1
compare LASTRESULT 0x6
if 0x1 goto 0x8290721
The checkitem command works by comparing the number of a specified item that you have to a chosen value (in this case, 0x1). If you have that many of the item or more, 0x800D is set to 0x1, if you have less, its set to 0x0. The compare line is then completely wrong, as 0x800D will never have 0x6 as a value from the previous command. This run on also breaks the if command as it will always be false, allowing the script to continue regardless as to whether you have the item or not.

Whenever you're making a script, I'd highly suggest that you use dynamic pointers. It ensures that you don't overwrite anything in the ROM by accident and if you're trying to get help here, its easier for others to follow the script's structure.
__________________
Reply With Quote
  #3   Link to this post, but load the entire thread.  
Old March 30th, 2019 (3:18 AM).
McPaul's Avatar
McPaul McPaul is offline
On my way to become a controversial and hated member.
 
Join Date: Mar 2018
Location: Switzerland
Gender: Male
Posts: 286
Thanks a lor DrFuji! I understood what you meant and can now proceed further!

The script I wrote had originally a dynamic offset command, but when I compiled the line disappeard, replaced by the offset the script went to and I just copypasted it.
Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 9:13 AM.