2016-09-07 18:50:38 +02:00
Public Class SmashRock
Inherits Entity
Public Overrides Sub ClickFunction ( )
If Screen . TextBox . Showing = False Then
Dim pName As String = " "
For Each p As Pokemon In Core . Player . Pokemons
If p . IsEgg ( ) = False Then
For Each a As BattleSystem . Attack In p . Attacks
If a . Name . ToLower ( ) = ( " Rock Smash " ) . ToLower ( ) Then
pName = p . GetDisplayName ( )
Exit For
End If
Next
End If
If pName <> " " Then
Exit For
End If
Next
2023-07-30 18:16:27 +02:00
Dim text As String = Localization . GetString ( " fieldmove_rocksmash_1 " , " This rock looks like~it can be broken! " )
2016-09-07 18:50:38 +02:00
If pName <> " " Or GameController . IS_DEBUG_ACTIVE = True Or Core . Player . SandBoxMode = True Then
2023-07-30 18:16:27 +02:00
text &= Localization . GetString ( " fieldmove_rocksmash_2 " , " *Do you want to~use Rock Smash? " ) & " % " & Localization . GetString ( " global_yes " , " Yes " ) & " | " & Localization . GetString ( " global_no " , " No " ) & " % "
2016-09-07 18:50:38 +02:00
End If
Screen . TextBox . Show ( text , { Me } )
SoundManager . PlaySound ( " select " )
End If
End Sub
Public Overrides Sub ResultFunction ( Result As Integer )
If Result = 0 Then
Dim pName As String = " "
For Each p As Pokemon In Core . Player . Pokemons
If p . IsEgg ( ) = False Then
For Each a As BattleSystem . Attack In p . Attacks
If a . Name . ToLower ( ) = ( " Rock Smash " ) . ToLower ( ) Then
pName = p . GetDisplayName ( )
Exit For
End If
Next
End If
If pName <> " " Then
Exit For
End If
Next
Dim spawnedPokemon As Pokemon = Nothing
If Core . Random . Next ( 0 , 100 ) < 20 Then
spawnedPokemon = Spawner . GetPokemon ( Screen . Level . LevelFile , Spawner . EncounterMethods . RockSmash , False )
If spawnedPokemon Is Nothing Then
2018-01-07 18:01:32 +01:00
Dim s As String = " version=2 " & Environment . NewLine &
2023-07-30 18:16:27 +02:00
" @text.show( " & pName & " " & Localization . GetString ( " fieldmove_rocksmash_used " , " used~Rock Smash! " ) & " ) " & Environment . NewLine &
" @sound.play(FieldMove_RockSmash) " & Environment . NewLine &
2016-09-07 18:50:38 +02:00
" :end "
CType ( Core . CurrentScreen , OverworldScreen ) . ActionScript . StartScript ( s , 2 )
Else
2018-01-07 18:01:32 +01:00
Dim s As String = " version=2 " & Environment . NewLine &
2023-07-30 18:16:27 +02:00
" @text.show( " & pName & " " & Localization . GetString ( " fieldmove_rocksmash_used " , " used~Rock Smash! " ) & " ) " & Environment . NewLine &
" @sound.play(FieldMove_RockSmash) " & Environment . NewLine &
2018-01-07 18:01:32 +01:00
" @level.update " & Environment . NewLine &
" @text.show(A wild Pokémon~appeared!) " & Environment . NewLine &
2022-07-11 01:19:10 +02:00
" @battle.wild( " & spawnedPokemon . GetSaveData ( ) & " ) " & Environment . NewLine &
2016-09-07 18:50:38 +02:00
" :end "
CType ( Core . CurrentScreen , OverworldScreen ) . ActionScript . StartScript ( s , 2 )
End If
Else
If Core . Random . Next ( 0 , 100 ) < 20 Then
Dim ItemID As Integer = GetItemID ( )
2018-01-07 18:01:32 +01:00
Dim s As String = " version=2 " & Environment . NewLine &
2023-07-30 18:16:27 +02:00
" @text.show( " & pName & " " & Localization . GetString ( " fieldmove_rocksmash_used " , " used~Rock Smash! " ) & " ) " & Environment . NewLine &
" @sound.play(FieldMove_RockSmash) " & Environment . NewLine &
2018-01-07 18:01:32 +01:00
" @level.update " & Environment . NewLine &
" @item.give( " & ItemID & " ,1) " & Environment . NewLine &
" @item.messagegive( " & ItemID & " ,1) " & Environment . NewLine &
2016-09-07 18:50:38 +02:00
" :end "
CType ( Core . CurrentScreen , OverworldScreen ) . ActionScript . StartScript ( s , 2 )
Else
2018-01-07 18:01:32 +01:00
Dim s As String = " version=2 " & Environment . NewLine &
2023-07-30 18:16:27 +02:00
" @text.show( " & pName & " " & Localization . GetString ( " fieldmove_rocksmash_used " , " used~Rock Smash! " ) & " ) " & Environment . NewLine &
" @sound.play(FieldMove_RockSmash) " & Environment . NewLine &
2016-09-07 18:50:38 +02:00
" :end "
CType ( Core . CurrentScreen , OverworldScreen ) . ActionScript . StartScript ( s , 2 )
End If
End If
PlayerStatistics . Track ( " Rock Smash used " , 1 )
Me . CanBeRemoved = True
End If
End Sub
Private Function GetItemID ( ) As Integer
Dim MatchingContainers As New List ( Of ItemContainer )
Dim Chances As New List ( Of Integer )
For Each c As ItemContainer In ItemContainerlist
If c . MapFile . ToLower ( ) = Screen . Level . LevelFile . ToLower ( ) Then
MatchingContainers . Add ( c )
Chances . Add ( c . Chance )
End If
Next
If MatchingContainers . Count = 0 Then
Return 190
End If
Return MatchingContainers ( GetRandomChance ( Chances ) ) . ItemID
End Function
Private Class ItemContainer
Public ItemID As Integer = 190
Public Chance As Integer = 0
Public MapFile As String = " "
Public Sub New ( ByVal MapFile As String , ByVal Data As String )
Me . MapFile = MapFile
'{ID,Chance}
Data = Data . Remove ( Data . Length - 1 , 1 ) . Remove ( 0 , 1 )
Dim DataArray ( ) As String = Data . Split ( CChar ( " , " ) )
Me . ItemID = CInt ( DataArray ( 0 ) )
Me . Chance = CInt ( DataArray ( 1 ) )
End Sub
End Class
Private Shared ItemContainerlist As New List ( Of ItemContainer )
Public Shared Sub Load ( )
ItemContainerlist . Clear ( )
Dim File As String = GameModeManager . GetContentFilePath ( " Data\smashrockitems.dat " )
If System . IO . File . Exists ( File ) = True Then
Security . FileValidation . CheckFileValid ( File , False , " SmashRock.vb " )
Dim data ( ) As String = System . IO . File . ReadAllLines ( File )
For Each line As String In data
Dim Linedata ( ) As String = line . Split ( CChar ( " | " ) )
Dim Mapfile As String = Linedata ( 0 )
For i = 1 To Linedata . Length - 1
ItemContainerlist . Add ( New ItemContainer ( Mapfile , Linedata ( i ) ) )
Next
Next
End If
End Sub
Public Overrides Sub UpdateEntity ( )
MyBase . UpdateEntity ( )
If Rotation . Y <> Screen . Camera . Yaw Then
Me . Rotation . Y = Screen . Camera . Yaw
Me . CreatedWorld = False
End If
End Sub
Public Overrides Sub Render ( )
2022-07-13 00:12:16 +02:00
If Me . Model Is Nothing Then
Me . Draw ( Me . BaseModel , Me . Textures , False )
Else
2022-07-16 14:48:29 +02:00
UpdateModel ( )
2022-07-13 00:12:16 +02:00
Draw ( Me . BaseModel , Me . Textures , True , Me . Model )
End If
2016-09-07 18:50:38 +02:00
End Sub
End Class