The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Script FBI's Playtime as a Clock Help

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 December 8th, 2016 (8:39 PM).
Puffle754's Avatar
Puffle754 Puffle754 is offline
 
Join Date: May 2011
Location: Ridge Island
Gender: Male
Nature: Timid
Posts: 48
Would someone be able to help me out with FBI's Playtime as a Clock system.

I have it inserted to free space, although I'm having a difficult time figuring out how to properly set up a script that utilizes it. In this case, could someone quick write up a basic script skeleton to help me understand what I'm doing wrong. Something basic, but with all the main bits, perhaps a berry bush that gives 1-3 cheri berries every 20 in game minutes.
Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old December 8th, 2016 (9:16 PM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by Puffle754 View Post
Would someone be able to help me out with FBI's Playtime as a Clock system.

I have it inserted to free space, although I'm having a difficult time figuring out how to properly set up a script that utilizes it. In this case, could someone quick write up a basic script skeleton to help me understand what I'm doing wrong. Something basic, but with all the main bits, perhaps a berry bush that gives 1-3 cheri berries every 20 in game minutes.
I'd honestly make a short routine to interact with the tree and use those routines as external helper functions to achieve this effect. It's quite possible without, but it takes up more resources which you don't want it to.

General algorithm to make a berry tree or person yield an item every 20 minutes:
1) First interaction always give away the item and record the time the item is given away
2) Next time the event is interacted with, subtract the logged minute with the current minute. If those minutes differ by 20, give the item again and log the new time. Otherwise it's not time to give the item.

Here is how you'd check to give the item or not, if 0x4011 is the variable you're using to log the time:

Quote:
compare 0x4011 0x0
if 0x0 goto check_if_item_should_be_given
additem ...
So we give the item if a minute value is not set. That means this is the first time we talk to the event.

After talking to the event, we need to log the time we talked to it, like this:
Quote:
callasm routine_that_gets_minutes
copyvar 0x4011 0x800D
addvar 0x4011 0x1
I've added 1 to it so it passes the first check on the chance that you talked to the event on a 0 minute like 0:00. This means the actual time variable will be between 1-60, instead of 0-59!

The next step is if it's not the first time interacting with the event, we need to judge if the item should be given. To do this, you want to retrieve the current time again, and compare it to the old time. If there is a 20 minute difference, give the item back. I suggest using a routine here for optimization purposes and ease. Scripts are very slow, so use a routine like this:

Quote:
.align 2
.thumb

main:
push {lr}
ldr r0, =(0x20370B8)
ldrh r3, [r0]
ldrh r1, [r0, #0x18]
mov r2, r1
add r1, r1, #20
sub r2, r2, #20
cmp r1, r3
ble give_item
cmp r3, r2
bgt end

give_item:
mov r1, #0x1
strh r1, [r0]

end:
pop {pc}


.align 2
This routine would write 0x1 in var 0x8000 if the value was 20 minutes away from the last value. It'd require var 0x8000 hold current time and Lastresult (0x800D) to hold the old time. Hopefully you can figure out the rest from that.
__________________
...
Reply With Quote
  #3   Link to this post, but load the entire thread.  
Old December 8th, 2016 (10:45 PM). Edited December 10th, 2016 by Puffle754.
Puffle754's Avatar
Puffle754 Puffle754 is offline
 
Join Date: May 2011
Location: Ridge Island
Gender: Male
Nature: Timid
Posts: 48
I...hate to sound so hopeless, but I'm afraid I really am at this point.

I"m afraid I'm missing something very fundimental here, so I'll walk through the thought process. I inderted your In Game Clock (minute) ASM at 00EA3D00, and the ASM you just provided me at 00ED0000. Next, I tried scripting, and the results have been...less than ideal. Here is the code I've mustered up so far (I'm using PKSV, not sure if that makes a difference). As you can see, I haven't even figured out how to use your second ASM yet. On top of that, I must have something really messed up in there, as when I compile it, and go back to check it, it gets all screwed up. Eitherway, this is what I had so far:

Code:
#dyn 0xEF00000
#org @start
'-----------------------------------
compare 0x4011 0x0
if 0x0 call @check
msgbox @yesberry
callstd MSG_LOCK 
giveitem CHERIBERRY 0x1
end

#org @check
'-----------------------------------
callasm 0x8EA3D00
copyvar 0x4011 LASTRESULT
addvar 0x4011 0x1
msgbox @noberry 
callstd MSG_LOCK 
end

#org @yesberry
= There are two berries on the bush!
#org @noberry
= The berry bush is bare...
I hate to keep barraging you with what are likely very beginner questions, but I hope you can help me out here.
Reply With Quote
  #4   Link to this post, but load the entire thread.  
Old December 9th, 2016 (8:00 AM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Quote:
Originally Posted by Puffle754 View Post
I...hate to sound so hopeless, but I'm afraid I really am at this point.

I"m afraid I'm missing something very fundimental here, so I'll walk through the thought process. I inderted your In Game Clock (minute) ASM at 00EA3D00, and the ASM you just provided me at 00ED0000. Next, I tried scripting, and the results have been...less than ideal. Here is the code I've mustered up so far (I'm using XSE, not sure if that makes a difference). As you can see, I haven't even figured out how to use your second ASM yet. On top of that, I must have something really messed up in there, as when I compile it, and go back to check it, it gets all screwed up. Eitherway, this is what I had so far:

Code:
#dyn 0xEF00000
#org @start
'-----------------------------------
compare 0x4011 0x0
if 0x0 call @check
msgbox @yesberry
callstd MSG_LOCK 
giveitem CHERIBERRY 0x1
end

#org @check
'-----------------------------------
callasm 0x8EA3D00
copyvar 0x4011 LASTRESULT
addvar 0x4011 0x1
msgbox @noberry 
callstd MSG_LOCK 
end

#org @yesberry
= There are two berries on the bush!
#org @noberry
= The berry bush is bare...
I hate to keep barraging you with what are likely very beginner questions, but I hope you can help me out here.
Rather, you're messing up the algorithm.

Quote:
#dyn 0xEF00000
#org @start
'-----------------------------------
compare 0x4011 0x0
if 0x0 call @check
msgbox @yesberry
callstd MSG_LOCK
giveitem CHERIBERRY 0x1
end
This has a few issues. I notice that you decide to 'call' instead of 'goto', which is incorrect. Call is generally used when you need to return after calling a portion of the script. Anyways, here it technically works because you end the script inside the called script. The next issue is also an optimization issue, since we'll be giving the item away at the start and if it's 20 minutes since the last one was given away, it's probably best to put the give item under a different label and call that label. Finally, you have ended the script without assigning 0x4011.


Quote:
#org @check
'-----------------------------------
callasm 0x8EA3D00
copyvar 0x4011 LASTRESULT
addvar 0x4011 0x1
msgbox @noberry
callstd MSG_LOCK
end
Before overwriting the last interacted time, you want to compare it first and only overwrite it if 20 mins has passed. Additionally, you have not given the item in the case that the 20 minute window was satisfied.

Overall, this script is failing on an algorithmic level. You should address that. I believe I've provided enough detail for you to do so.
__________________
...
Reply With Quote
  #5   Link to this post, but load the entire thread.  
Old December 10th, 2016 (10:09 PM).
Puffle754's Avatar
Puffle754 Puffle754 is offline
 
Join Date: May 2011
Location: Ridge Island
Gender: Male
Nature: Timid
Posts: 48
Thank you for your help! I took another crack at it today, and although I think my code is a fair bit better this time, after hours of trying, I still can't get this to work...

This is what I have now. The "PLAYER revived the RAZZ BERRIES" textbox gets stuck on screen, and it doesn't prevent me from going back for more immediately. As a side note, I don't have the foggiest how to specifically check if 20 minutes has passed. I'm guessing 0x1 would be 1 minute, but I'm not sure.

Code:
#dyn 0xBB3000
#org @start
'-----------------------------------
compare 0x4012 0x0
if = goto @giveberry
call @check
end

#org @check
'-----------------------------------
callasm 0x8EA3D01
copyvar 0x4011 LASTRESULT
comparevars2 0x4011 0x4012
if < jump @giveberry
call @noberry
end

#org @giveberry
'-----------------------------------
msgbox @yesberry2
callstd MSG_LOCK
copyvarifnotzero 0x8000 RAZZBERRY
copyvarifnotzero 0x8001 0x2
callstd MSG_OBTAIN ' Obtained the XXXXXX!
callasm 0x8EA3D01
copyvar 0x4012 0x4011
end

#org @noberry
'-----------------------------------
msgbox @noberry2 
callstd MSG_LOCK
end

#org @yesberry2
= There are two berries on the bush!
#org @noberry2
= The berry bush is bare...
Reply With Quote
  #6   Link to this post, but load the entire thread.  
Old March 21st, 2017 (8:10 PM).
Puffle754's Avatar
Puffle754 Puffle754 is offline
 
Join Date: May 2011
Location: Ridge Island
Gender: Male
Nature: Timid
Posts: 48
Bumping this, as I've started looking at this again. Still running into issues though, mainly due to me being lousy with scripting...
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

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:17 AM.