ベストプレープロ野球…エクセルVBAでツール作成⑤野手成長

ベスプレ画面 ゲーム

  

 

この記事は

一生遊べる野球ゲーム 【ベストプレープロ野球】

をエクセルVBAでオリジナルリーグを作成するツールを作り、自分だけの世界を楽しんでもらえる参考になればと思い書いております。

すでに自作ツールで運用している方にも良い刺激になればと思っております。

 

この記事で紹介する ツールのダウンロードはこちらから

前 回 まで

・野手シートと投手シートの選手名を自動で作成しました。

・リーグ運営の設定表作成(選手の能力・成長 決定)

・野手の初期パラメータ作成(16歳)

⇓出来上がったプログラム

・メインモジュール  プログラム Test・
・共通モジュール  プログラム Saikoro・Get_Name・Get_SeityoType・Get_Nouryoku
・野手編モジュール  プログラム 野手作成・Get_Daseki・Get_Type・Get_Sinrai・Get_KillLeft・Get_Daritu

 

前回で16歳時の (高校入学~1年生) 野手の能力を決定しましたので

今回で一定年齢まで成長させたいと思います。

リーグ初期が全員同じ年齢では違和感がありますので。

 

今回作成するプログラム 野手成長 では、能力変動と年齢加算と引退なども考慮して作成していきます。

野手モジュール

野手の初期能力(16歳)を作成しましたので、一定の年齢まで成長させます。

1・2軍⇒18 + (Saikoro(17)) + 1 20歳~36歳まで

外人⇒25 + (Saikoro(9)) + 1 27歳~35歳まで

若手(新人)⇒18 + ((Saikoro(4) * 2) – 2) + 1 19歳~25歳まで

 

前回選手作成時に設定年齢は⇑の計算式で算出されています。

実年齢 の行の下が 設定年齢です。

 

また野手のタイプ P⇒S S⇒P は100面体で 33か77がでれば変わります。

 

↓のプログラムを野手編ジュールに作成します。

Public Function 野手成長(SName As String)

Dim Low As Byte ‘行
Dim Col As Byte ‘列
Dim i As Byte ‘ショートループ
Dim j As Byte ‘年齢ループ
Dim k As Byte ‘選手数ループ
Dim L As Byte ‘設定年齢と実年齢の年数差
Dim ID As Integer ‘名前ID番号

Dim Nenrei As Byte ‘現在の年齢
Dim SetteiNenrei As Byte ‘設定年齢
Dim Nenreisa As Byte ’15歳から現在までの経過年数
Dim BStyle As String ‘打者タイプ

Dim Kokoro(1) As String ‘心の(0)成長タイプ:(1)成長モード
Dim Waza(1) As String ‘技の(0)成長タイプ:(1)成長モード
Dim Karada(1) As String ‘体の(0)成長タイプ:(1)成長モード
Dim Avipoint As Byte ‘特徴ポイント(確率補正)

Dim IntNoryoku As Integer ‘能力指数
Dim MaxNoryoku As Byte ‘最大能力値
Dim MaxIti As Byte ‘最大能力位置
Dim GetFrg As Boolean ‘サブポジション獲得:引退フラグ

Dim ch As Byte ‘クリティカル判定と確率ループに使用

On Error GoTo err

‘変数初期設定
Low = 0
Worksheets(SName).Activate

For k = 1 To 44
Low = Low + 3
Col = 2
MaxNoryoku = 0
GetFrg = False

Cells(Low – 1, 1).Select
Selection.Font.ColorIndex = 0

If Cells(Low – 1, Col) > 1 Then

‘年齢の取得
Nenrei = Cells(Low – 1, Col)
SetteiNenrei = Cells(Low, Col)

‘成長タイプ取得
Kokoro(0) = Cells(Low – 1, Col + 1)
Waza(0) = Cells(Low – 1, Col + 2)
Karada(0) = Cells(Low – 1, Col + 3)

L = SetteiNenrei – Nenrei

For j = 1 To L
Col = 2

‘タイプ変更
ch = Saikoro
If ch = 33 Or ch = 77 Then
If Cells(Low – 1, Col + 5) = “P” Then
Cells(Low – 1, Col + 5) = “S”
ch = Saikoro
If ch <= 70 And _
Cells(Low, Col + 17) <= 235 And _
Cells(Low, Col + 14) <= 245 Then

Cells(Low, Col + 17) = Cells(Low, Col + 17) + 13
Cells(Low, Col + 14) = Cells(Low, Col + 14) + 7
Else
If Cells(Low, Col + 18) >= 20 And _
Cells(Low, Col + 17) <= 225 And _
Cells(Low, Col + 14) <= 235 Then

Cells(Low, Col + 18) = Cells(Low, Col + 18) – 20
Cells(Low, Col + 17) = Cells(Low, Col + 17) + 26
Cells(Low, Col + 14) = Cells(Low, Col + 14) + 14
End If
End If
Else
Cells(Low – 1, Col + 5) = “P”
ch = Saikoro(10)
If ch <= 70 And _
Cells(Low, Col + 17) <= 235 And _
Cells(Low, Col + 14) <= 245 Then

Cells(Low, Col + 18) = Cells(Low, Col + 18) + 13
Cells(Low, Col + 14) = Cells(Low, Col + 14) + 7
Else
If Cells(Low, Col + 17) >= 20 And _
Cells(Low, Col + 18) <= 225 And _
Cells(Low, Col + 14) <= 235 Then

Cells(Low, Col + 17) = Cells(Low, Col + 17) – 20
Cells(Low, Col + 18) = Cells(Low, Col + 18) + 26
Cells(Low, Col + 14) = Cells(Low, Col + 14) + 14
End If
End If
End If
End If

‘打者タイプ取得
BStyle = Cells(Low – 1, Col + 4) & Cells(Low – 1, Col + 5)

‘年齢の再取得
Nenrei = Cells(Low – 1, Col)
‘年齢差取得
Nenreisa = Nenrei – 15 + 3
If Nenreisa >= 30 Then
Nenreisa = 29
End If

‘現在の成長モード取得
‘心の成長モードセル取得
Select Case Kokoro(0)
Case “早熟”
Kokoro(1) = “I” & CStr(Nenreisa)
Case “普通”
Kokoro(1) = “L” & CStr(Nenreisa)
Case “晩成”
Kokoro(1) = “O” & CStr(Nenreisa)
Case “安定”
Kokoro(1) = “R” & CStr(Nenreisa)
Case Else
Kokoro(1) = “U” & CStr(Nenreisa)
End Select

‘技の成長モードセル取得
Select Case Waza(0)
Case “早熟”
Waza(1) = “J” & CStr(Nenreisa)
Case “普通”
Waza(1) = “M” & CStr(Nenreisa)
Case “晩成”
Waza(1) = “P” & CStr(Nenreisa)
Case “安定”
Waza(1) = “S” & CStr(Nenreisa)
Case Else
Waza(1) = “V” & CStr(Nenreisa)
End Select

‘体の成長モードセル取得
Select Case Karada(0)
Case “早熟”
Karada(1) = “K” & CStr(Nenreisa)
Case “普通”
Karada(1) = “N” & CStr(Nenreisa)
Case “晩成”
Karada(1) = “Q” & CStr(Nenreisa)
Case “安定”
Karada(1) = “T” & CStr(Nenreisa)
Case Else
Karada(1) = “W” & CStr(Nenreisa)
End Select

‘心技体成長モード取得
Kokoro(1) = Sheets(“設定表”).Range(Kokoro(1))
Waza(1) = Sheets(“設定表”).Range(Waza(1))
Karada(1) = Sheets(“設定表”).Range(Karada(1))

‘守備力Up判定
For i = 1 To 6
Col = 7
Col = Col + i

‘能力指数Up
IntNoryoku = Cells(Low, Col)

‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力アップ
Call NouryokuUp(Waza(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
Call NouryokuDown(Waza(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘メインポジションと能力指数探索
If MaxNoryoku < Cells(Low, Col) Then
MaxNoryoku = Cells(Low, Col)
MaxIti = i
End If

‘能力値が規定以下
If GetFrg = True Then
Cells(Low – 1, Col) = “”
GetFrg = False
End If

‘ベスプレ用能力値書きこみ
If Len(Cells(Low – 1, Col)) <> 0 Then
Cells(Low – 1, Col) = Get_Nouryoku(IntNoryoku)
End If

Next i

‘サブポジション書きこみ(キャッチャー以外)
Col = Col – 6
IntNoryoku = Cells(Low, Col + MaxIti)
If MaxIti <> 1 Then
Cells(Low – 1, Col + MaxIti) = Get_Nouryoku(IntNoryoku)
End If

‘本職の守備位置書き込み
Select Case MaxIti
Case 1
Cells(Low + 1, 1) = “捕手”
Case 2
Cells(Low + 1, 1) = “ファースト”
Case 3
Cells(Low + 1, 1) = “セカンド”
Case 4
Cells(Low + 1, 1) = “サード”
Case 5
Cells(Low + 1, 1) = “ショート”
Case Else
Cells(Low + 1, 1) = “外野”
End Select

‘変数の値変更
Col = Col + 7
GetFrg = False

‘肩力
‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力指数Up
IntNoryoku = Cells(Low, Col)
Call NouryokuUp(Karada(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
IntNoryoku = Cells(Low, Col)
Call NouryokuDown(Karada(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力値決定
Cells(Low – 1, Col) = Get_Nouryoku(IntNoryoku)

‘変数の値変更
Col = Col + 1

‘走力決定
‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力指数Up
IntNoryoku = Cells(Low, Col)
Call NouryokuUp(Waza(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
IntNoryoku = Cells(Low, Col)
Call NouryokuDown(Waza(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力値決定
Cells(Low – 1, Col) = Get_Nouryoku(IntNoryoku)

‘変数の値変更
Col = Col + 1

‘選球眼決定
‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力指数Up
IntNoryoku = Cells(Low, Col)
Call NouryokuUp(Kokoro(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
IntNoryoku = Cells(Low, Col)
Call NouryokuDown(Kokoro(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力値決定
Cells(Low – 1, Col) = Get_Nouryoku(IntNoryoku)

‘変数の値変更
Col = Col + 1

‘実績決定
‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力指数Up
IntNoryoku = Cells(Low, Col)
Call NouryokuUp(Kokoro(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
IntNoryoku = Cells(Low, Col)
Call NouryokuDown(Kokoro(1), IntNoryoku, , Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力値決定
Cells(Low – 1, Col) = Get_Nouryoku(IntNoryoku)

‘変数の値変更
Col = Col + 1

‘体力決定
‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力指数Up
IntNoryoku = Cells(Low, Col)
Call NouryokuUp(Karada(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
IntNoryoku = Cells(Low, Col)
Call NouryokuDown(Karada(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力値決定 体力のみ+20
IntNoryoku = IntNoryoku + 20
Cells(Low – 1, Col) = Get_Nouryoku(IntNoryoku)

‘変数の値変更
Col = Col + 1

‘好打決定
‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力指数Up
IntNoryoku = Cells(Low, Col)
Call NouryokuUp(Waza(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
IntNoryoku = Cells(Low, Col)
Call NouryokuDown(Waza(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力値決定
If Right(BStyle, 1) = “S” Then
IntNoryoku = IntNoryoku + 10
End If
Cells(Low – 1, Col) = Get_Nouryoku(IntNoryoku)

‘変数の値変更
Col = Col + 1

‘長打決定
‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力指数Up
IntNoryoku = Cells(Low, Col)
Call NouryokuUp(Karada(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
IntNoryoku = Cells(Low, Col)
Call NouryokuDown(Karada(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力値決定
If Right(BStyle, 1) = “P” Then
IntNoryoku = IntNoryoku + 10
End If
Cells(Low – 1, Col) = Get_Nouryoku(IntNoryoku)

‘変数の値変更
Col = Col + 1

‘信頼決定
‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力指数Up
IntNoryoku = Cells(Low, Col)
Call NouryokuUp(Kokoro(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
IntNoryoku = Cells(Low, Col)
Call NouryokuDown(Kokoro(1), IntNoryoku, , Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力値決定
If Right(BStyle, 1) = “P” Then
IntNoryoku = IntNoryoku + 5
End If
Cells(Low – 1, Col) = Get_Sinrai(IntNoryoku, BStyle)
‘変数の値変更
Col = Col + 1

‘対左決定
‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力指数Up
IntNoryoku = Cells(Low, Col)
Call NouryokuUp(Kokoro(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
IntNoryoku = Cells(Low, Col)
Call NouryokuDown(Kokoro(1), IntNoryoku, , Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力値決定
If Right(BStyle, 1) = “S” Then
IntNoryoku = IntNoryoku + 5
End If
Cells(Low – 1, Col) = Get_KillLeft(IntNoryoku, BStyle)

‘変数の値変更
Col = Col + 1

‘打撃指数決定
‘アベレージポイント取得
Avipoint = Cells(Low + 1, Col)

‘能力指数Up
IntNoryoku = Cells(Low, Col)
Call NouryokuUp(Waza(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力指数Down
IntNoryoku = Cells(Low, Col)
Call NouryokuDown(Waza(1), IntNoryoku, GetFrg, Avipoint)
Cells(Low, Col) = IntNoryoku

‘能力値決定
Cells(Low – 1, Col) = Get_Daritu(Cells(Low, Col))

‘年齢を加算
Col = Col – 21
Cells(Low – 1, Col) = (Cells(Low – 1, Col)) + 1
If Cells(Low – 1, Col) >= 50 Then
GetFrg = True
End If

Col = Col + 21
‘引退フラグ
If GetFrg = True Then
Cells(Low – 1, Col + 1) = “退団”

For i = 1 To 6
Cells(Low – 1, Col + i – 16) = “”
Next i

Else
Select Case k
Case Is <= 16
Cells(Low – 1, Col + 1) = “1軍”
Cells(Low, Col + 1) = k
Case Is <= 34
Cells(Low – 1, Col + 1) = “2軍”
Cells(Low, Col + 1) = k
Case Is <= 39
Cells(Low – 1, Col + 1) = “外人”
Cells(Low, Col + 1) = k
Case Else
Cells(Low – 1, Col + 1) = “新人”
Cells(Low, Col + 1) = k
End Select
End If
Next j

End If

Next k

Exit Function
err:
MsgBox err.Description
Resume Next

End Function

 

↑ここまでを野手ジュールに作成しました。

共通モジュール

成長に関わる 能力アップ・ダウンと

実年齢を1つ加算する3つのプログラムを追加します。

これで野手の作成は完了です。

 

↓のプログラムを共通ジュールに作成しました。

 

Public Function NouryokuUp(mode As String, ByRef UpNoryoku As Integer, Optional ByRef GetFrg = False, Optional ByVal Avipoint As Byte = 0) As Integer

Dim ch As Byte

Select Case mode
Case “S”
NouryokuUp = Sheets(“設定表”).Range(“T33”)
Case “A”
NouryokuUp = Sheets(“設定表”).Range(“T34”)
Case “B”
NouryokuUp = Sheets(“設定表”).Range(“T35”)
Case “C”
NouryokuUp = Sheets(“設定表”).Range(“T36”)
Case “D”
NouryokuUp = Sheets(“設定表”).Range(“T37”)
Case “E”
NouryokuUp = Sheets(“設定表”).Range(“T38”)
Case Else
NouryokuUp = Sheets(“設定表”).Range(“T39”)
End Select

NouryokuUp = NouryokuUp – (5 + Avipoint)

‘確率リミット
If (NouryokuUp + Avipoint) >= 95 Then
NouryokuUp = 95
End If

If (NouryokuUp + Avipoint) <= 5 Then
NouryokuUp = 5
End If

‘能力アップ連荘判定(最終アップ)
Do While NouryokuUp > Saikoro(100)

‘クリティカル判定
If UpNoryoku <= 245 Then
ch = Saikoro(10)
Select Case ch
Case 3, 7
UpNoryoku = UpNoryoku + 1 + (Saikoro(2))
Case Else
UpNoryoku = UpNoryoku + 1
End Select
End If
Loop

End Function

Public Function NouryokuDown(mode As String, ByRef DownNoryoku As Integer, Optional ByRef GetFrg = False, Optional ByVal Avipoint As Integer = 0) As Integer

Dim ch As Byte

If DownNoryoku <= 10 Then
Exit Function
End If

Select Case mode
Case “S”
NouryokuDown = Sheets(“設定表”).Range(“U33”)
Case “A”
NouryokuDown = Sheets(“設定表”).Range(“U34”)
Case “B”
NouryokuDown = Sheets(“設定表”).Range(“U35”)
Case “C”
NouryokuDown = Sheets(“設定表”).Range(“U36”)
Case “D”
NouryokuDown = Sheets(“設定表”).Range(“U37”)
Case “E”
NouryokuDown = Sheets(“設定表”).Range(“U38”)
Case Else
NouryokuDown = Sheets(“設定表”).Range(“U39”)
End Select

NouryokuDown = NouryokuDown + (5 – Avipoint)

If (NouryokuDown + Avipoint) >= 95 Then
NouryokuDown = 95
End If

If (NouryokuDown + Avipoint) <= 5 Then
NouryokuDown = 5
End If

‘能力ダウン連荘判定(最終アップ)
Do While NouryokuDown > Saikoro(100)
‘引退フラグ判定とクリティカル判定
If DownNoryoku > 10 Then

ch = Saikoro(10)
Select Case ch
Case 3, 7
DownNoryoku = DownNoryoku – 1 – (Saikoro(2))
Case Else
DownNoryoku = DownNoryoku – 1
End Select
Else
GetFrg = True
End If
Loop

End Function

Public Function 年齢加算(PBi As String)

Dim j As Byte
Dim i As Byte
Dim ii As Byte
Dim k As Byte
Dim ID As Integer

Dim Low As Byte
Dim Col As Byte
Dim colcol As Byte
Dim Stat(30) As String
Dim PBJ As String

For j = 0 To 1

Low = 1
Col = 2

If j = 0 Then
PBJ = PBi & “_野手”
Sheets(PBJ).Activate
ii = 29
colcol = 24 + 3
Else
PBJ = PBi & “_投手”
Sheets(PBJ).Activate
ii = 29
colcol = 16 + 3
End If

For i = 0 To ii
‘年齢加算
Low = Low + 2

If Cells(Low, Col) > 1 Then
Cells(Low, Col) = Cells(Low, Col) + 1
‘状況を取得
Stat(i) = Cells(Low – 1, colcol – 3)

End If
Next i

Next j

End Function

 

↑ここまでです。

 

プログラム を 動かして 確認する。

これで 初期の野手選手(成長後)のデータを作る準備が出来上がりました。

 

開発画面、一番下のイミティエイト ウィンドウ に

野手成長(”T_野手”)

と打ち込んで ENTER キーを打ち込めば

野手⑤完成16歳から設定年齢まで成長した、各パラメータの入ったシートが出来上がります。

⇓ 前回作成した 選手データ(16歳)

野手④4初期能力入り

 

どうですか? 少しは成長してますね。

 

守備位置に注目してください。

1番目の選手 永野 千代美さん

16歳ではショート だったのが 27歳でサードにコンバートされてます。

もちろん、両方守れます。

 

このツールでは、毎年能力成長判定で最高の守備力値の場所が メインポジションとなります。

 そして、当然守ることが出来るので守備力(AやC)などが発生します。(16歳以外)

 これによってコンバートとしてます。(ユーティリティポジション)

 

これで野手は完了です。

次回からは投手を同じように作成していきたいと思います。

 

⇐前の記事 【目次】 次の記事⇒

 

ベストプレープロ野球を知りたい方は

ベストプレープロ野球…自由度が最強で一生遊べる野球ゲーム

 

ベストプレープロ野球 ソフトのお求めは⇓の画像から(Win,GBA,PS2)

  

タイトルとURLをコピーしました