Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- Infection chance is 3 in 65536
- 1-7 have 14% chance (7 a bit less)
- 9-F less than 0.5%
- Initial duration for strain i is 1+i%4
- Consequence: the following strains are illegal:
- 0x, 13, 14, 24, 42, 43, 44, 53, 54, 64,
- 8x, 93, 94, A4, C2, C3, C4, D3, D4, E4
- The infected Pokémon is chosen randomly in the party.
- You can't infect an egg from a wild battle.
- An infected/cured Pokémon can't get a different strain.
- Strain 0x will always transform into 10 regardless of duration
- xfr
- **/
- typedef enum {
- DexNumber=0x05,
- PokerusByte=0x97,
- IsEgg=0x4C,
- Happiness=0x09,
- ...
- } Stat;
- typedef struct {
- PartyPkm *target;
- Stat stat;
- uint value;
- } PartyPkmStat;
- PartyPkm *GetPartyPkm(void *PartyStart, uint position)
- {
- return (PartyPkm*)(PartyStart+8+position*220);
- }
- // @0201B054
- void GeneratePokerus(void *PartyStart)
- {
- PartyPkmStat s;
- uint i, party_count, pkrs_bitmask, dex, isEgg;
- party_count = (uint)*(PartyStart+4);
- pkrs_bitmask = 0;
- for(i=0; i<=party_count; i++)
- {
- s.target = GetPartyPkm(PartyStart, i);
- s.stat = PokerusByte;
- GetPokemonStat(&s);
- if(s.value) pkrs_bitmask |= 1<<i;
- }
- // 3 in 0x10000 chance
- if((MTRand()>>16) & 0x3FFF == 0)
- {
- do
- {
- i = (MTRand()*party_count)>>32;
- s.target = GetPartyPkm(PartyStart, i);
- s.stat = DexNumber;
- GetPokemonStat(&s);
- dex = s.value;
- s.stat = IsEgg;
- GetPokemonStat(&s);
- isEgg = s.value;
- }
- while(!dex || isEgg);
- // Do nothing if it already has it
- if(pkrs_bitmask & (1<<i)) return;
- do
- {
- // Generate strain and duration
- i = MTRand()>>24;
- }
- while(!(i&7));
- if(i>>4) i &= 7;
- i = ((i | i<<4)&0xF3)+1; // duration (1-4 days)
- s.stat = PokerusByte;
- s.value = i;
- SetPokemonStat(&s);
- }
- }
- // @0201B11C
- void DecayPokerus(void *PartyStart, uint8 days)
- {
- PartyPkmStat s;
- uint i, party_count, dex, pkr;
- party_count = (uint)*(PartyStart+4);
- for(i=0; i<=party_count; i++)
- {
- s.target = GetPartyPkm(PartyStart, i);
- s.stat = DexNumber;
- GetPokemonStat(&s);
- dex = s.value;
- s.stat = PokerusByte;
- GetPokemonStat(&s);
- pkr = s.value & 0xFF;
- if(!dex || !(pkr & 0xF)) continue;
- else if(!(pkr>>4)) pkr = 0x10;
- else if((pkr & 0xF)<days && days<=4) pkr -= days;
- else pkr &= 0xF0;
- s.value = pkr;
- SetPokemonStat(&s);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement