From e5d543c94531f4c0a4a473342bbdc47003ebbf6e Mon Sep 17 00:00:00 2001 From: darkfire006 Date: Wed, 29 Sep 2021 02:25:17 -0500 Subject: [PATCH] mastershinyrate create global control for shiny rate, update it for standard encounters and breeding and make it script callable --- P3D/Pokemon/Monster/Pokemon.vb | 45 ++++++++++++++----- P3D/Screens/Pokemon/Daycare.vb | 6 +-- .../V2/ScriptConstructs/DoPokemon.vb | 6 +++ 3 files changed, 42 insertions(+), 15 deletions(-) diff --git a/P3D/Pokemon/Monster/Pokemon.vb b/P3D/Pokemon/Monster/Pokemon.vb index ef2ebcb6b..416dbd494 100644 --- a/P3D/Pokemon/Monster/Pokemon.vb +++ b/P3D/Pokemon/Monster/Pokemon.vb @@ -6,7 +6,28 @@ Public Class Pokemon ''' ''' Defines which Pokémon in the default GameMode are considered "legendary". ''' - Public Shared ReadOnly Legendaries() As Integer = {144, 145, 146, 150, 151, 243, 244, 245, 249, 250, 251, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 716, 717, 718, 719, 720, 721} + Public Shared ReadOnly Legendaries() As Integer = {144, 145, 146, 150, 151, 243, 244, 245, 249, 250, 251, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 492, 493, 494, 638, 639, 640, 641, 642, 643, 644, 645, 646, 647, 648, 649, 716, 717, 718, 719, 720, 721, 772, 773, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 795, 796, 797, 798, 799, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 888, 889, 890, 891, 892, 893, 894, 895, 896, 897, 898} + + Public Shared ReadOnly Property MasterShinyRate(Optional ByVal adjusted As Boolean = True) As Integer + Get + Dim shinyRate As Integer = 4096 + + If adjusted Then + For Each mysteryEvent As MysteryEventScreen.MysteryEvent In MysteryEventScreen.ActivatedMysteryEvents + If mysteryEvent.EventType = MysteryEventScreen.EventTypes.ShinyMultiplier Then + shinyRate = CInt(shinyRate / CSng(mysteryEvent.Value.Replace(".", GameController.DecSeparator))) + End If + Next + + 'ShinyCharm + If Core.Player.Inventory.GetItemAmount(242) > 0 Then + shinyRate = CInt(shinyRate * 0.75F) + End If + End If + + Return shinyRate + End Get + End Property #Region "Events" @@ -1834,20 +1855,20 @@ Public Class Pokemon End If End If - Dim shinyRate As Integer = 4096 + Dim shinyRate As Integer = MasterShinyRate - For Each mysteryEvent As MysteryEventScreen.MysteryEvent In MysteryEventScreen.ActivatedMysteryEvents - If mysteryEvent.EventType = MysteryEventScreen.EventTypes.ShinyMultiplier Then - shinyRate = CInt(shinyRate / CSng(mysteryEvent.Value.Replace(".", GameController.DecSeparator))) - End If - Next + 'For Each mysteryEvent As MysteryEventScreen.MysteryEvent In MysteryEventScreen.ActivatedMysteryEvents + ' If mysteryEvent.EventType = MysteryEventScreen.EventTypes.ShinyMultiplier Then + ' shinyRate = CInt(shinyRate / CSng(mysteryEvent.Value.Replace(".", GameController.DecSeparator))) + ' End If + 'Next - 'ShinyCharm - If Core.Player.Inventory.GetItemAmount(242) > 0 Then - shinyRate = CInt(shinyRate * 0.75F) - End If + ''ShinyCharm + 'If Core.Player.Inventory.GetItemAmount(242) > 0 Then + ' shinyRate = CInt(shinyRate * 0.75F) + 'End If - If Core.Random.Next(0, shinyRate) = 0 And Pokemon.Legendaries.Contains(Me.Number) = False Then + If Core.Random.Next(0, shinyRate) = 0 Then Me.IsShiny = True End If diff --git a/P3D/Screens/Pokemon/Daycare.vb b/P3D/Screens/Pokemon/Daycare.vb index a016a924d..ee188ffad 100644 --- a/P3D/Screens/Pokemon/Daycare.vb +++ b/P3D/Screens/Pokemon/Daycare.vb @@ -315,12 +315,12 @@ Dim Shiny1 As Boolean = parent1.IsShiny Dim Shiny2 As Boolean = parent2.IsShiny - Dim chances As List(Of Integer) = {1, 4096}.ToList() + Dim chances As List(Of Integer) = {1, Pokemon.MasterShinyRate}.ToList() If Shiny1 = True And Shiny2 = True Then - chances = {12, 4096}.ToList() + chances = {12, Pokemon.MasterShinyRate}.ToList() '12/base rate odds ElseIf Shiny1 = True Or Shiny2 = True Then - chances = {6, 4096}.ToList() + chances = {6, Pokemon.MasterShinyRate}.ToList() '6/base rate odds End If If Core.Random.Next(0, chances(1)) < chances(0) Then diff --git a/P3D/World/ActionScript/V2/ScriptConstructs/DoPokemon.vb b/P3D/World/ActionScript/V2/ScriptConstructs/DoPokemon.vb index 1e1f639cf..89bdd66e6 100644 --- a/P3D/World/ActionScript/V2/ScriptConstructs/DoPokemon.vb +++ b/P3D/World/ActionScript/V2/ScriptConstructs/DoPokemon.vb @@ -449,6 +449,12 @@ If Core.Player.Pokemons.Count - 1 >= index Then Return Core.Player.Pokemons(index).EggSteps End If + Case "mastershinyrate" + Dim adjusted As Boolean = True + If argument <> "" Then + adjusted = CBool(argument) + End If + Return Pokemon.MasterShinyRate(adjusted) End Select Return DEFAULTNULL End Function