Go Back   The PokéCommunity Forums > ROM Hacking > Research & Development
Reload this Page Research: Hold Item Effects

Notices
For all updates, view the main page.

Research & Development Got a well-founded knack with ROM hacking? Love reverse-engineering the Pokémon games? Or perhaps you love your assembly language. This is the spot for polling and gathering your ideas, and then implementing them! Share your hypothesis, get ideas from others, and collaborate to create!
Research & Development programs in this forum are subject to moderator approval before they are displayed.



Reply
 
Thread Tools
  #1    
Old September 1st, 2014 (01:04 PM).
LocksmithArmy's Avatar
LocksmithArmy LocksmithArmy is offline
Mew!
 
Join Date: Feb 2013
Age: 26
Gender: Male
Posts: 402
When I was working on my new Item Editor tool I did research into what the bytes in the Items data were... there were some pretty good lists that explain alot but there were still some unknown bytes.
I figured out a little info and wanted to share it, I will post my more complete list here but this thread is only about one byte in particular:

Spoiler:
44 total bytes:

14 bytes for the name, a string in the same encoding as all in-game strings, finished by 0xFF
2 bytes for the item number, that is used for some integrity checks
2 bytes for the item market price
1 byte for the hold effect
1 byte used for item usage values, such as potion HP recovery or Repel steps
4 bytes for a pointer to a small description of the item, as seen in the market and in the bag screen
?1 byte for something else (key items); either 00, 01, 02 or 03(PokeBlock case)
1 byte set to 1 if key-item can be used from bag.
1 byte for the number of the pocket the item is stored in (tm case and berry bag included)
1 byte that usually allow to distinguish between between types of item
4 bytes pointer for item's THUMB routine start.
1 byte for item usage location
3 bytes that are always "0x00"
4 bytes for the battle routine start.
3 bytes that are always "0x00"
?1 byte that may do something; PokeBalls, Mail, Eon Ticket
I dont take credit for this whole list, just a few bolded changes


The bolded bytes above were previously unidentified (or still are).

This thread in only to talk about the first bolded byte, byte #18, it is now identified as the Hold Effect byte.

Byte #19 is also important in conjunction with Hold Effect byte, byte #19 is the Value byte.

I can only surmise that there is a table somewhere with pointers to THUMB scripts that actually handle the hold effects... but without knowing more about that I cannot go further than to figure out what each number placed in a the Hold Effect slot can do... so I did.

Spoiler:
Hold Effects list:
00 None
01 Heal HP (used) (Takes Value)
02 Cure Paralysis (used)
03 Cure Sleep (used)
04 Cure Poison (used)
05 Cure Burn (used)
06 Cure Freeze (used)
07 Heal PP (used) (Takes Value)
08 Cure Confusion (used)
09 Cure All Status Effects (used)
0A Heal HP (may confuse) (used) (Takes Value)
0B Heal HP (may confuse) (used) (Takes Value)
0C Heal HP (may confuse) (used) (Takes Value)
0D Heal HP (may confuse) (used) (Takes Value)
0E Heal HP (may confuse) (used) (Takes Value)
0F Raises ATTACK in a pinch (used) (Takes Value)
10 Raises DEFENSE in a pinch (used) (Takes Value)
11 Raises SPEED in a pinch (used) (Takes Value)
12 Raises SP. ATK in a pinch (used) (Takes Value)
13 Raises SP. DEF in a pinch (used) (Takes Value)
14 Raises Critical-hit Ratio in a pinch (used) (Takes Value)
15 Raises one stat in a pinch (used) (Takes Value)
16 Lowers Opponents Accuracy (Takes Value)
17 Restores any lowered stat (used)
18 Promotes strong growth but lowers SPEED while it is held.
19 The holder gets a share of EXP. points without having to battle.
1A The holder may be able to strike first. (Takes Value)
1B Promotes friendly growth.
1C Cures Infatuation (used)
1D Powers up one move, which becomes the only usable one.
1E It may cause the foe to flinch upon taking damage. (Takes Value)
1F Boosts the power of BUG-type moves. (Takes Value)
20 Doubles the battle money if the holding POKéMON takes part. (Takes Value)
21 Repels wild POKéMON if the holder is first in the party.
22 Raises the SP. ATK and SP. DEF stats. (LATIOS\LATIAS only)
23 Raises the SP. ATK stat.
24 Raises the SP. DEF stat.
25 The holding POKéMON can flee from any wild POKéMON for sure.
26 The holding POKéMON is prevented from evolving.
27 The holding POKéMON may endure an attack, leaving just 1 HP. (Takes Value)
28 Extra EXP. points in battle.
29 Boosts the critical-hit ratio of the holding POKéMON.
2A Boosts the power of STEEL-type moves. (Takes Value)
2B Heals HP after every turn in battle. (Takes Value)
2C ??? DRAGON SCALE ??? (Takes Value)
2D Doubles SP. ATK, may paralize opponents. (PIKACHU only)
2E Boosts the power of GROUND-type moves. (Takes Value)
2F Boosts the power of ROCK-type moves. (Takes Value)
30 Boosts the power of GRASS-type moves. (Takes Value)
31 Boosts the power of DARK-type moves. (Takes Value)
32 Boosts the power of FIGHTING-type moves. (Takes Value)
33 Boosts the power of ELECTRIC-type moves. (Takes Value)
34 Boosts the power of WATER-type moves. (Takes Value)
35 Boosts the power of FLYING-type moves. (Takes Value)
36 Boosts the power of POISON-type moves. (Takes Value)
37 Boosts the power of ICE-type moves. (Takes Value)
38 Boosts the power of GHOST-type moves. (Takes Value)
39 Boosts the power of PSYCHIC-type moves. (Takes Value)
3A Boosts the power of FIRE-type moves. (Takes Value)
3B Boosts the power of DRAGON-type moves. (Takes Value)
3C Boosts the power of NORMAL-type moves. (Takes Value)
3D ?? UP-GRADE ??
3E Heals HP after hitting an opponent in battle. (Takes Value)
3F Raises Critical-Hit Ratio (CHANSEY only)
40 Raises DEFENSE (DITTO only)
41 It raises the ATTACK stat. (CUBONE/MAROWAK only)
42 Raises Critical-Hit Ratio (FARFETCH'D only)


So lets look at what the (Takes Value) means. It basically means we(hackers) can change how awesome these hold effects are. For instance, the Oran Berrys Hold Effect is 0x01 Heals HP... Hold Effect 0x01 Takes Value, and its Value byte is 0x0A or 10... Oran Berry Heals 10 HP... How do we make the Oran Berry heal 100 HP, put 0x64 in its Value byte.

Lets do a really fun one...
Focus Band has a Hold Effect of 0x27 he holding POKéMON may endure an attack, leaving just 1 HP. Hold Effect 0x27 Takes Values, and its Value Byte is again 0x0A, 10... this time its not an amount, its a percentage, the pokemon has a 10% chance of not dying... Lets try changing that to 100, put a 0x64 there... now your pokemon will NEVER die when holding this item... cool huh...

one more note on Value bytes, say you have a chancy and you wanna heal all its 401 HP... well 0xFF (the largest value) is only 255, but that really just means, all... the game interprets 0xFF as all, so if you need to heal all PP, HP, or whatever, 0xFF will work, even if the poke needs more than 255.

All you crazy ASM mongers can take this info, find the table, and figure out if there are any other bytes in the table (above 0x42)... then figure out how to write new effects, or stop berries from being used up... or whatever... I would appreciate any info to be posted here, maybe I will be able to incorporate it into my tool (have a checkbox for if item is used up or not)...

Hope it was informative.
__________________
Reply With Quote
  #2    
Old September 1st, 2014 (04:04 PM). Edited September 4th, 2014 by MrDollSteak.
MrDollSteak's Avatar
MrDollSteak MrDollSteak is offline
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 20
Gender: Male
Posts: 567
I've done a little bit of work into adding new items, and you're right.

There are actual 4 unknown/misc bytes though. The first one as you've identified is usually the index that is checked when handling the ASM for hold-item effects. The second byte is often also used as you said, to calculate the percentage or damage of the secondary effects.

Though there isn't one specific table for every hold item sadly. Rather, item checks are scattered, similarly to abilities, around the different routines that handle battles.

I've found quite a lot that boost stats eg. Deepseascale, Deepseatooth, Quick Powder, Choice Band etc. within the damage calc routine. So this is a good place to add branches and checks for new items that raise Attack, Defense, Sp. Atk, Sp. Def (such as the Assault Vest).

Locations of some item checks to get you started:

Spoiler:
0x8014E40 - Macho Brace check for Speed drop
0x8014E68 - Quick Claw check for increased priority
0x803EF46 - Choice Band check for Attack Boost
0x803EF92 - Soul Dew check (Raises Sp. Atk and Sp. Def for Latios and Latias)
0x803EFCA - Deepseatooth check (Raises Sp. Atk for Clamperl)
0x803EFE4 - Deepseascale check (Raises Sp. Def for Clamperl)
0x803EFF8 - Light Ball check (Raises Sp. Atk for Pikachu)
0x803F00C - Metal Powder check (Raises Defense for Ditto)
0x803F022 - Thick Club check (Raises Attack for Cubone or Marowak)


I think this is also probably the place to post my Assault vest implementation. I've got it in my rombase and given it to Spherical Ice for Gaia too, but I haven't actually posted it up anywhere on PC before. Just give your item a mystery byte of 0x46 and you're good to go. Alternatively you can just edit all the mentions of 0x46 to an index of your choosing.

Assault Vest:


Spoiler:
Assault Vest I (Sp. Def boost)

Code:
.align 2
.thumb
.thumb_func
.global Assaultvest

assaultvest:
	ldr r2, [sp, #0x1C]
	cmp r2, #0x24
	beq seascale:
	cmp r2, #0x46
	bne return
vest:
	ldr r1, .return3
	bx r1
seascale:
	ldr r3, [sp, #0x4]
	ldrh r1, [r3]
	ldr r0, .return2
	bx r0
return:
	ldr r2, .return
	bx r2

.align
.return:        .word 0x0803EFF7
.return2:        .word 0x0803EFE9
.return3:        .word 0x0803EFEF
*Insert 80 46 01 4A 10 47 00 00 XX+1 XX XX 08* at 3EFDC

Assault Vest II (Prevents the use of Status moves)

Code:
.text
.align 2
.thumb
.thumb_func
.global Assaultvest2

main:
	mov r5, r1
	cmp r3, #0x1D
	beq choice
check:
	cmp r3, #0x46
	beq assaultvest
return:
	ldr r0, .return
	bx r0
choice:
	mov r0, r8
	ldrh r1, [r0]
	ldr r2, .return2
	bx r2
assaultvest:
	mov r2, r4
	mov r0, #0xC
	mul r2, r0
	ldr r0, .movedata
	add r0, r0, r2
	ldrb r0, [r0, #0xA]
	cmp r0, #0x2
	bne return
nostatus:
	ldr r0, .something
	strh r1, [r0]
	ldr r2, .else
	ldrb r1, [r5]
	mov r0, #0x58
	mul r0, r1
	add r0, r0, r7
	ldrh r0, [r0, #0x2E]
	strh r0, [r2]
	ldr r1, .scriptloc
	ldrb r0, [r5]
	lsl r0, r0, #0x2
	add r0, r0, r1
	ldr r1, .script
	str r1, [r0]
	add r0, r6, #0x1
	lsl r0, r0, #0x18
	lsr r6, r0, #0x18
	b return
	
.align
.return:        .word 0x0801773B
.return2:        .word 0x08017707
.movedata:        .word 0x08XXXXXX
.something:        .word 0x02023D4A
.else:        .word 0x02023D68
.scriptloc:        .word 0x02023D80
.script:        .word 0x08AAAAAA
*Insert 00 4D 28 47 XX+1 XX XX 08 at 176FC*

Change XXXXXX to the location of your move table.

Battle Script at AAAAAA (requires setword command at FA as well as messagebox hack):

Code:
FA 20 C0 03 02 BB BB BB 08 10 84 01 44 45 00 09 00 00 00 00 10 2F 01 12 40 00 3C
Message at BBBBBB:

Code:
CE DC D9 00 BB E7 E7 D5 E9 E0 E8 00 D0 D9 E7 E8 00 E4 E6 D9 EA D9 E2 E8 E7 00 E8 DC D9 FE E9 E7 D9 00 E3 DA 00 CD E8 D5 E8 E9 E7 00 C7 E3 EA D9 E7 AB FB

Assault Vest III
(Uses struggle if only status moves are left)

Code:
.text
.align 2
.thumb
.thumb_func
.global Assaultvest3

main:
	ldr r2, [sp]
	cmp r2, #0x1D
	beq choice
	cmp r2, #0x46
	bne return
assault:
	ldrh r2, [r5]
	mov r0, #0xC
	mul r2, r0
	ldr r0, .movedata
	add r0, r0, r2
	ldrb r0, [r0, #0xA]
	cmp r0, #0x2
	bne return
return3:
	ldr r0, .return3
	bx r0
choice:
	ldr r0, [sp, #0x4]
	ldrh r1, [r0]
	cmp r1, #0x0
	beq return
return2:
	ldr r0, .return2
	bx r0
return:
	ldr r0, .return
	bx r0
	
.align
.movedata:        .word 0x08XXXXXX
.return3:        .word 0x08017949
.return2:        .word 0x0801793D
.return:        .word 0x08017951
*insert 00 9A 00 48 00 47 XX+1 XX XX 08 at 0801792E*

Change XXXXXX to the location of your move table.
__________________
Reply With Quote
  #3    
Old September 2nd, 2014 (12:34 AM).
Touched's Avatar
Touched Touched is offline
Resident ASMAGICIAN
 
Join Date: Jul 2014
Gender: Male
Posts: 334
Just adding onto what MrDollSteak said. The function that loads the "held item effect byte" is located here: 0809A924. There are 27 references to this function, which means that there are 27 possible places to hook into or whatever. Many effects are actually checked twice, presumably that's just if the item has multiple effects. Battle and other routines seemingly just check whether to add the effect, rather than there being a table. If you want to add your own effect, it might just make more sense to hook into the battle function you're trying to alter. For example, the critical hit calculator checks the held items here: 0801E438.

However, there is a jump table at 0801CA64 and pointed to by 0801CA60 with a limiter at 0801CA4E that contains 27 cases. This is the berry effect check, and this is basically using a table.
Reply With Quote
  #4    
Old September 2nd, 2014 (03:15 AM).
ApocalypticAnarchist's Avatar
ApocalypticAnarchist ApocalypticAnarchist is offline
 
Join Date: Jul 2014
Location: Irvine, CA aka Hell on Earth
Gender: Male
Nature: Naughty
Posts: 73
How would I be able to implement an eviolite, or one thay doesn't require the pokemon to be able to evolve? Would it just be combining metal powder with the deepseascale and then bypassing the check so the game thinks its a clampearl/ditto thats holding the item?
__________________
Reply With Quote
  #5    
Old September 2nd, 2014 (05:08 PM). Edited September 2nd, 2014 by MrDollSteak.
MrDollSteak's Avatar
MrDollSteak MrDollSteak is offline
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 20
Gender: Male
Posts: 567
Quote originally posted by ApocalypticAnarchist:
How would I be able to implement an eviolite, or one thay doesn't require the pokemon to be able to evolve? Would it just be combining metal powder with the deepseascale and then bypassing the check so the game thinks its a clampearl/ditto thats holding the item?
Making the eviolite is quite easy actually.

All you'd need to do is branch to free space from the original check, load the relevant values over the branch location, then check for the original item ie. deepseascale or metal powder and then return to the original routine if it is correct. Then you'd check for the eviolite byte, and if it's not, then branch to the next item check.

Under the actual eviolite code, to check if a pokemon has an evolution you'd want to do the following.
Load the evo table (0x8259754) into one register. Load the user's pokemon's index number into another register, then mov #0x28 into a third register.
Multiply the index number by #0x28, then add that to the register containing 259754, then load the contents of that register into the same register, and compare that to 0x0. If it is NOT 0x0 (has some form of evolution) it will give a successful boost.

EDIT: I've made the code now!
The index I've used 0x47 is just for my rombase, feel free to change that to whatever you want.

Eviolite
Spoiler:
Eviolite I (Sp. Def boost)

Code:
.text
.align 2
.thumb
.thumb_func
.global eviolite

main:
	ldr r2, [sp, #0x1C]
	cmp r2, #0x24
	beq seascale
	cmp r2, #0x46
	beq vest
	cmp r2, #0x47
	bne return
eviolite:
	ldr r3, [sp, #0x4]
	ldrh r1, [r3] 
	mov r2, #0x28 
	mul r2, r1
	ldr r0, .evotable
	add r0, r1, r0 
	ldr r0, [r0]
	cmp r0, #0x0
	beq return
vest:
	ldr r1, .return3
	bx r1
seascale:
	ldr r3, [sp, #0x4]
	ldrh r1, [r3]
	ldr r0, .return2
	bx r0
return:
	ldr r2, .return
	bx r2

.align
.evotable:        .word 0x08259754
.return:        .word 0x0803EFF7
.return2:        .word 0x0803EFE9
.return3:        .word 0x0803EFEF
*Insert 80 46 01 4A 10 47 00 00 XX+1 XX XX 08* at 3EFDC
(This replaces Assault Vest I's code, so if you intend to use both, feel free to delete the other one)

Eviolite II (Defense boost)

Code:
.text
.align 2
.thumb
.thumb_func
.global eviolite

main:
	ldr r0, [sp, #0x1C]
	cmp r0, #0x40
	beq metalpowder
	cmp r0, #0x47
	bne return
eviolite:
	ldr r1, [sp, #0x4] 
	ldrh r0, [r1] 
	mov r2, #0x28 
	mul r2, r0 
	ldr r0, .evotable
	add r0, r2, r0 
	ldr r0, [r0] 
	cmp r0, #0x0
	beq return
success:
	ldr r3, .return
	bx r3
metalpowder:
	ldr r1, [sp, #0x4]
	ldrh r0, [r1]
	ldr r3, .return2
	bx r3
return:
	ldr r3, .return3
	bx r3

.align
.evotable:        .word 0x08259754
.return:        .word 0x0803F019
.return2:        .word 0x0803F015
.return3:        .word 0x0803F021
*Insert 01 48 00 47 00 00 XX+1 XX XX 08* at 3F00A
__________________
Reply With Quote
  #6    
Old September 2nd, 2014 (06:21 PM).
ApocalypticAnarchist's Avatar
ApocalypticAnarchist ApocalypticAnarchist is offline
 
Join Date: Jul 2014
Location: Irvine, CA aka Hell on Earth
Gender: Male
Nature: Naughty
Posts: 73
Thanks This is really gonna help me with my hack.
__________________
Reply With Quote
  #7    
Old September 2nd, 2014 (08:55 PM).
kearnseyboy6's Avatar
kearnseyboy6 kearnseyboy6 is offline
Aussie's Toughest Mudder
 
Join Date: Dec 2008
Posts: 294
Do you think this might work for forms? Like giratina or Arceus?
__________________
HOLIDAYING CURRENTLY!!
Reply With Quote
  #8    
Old September 4th, 2014 (12:55 AM).
InfiniteZero's Avatar
InfiniteZero InfiniteZero is offline
I never change my Avatar. D=
 
Join Date: Aug 2006
Age: 25
Nature: Brave
Posts: 62
Has anyone discovered or even have a clue on how would one go about making entirely new 'personal'-based item effects e.g Thick Club, Light Ball? Where would the check be located that indicates that the specific Pokemon is eligible to receive that stat boost so that it can be changed to another Pokemon? Like perhaps for example, making it so Seaking could use DeepSeaScale instead of Clamperl?
Reply With Quote
  #9    
Old September 4th, 2014 (02:22 AM).
MrDollSteak's Avatar
MrDollSteak MrDollSteak is offline
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 20
Gender: Male
Posts: 567
Quote originally posted by InfiniteZero:
Has anyone discovered or even have a clue on how would one go about making entirely new 'personal'-based item effects e.g Thick Club, Light Ball? Where would the check be located that indicates that the specific Pokemon is eligible to receive that stat boost so that it can be changed to another Pokemon? Like perhaps for example, making it so Seaking could use DeepSeaScale instead of Clamperl?
Very easily. If you look at my Assault Vest / Eviolite code for the Sp. Def boost you'll notice this section before it branches back to the original routine:

Code:
        ldr r3, [sp, #0x4]
	ldrh r1, [r3]
What this does is load the Pokemon's index number into r1.

This doesn't necessarily work anywhere in the rom, but it does in the immediate item check sections that I've detailed earlier, because of the way the registers are stacked.

Ultimately it's as simple as adding new checks to cmp r1 against the index of the Pokemon you want to get the boost, then upon a successful check branching to the original routine which had the stat boost.
Reply With Quote
  #10    
Old September 4th, 2014 (06:23 AM).
LocksmithArmy's Avatar
LocksmithArmy LocksmithArmy is offline
Mew!
 
Join Date: Feb 2013
Age: 26
Gender: Male
Posts: 402
Quote originally posted by MrDollSteak:
Very easily. If you look at my Assault Vest / Eviolite code for the Sp. Def boost you'll notice this section before it branches back to the original routine:

Code:
        ldr r3, [sp, #0x4]
	ldrh r1, [r3]
What this does is load the Pokemon's index number into r1.

This doesn't necessarily work anywhere in the rom, but it does in the immediate item check sections that I've detailed earlier, because of the way the registers are stacked.

Ultimately it's as simple as adding new checks to cmp r1 against the index of the Pokemon you want to get the boost, then upon a successful check branching to the original routine which had the stat boost.
It sounds to me like you should be writing tutorials on how to ASM lol
__________________
Reply With Quote
  #11    
Old September 4th, 2014 (05:29 PM).
pokepie pokepie is offline
 
Join Date: Oct 2012
Gender: Male
Posts: 23
Would there be any way to combine one of the power-a-certain-type effects AND make it used so we can have the type-boosting gems? Sounds like it shouldn't be hard to do do that since the power-a-certain-type effect takes values.
Reply With Quote
Reply
Quick Reply

Sponsored Links

You may also like.. (Beta)
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 UTC -8. The time now is 12:24 PM.