• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Other] [pokered] Limit stat exp depending on DV

McPaul

On my way to become a controversial and hated memb
288
Posts
6
Years
  • Hello! I have a rom hack project where "stat exp" as we know it doesn't exist, but they do as a kind of hyper training. You will be able to use vitamins to raise a stat to the equivalent of a DV of 15.

    I already began to code something for this in engine\items\item_effects.asm in .useVitamin section. I intend to modify from the .noCarry2 part so that giving one vitamin in one sat gives it virtually a DV of 15 in that stat.

    Here is what I currently made. This is not tested and I'm pretty sure it won't work but the structure is there:
    Code:
    .dv0
    	ld bc, wPartyMon1DVs
    	ld a, 0 ; the Pokémon has a DV of 0 in the stat
    	ld b, 56 ; the Pokémon must gain 14336 stat experience (256 * 56) to reach the equivalent of a DV of 15	
    	ld c, b
    	ld b, [hl] ; b = MSB of stat experience of the appropriate stat
    	cp 56 ; is there already at least 14336 (256 * 56) stat experience?
    	jr nc, .vitaminNoEffect ; if so, vitamins can't add any more
    	add c ; add 14336 (256 * 56) stat experience
    	jr nc, .dv1
    	ld b, 255
    .dv1
    	ld bc, wPartyMon1DVs
    	ld a, 1 ; the Pokémon has a DV of 1 in the stat
    	ld b, 49 ; the Pokémon must gain 12544 stat experience (256 * 49) to reach the equivalent of a DV of 15	
    	ld c, b
    	ld b, [hl] ; b = MSB of stat experience of the appropriate stat
    	cp 49 ; is there already at least 12544 (256 * 49) stat experience?
    	jr nc, .vitaminNoEffect ; if so, vitamins can't add any more
    	add c ; add 12544 (256 * 49) stat experience
    	jr nc, .dv2
    	ld b, 255

    And I'll continue with .dv2, .dv3, .dv4, etc. until .dv15 where vitamins won't work.

    Can someone help me to make my code work please? Thanks a lot in advance!
     

    McPaul

    On my way to become a controversial and hated memb
    288
    Posts
    6
    Years
  • I made a chart of the stat exp limitation needed depending on the DVs.

    Code:
    DV to stat experience chart
    
    If DV is 15	max stat exp is	0
    
    If DV is 14	max stat exp is	120
    
    If DV is 13	max stat exp is	360
    
    If DV is 12	max stat exp is	728
    
    If DV is 11	max stat exp is	1224
    
    If DV is 10	max stat exp is	1848
    
    If DV is 9	max stat exp is	2600
    
    If DV is 8	max stat exp is	3480
    
    If DV is 7	max stat exp is	4488
    
    If DV is 6	max stat exp is	5624
    
    If DV is 5	max stat exp is	6888
    
    If DV is 4	max stat exp is	8280
    
    If DV is 3	max stat exp is	9800
    
    If DV is 2	max stat exp is	11448
    
    If DV is 1	max stat exp is	13224
    
    If DV is 0	max stat exp is	15128

    And made a file gathering everything I think I need to create my code, but I need that little spark of help allowing me to begin something that works.

    Code:
    .getMonDVs
    	srl c
    	pop hl
    	push bc
    	ld bc, wPartyMon1DVs - (wPartyMon1HPExp - 1) ; also wEnemyMonDVs - wEnemyMonHP
    	add hl, bc
    	pop bc
    	ld a, c
    	cp $2
    	jr z, .getAttackDV
    	cp $3
    	jr z, .getDefenseDV
    	cp $4
    	jr z, .getSpeedDV
    	cp $5
    	jr z, .getSpecialDV
    .getHpDV
    	push bc
    	ld a, [hl]  ; Atk DV
    	swap a
    	and $1
    	sla a
    	sla a
    	sla a
    	ld b, a
    	ld a, [hli] ; Def DV
    	and $1
    	sla a
    	sla a
    	add b
    	ld b, a
    	ld a, [hl] ; Spd DV
    	swap a
    	and $1
    	sla a
    	add b
    	ld b, a
    	ld a, [hl] ; Spc DV
    	and $1
    	add b      ; HP DV: LSB of the other 4 DVs
    	pop bc
    	jr .calcStatFromDV
    .getAttackDV
    	ld a, [hl]
    	swap a
    	and $f
    	jr .calcStatFromDV
    .getDefenseDV
    	ld a, [hl]
    	and $f
    	jr .calcStatFromDV
    .getSpeedDV
    	inc hl
    	ld a, [hl]
    	swap a
    	and $f
    	jr .calcStatFromDV
    .getSpecialDV
    	inc hl
    	ld a, [hl]
    	and $f
    	
    	dec de
    	ld a, [de]
    	inc a
    	jr z, .maxStatExp ; jump if the value overflowed
    	ld [de], a
    	inc de
    	jr .nextBaseStat
    .maxStatExp ; if the upper byte also overflowed, then we have hit the max stat exp
    	ld a, $ff
    	ld [de], a
    	inc de
    	ld [de], a	
    	
    .noCarry2
    	ld a, 255
    	ld b, a
    	ld a, [hl] ; a = MSB of stat experience of the appropriate stat
    	cp 255 ; is there already at least 25600 (256 * 100) stat experience?
    	jr nc, .vitaminNoEffect ; if so, vitamins can't add any more
    	add b ; add 2560 (256 * 10) stat experience
    	jr nc, .noCarry3 ; a carry should be impossible here, so this will always jump
    	ld a, 255
    .noCarry3
    	ld [hl], a
    	pop hl
    	call .recalculateStats
    	ld hl, VitaminStats
    	ld a, [wcf91]
    	sub HP_UP - 1
    	ld c, a
     
    Back
    Top