Go Back   The PokéCommunity Forums > ROM Hacking > Research & Development
Reload this Page Development: Ability Resource Thread

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 January 29th, 2015 (08:09 PM). Edited February 19th, 2015 by MrDollSteak.
MrDollSteak's Avatar
MrDollSteak
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 20
Gender: Male

Ability Resource Thread



This thread is for the development and sharing of new ability routines and battle scripts for Fire Red and Emerald. Requests made by users can definitely be considered just make sure you follow the posting guidelines. Abilities are one of the things that I and other hackers are often asked to share, and make tutorials for, sadly the way in which abilities work, there is no real tutorial that can assist in making an ability outside of general ASM and battle scripting knowledge. For this reason I have decided to create this thread. It also makes it far easier for people to discover bugs or errors in routines, allowing for them to be fixed far more easily.

Extra Information


Before you get started, refer to the following threads for information about the procedure of inserting ASM and of how battle scripts work:

Inserting ASM Routines by FBI Agent
HackMew's Knowledge by HackMew
GBA ASM Programming by Shiny Quagsire
Yet another ASM tutorial by knizz
BSP Scripting Tutorial by Jambo51

Thread rules


Do not demand for your requests to be fulfilled!
People do not have to fulfil your requests, they do it because they want to! Not only are those posts annoying, they also are completely pointless! If such a post is found, it will probably be deleted.

Wrap your abilities and routines in [SPOILER]spoiler tags[/SPOILER].
This is here to keep the thread as easy to browse as possible, as most routines and whatnot tend to take up multiple lines and this can make scrolling through the thread a chore.

Be reasonable with your requests!
This thread is for mostly small ability routines or battle scripts: don't be greedy! No-one is going to make an entire hack for you.

Give credit when requested!
If and when you use any of the routines posted here, give credit to the original creator if they ask for it. If they don't explicitly ask for credit, assume they do. Theft won't be tolerated and if you're caught the moderators will request you add credits to your hack threads, and if not your thread may be deleted.

State the base game for which your requests / abilities are for.
This is mostly to avoid confusion, and to allow for easier organisation of the thread. Please try not to request abilities for Ruby or Sapphire: these games are very difficult to code for and Emerald tends to be far better in nearly every way.

Read the thread before making a request!
Again for organisational reasons, it is a waste of space and time to request abilities which have already been created.

New Abilities


All the routines here are for abilities from Gen 4 and above. They are treated in the index order of the most recent games ORAS +1. This is because Cacophony no longer exists in those games, and therefore does not take an index slot. For this reason while Tangled Feet is listed as ability number 77 on Bulbapedia, if you have expanded your ability table, it will in fact be ability number 78. Remember also that this is the decimal index number, so the routines themselves will be listed with their indexes in hex.

Additionally because some abilities are tied to the same routine, or have prerequisites please look at the ability routines themselves, because you may not need to insert it multiple times, or will need to have inserted other routines to get them to work.

Spoiler:
4E - Tangled Feet
4F - Motor Drive
50 - Rivalry
51 - Steadfast
52 - Snow Cloak
53 - Gluttony
54 - Anger Point
55 - Unburden
56 - Heatproof
57 - Simple
58 - Dry Skin
59 - Download
5A - Iron Fist
5B - Poison Heal
5C - Adaptability
5D - Skill Link
5E - Hydration
5F - Solar Power
60 - Quick Feet
61 - Normalize
62 - Sniper [FR] [EM]
63 - Magic Guard
64 - No Guard
65 - Stall
66 - Technician [FR] [EM]
67 - Leaf Guard
68 - Klutz
69 - Mold Breaker
6A - Super Luck
6B - Aftermath
6C - Anticipation
6D - Forewarn
6E - Unaware
6F - Tinted Lens
70 - Filter
71 - Slow Start
72 - Scrappy
73 - Storm Drain
74 - Ice Body
75 - Solid Rock
76 - Snow Warning
77 - Honey Gather
78 - Frisk
79 - Reckless
7A - Multitype
7B - Flower Gift
7C - Bad Dreams
7D - Pickpocket
7E - Sheer Force
7F - Contrary
80 - Unnerve
81 - Defiant
82 - Defeatist
83 - Cursed Body
84 - Healer
85 - Friend Guard
86 - Weak Armor
87 - Heavy Metal
88 - Light Metal
89 - Multiscale [FR] [EM]
8A - Toxic Boost [FR] [EM]
8B - Flare Boost [FR] [EM]
8C - Harvest
8D - Telepathy
8E - Moody
8F - Overcoat
90 - Poison Touch
91 - Regenerator
92 - Big Pecks
93 - Sand Rush
94 - Wonder Skin
95 - Analytic
96 - Illusion
97 - Imposter
98 - Infiltrator
99 - Mummy
9A - Moxie [FR] [EM]
9B - Justified
9C - Rattled
9D - Magic Bounce [FR] [EM]
9E - Sap Sipper
9F - Prankster
A0 - Sand Force
A1 - Iron Barbs
A2 - Zen Mode
A3 - Victory Star
A4 - Turboblaze
A5 - Teravolt
A6 - Aroma Veil
A7 - Flower Veil
A8 - Cheek Pouch
A9 - Protean
AA - Fur Coat [FR] [EM]
AB - Magician
AC - Bulletproof
AD - Competitive
AE - Strong Jaw
AF - Refrigerate
B0 - Sweet Veil
B1 - Stance Change
B2 - Gale Wings
B3 - Mega Launcher
B4 - Grass Pelt
B5 - Symbiosis
B6 - Tough Claws
B7 - Pixilate
B8 - Gooey
B9 - Aerilate
BA - Parental Bond
BB - Dark Aura
BC - Fairy Aura
BD - Aura Break
BE - Primordial Sea
BF - Desolate Land
C0 - Delta Stream


Updated Effects



All the routines here are to add effects that did not exist in Gen 3 to abilities that did. They use the same index numbers as the existing abilities.

Spoiler:
01 - Stench
05 - Sturdy [FR] [EM]
0C - Oblivious
17 - Shadow Tag
18 - Rough Skin [FR] [EM]
1F - Lightning Rod
28 - Magma Armor
2E - Pressure
31 - Flame Body
__________________
Reply With Quote
  #2    
Old January 30th, 2015 (01:21 AM). Edited February 4th, 2015 by MrDollSteak.
MrDollSteak's Avatar
MrDollSteak
Formerly known as 11bayerf1
 
Join Date: Dec 2008
Location: Hong Kong
Age: 20
Gender: Male
To start off here are a few damage-calc related abilities as well as an update Sturdy effect!

These abilities require Doesnt's PSS Split, because of a few shifting bytes.

Sniper, Technician and the Slow Start Attack Drop
Spoiler:
Fire Red
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global snipertechnicianandslowstartattackdrop
 
Main:
	cmp r4, #0x37
	bne Sniper
HustleBoost:
	lsr r0, r7, #0x1
	add r7, r0, r7
Sniper:
	cmp r4, #0x62
	bne Technician
CheckCrit:
	ldr r0, .CritLoc
	ldrb r0, [r0]
	cmp r0, #0x2
	bne Return
	b Boost
Technician:
	cmp r4, #066
	bne SlowStart
CheckBasePower:
	ldr r0, .BasePower
	ldrb r0, [r0]
	cmp r0, #0x3D
	bge Return
Boost:
	lsr r0, r7, #0x1
	add r7, r0, r7
	mov r2, r8
	lsr r0, r2, #0x1
	add r0, r0, r2
	mov r8, r0
SlowStart:
	cmp r4, #0x71
	bne Return
CheckCounter:
	ldr r0, .SlowStartLoc
	ldr r2, [sp, #0xC]
	add r0, r0, r2
	ldrb r0, [r0]
	cmp r0, #0x0
	beq Return
AttackDrop:
	lsr r7, r7, #0x1
Return:
	ldr r0, .Return
	bx r0

.align 2
.CritLoc: .word 0x02023D71
.BasePower: .word 0x02024020
.SlowStartLoc: .word 0x0203C024
.Return: .word 0x0803F065

#Insert 00 48 00 47 xx xx xx 08 at 03F05C
.SlowStartLoc is a free ram location that you can use to have the counter for slow start.

It has come to my attention that Technician can apply some unwanted boosts to Revenge and a few other moves, so the code will be amended in the future.

Emerald
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global snipertechnicianandslowstartattackdrop
 
Main:
	cmp r4, #0x37
	bne Sniper
HustleBoost:
	lsr r0, r7, #0x1
	add r7, r0, r7
Sniper:
	cmp r4, #0x62
	bne Technician
CheckCrit:
	ldr r0, .CritLoc
	ldrb r0, [r0]
	cmp r0, #0x2
	bne Return
	b Boost
Technician:
	cmp r4, #066
	bne SlowStart
CheckBasePower:
	ldr r0, .BasePower
	ldrb r0, [r0]
	cmp r0, #0x3D
	bge Return
Boost:
	lsr r0, r7, #0x1
	add r7, r0, r7
	mov r2, r8
	lsr r0, r2, #0x1
	add r0, r0, r2
	mov r8, r0
SlowStart:
	cmp r4, #0x71
	bne Return
CheckCounter:
	ldr r0, .SlowStartLoc
	ldr r2, [sp, #0x10]
	add r0, r0, r2
	ldrb r0, [r0]
	cmp r0, #0x0
	beq Return
AttackDrop:
	lsr r7, r7, #0x1
Return:
	ldr r0, .Return
	bx r0

.align 2
.CritLoc: .word 0x02024211
.BasePower: .word 0x020244E0
.SlowStartLoc: .word 0x0203E324
.Return: .word 0x0806989B

#Insert 00 48 00 47 xx xx xx 08 at 069888
.SlowStartLoc is a free ram location that you can use to have the counter for slow start.

It has come to my attention that Technician can apply some unwanted boosts to Revenge and a few other moves, so the code will be amended in the future.


Toxic Boost and Flare Boost
Spoiler:
Fire Red
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global statusboostabilities
 
Main:
  	ldr r1, [sp, #0x24]
	ldrb r0, [r1]
	cmp r0, #0x8A
	beq ToxicBoost
	cmp r0, #0x8B
	beq FlareBoost
	cmp r0, #0x3E
	bne MarvelScaleCheck
GutsReturn:
	ldr r0, .Return
	bx r0
ToxicBoost:
	ldr r0, [r6, #0x4C]
CheckPoison:
	cmp r0, #0x8
	beq AttackBoost
	cmp r0, #0x80
	bne MarvelScaleCheck
AttackBoost:
	lsr r0, r7, #0x1
	add r7, r0, r7
	b MarvelScaleCheck
FlareBoost:
	ldr r0, [r6, #0x4C]
CheckBurn:
	cmp r0, #0x10
	bne MarvelScaleCheck
SpAtkBoost:
	mov r2, r8
	lsr r0, r2, #0x1
	add r2, r0, r2
	mov r8, r2
MarvelScaleCheck:
	ldr r0, .Return2
	bx r0
 
.align 2
.Return: .word 0x0803F0CD
.Return2: .word 0x0803F0E1

#insert 00 48 00 47 xx xx xx 08 at 03F0C4

Emerald
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global statusboostabilities
 
Main:
	ldrb r0, [r1]
	cmp r0, #0x8A
	beq ToxicBoost
	cmp r0, #0x8B
	beq FlareBoost
	cmp r0, #0x3E
	bne MarvelScaleCheck
Guts:
CheckStatus:
	ldr r0, [r6, #0x4C]
	cmp r0, #0x0
	beq MarvelScaleCheck
GutsReturn:
	ldr r0, .Return
	bx r0
ToxicBoost:
	ldr r0, [r6, #0x4C]
CheckPoison:
	cmp r0, #0x8
	beq AttackBoost
	cmp r0, #0x80
	bne MarvelScaleCheck
AttackBoost:
	lsr r0, r7, #0x1
	add r7, r0, r7
	b MarvelScaleCheck
FlareBoost:
	ldr r0, [r6, #0x4C]
CheckBurn:
	cmp r0, #0x10
	bne MarvelScaleCheck
SpAtkBoost:
	mov r2, r8
	lsr r0, r2, #0x1
	add r2, r0, r2
	mov r8, r2
MarvelScaleCheck:
	ldr r0, .Return2
	bx r0
 
.align 2
.Return: .word 0x08069909
.Return2: .word 0x08069917

#insert 00 48 00 47 xx xx xx 08 at 0698FC


Multiscale and Furcoat
Spoiler:
Fire Red
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global multiscaleandfurcoat
 
Main:
	ldr r2, [sp, #0x28]
	ldrb r0, [r2]
	cmp r0, #0x3F
	bne Multiscale
	ldr r0, .Return
	bx r0
Multiscale:
	cmp r0, #0x89
	bne FurCoat
CheckHP:
	ldr r1, [sp, #0x4]
	ldrh r0, [r1, #0x28]
	ldrh r1, [r1, #0x2C]
	cmp r1, r0
	bne Return
HalveDamage:
	lsr r7, r7, #0x1
	mov r0, r8
	lsr r0, r0, #0x1
	mov r8, r0
FurCoat:
	cmp r0, #0xAA
	bne Return
DefenseBoost:
	ldr r1, [sp, #0x14]
	mov r0, r1
	add r1, r0, r0
	str r1, [sp, #0x14]
Return:
	ldr r2, .Return2
	bx r2

.align 2
.Return: .word 0x0803F0E9
.Return2: .word 0x0803F103

#insert 00 48 00 47 xx xx xx 08 at 03F0E0

Emerald
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global multiscaleandfurcoat
 
Main:
	ldrb r0, [r2]
	cmp r0, #0x3F
	bne Multiscale
	ldr r3, [sp, #0x4]
	ldr r0, .Return
	bx r0
Multiscale:
	cmp r0, #0x89
	bne Furcoat
CheckHP:
	ldr r1, [sp, #0x4]
	ldrh r0, [r1, #0x28]
	ldrh r1, [r1, #0x2C]
	cmp r1, r0
	bne Return
HalveDamage:
	lsr r7, r7, #0x1
	mov r0, r8
	lsr r0, r0, #0x1
	mov r8, r0
FurCoat:
	cmp r0, #0xAA
	bne Return
DefenseBoost:
	ldr r1, [sp, #0x18]
	mov r0, r1
	add r1, r0, r0
	str r1, [sp, #0x18]
Return:
	ldr r2, .Return2
	bx r2

.align 2
.Return: .word 0x08069921
.Return2: .word 0x08069939

#insert 00 48 00 47 xx xx xx 08 at 069918


Sturdy
Spoiler:
Fire Red
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global sturdyupdate
 
Sturdy:
	ldrb r0, [r3]
	mov r1, #0x58
	mul r0, r1
	add r0, r0, r2
	add r0, #0x20
	ldrb r1, [r0]
	cmp r1, #0x5
	bne FalseSwipeCheck
CheckHP:
	ldrh r1, [r0, #0xC]
	ldrh r0, [r0, #0x8]
	cmp r0, r1
	beq SturdySuccess
FalseSwipeCheck:
	ldr r0, .Moveloc
	ldrh r1, [r0]
	lsl r0, r1, #0x1
	add r0, r0, r1
	ldr r2, .Return
	bx r2
SturdySuccess:
DisplayEndureMessage:
	mov r0, #0x56
	ldr r1, .index
	ldrb r2, [r3]
	lsl r0, r2, #0x4
	add r0, r0, r1
	mov r1, #0x2
	strb r1, [r0]
Return:
	ldr r0, .Return2
	bx r0

.align 2

.MoveLoc: .word 0x02023D4A
.Return: .word 0x0801F1ED
.Index: .word 0x02023E8C
.Return2: .word 0x0801F217

#insert 01 48 00 47 00 00 xx xx xx 08 1A 4A at 01F1E2
It should be noted that this doesn't work fully with Multi-hit moves, in that they do not break Sturdy. I am planning on rewriting the entire Multi-hit system to make Parental Bond.

Emerald
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global sturdyupdate
 
Sturdy:
	ldrb r0, [r3]
	mov r1, #0x58
	mul r0, r1
	add r0, r0, r2
	add r0, #0x20
	ldrb r1, [r0]
	cmp r1, #0x5
	bne FalseSwipeCheck
CheckHP:
	ldrh r1, [r0, #0xC]
	ldrh r0, [r0, #0x8]
	cmp r0, r1
	beq SturdySuccess
FalseSwipeCheck:
	ldr r0, .MoveLoc
	ldrh r1, [r0]
	lsl r0, r1, #0x1
	add r0, r0, r1
	ldr r2, .Return
	bx r2
SturdySuccess:
DisplayEndureMessage:
	mov r0, #0x56
	ldr r1, .Index
	ldrb r2, [r3]
	lsl r0, r2, #0x4
	add r0, r0, r1
	mov r1, #0x2
	strb r1, [r0]
Return:
	ldr r0, .Return2
	bx r0

.align 2

.MoveLoc: .word 0x020241EA
.Return: .word 0x080479DD
.Index: .word 0x0202433C
.Return2: .word 0x08047A07

#insert 01 48 00 47 00 00 xx xx xx 08 1A 4A at 0479D2
It should be noted that this doesn't work fully with Multi-hit moves, in that they do not break Sturdy. I am planning on rewriting the entire Multi-hit system to make Parental Bond.
__________________
Reply With Quote
  #3    
Old January 30th, 2015 (02:52 AM). Edited January 30th, 2015 by RaileysXerilyasRX.
RaileysXerilyasRX's Avatar
RaileysXerilyasRX
Impressive. Most impressive.
 
Join Date: Feb 2014
Location: Philippines
Gender: Male
Nature: Adamant
Send a message via Skype™ to RaileysXerilyasRX
It is an excellent thing that someone finally made this kind of thread. Keep it up dude!
It is kinda bit complicated for me about how abilities are triggered when in need. Well, I'm off to study them.

EDIT: One good question: if two routines (one is old and one is latest but different abilities) collides when "insert this at whatever offset", will you rewrite the asm? I don't know if you understand this question and I don't also know if this will possible in progress.

EDIT2: Ported the new Sturdy... there is a bug/error at: In the same turn, if the faster one attacks the enemy then enemy activates sturdy then the enemy uses a status move that affects with snatch, there will be a message appear that is snatch related. I don't know if you can understand this but do a battle in the same turn that you attack first that makes that sturdy effect on the enemy and the enemy uses a status move that affects snatch so you will see what I mean. It snatched itself. A status move used in the next turn after sturdy's turn still works fine (no snatch message). Noted that I have applied expansion of pokemon, types, attacks, abilities, and the pss patch and icons whenever I'm going to post some errors dude.
__________________
Reply With Quote
  #4    
Old January 31st, 2015 (12:50 AM). Edited January 31st, 2015 by KDS.
KDS's Avatar
KDS
 
Join Date: Jul 2013
Age: 20
Gender: Male
There was a report mentioning problems with the Magic Bounce Ability in MrDS's Rombase, so I decided it to implement this myself from scratch, and it is working fine in Trainer Battles and Doubles.
Here it is posted with Moxie.

Magic Bounce
Spoiler:
Fire Red
Spoiler:
Routine At XXXXXX:
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global magicbounce
.align 2
     
        mov r9, r2
        ldr r1, freeRAMLoc
        ldrb r1, [r1, #0x0]
        cmp r1, #0x0
        bne nobouncing
        cmp r0, #0x0
        bge magicbouncecheck
        
        ldr r2, moveTable
        ldr r1, =0x0801D8E9
        bx r1

magicbouncecheck:
        ldr r2, =0x02023C04
        ldr r1, =0x02023D6C
        ldrb r3, [r1, #0x0]
        mov r1, #0x58
        mul r1, r3
        add r1, r1, r2
        ldrb r1, [r1, #0x0]
        cmp r1, #0x9D
        bne nobouncing

        ldr r2, =0x02023DFC
        lsl r1, r3, #0x02
        add r1, r1, r2
        ldr r1, [r1, #0x0]
        ldr r0, =0x000400C0
        and r0, r1
        cmp r0, #0x0
        bne nobouncing

        ldr r2, moveTable
        ldr r0, =0x02023D4A
        ldrh r1, [r0, #0x0]
        lsl r0, r1, #0x01
        add r0, r0, r1
        lsl r0, r0, #0x02
        add r0, r0, r2
        ldrb r1, [r0, #0x8]
        mov r0, #0x4
        and r0, r1
        cmp r0, #0x0
        beq nobouncing 

        ldr r0, =0x02023D6B
        ldrb r0, [r0, #0x0]
        ldr r2, =0x00000115
        add r1, r3, #0x0
        bl pressure

        bl returnSetter

        ldr r1, =0x02023D74
        ldr r0, MBScript
        str r0, [r1, #0x0]
        ldr r0, =0x0801DAFD
        bx r0

nobouncing:
        ldr r1, =0x0801D94D
        bx r1

pressure:
        ldr r3, =0x08016EC9
        bx r3

returnSetter:
        ldr r1, =0x08017545
        bx r1

.align 2
freeRAMLoc: .word 0x0203C030
moveTable: .word 0x08250C04
MBScript: .word 0x08VVVVVV

@At 1D8E0, insert: 00 49 08 47 XX+1 XX XX 08


Routine At YYYYYY:
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global bounceflagclear
.align 2

ldr r3, freeRAMLoc
ldrb r0, [r3, #0x0]
cmp r0, #0x0
beq exit
sub r0, r0, #0x1
strb r0, [r3, #0x0]

exit:
add sp, #0x4
pop {r3, r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0

.align 2
freeRAMLoc: .word 0x0203C030

@At 1DAFC, insert: 00 48 00 47 YY+1 YY YY 08


Routine At ZZZZZZ:
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global setbouncereflectionflag

main:    
    push {lr}
    ldr r0, freeRAMLoc
    ldr r1, =0x02023BCC
    ldrb r1, [r1, #0x0]
    cmp r1, #0x2
    beq oneexit

    ldr r2, =0x02023D4A
    ldr r1, moveTable
    mov r3, #0xC
    ldrb r2, [r2, #0x0]
    mul r3, r2
    add r1, r1, r3
    ldrb r1, [r1, #0x6]
    cmp r1, #0x8
    bne oneexit

    ldr r2, =0x02023D6D
    ldrb r2, [r2, #0x0]
    mov r1, #0x58
    mul r1, r2
    ldr r3, =0x02023C0C
    add r3, r3, r1
    ldrh r3, [r3, #0x0]
    cmp r3, #0x0
    beq oneexit

    mov r1, #0x2
    strb r1, [r0, #0x0]
    pop {r0}
    bx r0

oneexit:
    mov r1, #0x1
    strb r1, [r0, #0x0]
    pop {r0}
    bx r0

.align 2
freeRAMLoc: .word 0x0203C030
moveTable: .word 0x08250C04


Magic Coat Script (At UUUUUU):
Spoiler:
At x1D934, insert in reverse hex: UU UU UU 08
Code:
02 03 39 20 00 10 BE 00 12 40 00 F8 ZZ+1 ZZ ZZ 08 35 D0 3D 02 02 00 0C 80 00 76 01 01 3C


Magic Bounce Script (At VVVVVV):
Spoiler:
Code:
02 03 39 20 00 FA 20 C0 03 02 SS SS SS 08 10 84 01 12 40 00 F8 ZZ+1 ZZ ZZ 08 35 D0 3D 02 02 00 0C 80 00 76 01 01 3C


String At SSSSSS:
Code:
FD 13 B4 E7 00 FD 14 FE EB D5 E7 00 D6 E3 E9 E2 D7 D9 D8 00 D6 D5 D7 DF 00 D6 ED 00 FD 1B AB FF
Notes to understand this:
Spoiler:

+ If for some stupid reason, Magic Coat is used on a Magic Bounce pokemon, then Magic coat activates before Magic bounce.
+ Magic Bounce does not activate, if the mon with Magic Bounce is in a semi-invulnerable state (fly, dive etc.).
+ Added a special Flag to ensure that Magic Bounce does not re-reflect a move reflected by Magic Bounce/Magic Coat. Otherwise, a infinite ping-pong loop happens between two Magic Bounce pokemon.
+ A free RAM location is used for this Flag. Initially, it is set to 0. When the condition for Magic Coat or Magic Bounce is met, it is set to 1 (e.g, always the case in singles, reflected spore in doubles) or 2 (e.g reflected growl in doubles), according to the no. of mons the rebounded Move can affect, and then the Rebound is executed.
+ If the value of the Flag is non-zero, the Magic Bounce and Magic Coat checks are automatically skipped to avoid the re-reflection situation and the Flag is decremented by 1 and this Step is repeated until the Flag is cleared to 0.
+ This to try to ensure that during the Rebound itself, the Flag is successfully cleared to 0.
+ The free RAM location refered in the 3 routines MUST BE SAME.
+ Will port to Emerald soon.




Moxie
Spoiler:
Fire Red
Spoiler:
At x213DC, insert in reverse hex: XX XX XX 08

Battle Script at XXXXXX:
Spoiler:
Code:
56 00
39 40 00
1A 00
1B 00
10 1D 00
10 30 01
1E 01 9A YY YY YY 08
3C


Battle Script at YYYYYY:
Spoiler:
Code:
E3 01 ZZ ZZ ZZ 08
20 01 00 01 0C ZZ ZZ ZZ 08
39 20 00
2E DF 3F 02 02 00
48 01 02 00
2E DE 3F 02 02 11
89 41 ZZ ZZ ZZ 08
FA 20 C0 03 02 SS SS SS 08 
10 84 01
12 40 00
3C


Battle Script at ZZZZZZ:
Code:
3C
String at SSSSSS:
Code:
FD 0F B4 E7 00 C7 E3 EC DD D9 FE E6 D5 DD E7 D9 D8 00 DD E8 E7 00 BB E8 E8 D5 D7 DF AB FF


Emerald
Spoiler:

At x49C04, insert in reverse hex: XX XX XX 08

Battle Script at XXXXXX:
Spoiler:
Code:
56 00
39 40 00
1A 00
1B 00
10 1D 00
10 30 01
1E 01 9A YY YY YY 08
3C


Battle Script at YYYYYY:
Spoiler:
Code:
E3 01 ZZ ZZ ZZ 08
20 01 00 01 0C ZZ ZZ ZZ 08
39 20 00
2E 8F 44 02 02 00
48 01 02 00
2E 8E 44 02 02 11
89 41 ZZ ZZ ZZ 08
FB 20 E3 03 02 SS SS SS 08 //Assuming that setword command is at FB, and the RAM location for the string pointer is at 0x203E320. If not, then change this line accordingly
10 84 01
12 40 00
3C


Battle Script at ZZZZZZ:
Code:
3C
String At SSSSSS:
Code:
FD 0F B4 E7 00 C7 E3 EC DD D9 FE E6 D5 DD E7 D9 D8 00 DD E8 E7 00 BB E8 E8 D5 D7 DF AB FF



Also, these require Jambo's Callasm and Setword commands, and his Battle String Loader Hack.
Reply With Quote
  #5    
Old January 31st, 2015 (01:04 AM).
Lance32497's Avatar
Lance32497
LanceKoijer of Pokemon_Addicts
 
Join Date: Aug 2014
Location: Criscanto town-Ginoa Region xD
Gender: Male
Nature: Adamant
Finally
This is what I'm waiting for!
__________________
My Threads

Reply With Quote
  #6    
Old February 1st, 2015 (05:55 PM).
HidoranBlaze's Avatar
HidoranBlaze
 
Join Date: Apr 2013
Age: 18
Gender: Male
Quote originally posted by RaileysXerilyasRX:
It is an excellent thing that someone finally made this kind of thread. Keep it up dude!
It is kinda bit complicated for me about how abilities are triggered when in need. Well, I'm off to study them.

EDIT: One good question: if two routines (one is old and one is latest but different abilities) collides when "insert this at whatever offset", will you rewrite the asm? I don't know if you understand this question and I don't also know if this will possible in progress.

EDIT2: Ported the new Sturdy... there is a bug/error at: In the same turn, if the faster one attacks the enemy then enemy activates sturdy then the enemy uses a status move that affects with snatch, there will be a message appear that is snatch related. I don't know if you can understand this but do a battle in the same turn that you attack first that makes that sturdy effect on the enemy and the enemy uses a status move that affects snatch so you will see what I mean. It snatched itself. A status move used in the next turn after sturdy's turn still works fine (no snatch message). Noted that I have applied expansion of pokemon, types, attacks, abilities, and the pss patch and icons whenever I'm going to post some errors dude.
That's a bug MrDS and I encountered when we were making sturdy. It's fixed in the FR version, but not EM's for some reason (probably a goof on Dollsteak's part). At DisplayEndureMessage, change mov r1, #0x32 to mov r1, #0x2.
Reply With Quote
  #7    
Old February 12th, 2015 (12:58 AM).
Urobolos
 
Join Date: Nov 2014
Quote originally posted by KDS:
Also, these require Jambo's Callasm and Setword commands, and his Battle String Loader Hack.
Where can I find the files to patch those in.

Also, would this work with the Mr Dollsteak's Decap Patch?
Reply With Quote
  #8    
Old February 13th, 2015 (03:04 PM).
Z-nogyroP
 
Join Date: May 2014
Gender: Male
Alright, I tried implementing the Sturdy for FireRed with MrDollSteak's patch applied to it, but the game froze when I tried the opposing Tepig used Overheat on my Turtwig. At first I thought it was an issue with Overheat, so I tried changing it to Blast Burn, but same thing happened. Note that both times I used Withdraw on the first turn. I tried again, but I used Tackle, and it froze. I wondered if it was an issue with the Rombase and not being compatible, so I went to a clean FireRed ROM, inserted it there, and it happened again. Am I doing something wrong, or can someone else verify that the Sturdy routine is messed up?
Reply With Quote
  #9    
Old February 13th, 2015 (11:15 PM).
ShyRayq's Avatar
ShyRayq
Unprofessional Unprofessional
 
Join Date: Aug 2007
Gender: Male
Nature: Adamant
Quote originally posted by Z-nogyroP:
Alright, I tried implementing the Sturdy for FireRed with MrDollSteak's patch applied to it, but the game froze when I tried the opposing Tepig used Overheat on my Turtwig. At first I thought it was an issue with Overheat, so I tried changing it to Blast Burn, but same thing happened. Note that both times I used Withdraw on the first turn. I tried again, but I used Tackle, and it froze. I wondered if it was an issue with the Rombase and not being compatible, so I went to a clean FireRed ROM, inserted it there, and it happened again. Am I doing something wrong, or can someone else verify that the Sturdy routine is messed up?
When you placed the hook in, did you add 1 to the routine's pointer? Because you need to do that. If you did, I'm not sure what the problem is.
__________________
3DS Friend Code: 5069-3944-3902
IGN: Peter, (Pokemon Y, Pokemon OR)
Friend Safari: (Fighting) Throh, Meditite, Breloom
Live Pokedex (Y) Completed as of 02/03/14 (718), 10/11/14 (719)
Live Pokedex (OR) Completed as of 25/12/14 (719)
Big thanks especially to DestinedJagold, Xerneas_X, Elements1 and ~RNC~

PM me if you want to trade, or add my FC.
Reply With Quote
  #10    
Old February 14th, 2015 (05:08 AM).
Z-nogyroP
 
Join Date: May 2014
Gender: Male
...durr, I pulled a dumb. Works perfectly now! Thank you!

Also, do you plan on adding these abilities to your ROMbase if they aren't already there (like the upgraded Sturdy, and KDS's new Magic Bounce)?
Reply With Quote
  #11    
Old February 15th, 2015 (02:27 AM).
AtecainCorp.'s Avatar
AtecainCorp.
Rejishan awake...
 
Join Date: Jun 2008
Location: Takoabe Town (Region Thonsu)
Age: 22
Gender: Male
Nature: Hardy
Quote originally posted by KDS:
There was a report mentioning problems with the Magic Bounce Ability in MrDS's Rombase, so I decided it to implement this myself from scratch, and it is working fine in Trainer Battles and Doubles.
Here it is posted with Moxie.

Magic Bounce
Spoiler:
Fire Red
Spoiler:
Routine At XXXXXX:
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global magicbounce
.align 2
     
        mov r9, r2
        ldr r1, freeRAMLoc
        ldrb r1, [r1, #0x0]
        cmp r1, #0x0
        bne nobouncing
        cmp r0, #0x0
        bge magicbouncecheck
        
        ldr r2, moveTable
        ldr r1, =0x0801D8E9
        bx r1

magicbouncecheck:
        ldr r2, =0x02023C04
        ldr r1, =0x02023D6C
        ldrb r3, [r1, #0x0]
        mov r1, #0x58
        mul r1, r3
        add r1, r1, r2
        ldrb r1, [r1, #0x0]
        cmp r1, #0x9D
        bne nobouncing

        ldr r2, =0x02023DFC
        lsl r1, r3, #0x02
        add r1, r1, r2
        ldr r1, [r1, #0x0]
        ldr r0, =0x000400C0
        and r0, r1
        cmp r0, #0x0
        bne nobouncing

        ldr r2, moveTable
        ldr r0, =0x02023D4A
        ldrh r1, [r0, #0x0]
        lsl r0, r1, #0x01
        add r0, r0, r1
        lsl r0, r0, #0x02
        add r0, r0, r2
        ldrb r1, [r0, #0x8]
        mov r0, #0x4
        and r0, r1
        cmp r0, #0x0
        beq nobouncing 

        ldr r0, =0x02023D6B
        ldrb r0, [r0, #0x0]
        ldr r2, =0x00000115
        add r1, r3, #0x0
        bl pressure

        bl returnSetter

        ldr r1, =0x02023D74
        ldr r0, MBScript
        str r0, [r1, #0x0]
        ldr r0, =0x0801DAFD
        bx r0

nobouncing:
        ldr r1, =0x0801D94D
        bx r1

pressure:
        ldr r3, =0x08016EC9
        bx r3

returnSetter:
        ldr r1, =0x08017545
        bx r1

.align 2
freeRAMLoc: .word 0x0203C030
moveTable: .word 0x08250C04
MBScript: .word 0x08VVVVVV

@At 1D8E0, insert: 00 49 08 47 XX+1 XX XX 08


Routine At YYYYYY:
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global bounceflagclear
.align 2

ldr r3, freeRAMLoc
ldrb r0, [r3, #0x0]
cmp r0, #0x0
beq exit
sub r0, r0, #0x1
strb r0, [r3, #0x0]

exit:
add sp, #0x4
pop {r3, r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0

.align 2
freeRAMLoc: .word 0x0203C030

@At 1DAFC, insert: 00 48 00 47 YY+1 YY YY 08


Routine At ZZZZZZ:
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global setbouncereflectionflag

main:    
    push {lr}
    ldr r0, freeRAMLoc
    ldr r1, =0x02023BCC
    ldrb r1, [r1, #0x0]
    cmp r1, #0x2
    beq oneexit

    ldr r2, =0x02023D4A
    ldr r1, moveTable
    mov r3, #0xC
    ldrb r2, [r2, #0x0]
    mul r3, r2
    add r1, r1, r3
    ldrb r1, [r1, #0x6]
    cmp r1, #0x8
    bne oneexit

    ldr r2, =0x02023D6D
    ldrb r2, [r2, #0x0]
    mov r1, #0x58
    mul r1, r2
    ldr r3, =0x02023C0C
    add r3, r3, r1
    ldrh r3, [r3, #0x0]
    cmp r3, #0x0
    beq oneexit

    mov r1, #0x2
    strb r1, [r0, #0x0]
    pop {r0}
    bx r0

oneexit:
    mov r1, #0x1
    strb r1, [r0, #0x0]
    pop {r0}
    bx r0

.align 2
freeRAMLoc: .word 0x0203C030
moveTable: .word 0x08250C04


Magic Coat Script (At UUUUUU):
Spoiler:
At x1D934, insert in reverse hex: UU UU UU 08
Code:
02 03 39 20 00 10 BE 00 12 40 00 F8 ZZ+1 ZZ ZZ 08 35 D0 3D 02 02 00 0C 80 00 76 01 01 3C


Magic Bounce Script (At VVVVVV):
Spoiler:
Code:
02 03 39 20 00 FA 20 C0 03 02 SS SS SS 08 10 84 01 12 40 00 F8 ZZ+1 ZZ ZZ 08 35 D0 3D 02 02 00 0C 80 00 76 01 01 3C


String At SSSSSS:
Code:
FD 13 B4 E7 00 FD 14 FE EB D5 E7 00 D6 E3 E9 E2 D7 D9 D8 00 D6 D5 D7 DF 00 D6 ED 00 FD 1B AB FF
Notes to understand this:
Spoiler:

+ If for some stupid reason, Magic Coat is used on a Magic Bounce pokemon, then Magic coat activates before Magic bounce.
+ Magic Bounce does not activate, if the mon with Magic Bounce is in a semi-invulnerable state (fly, dive etc.).
+ Added a special Flag to ensure that Magic Bounce does not re-reflect a move reflected by Magic Bounce/Magic Coat. Otherwise, a infinite ping-pong loop happens between two Magic Bounce pokemon.
+ A free RAM location is used for this Flag. Initially, it is set to 0. When the condition for Magic Coat or Magic Bounce is met, it is set to 1 (e.g, always the case in singles, reflected spore in doubles) or 2 (e.g reflected growl in doubles), according to the no. of mons the rebounded Move can affect, and then the Rebound is executed.
+ If the value of the Flag is non-zero, the Magic Bounce and Magic Coat checks are automatically skipped to avoid the re-reflection situation and the Flag is decremented by 1 and this Step is repeated until the Flag is cleared to 0.
+ This to try to ensure that during the Rebound itself, the Flag is successfully cleared to 0.
+ The free RAM location refered in the 3 routines MUST BE SAME.
+ Will port to Emerald soon.




Moxie
Spoiler:
Fire Red
Spoiler:
At x213DC, insert in reverse hex: XX XX XX 08

Battle Script at XXXXXX:
Spoiler:
Code:
56 00
39 40 00
1A 00
1B 00
10 1D 00
10 30 01
1E 01 9A YY YY YY 08
3C


Battle Script at YYYYYY:
Spoiler:
Code:
E3 01 ZZ ZZ ZZ 08
20 01 00 01 0C ZZ ZZ ZZ 08
39 20 00
2E DF 3F 02 02 00
48 01 02 00
2E DE 3F 02 02 11
89 41 ZZ ZZ ZZ 08
FA 20 C0 03 02 SS SS SS 08 
10 84 01
12 40 00
3C


Battle Script at ZZZZZZ:
Code:
3C
String at SSSSSS:
Code:
FD 0F B4 E7 00 C7 E3 EC DD D9 FE E6 D5 DD E7 D9 D8 00 DD E8 E7 00 BB E8 E8 D5 D7 DF AB FF


Emerald
Spoiler:

At x49C04, insert in reverse hex: XX XX XX 08

Battle Script at XXXXXX:
Spoiler:
Code:
56 00
39 40 00
1A 00
1B 00
10 1D 00
10 30 01
1E 01 9A YY YY YY 08
3C


Battle Script at YYYYYY:
Spoiler:
Code:
E3 01 ZZ ZZ ZZ 08
20 01 00 01 0C ZZ ZZ ZZ 08
39 20 00
2E 8F 44 02 02 00
48 01 02 00
2E 8E 44 02 02 11
89 41 ZZ ZZ ZZ 08
FB 20 E3 03 02 SS SS SS 08 //Assuming that setword command is at FB, and the RAM location for the string pointer is at 0x203E320. If not, then change this line accordingly
10 84 01
12 40 00
3C


Battle Script at ZZZZZZ:
Code:
3C
String At SSSSSS:
Code:
FD 0F B4 E7 00 C7 E3 EC DD D9 FE E6 D5 DD E7 D9 D8 00 DD E8 E7 00 BB E8 E8 D5 D7 DF AB FF



Also, these require Jambo's Callasm and Setword commands, and his Battle String Loader Hack.

Someone can traslate me MOXIE effect for Pokemon Fire Red? I'm confused.
__________________
This signature has been disabled.
Exceeds the 600px width limit.
Please review and fix the issues by reading the signature rules.

You must edit it to meet the limits set by the rules before you may remove the [sig-reason] code from your signature. Removing this tag will re-enable it.

Do not remove the tag until you fix the issues in your signature. You may be infracted for removing this tag if you do not fix the specified issues. Do not use this tag for decoration purposes.
Reply With Quote
  #12    
Old February 16th, 2015 (09:43 AM).
Z-nogyroP
 
Join Date: May 2014
Gender: Male
If I may make a suggestion? I think it would be very useful to upload the codes for Mega Launcher and Reckless, because those abilities (boost moves if they are in a certain table) could be very useful in making "new" abilities. Just a thought.
Reply With Quote
  #13    
Old 4 Weeks Ago (07:46 AM).
KDS's Avatar
KDS
 
Join Date: Jul 2013
Age: 20
Gender: Male
Quote originally posted by Urobolos:
Where can I find the files to patch those in.

Also, would this work with the Mr Dollsteak's Decap Patch?
Sorry the for the late reply. The callasm command and battle string loader hack are posted in the Quick R&D thread and these things are already installed in MrDS' Patch.

Quote originally posted by AtecainCorp.:
Someone can traslate me MOXIE effect for Pokemon Fire Red? I'm confused.
Lol, you just the need to make the byte changes mentioned the post in a Hex Editor and install Jambo's battle string and setword command.

Anyway, here are some more abilities!

1. Mold Breaker, Teravolt and Turboblaze:
Spoiler:
Fire Red:
Spoiler:
Step I
Spoiler:
Mold Breaker Table:-
Code:
00 00 00 00 01 01 00 01 01 00 01 01 01 00 00 01 
00 02 01 01 01 01 00 00 00 01 02 00 00 01 00 00 
00 00 00 00 00 00 00 01 01 01 00 01 00 00 00 01 
00 00 00 01 01 00 00 00 00 00 00 00 01 00 00 01 
00 00 00 00 00 00 00 00 01 01 00 01 00 00 01 01 
00 00 01 00 00 00 01 01 01 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 02 00 00 00 00 00 00 01 00 
01 00 00 00 00 01 00 00 00 00 00 01 00 00 00 01 
00 00 00 00 00 00 00 01 01 01 00 00 00 01 00 01 
00 00 01 00 01 00 00 00 00 00 00 00 00 01 01 00 
00 00 00 00 00 00 00 00 00 00 01 00 01 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Insert this table if your ROM has the abilities in the same order that is mentioned in the OP (otherwise you will have to modify according to the format.
There are 256 entries in this table which equal to the maximum No. of abilities that can be accomodated in a GBA rom.

An entry for each ability takes one byte of space and there are entries for every ability. The entry is set to 00 if Mold Breaker does not negate the ability, 01 (or a non-zero value) if Mold Breaker is able to negate it and 02 if the the ability is negated to simulate the Gen V hazard effect.

For e.g, the first entry is for Ability ID 0x0 and does not need to be negated by mold breaker so its entry is set to 00. The second entry is for Stench (ID = 0x1) so set to 00. The 6th entry is set to 01 because MB negates Sturdy (ID = 0x5).

There are some abilities that do not work with this method and require special explicit checks and there entry is set to 00 to avoid wastage of time.
Spoiler:

1. Damp (it checks in the whole battle field rather than a single target, so the 'faintifnotdamp' battlescript command needs to be edited for this. I'm leaving this for now because I'm lazy

2. Lightning and Storm Drain (mold breaker should allow redirection of move).

3. Friend Guard, Aroma Veil, Sweet Veil, Flower Veil (the target's boosts are sometimes by virtue of its ally's ability).



Modify the table accordingly if there is a need to.

Step II
Spoiler:
1a. Replace x8TTTTTT in the routines with the offset of the Mold breaker table.
1b. Insert these routines with byte changes in the respective code comments.

Routine I (Checks for user's Mold Breaker prior to move execution and then disables abilities that negate, also probably the best place to insert Stance Change)
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func
.global moldbreakterravoltturboblaze
     
     push {r2-r4}
     ldr r0, =0x02023c04
     ldr r1, =0x02023D6B
     ldrb r1, [r1, #0x0]
     mov r2, #0x58
     mul r2, r1
     add r1, r2, r0
     ldrb r2, [r1, #0x0]
     cmp r2, #0x69
     beq breakability
     cmp r2, #0xA4
     beq breakability
     cmp r2, #0xA5
     bne exit

breakability:
     ldr r1, =0x02023D6C
     ldrb r4, [r1, #0x0]
     mov r2, #0x58
     mul r2, r4
     add r1, r2, r0
     ldrb r3, [r1, #0x0]
     ldr r0, moldBreakerTable
     add r2, r3, r0
     ldrb r0, [r2, #0x0]
     cmp r0, #0x0
     beq exit
     mov r0, #0xFF
     strb r0, [r1, #0x0]
     ldr r0, disabledabilities
     add r0, r4
     strb r3, [r0, #0x0]

exit:
     pop {r2-r4}
     bl canceler
     lsl r0, r0, #0x18
     lsr r2, r0, #0x18
     cmp r2, #0x0
     beq cont
     ldr r0, =0x0801DAFD
     bx r0
cont:
     ldr r0, =0x0801D7D7
     bx r0

canceler:
     ldr r0, =0x080192D5
     bx r0

.align 2
moldBreakerTable: .word 0x08TTTTTT
disabledabilities: .word 0x0203c034

@At 1D7C8: 00 48 00 47 XX+1 XX XX 08

Routine II (Checks for user's Mold Breaker in target iterating moves like Earthquake and then disables abilities that negate damage)
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func
.global iteratorbreak
     
     push {r1-r4}
     ldr r0, =0x02023c04
     ldr r1, =0x02023D6B
     ldrb r1, [r1, #0x0]
     mov r2, #0x58
     mul r2, r1
     add r1, r2, r0
     ldrb r2, [r1, #0x0]
     cmp r2, #0x69
     beq breakability
     cmp r2, #0xA4
     beq breakability
     cmp r2, #0xA5
     bne exit

breakability:
     ldr r1, =0x02023D6C
     ldrb r4, [r1, #0x0]
     mov r2, #0x58
     mul r2, r4
     add r1, r2, r0
     ldrb r3, [r1, #0x0]
     ldr r0, moldBreakerTable
     add r2, r3, r0
     ldrb r0, [r2, #0x0]
     cmp r0, #0x0
     beq exit
     mov r0, #0xFF
     strb r0, [r1, #0x0]
     ldr r0, disabledabilities
     add r0, r4
     strb r3, [r0, #0x0]

exit:
     pop {r1-r4}
     ldr r0, [r1]
     add r0, #0x1
     str r0, [r1, #0x0]
     pop {r0}
     bx r0

.align 2
moldBreakerTable: .word 0x08TTTTTT
disabledabilities: .word 0x0203c034

@At 225E0: 00 48 00 47 XX+1 XX XX 08

Routine III and its associated Battle Script (Generation V effect. Makes the foe affected by entry hazards even if it has an ability to negate the hazards effect (except Magic Guard))
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func
.global hazardswitchinbreak
     
     push {lr}
     ldr r0, =0x02023c04
     ldr r1, =0x02023D6B
     ldrb r1, [r1, #0x0]
     mov r2, #0x58
     mul r2, r1
     add r1, r2, r0
     ldrb r2, [r1, #0x0]
     cmp r2, #0x69
     beq breakability
     cmp r2, #0xA4
     beq breakability
     cmp r2, #0xA5
     bne exit

breakability:
     ldr r1, =0x02023D6C
     ldrb r4, [r1, #0x0]
     mov r2, #0x58
     mul r2, r4
     add r1, r2, r0
     ldrb r3, [r1, #0x0]
     ldr r0, moldBreakerTable
     add r2, r3, r0
     ldrb r0, [r2, #0x0]
     cmp r0, #0x0
     beq exit
     mov r0, #0xFF
     strb r0, [r1, #0x0]
     ldr r0, disabledabilities
     add r0, r4
     strb r3, [r0, #0x0]

exit:
     pop {r0}
     bx r0

.align 2
moldBreakerTable: .word 0x08TTTTTT
Battle Script at YYYYYY:
Code:
09 0A E2 00 58 00 3A 2B 04 4C 2B 02 02 08 00 00 00 ZZ ZZ ZZ 08 2E 8A 3E 02 02 05 F6
Battle Script at ZZZZZZ:
Code:
4C 00 4D 00 4E 00 00 3A 10 54 01 F8 XX+1 XX XX 28 52 00 28 4E 69 1D 08
At x28308 insert YY YY YY 08 in reverse hex


Routine IV (Restores disabled abilities at the end of move execution)
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global endcommandwithabiltyrestoration
    
   ldr r0, =0x2023DCC
   mov r1, #0x0
   strb r1, [r0, #0x0]
   ldr r0, =0x2023BC4
   strb r1, [r0, #0x0]
   
   push {r2-r6}
   ldr r4, =0x2023BCC
   ldrb r4, [r4, #0x0]
   mov r5, #0x0
   ldr r6, =0x2023C04
   ldr r2, disablity

loop:
   
   ldrb r3, [r6, #0x0]
   cmp r3, #0xFF
   bne loopend
   add r1, r2, r5
   ldrb r1, [r1, #0x0]
   strb r1, [r6, #0x0]

loopend:
   add r5, r5, #0x1
   cmp r5, r4
   bge exit
   add r6, r6, #0x58
   b loop

exit:
   ldr r1, [r2, #0x0]
   sub r1, r1, r1
   str r1, [r2, #0x0]
   pop {r2-r6}
   ldr r1, =0x2023BE3
   mov r0, #0xB
   strb r0, [r1, #0x0]
   bx lr

.align 2
disablity: .word 0x0203C034

@ Go to your Battle Script command table, search for CD 2C 02 08 and replace it by XX+1 XX XX 08






2. Unaware (+ Sacred Sword Effect)
Spoiler:
This only works with Doesntknowhowtoplay's DPSS patch.
LL is the move effect ID for Sacred sword effect (give it basic damaging script in the effect battle script pointer).

Fire Red:
Spoiler:
Just insert these routines and make bytes changes mentioned their comments.

Attack and Special Attack Unaware:
Spoiler:

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

main:
cmp r4, #0x2
bne nocrit
cmp r2, #0x6
ble ignorestat

nocrit:
mov r0, #0x20
ldr r1, [sp, #0x4]
ldrb r1, [r1, r0]
cmp r1, #0x6E
beq ignorestat
ldr r1, return1
bx r1

ignorestat:
ldr r1, return2
bx r1

.align 2
return1: .word 0x0803F3D1
return2: .word 0x0803F3E1

@At 3F3C8: 00 49 08 47 XX XX XX 08

Defense and Special Defense Unaware:
Spoiler:

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

main:
cmp r4, #0x2
bne nocrit
cmp r2, #0x5
bgt ignorestat

nocrit:
mov r0, #0x20
ldrb r1, [r6, r0]
cmp r1, #0x6E
beq ignorestat

ldr r1, currMove
ldrh r1, [r1, #0x0]
mov r0, #0xC
mul r1, r0
ldr r0, moveTable
add r0, r0, r1
ldrb r1, [r0, #0x0]
cmp r1, #0xLL
beq ignorestat

ldr r1, return1
bx r1

ignorestat:
ldr r1, return2
bx r1

.align 2
currMove: .word 0x02023D4C
moveTable: .word 0x08250C04
return1: .word 0x0803F419
return2: .word 0x0803F429

@At 3F410: 00 49 08 47 XX XX XX 08

Accuracy and Evasiveness Unaware (When foresite is not on)
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func

main:
mov r2, #0x20
add r1, r4, r3
ldrb r1, [r1, r2]
cmp r1, #0x6E
beq foeunaware
ldrb r5, [r0, #0x1e]
b cont

foeunaware:
mov r5, #0x6 

cont:
ldrb r1, [r0, r2]
cmp r1, #0x6E
beq ignorestat

ldr r1, currMove
ldrh r1, [r1, #0x0]
mov r0, #0xC
mul r1, r0
ldr r0, moveTable
add r0, r0, r1
ldrb r1, [r0, #0x0]
cmp r1, #0xLL
beq ignorestat

add r1, r4, r3
ldrb r1, [r1, #0x1f]
lsl r0, r5, #0x0
add r0, #0x6
ldr r2, return
bx r2

ignorestat:
ldr r2, return2
bx r2

.align 2
currMove: .word 0x02023D4A
moveTable: .word 0x08250C04
return: .word 0x0801DFA9
return2: .word 0x0801DFAF

@At 1DFA0: 00 4A 10 47 XX XX XX 08

Accuracy and Evasiveness Unaware (When foresite is in effect on the target. Also updates foresite)
Spoiler:

Code:
.text
.align 2
.thumb
.thumb_func

main:
mul r0, r2
add r0, r0, r3
mov r2, #0x20
add r1, r4, r3
ldrb r1, [r1, r2]
cmp r1, #0x6E
beq foeunaware
ldrb r5, [r0, #0x1e]
b cont

foeunaware:
mov r5, #0x6 

cont:
ldrb r1, [r0, r2]
cmp r1, #0x6E
beq ignorestat

ldr r1, currMove
ldrh r1, [r1, #0x0]
mov r0, #0xC
mul r1, r0
ldr r0, moveTable
add r0, r0, r1
ldrb r1, [r0, #0x0]
cmp r1, #0xLL
beq ignorestat

add r1, r4, r3
ldrb r1, [r1, #0x1f]
cmp r1, #0x5
bgt ignorestat

lsl r0, r5, #0x0
add r0, #0x6
ldr r2, return
bx r2

ignorestat:
ldr r2, return2
bx r2

.align 2
currMove: .word 0x02023D4A
moveTable: .word 0x08250C04
return: .word 0x0801DFA9
return2: .word 0x0801DFAF

@ At 1DF80: 00 49 08 47 XX XX XX 08





3. New Switch-in Ability System
Spoiler:
Note:-
Spoiler:
There is an existing one made that has been used for implementing abilities like Download etc.
But there is one problem with that switch-in manager. It performs an OR logic with status byte of the banked pokemon with x00000200 (so that the switch-in script does not execute repeatedly at the start of a turn) which causes a nasty side effect. The nasty side effect is that pokemon possessing an ability which uses that switch-in logic becomes totally immune to non-volatile status conditions (e.g burn, poison, sleep etc.).

A battling banked mon's status condition is stored in a Word and the functions responible for inflicting these status have a check that the content of status Word should be absolute zero otherwise no status infliction happens. So when the switch-in ability mon is inflicted with a Status Move, the Status Word of the banked mon would always atleast consist of x00000200 (i.e 1 in its 9th bit) and hence fails to be inflicted with the status.

The new system in this post hooks with the Intimidate ability and ORs special status flag with x800000 to avoid the repetitive problem instead of ORing with the status byte to avoid the statusimmunity problem. This also uses a similar table system compared that previous switch-in one but uses custom Battle Scripts instead of custom ASM as entries.

Also, there is logic added to solve inconsistencies due to Trace, Skill Swap and Role Play on switch-in abilities while simultaneously updating Intimidate to latest Generation (activation due to copying by Trace, RolePlay etc.)

Fire Red:
Spoiler:
Step I
Spoiler:

1a. Two custom tables of same size ((No. of Switch-in Abilities)*8 bytes) are going to be used for this system, so select suitable starting offsets for these tables according to the requirements.
1b. In the first routine, replace x8TTTTTT (near the last line) with the first table's starting offset and in the second one, replace x8TTTTTT with the second tables's one.
1c. Insert these two routines somewhere and make byte changes mentioned in their comment sections.
Routine I:
Code:
.text
.align 2
.thumb
.thumb_func
.global switchinabilities

IntimidateCheck:
cmp r1, #0x16
bne LoadTable
ldr r0, [r2, #0x0]
and r0, r6
cmp r0, #0x0
beq NextIter
ldr r0, =0x0801BAAD
bx r0

LoadTable:
push {r2-r3}
mov r3, #0x0
ldr r0, .TableLoc
Loop:
lsl r2, r3, #0x3
add r2, r2, r0
ldrb r2, [r2]
cmp r1, r2
beq Success
cmp r2, #0xFF
beq PopBeforeNextIter
add r3, #0x1
b Loop

Success:
lsl r2, r3, #0x3
add r2, r2, r0
ldr r0, [r2, #0x4]
pop {r2-r3}
push {r0}
ldr r0, [r2, #0x0]
and r0, r6
cmp r0, #0x0
bne PopR0BeforeNextIter
mov r4, r8
strb r1, [r4, #0x0]
ldr r0, [r2, #0x0]
orr r0, r6
str r0, [r2, #0x0]
ldr r0, =0x02023D6B
strb r5, [r0]
pop {r0}
ldr r1, =0x0801BABB
bx r1

PopR0BeforeNextIter:
pop {r0}
b NextIter

PopBeforeNextIter:
pop {r2-r3}

NextIter:
ldr r0, =0x0801B4FF
bx r0


.align
.TableLoc: .word 0x8TTTTTT

@insert 00 48 00 47 xx+1 xx xx 08 at 1B4F0
Routine II:
Code:
.text
.align 2
.thumb
.thumb_func
.global switchinabilities2

IntimidateCheck:
cmp r1, #0x16
bne LoadTable
ldr r0, [r2, #0x0]
and r0, r6
cmp r0, #0x0
beq NextIter
ldr r0, =0x0801BB3D
bx r0

LoadTable:
push {r2-r3}
mov r3, #0x0
ldr r0, .TableLoc
Loop:
lsl r2, r3, #0x3
add r2, r2, r0
ldrb r2, [r2]
cmp r1, r2
beq Success
cmp r2, #0xFF
beq PopBeforeNextIter
add r3, #0x1
b Loop

Success:
lsl r2, r3, #0x3
add r2, r2, r0
ldr r0, [r2, #0x4]
pop {r2-r3}
push {r0}
ldr r0, [r2, #0x0]
and r0, r6
cmp r0, #0x0
bne PopR0BeforeNextIter
mov r3, r8
strb r1, [r3, #0x0]
ldr r0, [r2, #0x0]
orr r0, r6
str r0, [r2, #0x0]
ldr r0, =0x02023D6B
strb r5, [r0]
bl ScriptPlacer
pop {r0}
ldr r1, =0x02023D74
str r0, [r1, #0x0]
ldr r0, =0x0801BB53
bx r0

PopR0BeforeNextIter:
pop {r0}
b NextIter

PopBeforeNextIter:
pop {r2-r3}

NextIter:
ldr r0, =0x0801B727
bx r0

ScriptPlacer:
ldr r1, =0x08017545
bx r1

.align
.TableLoc: .word 0x8TTTTTT

@insert 00 48 00 47 xx+1 xx xx 08 at 1B718

Step II
Spoiler:

Now, here are some sample Battle Scripts to understand how to make custom Battle Scripts for switch-in abilities.

Pressure Message Battle Script:
Spoiler:

#dynamic 0x740280

#org @main
call @pressuremessage
// First table should have pointer to this
end3

#org @pressuremessage
pause 0x20


setbyte 0x2023D6C 0x0 //Second table shoudl have pointer this one
cmde1 0x81D936A

setword 0x0203C020 ("Offset to pressure message")
printstring 0x184
waitmessage 0x40
return

// Pressure Message Hex: FD 13 FE DD E7 00 D9 EC D9 E6 E8 DD E2 DB 00 E4 E6 D9 E7 E7 E9 E6 D9 AB FF


The bolded part will be the crux of every switch-in script using this system, so make sure to start your switch-in battle script using these lines. Also, in case if you want to understand the need for this part:
Spoiler:

'pause 0x20' - Pauses for half a second
'setbyte 0x2023D6C 0x0 - Sets the content of 0x2023D6C to 0x0. This must be set to zero for command e1 to work properly.
'cmd e1 0x81D936A' - This sets the user buffer (0x2023FDB not 0x2023D6B in this case) and target buffer (0x2023D6C) and is used in Target Iteration for Intimidate in doubles. The second parameter is an offset to branch after the Iteration finishes, the offset '0x81D936A' just contains a script containing the command '3C' (i.e a return command).


Similarly, message scripts can be created for Mold Breaker, Terravolt and Turboblaze.
Abilities like Download, Imposter and Frisk would require some extra logic.

Now compile them and also note down the first table and second table pointers of the script

Step III
Spoiler:

Now create the first table in the format: (Ability ID) 00 00 00 (first pointer to the associated script) , and second table in a similar format (Ability ID) 00 00 00 (second pointer to the associated script). Hence, each ability entry will use 8 (1+1+1+1+4) entries per table for this implementation.
Only include those abilities in the tables that have switch-in logic. Also make sure that both the tables are terminated by a FF.

Step IV
Spoiler:

This adjusts Trace, Skill Swap and Role Play to the latest standards while simultaneously solving the inconsistencies due to the routines.

Insert these custom ASM and corresponding battle scripts.

Skill Swap Adjust:
Spoiler:

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

push {lr}
ldr r6, =0x2023C04
ldr r7, =0x2023DFC
mov r5, #0x80
lsl r5, r5, #0xC
mov r4, #0x58
ldr r3, =0x2023D6B
ldrb r2, [r3, #0x0]
lsl r1, r2, #0x2
add r1, r1, r7
ldr r0, [r1] 
mul r2, r4
add r2, r2, r6
ldrb r2, [r2, #0x0]
cmp r2, #0x16
beq orrmarker
bic r0, r5
b cont

orrmarker:
orr r0, r5
cont: 
str r0, [r1]
add r3, #0x1
ldrb r2, [r3, #0x0]
lsl r1, r2, #0x2
add r1, r1, r7
ldr r0, [r1] 
mul r2, r4
add r2, r2, r6
ldrb r2, [r2, #0x0]
cmp r2, #0x16
beq orrmarker2
bic r0, r5
b cont2

orrmarker2:
orr r0, r5
cont2: 
str r0, [r1]
pop {r0}
bx r0
Battle Script at YYYYYY:
Code:
F8 XX+1 XX XX 28 4E 69 1D 08
At x1D82C6 insert YY YY YY 08 in reverse hex



Role Play Adjust
Spoiler:

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

push {lr}
ldr r6, =0x2023C04
ldr r7, =0x2023DFC
mov r5, #0x80
lsl r5, r5, #0xC
mov r4, #0x58
ldr r3, =0x2023D6B
ldrb r2, [r3, #0x0]
lsl r1, r2, #0x2
add r1, r1, r7
ldr r0, [r1] 
mul r2, r4
add r2, r2, r6
ldrb r2, [r2, #0x0]
cmp r2, #0x16
beq orrmarker
bic r0, r5
b cont

orrmarker:
orr r0, r5
cont: 
str r0, [r1]
pop {r0}
bx r0
Battle Script at YYYYYY:
Code:
F8 XX+1 XX XX 28 4E 69 1D 08
At x1D813D insert YY YY YY 08 in reverse hex



Trace Adjust
Spoiler:

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

push {lr}
ldr r6, =0x2023c04
ldr r7, =0x2023DFC
mov r5, #0x80
lsl r5, r5, #0xC
mov r4, #0x58
ldr r3, =0x2023FDB
ldrb r2, [r3, #0x0]
lsl r1, r2, #0x2
add r1, r1, r7
ldr r0, [r1] 
mul r2, r4
add r2, r2, r6
ldrb r2, [r2, #0x0]
cmp r2, #0x16
beq orrmarker
bic r0, r5
b cont

orrmarker:
orr r0, r5
cont: 
str r0, [r1]
pop {r0}
bx r0
Battle Script at YYYYYY:
Code:
39 20 00 10 D0 00 12 40 00 F8 XX+1 XX XX 08 3F
At x1BB18 insert YY YY YY 08 in reverse hex




Reply With Quote
  #14    
Old 4 Weeks Ago (11:03 AM).
Urobolos
 
Join Date: Nov 2014
Quote originally posted by KDS:
Sorry the for the late reply. The callasm command and battle string loader hack are posted in the Quick R&D thread and these things are already installed in MrDS' Patch.
Yeah, would the routines (for both the Magic Coat/Bounce fix and the fixed Ability Switch-In routines) still work if I compile and put them in a rom currently using the MrDS patch? Because I'm pretty sure the MrDS patch still uses the erroneous original routines.
Reply With Quote
  #15    
Old 3 Weeks Ago (09:31 PM).
KDS's Avatar
KDS
 
Join Date: Jul 2013
Age: 20
Gender: Male
Quote originally posted by Urobolos:
Yeah, would the routines (for both the Magic Coat/Bounce fix and the fixed Ability Switch-In routines) still work if I compile and put them in a rom currently using the MrDS patch? Because I'm pretty sure the MrDS patch still uses the erroneous original routines.
You need to remove the old ones before inserting the new ones.
Reply With Quote
  #16    
Old 3 Weeks Ago (09:59 PM).
Urobolos
 
Join Date: Nov 2014
Quote originally posted by KDS:
You need to remove the old ones before inserting the new ones.
Where can I even find the old routines to remove in the first place?
Reply With Quote
  #17    
Old 3 Weeks Ago (01:00 AM).
DizzyEgg's Avatar
DizzyEgg
 
Join Date: Feb 2014
Age: 17
Gender: Male
Nature: Timid
I have a question. How do you insert those abilities? I mean, I know how to insert ASM routine but what am I supposed to do later? How to write these abilities' effect into one that exists?
__________________
Please excuse my poor English. I'm still learning
Reply With Quote
  #18    
Old 3 Weeks Ago (07:06 AM).
KDS's Avatar
KDS
 
Join Date: Jul 2013
Age: 20
Gender: Male
Quote originally posted by Urobolos:
Where can I even find the old routines to remove in the first place?
For Magic Bounce at x1D8D6 insert, 18 01 80 18 00 78 C0 06 88 46 before applying the new routines.
For the switch-in one, I advise to wait till the next version of the base since MrDS will be making many switch-in abilities using this system.
Reply With Quote
Reply
Quick Reply

Sponsored Links
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 04:13 PM.