Merge pull request #112 from AnonymousRandomPerson/main
Some checks failed
build / build (push) Has been cancelled

Decomped more AI functions
This commit is contained in:
AnonymousRandomPerson
2025-03-03 00:37:11 -05:00
committed by GitHub
27 changed files with 656 additions and 638 deletions

View File

@@ -1,12 +1,5 @@
#pragma once
.public AbilityIsActive
.public CanSeeInvisibleMonsters
.public GetApparentWeather
.public IsExperienceLocked
.public IsMonster__02301A60
.public LogMessageByIdWithPopupCheckUserTarget
.public ov29_022E62A8
.public ov29_023527A0
.public ShouldMonsterRunAway
.public SubstitutePlaceholderStringTags
.public UpdateStateFlags
.public ov29_022E62A8

View File

@@ -0,0 +1,7 @@
#pragma once
.public AbilityIsActive
.public GetApparentWeather
.public IsExperienceLocked
.public IsMonster__02301A60
.public LogMessageByIdWithPopupCheckUserTarget
.public SubstitutePlaceholderStringTags

View File

@@ -1,12 +0,0 @@
#pragma once
.public abs
.public AI_THROWN_ITEM_ACTION_CHOICE_COUNT
.public AI_THROWN_ITEM_DIRECTION_IS_USED
.public AI_THROWN_ITEM_DIRECTIONS
.public AI_THROWN_ITEM_PROBABILITIES
.public CanSeeTarget
.public DUNGEON_PTR
.public EntityIsValid__0230F008
.public GetAiUseItemProbability
.public GetTreatmentBetweenMonsters
.public IsTargetInRange

View File

@@ -195,5 +195,3 @@
.public ov29_02351974
.public ov29_02351B00
.public ov29_02351C94
.public ov29_023529C4
.public ov29_023529EC

View File

@@ -0,0 +1,3 @@
#pragma once
.public ov29_023529C4
.public ov29_023529EC

View File

@@ -56,275 +56,3 @@ ov29_023016D8: ; 0x023016D8
.align 2, 0
_02301758: .word 0x000003E7
arm_func_end ov29_023016D8
arm_func_start GetTreatmentBetweenMonsters
GetTreatmentBetweenMonsters: ; 0x0230175C
stmdb sp!, {r3, r4, r5, lr}
ldr r4, [r0, #0xb4]
ldr r5, [r1, #0xb4]
cmp r0, r1
moveq r0, #0
ldmeqia sp!, {r3, r4, r5, pc}
ldrb r1, [r4, #9]
cmp r1, #1
ldrneb r1, [r5, #9]
cmpne r1, #1
moveq r0, #2
ldmeqia sp!, {r3, r4, r5, pc}
ldrb r1, [r4, #0xbc]
cmp r1, #7
ldrneb r1, [r5, #0xbc]
cmpne r1, #7
moveq r0, #2
ldmeqia sp!, {r3, r4, r5, pc}
cmp r3, #0
beq _023017C4
ldrb r1, [r4, #6]
cmp r1, #0
ldreqb r1, [r5, #0xc4]
cmpeq r1, #6
moveq r0, #2
ldmeqia sp!, {r3, r4, r5, pc}
_023017C4:
cmp r2, #0
ldreqb r1, [r5, #0xef]
cmpeq r1, #1
bne _023017E4
bl CanSeeInvisibleMonsters
cmp r0, #0
moveq r0, #2
ldmeqia sp!, {r3, r4, r5, pc}
_023017E4:
#ifdef JAPAN
ldrb r0, [r4, #0x10b]
#else
ldrb r0, [r4, #0x10c]
#endif
cmp r0, #0
bne _02301804
ldrb r0, [r4, #7]
cmp r0, #0
movne r1, #0
moveq r1, #1
b _02301810
_02301804:
cmp r0, #1
moveq r1, #2
movne r1, #3
_02301810:
ldrb r0, [r4, #9]
cmp r0, #0
beq _02301828
cmp r0, #3
moveq r2, #1
b _02301844
_02301828:
ldrb r0, [r4, #6]
cmp r0, #0
movne r2, #1
moveq r2, #0
cmp r0, #0
ldrneb r0, [r4, #8]
cmpne r0, #0
_02301844:
ldrb r0, [r5, #9]
movne r2, #0
cmp r0, #0
beq _02301860
cmp r0, #3
moveq r3, #1
b _0230187C
_02301860:
ldrb r0, [r5, #6]
cmp r0, #0
movne r3, #1
moveq r3, #0
cmp r0, #0
ldrneb r0, [r5, #8]
cmpne r0, #0
_0230187C:
ldrb r0, [r5, #0xd8]
movne r3, #0
cmp r0, #2
ldr r0, _023018A8 ; =ov29_023527A0
moveq r4, #1
add r0, r0, r1, lsl #3
add r0, r0, r2, lsl #2
movne r4, #0
add r0, r0, r3, lsl #1
ldrb r0, [r4, r0]
ldmia sp!, {r3, r4, r5, pc}
.align 2, 0
_023018A8: .word ov29_023527A0
arm_func_end GetTreatmentBetweenMonsters
arm_func_start ov29_023018AC
ov29_023018AC: ; 0x023018AC
stmdb sp!, {r3, r4, r5, lr}
ldr r4, [r0, #0xb4]
ldr r5, [r1, #0xb4]
ldrb r0, [r4, #0xbc]
cmp r0, #7
moveq r0, #2
ldmeqia sp!, {r3, r4, r5, pc}
mov r0, r4
bl IsExperienceLocked
cmp r0, #0
movne r0, #2
ldmneia sp!, {r3, r4, r5, pc}
ldrb r0, [r4, #9]
cmp r0, #0
#ifndef JAPAN
cmpne r0, #3
#endif
movne r0, #2
ldmneia sp!, {r3, r4, r5, pc}
ldrb r0, [r5, #0xbc]
cmp r0, #7
moveq r0, #2
ldmeqia sp!, {r3, r4, r5, pc}
mov r0, r5
bl IsExperienceLocked
cmp r0, #0
movne r0, #2
ldmneia sp!, {r3, r4, r5, pc}
ldrb r0, [r5, #9]
cmp r0, #0
#ifndef JAPAN
cmpne r0, #3
#endif
movne r0, #2
ldmneia sp!, {r3, r4, r5, pc}
ldrb r1, [r4, #6]
ldrb r0, [r5, #6]
cmp r1, r0
movne r0, #1
moveq r0, #0
#ifdef JAPAN
and r0, r0, #0xff
#endif
ldmia sp!, {r3, r4, r5, pc}
arm_func_end ov29_023018AC
arm_func_start SafeguardIsActive
SafeguardIsActive: ; 0x02301940
stmdb sp!, {r3, r4, r5, lr}
mov r4, r1
ldr r3, [r4, #0xb4]
mov r5, r0
ldrb r0, [r3, #0xd5]
cmp r0, #2
bne _02301988
cmp r2, #0
beq _02301980
mov r0, #0
mov r2, r0
bl SubstitutePlaceholderStringTags
ldr r2, _02301990 ; =0x00000C36
mov r0, r5
mov r1, r4
bl LogMessageByIdWithPopupCheckUserTarget
_02301980:
mov r0, #1
ldmia sp!, {r3, r4, r5, pc}
_02301988:
mov r0, #0
ldmia sp!, {r3, r4, r5, pc}
.align 2, 0
#ifdef JAPAN
_02301990: .word 0x00000975
#else
_02301990: .word 0x00000C36
#endif
arm_func_end SafeguardIsActive
arm_func_start LeafGuardIsActive
LeafGuardIsActive: ; 0x02301994
stmdb sp!, {r4, r5, r6, lr}
mov r5, r1
mov r6, r0
mov r0, r5
mov r4, r2
bl GetApparentWeather
cmp r0, #1
bne _02301A00
mov r0, r6
mov r1, r5
mov r2, #0x7b
#ifndef JAPAN
mov r3, #1
#endif
bl DefenderAbilityIsActive__02301A0C
cmp r0, #0
beq _02301A00
cmp r4, #0
beq _023019F8
mov r0, #0
mov r1, r5
mov r2, r0
bl SubstitutePlaceholderStringTags
ldr r2, _02301A08 ; =0x00000C37
mov r0, r6
mov r1, r5
bl LogMessageByIdWithPopupCheckUserTarget
_023019F8:
mov r0, #1
ldmia sp!, {r4, r5, r6, pc}
_02301A00:
mov r0, #0
ldmia sp!, {r4, r5, r6, pc}
.align 2, 0
#ifdef JAPAN
_02301A08: .word 0x00000976
#else
_02301A08: .word 0x00000C37
#endif
arm_func_end LeafGuardIsActive
arm_func_start DefenderAbilityIsActive__02301A0C
DefenderAbilityIsActive__02301A0C: ; 0x02301A0C
#ifdef JAPAN
stmdb sp!, {r4, r5, r6, lr}
mov r6, r0
mov r5, r1
mov r4, r2
cmp r6, r5
#else
stmdb sp!, {r3, r4, r5, r6, r7, lr}
mov r7, r0
mov r6, r1
mov r5, r2
mov r4, r3
cmp r7, r6
#endif
beq _02301A50
bl IsMonster__02301A60
cmp r0, #0
#ifdef JAPAN
beq _02301A50
mov r0, r6
#else
cmpne r4, #0
beq _02301A50
mov r0, r7
#endif
mov r1, #0x53
bl AbilityIsActive
cmp r0, #0
movne r0, #0
#ifdef JAPAN
ldmneia sp!, {r4, r5, r6, pc}
_02301A50:
mov r0, r5
mov r1, r4
bl AbilityIsActive
ldmia sp!, {r4, r5, r6, pc}
#else
ldmneia sp!, {r3, r4, r5, r6, r7, pc}
_02301A50:
mov r0, r6
mov r1, r5
bl AbilityIsActive
ldmia sp!, {r3, r4, r5, r6, r7, pc}
#endif
arm_func_end DefenderAbilityIsActive__02301A0C

175
asm/overlay_29_023018AC.s Normal file
View File

@@ -0,0 +1,175 @@
.include "asm/macros.inc"
.include "overlay_29_023018AC.inc"
.text
arm_func_start ov29_023018AC
ov29_023018AC: ; 0x023018AC
stmdb sp!, {r3, r4, r5, lr}
ldr r4, [r0, #0xb4]
ldr r5, [r1, #0xb4]
ldrb r0, [r4, #0xbc]
cmp r0, #7
moveq r0, #2
ldmeqia sp!, {r3, r4, r5, pc}
mov r0, r4
bl IsExperienceLocked
cmp r0, #0
movne r0, #2
ldmneia sp!, {r3, r4, r5, pc}
ldrb r0, [r4, #9]
cmp r0, #0
#ifndef JAPAN
cmpne r0, #3
#endif
movne r0, #2
ldmneia sp!, {r3, r4, r5, pc}
ldrb r0, [r5, #0xbc]
cmp r0, #7
moveq r0, #2
ldmeqia sp!, {r3, r4, r5, pc}
mov r0, r5
bl IsExperienceLocked
cmp r0, #0
movne r0, #2
ldmneia sp!, {r3, r4, r5, pc}
ldrb r0, [r5, #9]
cmp r0, #0
#ifndef JAPAN
cmpne r0, #3
#endif
movne r0, #2
ldmneia sp!, {r3, r4, r5, pc}
ldrb r1, [r4, #6]
ldrb r0, [r5, #6]
cmp r1, r0
movne r0, #1
moveq r0, #0
#ifdef JAPAN
and r0, r0, #0xff
#endif
ldmia sp!, {r3, r4, r5, pc}
arm_func_end ov29_023018AC
arm_func_start SafeguardIsActive
SafeguardIsActive: ; 0x02301940
stmdb sp!, {r3, r4, r5, lr}
mov r4, r1
ldr r3, [r4, #0xb4]
mov r5, r0
ldrb r0, [r3, #0xd5]
cmp r0, #2
bne _02301988
cmp r2, #0
beq _02301980
mov r0, #0
mov r2, r0
bl SubstitutePlaceholderStringTags
ldr r2, _02301990 ; =0x00000C36
mov r0, r5
mov r1, r4
bl LogMessageByIdWithPopupCheckUserTarget
_02301980:
mov r0, #1
ldmia sp!, {r3, r4, r5, pc}
_02301988:
mov r0, #0
ldmia sp!, {r3, r4, r5, pc}
.align 2, 0
#ifdef JAPAN
_02301990: .word 0x00000975
#else
_02301990: .word 0x00000C36
#endif
arm_func_end SafeguardIsActive
arm_func_start LeafGuardIsActive
LeafGuardIsActive: ; 0x02301994
stmdb sp!, {r4, r5, r6, lr}
mov r5, r1
mov r6, r0
mov r0, r5
mov r4, r2
bl GetApparentWeather
cmp r0, #1
bne _02301A00
mov r0, r6
mov r1, r5
mov r2, #0x7b
#ifndef JAPAN
mov r3, #1
#endif
bl DefenderAbilityIsActive__02301A0C
cmp r0, #0
beq _02301A00
cmp r4, #0
beq _023019F8
mov r0, #0
mov r1, r5
mov r2, r0
bl SubstitutePlaceholderStringTags
ldr r2, _02301A08 ; =0x00000C37
mov r0, r6
mov r1, r5
bl LogMessageByIdWithPopupCheckUserTarget
_023019F8:
mov r0, #1
ldmia sp!, {r4, r5, r6, pc}
_02301A00:
mov r0, #0
ldmia sp!, {r4, r5, r6, pc}
.align 2, 0
#ifdef JAPAN
_02301A08: .word 0x00000976
#else
_02301A08: .word 0x00000C37
#endif
arm_func_end LeafGuardIsActive
arm_func_start DefenderAbilityIsActive__02301A0C
DefenderAbilityIsActive__02301A0C: ; 0x02301A0C
#ifdef JAPAN
stmdb sp!, {r4, r5, r6, lr}
mov r6, r0
mov r5, r1
mov r4, r2
cmp r6, r5
#else
stmdb sp!, {r3, r4, r5, r6, r7, lr}
mov r7, r0
mov r6, r1
mov r5, r2
mov r4, r3
cmp r7, r6
#endif
beq _02301A50
bl IsMonster__02301A60
cmp r0, #0
#ifdef JAPAN
beq _02301A50
mov r0, r6
#else
cmpne r4, #0
beq _02301A50
mov r0, r7
#endif
mov r1, #0x53
bl AbilityIsActive
cmp r0, #0
movne r0, #0
#ifdef JAPAN
ldmneia sp!, {r4, r5, r6, pc}
_02301A50:
mov r0, r5
mov r1, r4
bl AbilityIsActive
ldmia sp!, {r4, r5, r6, pc}
#else
ldmneia sp!, {r3, r4, r5, r6, r7, pc}
_02301A50:
mov r0, r6
mov r1, r5
bl AbilityIsActive
ldmia sp!, {r3, r4, r5, r6, r7, pc}
#endif
arm_func_end DefenderAbilityIsActive__02301A0C

View File

@@ -1,176 +0,0 @@
.include "asm/macros.inc"
.include "overlay_29_0230EDB0.inc"
.text
arm_func_start GetPossibleAiThrownItemDirections
GetPossibleAiThrownItemDirections: ; 0x0230EDB0
stmdb sp!, {r4, r5, r6, r7, r8, sb, sl, fp, lr}
sub sp, sp, #0x14
ldr r4, _0230EFF4 ; =AI_THROWN_ITEM_ACTION_CHOICE_COUNT
mov r5, #0
mov sl, r0
str r3, [sp, #8]
ldr r0, _0230EFF8 ; =AI_THROWN_ITEM_DIRECTION_IS_USED
str r1, [sp]
str r2, [sp, #4]
str r5, [r4]
mov fp, r5
_0230EDDC:
strb fp, [r0, r5]
add r5, r5, #1
cmp r5, #8
blt _0230EDDC
mvn r0, #0
str r0, [sp, #0x10]
_0230EDF4:
ldr r0, _0230EFFC ; =DUNGEON_PTR
ldr r0, [r0]
add r0, r0, fp, lsl #2
add r0, r0, #0x12000
#ifdef JAPAN
ldr r4, [r0, #0xad4]
#else
ldr r4, [r0, #0xb78]
#endif
mov r0, r4
bl EntityIsValid__0230F008
cmp r0, #0
cmpne sl, r4
beq _0230EFE0
ldr r0, [sp]
mov r2, #0
cmp r0, #1
mov r0, sl
mov r1, r4
bne _0230EE50
mov r3, r2
bl GetTreatmentBetweenMonsters
cmp r0, #0
bne _0230EFE0
mov r0, #3
str r0, [sp, #0xc]
b _0230EE68
_0230EE50:
mov r3, #1
bl GetTreatmentBetweenMonsters
cmp r0, #1
bne _0230EFE0
mov r0, #1
str r0, [sp, #0xc]
_0230EE68:
mov r0, sl
mov r1, r4
bl CanSeeTarget
cmp r0, #0
beq _0230EFE0
ldrsh r6, [r4, #4]
ldrsh r7, [sl, #4]
sub r0, r7, r6
bl abs
mov r5, r0
ldrsh r8, [r4, #6]
ldrsh sb, [sl, #6]
sub r0, sb, r8
bl abs
ldr r1, [sl, #0xb4]
ldrb r1, [r1, #0xee]
cmp r1, #0
bne _0230EEC4
cmp r5, r0
movgt r1, r5
movle r1, r0
cmp r1, #0xa
bgt _0230EFE0
_0230EEC4:
cmp r5, r0
ldr r5, [sp, #0x10]
bne _0230EF08
cmp r7, r6
cmplt sb, r8
movlt r5, #1
blt _0230EF54
cmp r7, r6
bge _0230EEF4
cmp sb, r8
movgt r5, #3
bgt _0230EF54
_0230EEF4:
cmp r7, r6
cmpgt sb, r8
movgt r5, #5
movle r5, #7
b _0230EF54
_0230EF08:
cmp r7, r6
bne _0230EF1C
cmp sb, r8
movlt r5, #0
blt _0230EF54
_0230EF1C:
cmp r7, r6
bge _0230EF30
cmp sb, r8
moveq r5, #2
beq _0230EF54
_0230EF30:
cmp r7, r6
bne _0230EF44
cmp sb, r8
movgt r5, #4
bgt _0230EF54
_0230EF44:
cmp r7, r6
ble _0230EF54
cmp sb, r8
moveq r5, #6
_0230EF54:
cmp r5, #0
blt _0230EFE0
ldr r0, _0230EFF8 ; =AI_THROWN_ITEM_DIRECTION_IS_USED
ldrb r0, [r0, r5]
cmp r0, #0
bne _0230EFE0
mov r0, sl
mov r1, r4
mov r2, r5
mov r3, #0xa
bl IsTargetInRange
cmp r0, #0
beq _0230EFE0
ldr r0, _0230EFF8 ; =AI_THROWN_ITEM_DIRECTION_IS_USED
mov r1, #1
strb r1, [r0, r5]
ldr r0, [sp, #8]
cmp r0, #0
ldr r0, _0230EFF4 ; =AI_THROWN_ITEM_ACTION_CHOICE_COUNT
ldr r1, [r0]
ldr r0, _0230F000 ; =AI_THROWN_ITEM_DIRECTIONS
str r5, [r0, r1, lsl #2]
movne r0, #0x64
bne _0230EFC4
ldr r2, [sp, #0xc]
ldr r1, [sp, #4]
mov r0, r4
bl GetAiUseItemProbability
_0230EFC4:
ldr r1, _0230EFF4 ; =AI_THROWN_ITEM_ACTION_CHOICE_COUNT
ldr r2, [r1]
ldr r1, _0230F004 ; =AI_THROWN_ITEM_PROBABILITIES
str r0, [r1, r2, lsl #2]
ldr r0, _0230EFF4 ; =AI_THROWN_ITEM_ACTION_CHOICE_COUNT
add r1, r2, #1
str r1, [r0]
_0230EFE0:
add fp, fp, #1
cmp fp, #0x14
blt _0230EDF4
add sp, sp, #0x14
ldmia sp!, {r4, r5, r6, r7, r8, sb, sl, fp, pc}
.align 2, 0
_0230EFF4: .word AI_THROWN_ITEM_ACTION_CHOICE_COUNT
_0230EFF8: .word AI_THROWN_ITEM_DIRECTION_IS_USED
_0230EFFC: .word DUNGEON_PTR
_0230F000: .word AI_THROWN_ITEM_DIRECTIONS
_0230F004: .word AI_THROWN_ITEM_PROBABILITIES
arm_func_end GetPossibleAiThrownItemDirections

View File

@@ -157,6 +157,3 @@ ov29_0237C9C9:
.global ov29_0237C9CC
ov29_0237C9CC:
.space 0x4
.global AI_THROWN_ITEM_DIRECTION_IS_USED
AI_THROWN_ITEM_DIRECTION_IS_USED:
.space 0x8

View File

@@ -2182,135 +2182,3 @@ ov29_02352790:
ov29_02352798:
.byte 0x01, 0x02, 0x04, 0x08
.byte 0x10, 0x20, 0x40, 0x80
.global ov29_023527A0
ov29_023527A0:
.byte 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x02, 0x01, 0x02
.byte 0x01, 0x02, 0x00, 0x02, 0x00, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01
.byte 0x01, 0x02, 0x00, 0x02
.global ov29_023527C0
ov29_023527C0:
.byte 0x5B, 0x43, 0x53, 0x3A, 0x46, 0x5D, 0x25, 0x73, 0x5B, 0x43, 0x52, 0x5D
.byte 0x00, 0x00, 0x00, 0x00
.global ov29_023527D0
ov29_023527D0:
.byte 0x5B, 0x43, 0x53, 0x3A, 0x25, 0x63, 0x5D, 0x25, 0x73, 0x5B, 0x43, 0x52
.byte 0x5D, 0x00, 0x00, 0x00
.global ov29_023527E0
ov29_023527E0:
.byte 0x00, 0x00, 0x00, 0x00
.global ov29_023527E4
ov29_023527E4:
.byte 0x0A, 0x00, 0x00, 0x00
.global ov29_023527E8
ov29_023527E8:
.byte 0x5B, 0x4B, 0x5D, 0x0A
.byte 0x00, 0x00, 0x00, 0x00
.global ov29_023527F0
ov29_023527F0:
.byte 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00
.global ov29_023527F8
ov29_023527F8:
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.global ov29_02352808
ov29_02352808:
.byte 0x03, 0x04, 0x05, 0x00
.global ov29_0235280C
ov29_0235280C:
.byte 0x00, 0x00, 0x00, 0x00
.global ov29_02352810
ov29_02352810:
.byte 0x00, 0x01, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07
.byte 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
.byte 0x07, 0x07, 0x07, 0x05, 0x06, 0x07, 0x07, 0x07, 0x07, 0x0B, 0x07, 0x00
.global ov29_02352838
ov29_02352838:
.byte 0x00, 0x00, 0x00, 0x00
.global DAMAGE_MULTIPLIER_0_5
DAMAGE_MULTIPLIER_0_5:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00
.global DAMAGE_MULTIPLIER_1_5
DAMAGE_MULTIPLIER_1_5:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00
.global DAMAGE_MULTIPLIER_2
DAMAGE_MULTIPLIER_2:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.global CLOUDY_DAMAGE_MULTIPLIER
CLOUDY_DAMAGE_MULTIPLIER:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00
.global SOLID_ROCK_MULTIPLIER
SOLID_ROCK_MULTIPLIER:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00
.global DAMAGE_FORMULA_MAX_BASE
DAMAGE_FORMULA_MAX_BASE:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.global DAMAGE_FORMULA_MIN_BASE
DAMAGE_FORMULA_MIN_BASE:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
.global ov29_02352884
ov29_02352884:
.byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00
.global ov29_02352894
ov29_02352894:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00
.global TYPE_DAMAGE_NEGATING_EXCLUSIVE_ITEM_EFFECTS
TYPE_DAMAGE_NEGATING_EXCLUSIVE_ITEM_EFFECTS:
.byte 0x02, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00
.byte 0x05, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6A, 0x00, 0x00, 0x00
.byte 0x09, 0x00, 0x00, 0x00, 0x6B, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00
.byte 0x0B, 0x00, 0x00, 0x00, 0x6D, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x00, 0x00
.byte 0x0F, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00
.byte 0x11, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00
.byte 0x05, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00
.byte 0x0A, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x7A, 0x00, 0x00, 0x00
.byte 0x0C, 0x00, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00
.byte 0x0E, 0x00, 0x00, 0x00, 0x7D, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00
.byte 0x10, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00
.byte 0x12, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00
.global ov29_02352984
ov29_02352984:
.byte 0x46, 0x4C, 0x56, 0x20, 0x3A, 0x20, 0x25, 0x64
.byte 0x0A, 0x00, 0x00, 0x00
.global ov29_02352990
ov29_02352990:
.byte 0x41, 0x54, 0x20, 0x3A, 0x20, 0x25, 0x64, 0x0A, 0x00, 0x00, 0x00, 0x00
.global ov29_0235299C
ov29_0235299C:
.byte 0x44, 0x45, 0x46, 0x20, 0x3A, 0x20, 0x25, 0x64, 0x0A, 0x00, 0x00, 0x00
.global ov29_023529A8
ov29_023529A8:
.byte 0x0D, 0x00, 0x00, 0x00
.global ov29_023529AC
ov29_023529AC:
.byte 0x00, 0x00, 0x00, 0x00
.global ov29_023529B0
ov29_023529B0:
.byte 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00
.global ov29_023529B8
ov29_023529B8:
.word ov29_023529C4
.word ov29_023529C4
.word ov29_023529EC
.global ov29_023529C4
ov29_023529C4:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF
.byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0x63, 0x00, 0x63, 0x00
.global ov29_023529EC
ov29_023529EC:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00
.byte 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00
.byte 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0x02, 0x00, 0xFE, 0xFF
.byte 0x01, 0x00, 0xFE, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF
.byte 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0xFE, 0xFF, 0x02, 0x00
.byte 0xFF, 0xFF, 0x02, 0x00, 0x63, 0x00, 0x63, 0x00
.global ov29_02352A54
ov29_02352A54:
.byte 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF
.byte 0xFF, 0xFF, 0xFF, 0xFF

View File

@@ -0,0 +1,131 @@
.include "asm/macros.inc"
.include "overlay_29_rodata_023527C0.inc"
.rodata
.global ov29_023527C0
ov29_023527C0:
.byte 0x5B, 0x43, 0x53, 0x3A, 0x46, 0x5D, 0x25, 0x73, 0x5B, 0x43, 0x52, 0x5D
.byte 0x00, 0x00, 0x00, 0x00
.global ov29_023527D0
ov29_023527D0:
.byte 0x5B, 0x43, 0x53, 0x3A, 0x25, 0x63, 0x5D, 0x25, 0x73, 0x5B, 0x43, 0x52
.byte 0x5D, 0x00, 0x00, 0x00
.global ov29_023527E0
ov29_023527E0:
.byte 0x00, 0x00, 0x00, 0x00
.global ov29_023527E4
ov29_023527E4:
.byte 0x0A, 0x00, 0x00, 0x00
.global ov29_023527E8
ov29_023527E8:
.byte 0x5B, 0x4B, 0x5D, 0x0A
.byte 0x00, 0x00, 0x00, 0x00
.global ov29_023527F0
ov29_023527F0:
.byte 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x00, 0x00
.global ov29_023527F8
ov29_023527F8:
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.global ov29_02352808
ov29_02352808:
.byte 0x03, 0x04, 0x05, 0x00
.global ov29_0235280C
ov29_0235280C:
.byte 0x00, 0x00, 0x00, 0x00
.global ov29_02352810
ov29_02352810:
.byte 0x00, 0x01, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07
.byte 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x05, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07
.byte 0x07, 0x07, 0x07, 0x05, 0x06, 0x07, 0x07, 0x07, 0x07, 0x0B, 0x07, 0x00
.global ov29_02352838
ov29_02352838:
.byte 0x00, 0x00, 0x00, 0x00
.global DAMAGE_MULTIPLIER_0_5
DAMAGE_MULTIPLIER_0_5:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00
.global DAMAGE_MULTIPLIER_1_5
DAMAGE_MULTIPLIER_1_5:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00
.global DAMAGE_MULTIPLIER_2
DAMAGE_MULTIPLIER_2:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.global CLOUDY_DAMAGE_MULTIPLIER
CLOUDY_DAMAGE_MULTIPLIER:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00
.global SOLID_ROCK_MULTIPLIER
SOLID_ROCK_MULTIPLIER:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00
.global DAMAGE_FORMULA_MAX_BASE
DAMAGE_FORMULA_MAX_BASE:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE7, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.global DAMAGE_FORMULA_MIN_BASE
DAMAGE_FORMULA_MIN_BASE:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
.global ov29_02352884
ov29_02352884:
.byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00
.byte 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00
.global ov29_02352894
ov29_02352894:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00
.global TYPE_DAMAGE_NEGATING_EXCLUSIVE_ITEM_EFFECTS
TYPE_DAMAGE_NEGATING_EXCLUSIVE_ITEM_EFFECTS:
.byte 0x02, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00
.byte 0x05, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6A, 0x00, 0x00, 0x00
.byte 0x09, 0x00, 0x00, 0x00, 0x6B, 0x00, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00
.byte 0x0B, 0x00, 0x00, 0x00, 0x6D, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x00, 0x00, 0x6E, 0x00, 0x00, 0x00
.byte 0x0F, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00
.byte 0x11, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00
.byte 0x03, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00
.byte 0x05, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00
.byte 0x07, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00
.byte 0x0A, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x00, 0x00, 0x7A, 0x00, 0x00, 0x00
.byte 0x0C, 0x00, 0x00, 0x00, 0x7B, 0x00, 0x00, 0x00, 0x0D, 0x00, 0x00, 0x00, 0x7C, 0x00, 0x00, 0x00
.byte 0x0E, 0x00, 0x00, 0x00, 0x7D, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00
.byte 0x10, 0x00, 0x00, 0x00, 0x7F, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00
.byte 0x12, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00
.global ov29_02352984
ov29_02352984:
.byte 0x46, 0x4C, 0x56, 0x20, 0x3A, 0x20, 0x25, 0x64
.byte 0x0A, 0x00, 0x00, 0x00
.global ov29_02352990
ov29_02352990:
.byte 0x41, 0x54, 0x20, 0x3A, 0x20, 0x25, 0x64, 0x0A, 0x00, 0x00, 0x00, 0x00
.global ov29_0235299C
ov29_0235299C:
.byte 0x44, 0x45, 0x46, 0x20, 0x3A, 0x20, 0x25, 0x64, 0x0A, 0x00, 0x00, 0x00
.global ov29_023529A8
ov29_023529A8:
.byte 0x0D, 0x00, 0x00, 0x00
.global ov29_023529AC
ov29_023529AC:
.byte 0x00, 0x00, 0x00, 0x00
.global ov29_023529B0
ov29_023529B0:
.byte 0x01, 0x00, 0x02, 0x00, 0x04, 0x00, 0x08, 0x00
.global ov29_023529B8
ov29_023529B8:
.word ov29_023529C4
.word ov29_023529C4
.word ov29_023529EC
.global ov29_023529C4
ov29_023529C4:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00
.byte 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF
.byte 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x01, 0x00, 0x63, 0x00, 0x63, 0x00
.global ov29_023529EC
ov29_023529EC:
.byte 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00
.byte 0x01, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00
.byte 0xFF, 0xFF, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x02, 0x00, 0x02, 0x00
.byte 0x02, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x00, 0xFF, 0xFF, 0x02, 0x00, 0xFE, 0xFF
.byte 0x01, 0x00, 0xFE, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF
.byte 0xFE, 0xFF, 0xFF, 0xFF, 0xFE, 0xFF, 0x00, 0x00, 0xFE, 0xFF, 0x01, 0x00, 0xFE, 0xFF, 0x02, 0x00
.byte 0xFF, 0xFF, 0x02, 0x00, 0x63, 0x00, 0x63, 0x00
.global ov29_02352A54
ov29_02352A54:
.byte 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF
.byte 0xFF, 0xFF, 0xFF, 0xFF

View File

@@ -0,0 +1,6 @@
#ifndef PMDSKY_DUNGEON_AI_ATTACK_H
#define PMDSKY_DUNGEON_AI_ATTACK_H
#define RANGED_ATTACK_RANGE 10
#endif //PMDSKY_DUNGEON_AI_ATTACK_H

View File

@@ -3,6 +3,10 @@
#include "dungeon_mode.h"
extern bool8 AI_THROWN_ITEM_DIRECTION_IS_USED[NUM_DIRECTIONS];
extern u32 AI_THROWN_ITEM_PROBABILITIES[NUM_DIRECTIONS];
extern u32 AI_THROWN_ITEM_DIRECTIONS[NUM_DIRECTIONS];
// Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity).
bool8 EntityIsValid__0230E8F0(struct entity *entity);
// Decides whether or not an AI should use its held item and updates its action_data fields accordingly.

View File

@@ -0,0 +1,21 @@
#ifndef PMDSKY_DUNGEON_AI_ITEMS_1_H
#define PMDSKY_DUNGEON_AI_ITEMS_1_H
#include "dungeon_mode.h"
// If the entity can throw an item at a target in a certain direction,
// adds that direction to AI_THROWN_ITEM_DIRECTIONS and the probability of throwing it to AI_THROWN_ITEM_PROBABILITIES (if it is not already present).
// The size of the arrays will be stored in AI_THROWN_ITEM_ACTION_CHOICE_COUNT.
// The caller function will select the direction to throw the item by iterating through the array(s), rolling the probability, and then throwing in that direction if the roll succeeds.
// Nothing will be thrown if all rolls fail.
//
// pokemon: Entity pointer
// thrown_ai_flag: Integer in {1, 2}. If 1, target allies; if 2, target enemies.
// item: Item struct pointer
// ignore_roll_chance: If false, will call GetAiUseItemProbability to get the probability of throwing in a certain direction.
// If true, the added probability will always be 100.
void GetPossibleAiThrownItemDirections(struct entity *pokemon, s32 thrown_ai_flag, struct item *item, bool8 ignore_roll_chance);
// Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity).
bool8 EntityIsValid__0230F008(struct entity *entity);
#endif //PMDSKY_DUNGEON_AI_ITEMS_1_H

View File

@@ -0,0 +1,17 @@
#ifndef PMDSKY_DUNGEON_AI_TARGETING_1_H
#define PMDSKY_DUNGEON_AI_TARGETING_1_H
#include "dungeon_mode.h"
#include "targeting.h"
// Called to check if a monster should treat another as an ally, enemy, or ignore it.
// (Examples of the "ignore" case: target is a shopkeeper, there is a decoy on the floor, etc.)
//
// r0: Pointer to entity 1
// r1: Pointer to entity 2
// r2: If false, return TREATMENT_IGNORE if entity 2 is invisible and entity 1 cannot see invisible monsters
// r3: If true, return TREATMENT_IGNORE if entity 1 is a team member and entity 2 has the STATUS_PETRIFIED status
// return: Treatment that monster 1 should apply to monster 2
enum monster_treatment GetTreatmentBetweenMonsters(struct entity *pokemon, struct entity *target_pokemon, bool8 ignore_invisible, bool8 check_petrified);
#endif //PMDSKY_DUNGEON_AI_TARGETING_1_H

View File

@@ -149,6 +149,16 @@ struct curse_class_status {
u8 curse_damage_countdown;
};
struct long_toss_class_status {
u8 status; // 0x0: STATUS_LONG_TOSS if 1
};
struct invisible_class_status
{
u8 status; // 0x0: STATUS_INVISIBLE if 1
u8 turns; // 0x1: Turns left for the status in statuses::invisible
};
struct blinker_class_status {
u8 blinded; // 0x0: STATUS_BLINKER if 1
u8 blinded_turns; // 0x1: Turns left for the status in statuses::blinded
@@ -165,7 +175,7 @@ struct monster {
bool8 is_team_leader; // 0x7
// 0x8: An ally is an NPC that isn't a normal team member, e.g. for story boss battles
bool8 is_ally;
enum shopkeeper_mode shopkeeper : 8; // 0x9
enum shopkeeper_mode shopkeeper; // 0x9
u8 level; // 0xA
u8 field_0xb;
s16 team_index; // 0xC: In order by team lineup
@@ -278,9 +288,8 @@ struct monster {
u8 field_0xEB;
u8 sure_shot; // 0xEC: STATUS_SURE_SHOT if 1
u8 sure_shot_turns; // 0xED: Turns left for the status in statuses::sure_shot
u8 long_toss; // 0xEE: STATUS_LONG_TOSS if 1
u8 invisible; // 0xEF: STATUS_INVISIBLE if 1
u8 invisible_turns; // 0xF0: Turns left for the status in statuses::invisible
struct long_toss_class_status long_toss_class_status; // 0xEE
struct invisible_class_status invisible_class_status; // 0xEF
struct blinker_class_status blinker_class_status; // 0xF1
u8 muzzled; // 0xF3: STATUS_MUZZLED if 1
u8 muzzled_turns; // 0xF4: Turns left for the status in statuses::muzzled

View File

@@ -2309,6 +2309,12 @@ enum status_sure_shot_id {
STATUS_SURE_SHOT_FOCUS_ENERGY = 4,
};
enum status_invisible_id {
STATUS_INVISIBLE_INVISIBLE = 1,
STATUS_INVISIBLE_TRANSFORMED = 2,
STATUS_INVISIBLE_MOBILE = 3,
};
enum status_blinker_id {
STATUS_BLINKER_NONE = 0,
STATUS_BLINKER_BLINKER = 1,
@@ -2893,11 +2899,4 @@ enum movement_flag
MOVEMENT_FLAG_SWAPPING_PLACES_PETRIFIED_ALLY = 1 << 15, // Set if the Pokémon is petrified and the leader cures them by swapping places.
};
enum decoy_ai
{
DECOY_AI_NONE = 0,
DECOY_AI_TEAM = 1,
DECOY_AI_WILD = 2,
};
#endif //PMDSKY_ENUMS_H

View File

@@ -1411,6 +1411,7 @@ enum item_id {
ITEM_UNNAMED_0x575 = 1397,
ITEM_UNNAMED_0x576 = 1398,
ITEM_UNNAMED_0x577 = 1399,
NUM_ITEM_IDS = 1400
};
enum item_category {

View File

@@ -1,9 +0,0 @@
#ifndef PMDSKY_OVERLAY_29_0230F008_H
#define PMDSKY_OVERLAY_29_0230F008_H
#include "dungeon_mode.h"
// Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity).
bool8 EntityIsValid__0230F008(struct entity *entity);
#endif //PMDSKY_OVERLAY_29_0230F008_H

18
include/targeting.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef PMDSKY_TARGETING_H
#define PMDSKY_TARGETING_H
enum decoy_ai
{
DECOY_AI_NONE = 0,
DECOY_AI_TEAM = 1,
DECOY_AI_WILD = 2,
};
enum monster_treatment
{
TREATMENT_TREAT_AS_ALLY = 0,
TREATMENT_TREAT_AS_ENEMY = 1,
TREATMENT_IGNORE = 2,
};
#endif //PMDSKY_TARGETING_H

View File

@@ -285,6 +285,9 @@ Overlay OVY_29
Object asm/overlay_29_02300D00.o
Object src/dungeon_ai_targeting.o
Object asm/overlay_29_023016A8.o
Object src/dungeon_ai_targeting_1.o
Object asm/overlay_29_rodata_023527C0.o
Object asm/overlay_29_023018AC.o
Object src/overlay_29_02301A60.o
Object asm/overlay_29_02301A84.o
Object src/dungeon_pokemon_attributes.o
@@ -310,10 +313,9 @@ Overlay OVY_29
Object src/overlay_29_0230A994.o
Object asm/overlay_29_0230A9B8.o
Object src/dungeon_ai_items.o
Object src/dungeon_ai_items_1.o
Object asm/overlay_29_data_02353700.o
Object asm/overlay_29_bss_0237CA18.o
Object asm/overlay_29_0230EDB0.o
Object src/overlay_29_0230F008.o
Object asm/overlay_29_0230F02C.o
Object src/overlay_29_0230F980.o
Object asm/overlay_29_0230F9A4.o

View File

@@ -4,6 +4,7 @@
#include "dungeon_capabilities_1.h"
#include "dungeon_util_static.h"
#include "dungeon_util.h"
#include "targeting.h"
#ifdef JAPAN
#define CANNOT_USE_ITEM_MESSAGE 0xB2D

View File

@@ -8,6 +8,7 @@
#define NUM_POTENTIAL_ROCK_TARGETS 20
bool8 AI_THROWN_ITEM_DIRECTION_IS_USED[NUM_DIRECTIONS] = {0};
u32 AI_THROWN_ITEM_PROBABILITIES[NUM_DIRECTIONS] = {0};
u32 AI_THROWN_ITEM_DIRECTIONS[NUM_DIRECTIONS] = {0};
@@ -211,3 +212,4 @@ void AiDecideUseItem(struct entity *pokemon)
}
}
}

111
src/dungeon_ai_items_1.c Normal file
View File

@@ -0,0 +1,111 @@
#include "dungeon_ai_items_1.h"
#include "dungeon.h"
#include "dungeon_ai_attack.h"
#include "dungeon_ai_items.h"
#include "dungeon_ai_targeting_1.h"
#include "dungeon_util_static.h"
#include "item.h"
#include "targeting.h"
// dungeon_ai_items.c and dungeon_ai_items_1.c are split up to define AI_THROWN_ITEM_ACTION_CHOICE_COUNT differently.
// This needs to be marked as non-volatile here to match GetPossibleAiThrownItemDirections,
// but AiDecideUseItem needs it to be volatile to match.
extern s32 AI_THROWN_ITEM_ACTION_CHOICE_COUNT;
extern struct dungeon *DUNGEON_PTR[];
extern bool8 CanSeeTarget(struct entity *entity, struct entity *target_entity);
extern bool8 IsTargetInRange(struct entity *pokemon, struct entity *target_pokemon, s32 direction, s32 max_range);
extern u32 GetAiUseItemProbability(struct entity *target_pokemon, struct item *item, u32 item_target_flags);
extern s32 abs(s32 value);
void GetPossibleAiThrownItemDirections(struct entity *pokemon, s32 thrown_ai_flag, struct item *item, bool8 ignore_roll_chance)
{
AI_THROWN_ITEM_ACTION_CHOICE_COUNT = 0;
s32 i;
for (i = 0; i < NUM_DIRECTIONS; i++)
{
AI_THROWN_ITEM_DIRECTION_IS_USED[i] = FALSE;
}
i = 0;
do
{
struct entity *target_pokemon = DUNGEON_PTR[0]->active_monster_ptrs[i];
if (!EntityIsValid__0230F008(target_pokemon))
continue;
if (pokemon == target_pokemon)
continue;
s32 targeting_flags;
if (thrown_ai_flag == ITEM_AI_FLAG_TARGET_ALLY)
{
if (GetTreatmentBetweenMonsters(pokemon, target_pokemon, FALSE, FALSE) == TREATMENT_TREAT_AS_ALLY)
targeting_flags = ITEM_TARGET_OTHER | ITEM_TARGET_ALLY;
else
continue;
}
else if (GetTreatmentBetweenMonsters(pokemon, target_pokemon, FALSE, TRUE) == TREATMENT_TREAT_AS_ENEMY)
targeting_flags = ITEM_TARGET_OTHER;
else
continue;
if (!CanSeeTarget(pokemon, target_pokemon))
continue;
s32 target_direction;
s32 target_pos_x = target_pokemon->pos.x;
s32 pokemon_pos_x = pokemon->pos.x;
s32 distance_x = abs(pokemon_pos_x - target_pos_x);
s32 target_pos_y = target_pokemon->pos.y;
s32 pokemon_pos_y = pokemon->pos.y;
s32 distance_y = abs(pokemon->pos.y - target_pos_y);
if (GetEntInfo(pokemon)->long_toss_class_status.status == STATUS_NONE)
{
s32 distance = distance_x > distance_y ? distance_x : distance_y;
if (distance > RANGED_ATTACK_RANGE)
continue;
}
target_direction = -1;
if (distance_x == distance_y)
{
if (pokemon_pos_x < target_pos_x && pokemon_pos_y < target_pos_y)
target_direction = DIR_DOWN_RIGHT;
else if (pokemon_pos_x < target_pos_x && pokemon_pos_y > target_pos_y)
target_direction = DIR_UP_RIGHT;
else if (pokemon_pos_x > target_pos_x && pokemon_pos_y > target_pos_y)
target_direction = DIR_UP_LEFT;
else
target_direction = DIR_DOWN_LEFT;
}
else
{
if (pokemon_pos_x == target_pos_x && pokemon_pos_y < target_pos_y)
target_direction = DIR_DOWN;
else if (pokemon_pos_x < target_pos_x && pokemon_pos_y == target_pos_y)
target_direction = DIR_RIGHT;
else if (pokemon_pos_x == target_pos_x && pokemon_pos_y > target_pos_y)
target_direction = DIR_UP;
else if (pokemon_pos_x > target_pos_x && pokemon_pos_y == target_pos_y)
target_direction = DIR_LEFT;
}
if (target_direction >= DIR_DOWN && !AI_THROWN_ITEM_DIRECTION_IS_USED[target_direction] && IsTargetInRange(pokemon, target_pokemon, target_direction, RANGED_ATTACK_RANGE))
{
AI_THROWN_ITEM_DIRECTION_IS_USED[target_direction] = TRUE;
AI_THROWN_ITEM_DIRECTIONS[AI_THROWN_ITEM_ACTION_CHOICE_COUNT] = target_direction;
AI_THROWN_ITEM_PROBABILITIES[AI_THROWN_ITEM_ACTION_CHOICE_COUNT] = ignore_roll_chance ? 100 : GetAiUseItemProbability(target_pokemon, item, targeting_flags);
AI_THROWN_ITEM_ACTION_CHOICE_COUNT++;
}
} while (++i < DUNGEON_MAX_POKEMON);
}
bool8 EntityIsValid__0230F008(struct entity *entity)
{
if (entity == NULL)
{
return FALSE;
}
return entity->type != ENTITY_NOTHING;
}

View File

@@ -0,0 +1,134 @@
#include "dungeon_ai_targeting_1.h"
#include "dungeon_util_static.h"
const enum monster_treatment TREATMENT_DATA[4][2][2][2] = {
{
{
{TREATMENT_TREAT_AS_ALLY, TREATMENT_TREAT_AS_ENEMY},
{TREATMENT_TREAT_AS_ENEMY, TREATMENT_IGNORE}
},
{
{TREATMENT_TREAT_AS_ENEMY, TREATMENT_IGNORE},
{TREATMENT_TREAT_AS_ALLY, TREATMENT_IGNORE}
}
},
{
{
{TREATMENT_TREAT_AS_ALLY, TREATMENT_IGNORE},
{TREATMENT_TREAT_AS_ENEMY, TREATMENT_IGNORE}
},
{
{TREATMENT_TREAT_AS_ENEMY, TREATMENT_IGNORE},
{TREATMENT_TREAT_AS_ALLY, TREATMENT_IGNORE}
}
},
{
{
{TREATMENT_TREAT_AS_ALLY, TREATMENT_IGNORE},
{TREATMENT_TREAT_AS_ENEMY, TREATMENT_IGNORE}
},
{
{TREATMENT_IGNORE, TREATMENT_TREAT_AS_ENEMY},
{TREATMENT_IGNORE, TREATMENT_TREAT_AS_ENEMY}
}
},
{
{
{TREATMENT_IGNORE, TREATMENT_TREAT_AS_ENEMY},
{TREATMENT_IGNORE, TREATMENT_TREAT_AS_ENEMY}
},
{
{TREATMENT_TREAT_AS_ENEMY, TREATMENT_IGNORE},
{TREATMENT_TREAT_AS_ALLY, TREATMENT_IGNORE}
}
}
};
enum decoy_ai_treatment
{
DECOY_AI_TREATMENT_NONE_LEADER = 0,
DECOY_AI_TREATMENT_NONE_NONLEADER = 1,
DECOY_AI_TREATMENT_TEAM = 2,
DECOY_AI_TREATMENT_WILD = 3,
};
extern bool8 CanSeeInvisibleMonsters(struct entity *pokemon);
enum monster_treatment GetTreatmentBetweenMonsters(struct entity *pokemon, struct entity *target_pokemon, bool8 ignore_invisible, bool8 check_petrified)
{
struct monster *pokemon_info = GetEntInfo(pokemon);
struct monster *target_data = GetEntInfo(target_pokemon);
if (pokemon == target_pokemon)
return TREATMENT_TREAT_AS_ALLY;
if (pokemon_info->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER || target_data->shopkeeper == SHOPKEEPER_MODE_SHOPKEEPER)
return TREATMENT_IGNORE;
if (pokemon_info->monster_behavior == BEHAVIOR_RESCUE_TARGET || target_data->monster_behavior == BEHAVIOR_RESCUE_TARGET)
return TREATMENT_IGNORE;
if (check_petrified && !pokemon_info->is_not_team_member && target_data->frozen_class_status.freeze == STATUS_FROZEN_PETRIFIED)
return TREATMENT_IGNORE;
if (!ignore_invisible && target_data->invisible_class_status.status == STATUS_INVISIBLE_INVISIBLE && !CanSeeInvisibleMonsters(pokemon))
return TREATMENT_IGNORE;
u8 pokemon_targeting_decoy = pokemon_info->decoy_ai_tracker;
u8 decoy_ai_tracker;
if (pokemon_targeting_decoy == DECOY_AI_NONE)
{
if (pokemon_info->is_team_leader)
decoy_ai_tracker = DECOY_AI_TREATMENT_NONE_LEADER;
else
decoy_ai_tracker = DECOY_AI_TREATMENT_NONE_NONLEADER;
}
else if (pokemon_targeting_decoy == DECOY_AI_TEAM)
decoy_ai_tracker = DECOY_AI_TREATMENT_TEAM;
else
decoy_ai_tracker = DECOY_AI_TREATMENT_WILD;
bool8 pokemon_is_enemy;
if (pokemon_info->shopkeeper != SHOPKEEPER_MODE_NORMAL)
{
if (pokemon_info->shopkeeper == SHOPKEEPER_MODE_ATTACK_TEAM)
pokemon_is_enemy = TRUE;
else
pokemon_is_enemy = FALSE;
}
else
{
if (pokemon_info->is_not_team_member)
pokemon_is_enemy = TRUE;
else
pokemon_is_enemy = FALSE;
if (pokemon_info->is_not_team_member && pokemon_info->is_ally)
pokemon_is_enemy = FALSE;
}
bool8 target_is_enemy;
if (target_data->shopkeeper != SHOPKEEPER_MODE_NORMAL)
{
if (target_data->shopkeeper == SHOPKEEPER_MODE_ATTACK_TEAM)
target_is_enemy = TRUE;
else
target_is_enemy = FALSE;
}
else
{
if (target_data->is_not_team_member)
target_is_enemy = TRUE;
else
target_is_enemy = FALSE;
if (target_data->is_not_team_member && target_data->is_ally)
target_is_enemy = FALSE;
}
u32 target_is_decoy;
if (target_data->curse_class_status.curse == STATUS_CURSE_DECOY)
target_is_decoy = TRUE;
else
target_is_decoy = FALSE;
return TREATMENT_DATA[decoy_ai_tracker][pokemon_is_enemy][target_is_enemy][target_is_decoy];
}

View File

@@ -11,7 +11,7 @@ enum item_category GetItemCategory(s16 item_id)
s16 EnsureValidItem(s16 item_id)
{
if (item_id <= 0 || item_id >= 0x578)
if (item_id <= 0 || item_id >= NUM_ITEM_IDS)
return ITEM_PLAIN_SEED;
if (!IsItemValid(item_id))

View File

@@ -1,10 +0,0 @@
#include "overlay_29_0230F008.h"
bool8 EntityIsValid__0230F008(struct entity *entity)
{
if (entity == NULL)
{
return FALSE;
}
return entity->type != ENTITY_NOTHING;
}