So if you ever wanted to run a script via item, here's how to do it in Emerald. I think FR already has a tut on it.
So first, you create a script you want your item to run.
Then you insert this routine and keep track of where you inserted it.
Then you assemble this routine. Save where you inserted it.
Then you open Kurapika's GEN 3 tools and in the field script section of your item, you put the offset to the second routine + 1 and set item type to '2 Use of SELECT'.
Also, this is a different approach from the FR version, so you have to repeat the process of inserting those two routines for every item you'd like to run a custom script. The upside is, this method allows you to run both ASM and script.
So first, you create a script you want your item to run.
Then you insert this routine and keep track of where you inserted it.
Spoiler:
Code:
.text
.thumb
.thumb_func
.align 2
main:
push {r4, lr}
mov r4, r0
ldr r2, script_env2_enable
bl callviar2
ldr r0, script_to_run
ldr r2, script_run
bl callviar2
mov r0, r4
ldr r2, task_delete
bl callviar2
pop {r4}
pop {r0}
bx r0
callviar2:
bx r2
.align 2
script_env2_enable: .word 0x08098E55
script_run: .word 0x08098EF9
script_to_run: .word 0x pointer to your script, do not +1!
task_delete: .word 0x080A909D
Then you assemble this routine. Save where you inserted it.
Spoiler:
Code:
.text
.thumb
.thumb_func
.align 2
main:
push {lr}
ldr r1, routine_to_run_after_graphics
ldr r2, run_custom_script
str r2, [r1]
ldr r2, run_after_graphics
bl callviar2
pop {r0}
bx r0
callviar2:
bx r2
.align 2
routine_to_run_after_graphics: .word 0x0203A0F4
run_custom_script: .word 0x pointer to the run script routine + 1
run_after_graphics: .word 0x080FD0DD
Then you open Kurapika's GEN 3 tools and in the field script section of your item, you put the offset to the second routine + 1 and set item type to '2 Use of SELECT'.
Also, this is a different approach from the FR version, so you have to repeat the process of inserting those two routines for every item you'd like to run a custom script. The upside is, this method allows you to run both ASM and script.
Last edited: