| 
35 | 35 | #include "pokemon_icon.h"  | 
36 | 36 | #include "pokemon_summary_screen.h"  | 
37 | 37 | #include "pokemon_storage_system.h"  | 
 | 38 | +#include "pokerus.h"  | 
38 | 39 | #include "random.h"  | 
39 | 40 | #include "recorded_battle.h"  | 
40 | 41 | #include "rtc.h"  | 
@@ -2523,6 +2524,12 @@ u32 GetBoxMonData3(struct BoxPokemon *boxMon, s32 field, u8 *data)  | 
2523 | 2524 |         case MON_DATA_POKERUS:  | 
2524 | 2525 |             retVal = GetSubstruct3(boxMon)->pokerus;  | 
2525 | 2526 |             break;  | 
 | 2527 | +        case MON_DATA_POKERUS_STRAIN:  | 
 | 2528 | +            retVal = (GetSubstruct3(boxMon)->pokerus & 0xF0);  | 
 | 2529 | +            break;  | 
 | 2530 | +        case MON_DATA_POKERUS_DAYS_LEFT:  | 
 | 2531 | +            retVal = (GetSubstruct3(boxMon)->pokerus & 0x0F);  | 
 | 2532 | +            break;  | 
2526 | 2533 |         case MON_DATA_MET_LOCATION:  | 
2527 | 2534 |             retVal = GetSubstruct3(boxMon)->metLocation;  | 
2528 | 2535 |             break;  | 
@@ -3019,6 +3026,12 @@ void SetBoxMonData(struct BoxPokemon *boxMon, s32 field, const void *dataArg)  | 
3019 | 3026 |         case MON_DATA_POKERUS:  | 
3020 | 3027 |             SET8(GetSubstruct3(boxMon)->pokerus);  | 
3021 | 3028 |             break;  | 
 | 3029 | +        case MON_DATA_POKERUS_STRAIN:  | 
 | 3030 | +            GetSubstruct3(boxMon)->pokerus = (*data << 4) | (GetSubstruct3(boxMon)->pokerus & 0x0F);  | 
 | 3031 | +            break;  | 
 | 3032 | +        case MON_DATA_POKERUS_DAYS_LEFT:  | 
 | 3033 | +            GetSubstruct3(boxMon)->pokerus = (GetSubstruct3(boxMon)->pokerus & 0xF0) | *data;  | 
 | 3034 | +            break;  | 
3022 | 3035 |         case MON_DATA_MET_LOCATION:  | 
3023 | 3036 |             SET8(GetSubstruct3(boxMon)->metLocation);  | 
3024 | 3037 |             break;  | 
@@ -5408,152 +5421,6 @@ u16 GetMonEVCount(struct Pokemon *mon)  | 
5408 | 5421 |     return count;  | 
5409 | 5422 | }  | 
5410 | 5423 | 
 
  | 
5411 |  | -void RandomlyGivePartyPokerus(struct Pokemon *party)  | 
5412 |  | -{  | 
5413 |  | -    u16 rnd = Random();  | 
5414 |  | -    if (rnd == 0x4000 || rnd == 0x8000 || rnd == 0xC000)  | 
5415 |  | -    {  | 
5416 |  | -        struct Pokemon *mon;  | 
5417 |  | - | 
5418 |  | -        do  | 
5419 |  | -        {  | 
5420 |  | -            rnd = Random() % PARTY_SIZE;  | 
5421 |  | -            mon = &party[rnd];  | 
5422 |  | -        }  | 
5423 |  | -        while (!GetMonData(mon, MON_DATA_SPECIES, 0) || GetMonData(mon, MON_DATA_IS_EGG, 0));  | 
5424 |  | - | 
5425 |  | -        if (!(CheckPartyHasHadPokerus(party, 1u << rnd)))  | 
5426 |  | -        {  | 
5427 |  | -            u8 rnd2;  | 
5428 |  | - | 
5429 |  | -            do  | 
5430 |  | -            {  | 
5431 |  | -                rnd2 = Random();  | 
5432 |  | -            }  | 
5433 |  | -            while ((rnd2 & 0x7) == 0);  | 
5434 |  | - | 
5435 |  | -            if (rnd2 & 0xF0)  | 
5436 |  | -                rnd2 &= 0x7;  | 
5437 |  | - | 
5438 |  | -            rnd2 |= (rnd2 << 4);  | 
5439 |  | -            rnd2 &= 0xF3;  | 
5440 |  | -            rnd2++;  | 
5441 |  | - | 
5442 |  | -            SetMonData(&party[rnd], MON_DATA_POKERUS, &rnd2);  | 
5443 |  | -        }  | 
5444 |  | -    }  | 
5445 |  | -}  | 
5446 |  | - | 
5447 |  | -u8 CheckPartyPokerus(struct Pokemon *party, u8 selection)  | 
5448 |  | -{  | 
5449 |  | -    u8 retVal;  | 
5450 |  | - | 
5451 |  | -    int partyIndex = 0;  | 
5452 |  | -    unsigned curBit = 1;  | 
5453 |  | -    retVal = 0;  | 
5454 |  | - | 
5455 |  | -    if (selection)  | 
5456 |  | -    {  | 
5457 |  | -        do  | 
5458 |  | -        {  | 
5459 |  | -            if ((selection & 1) && (GetMonData(&party[partyIndex], MON_DATA_POKERUS, 0) & 0xF))  | 
5460 |  | -                retVal |= curBit;  | 
5461 |  | -            partyIndex++;  | 
5462 |  | -            curBit <<= 1;  | 
5463 |  | -            selection >>= 1;  | 
5464 |  | -        }  | 
5465 |  | -        while (selection);  | 
5466 |  | -    }  | 
5467 |  | -    else if (GetMonData(&party[0], MON_DATA_POKERUS, 0) & 0xF)  | 
5468 |  | -    {  | 
5469 |  | -        retVal = 1;  | 
5470 |  | -    }  | 
5471 |  | - | 
5472 |  | -    return retVal;  | 
5473 |  | -}  | 
5474 |  | - | 
5475 |  | -u8 CheckPartyHasHadPokerus(struct Pokemon *party, u8 selection)  | 
5476 |  | -{  | 
5477 |  | -    u8 retVal;  | 
5478 |  | - | 
5479 |  | -    int partyIndex = 0;  | 
5480 |  | -    unsigned curBit = 1;  | 
5481 |  | -    retVal = 0;  | 
5482 |  | - | 
5483 |  | -    if (selection)  | 
5484 |  | -    {  | 
5485 |  | -        do  | 
5486 |  | -        {  | 
5487 |  | -            if ((selection & 1) && GetMonData(&party[partyIndex], MON_DATA_POKERUS, 0))  | 
5488 |  | -                retVal |= curBit;  | 
5489 |  | -            partyIndex++;  | 
5490 |  | -            curBit <<= 1;  | 
5491 |  | -            selection >>= 1;  | 
5492 |  | -        }  | 
5493 |  | -        while (selection);  | 
5494 |  | -    }  | 
5495 |  | -    else if (GetMonData(&party[0], MON_DATA_POKERUS, 0))  | 
5496 |  | -    {  | 
5497 |  | -        retVal = 1;  | 
5498 |  | -    }  | 
5499 |  | - | 
5500 |  | -    return retVal;  | 
5501 |  | -}  | 
5502 |  | - | 
5503 |  | -void UpdatePartyPokerusTime(u16 days)  | 
5504 |  | -{  | 
5505 |  | -    int i;  | 
5506 |  | -    for (i = 0; i < PARTY_SIZE; i++)  | 
5507 |  | -    {  | 
5508 |  | -        if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, 0))  | 
5509 |  | -        {  | 
5510 |  | -            u8 pokerus = GetMonData(&gPlayerParty[i], MON_DATA_POKERUS, 0);  | 
5511 |  | -            if (pokerus & 0xF)  | 
5512 |  | -            {  | 
5513 |  | -                if ((pokerus & 0xF) < days || days > 4)  | 
5514 |  | -                    pokerus &= 0xF0;  | 
5515 |  | -                else  | 
5516 |  | -                    pokerus -= days;  | 
5517 |  | - | 
5518 |  | -                if (pokerus == 0)  | 
5519 |  | -                    pokerus = 0x10;  | 
5520 |  | - | 
5521 |  | -                SetMonData(&gPlayerParty[i], MON_DATA_POKERUS, &pokerus);  | 
5522 |  | -            }  | 
5523 |  | -        }  | 
5524 |  | -    }  | 
5525 |  | -}  | 
5526 |  | - | 
5527 |  | -void PartySpreadPokerus(struct Pokemon *party)  | 
5528 |  | -{  | 
5529 |  | -    if ((Random() % 3) == 0)  | 
5530 |  | -    {  | 
5531 |  | -        int i;  | 
5532 |  | -        for (i = 0; i < PARTY_SIZE; i++)  | 
5533 |  | -        {  | 
5534 |  | -            if (GetMonData(&party[i], MON_DATA_SPECIES, 0))  | 
5535 |  | -            {  | 
5536 |  | -                u8 pokerus = GetMonData(&party[i], MON_DATA_POKERUS, 0);  | 
5537 |  | -                u8 curPokerus = pokerus;  | 
5538 |  | -                if (pokerus)  | 
5539 |  | -                {  | 
5540 |  | -                    if (pokerus & 0xF)  | 
5541 |  | -                    {  | 
5542 |  | -                        // Spread to adjacent party members.  | 
5543 |  | -                        if (i != 0 && !(GetMonData(&party[i - 1], MON_DATA_POKERUS, 0) & 0xF0))  | 
5544 |  | -                            SetMonData(&party[i - 1], MON_DATA_POKERUS, &curPokerus);  | 
5545 |  | -                        if (i != (PARTY_SIZE - 1) && !(GetMonData(&party[i + 1], MON_DATA_POKERUS, 0) & 0xF0))  | 
5546 |  | -                        {  | 
5547 |  | -                            SetMonData(&party[i + 1], MON_DATA_POKERUS, &curPokerus);  | 
5548 |  | -                            i++;  | 
5549 |  | -                        }  | 
5550 |  | -                    }  | 
5551 |  | -                }  | 
5552 |  | -            }  | 
5553 |  | -        }  | 
5554 |  | -    }  | 
5555 |  | -}  | 
5556 |  | - | 
5557 | 5424 | bool8 TryIncrementMonLevel(struct Pokemon *mon)  | 
5558 | 5425 | {  | 
5559 | 5426 |     u16 species = GetMonData(mon, MON_DATA_SPECIES, 0);  | 
 | 
0 commit comments