Quote:
Originally Posted by Puffle754
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.