2021-10-05 22:15:58 +00:00
|
|
|
Scriptname _SAG_DicesGame_MainScript extends Quest
|
|
|
|
|
|
|
|
Message Property PlaceYourBet Auto
|
|
|
|
String s_chargeninitialtext
|
|
|
|
GlobalVariable Property _SAG_ProphDiceLostGames Auto
|
|
|
|
GlobalVariable Property _SAG_ProphDiceWonGames Auto
|
|
|
|
GlobalVariable Property _SAG_ProphDiceLostGold Auto
|
|
|
|
GlobalVariable Property _SAG_ProphDiceWonGold Auto
|
|
|
|
|
|
|
|
Actor Property Commentator Auto
|
|
|
|
ReferenceAlias Property Opponent Auto
|
|
|
|
Actor Property PlayerRef Auto
|
|
|
|
ObjectReference[] Property PlayerDicesLeft Auto
|
|
|
|
ObjectReference[] Property OpponentDicesLeft Auto
|
|
|
|
ObjectReference[] Property PlayerDicesRight Auto
|
|
|
|
ObjectReference[] Property OpponentDicesRight Auto
|
|
|
|
ObjectReference Property Marker Auto
|
|
|
|
ObjectReference InitialFurn
|
|
|
|
ObjectReference Property PlayerPosition Auto
|
|
|
|
Int PlayerBet
|
|
|
|
Int OpponentBet
|
|
|
|
Int MaxBet
|
|
|
|
Int PlayerScore
|
|
|
|
Int OpponentScore
|
|
|
|
ObjectReference PRandomDice1
|
|
|
|
ObjectReference PRandomDice2
|
|
|
|
ObjectReference ORandomDice1
|
|
|
|
ObjectReference ORandomDice2
|
|
|
|
MiscObject Property Gold001 Auto
|
|
|
|
Message Property Question Auto
|
|
|
|
int Choice
|
|
|
|
|
|
|
|
Function InitiateGame()
|
|
|
|
s_chargeninitialtext = Game.GetGameSettingString("sCharGenControlsDisabled")
|
|
|
|
Game.SetGameSettingString("sCharGenControlsDisabled","")
|
|
|
|
Commentator.GetActorBase().SetVoiceType(Opponent.GetActorReference().GetVoiceType())
|
|
|
|
Commentator.SetDisplayName(Opponent.GetReference().GetDisplayName(), true)
|
|
|
|
initialFurn = PlayerRef.GetFurnitureReference()
|
|
|
|
game.DisablePlayerControls(true, true, true, true, true, false, true, false, 0)
|
|
|
|
game.ForceFirstPerson()
|
|
|
|
game.SetInChargen(true, true, true)
|
|
|
|
PlayerPosition.MoveTo(PlayerRef as objectreference, 0.000000, 0.000000, 0.000000, true)
|
|
|
|
utility.Wait(0.300000)
|
|
|
|
PlayerRef.MoveTo(Marker, 0.000000, 0.000000, 0.000000, true)
|
|
|
|
if Opponent.GetReference().IsDisabled()
|
|
|
|
Opponent.GetReference().Enable(false)
|
|
|
|
endIf
|
|
|
|
Utility.Wait(3.0)
|
|
|
|
Step01()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function Step01()
|
|
|
|
ORandomDice1.Disable()
|
|
|
|
ORandomDice2.Disable()
|
|
|
|
PRandomDice1.Disable()
|
|
|
|
PRandomDice2.Disable()
|
2024-02-15 15:20:20 +00:00
|
|
|
|
|
|
|
if PlayerRef.GetItemCount(Gold001) <= Opponent.GetReference().GetItemCount(Gold001)
|
|
|
|
MaxBet = (PlayerRef.GetItemCount(Gold001)/2) as INT
|
|
|
|
elseif PlayerRef.GetItemCount(Gold001) > Opponent.GetReference().GetItemCount(Gold001)
|
|
|
|
MaxBet = (Opponent.GetReference().GetItemCount(Gold001)/2) as INT
|
|
|
|
endif
|
|
|
|
|
2024-02-15 15:28:23 +00:00
|
|
|
if EnderalFunctions.TextInputEnabled()
|
2024-02-15 15:20:20 +00:00
|
|
|
PlayerBet = (((self as Quest) as form) as uilib_1).ShowTextInput(PlaceYourBet.GetName() + MaxBet as String, MaxBet as String) as Int
|
|
|
|
else
|
|
|
|
float fPrevValue = PlayerRef.GetActorValue("Variable08")
|
|
|
|
PlayerRef.SetActorValue("Variable08", MaxBet)
|
|
|
|
int iBet = _SAG_SelectBetMessage.Show()
|
|
|
|
PlayerRef.SetActorValue("Variable08", fPrevValue)
|
|
|
|
|
|
|
|
if iBet == 0
|
|
|
|
PlayerBet = 50
|
|
|
|
elseif iBet == 1
|
|
|
|
PlayerBet = 100
|
|
|
|
elseif iBet == 2
|
|
|
|
PlayerBet = 200
|
|
|
|
elseif iBet == 3
|
|
|
|
PlayerBet = 350
|
|
|
|
elseif iBet == 4
|
|
|
|
PlayerBet = 500
|
|
|
|
elseif iBet == 5
|
|
|
|
PlayerBet = 750
|
|
|
|
elseif iBet == 6
|
|
|
|
PlayerBet = 1000
|
|
|
|
else
|
|
|
|
QuitGame()
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
if PlayerBet > MaxBet || PlayerBet <= 0
|
|
|
|
Step01()
|
|
|
|
Return
|
|
|
|
endif
|
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
OpponentBet = PlayerBet
|
|
|
|
Step02()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function Step02()
|
|
|
|
Int diceplayer = Utility.RandomInt(0,5)
|
|
|
|
Int diceplayer2 = Utility.RandomInt(0,5)
|
|
|
|
PRandomDice1 = PlayerDicesLeft[diceplayer]
|
|
|
|
PRandomDice2 = PlayerDicesRight[diceplayer2]
|
|
|
|
PRandomDice1.Enable(true)
|
|
|
|
PRandomDice2.Enable(true)
|
|
|
|
PlayerScore = diceplayer + diceplayer2 + 2
|
|
|
|
Utility.Wait(2.0)
|
|
|
|
Step03()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function Step03()
|
|
|
|
Choice = Question.Show(playerscore) ; 0 =less, 1 = more, 2 = equal
|
|
|
|
if Choice == 2
|
|
|
|
PlayerBet = PlayerBet*3
|
|
|
|
endif
|
|
|
|
PickOpponentDice()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function PickOpponentDice()
|
|
|
|
Int diceopponent = Utility.RandomInt(0,5)
|
|
|
|
Int diceopponent2 = Utility.RandomInt(0,5)
|
|
|
|
ORandomDice1 = OpponentDicesLeft[diceopponent]
|
|
|
|
ORandomDice2 = OpponentDicesRight[diceopponent2]
|
|
|
|
ORandomDice1.Enable(true)
|
|
|
|
ORandomDice2.Enable(true)
|
|
|
|
OpponentScore = diceopponent + diceopponent2 +2
|
|
|
|
Utility.Wait(3.0)
|
|
|
|
CheckResult()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function CheckResult()
|
|
|
|
if Choice == 0 ; we bet on less
|
|
|
|
if PlayerScore <= OpponentScore
|
|
|
|
PlayerLost()
|
|
|
|
else
|
|
|
|
PlayerWon()
|
|
|
|
endif
|
|
|
|
elseif Choice == 1 ; more
|
|
|
|
if PlayerScore < OpponentScore
|
|
|
|
PlayerWon()
|
|
|
|
else
|
|
|
|
PlayerLost()
|
|
|
|
endif
|
|
|
|
elseif Choice == 2
|
|
|
|
if PlayerScore == OpponentScore
|
|
|
|
PlayerWon()
|
|
|
|
else
|
|
|
|
PlayerLost()
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function PlayerLost()
|
|
|
|
Utility.Wait(2.0)
|
|
|
|
PlayerLost.Show(playerscore, opponentscore,playerbet)
|
|
|
|
PlayerRef.RemoveItem(Gold001, playerbet, false, Opponent.GetReference())
|
|
|
|
_SAG_ProphDiceLostGames.Value += 1
|
|
|
|
_SAG_ProphDiceLostGold.Value += playerbet
|
|
|
|
PlayAgain()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function PlayerWon()
|
|
|
|
Utility.Wait(2.0)
|
|
|
|
PlayerWon.Show(playerscore, opponentscore,playerbet)
|
|
|
|
PlayerRef.AddItem(Gold001, playerbet)
|
|
|
|
Opponent.GetReference().RemoveItem(Gold001, playerbet)
|
|
|
|
_SAG_ProphDiceWonGames.Value += 1
|
|
|
|
_SAG_ProphDiceWonGold.Value += playerbet
|
|
|
|
|
2024-01-10 00:46:13 +00:00
|
|
|
If _SAG_ProphDiceWonGames.GetValueInt() == 10
|
2022-08-03 21:19:58 +00:00
|
|
|
Steam.UnlockAchievement("END_DICEGOD_01")
|
2021-10-05 22:15:58 +00:00
|
|
|
EndIf
|
|
|
|
|
|
|
|
PlayAgain()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function PlayAgain()
|
|
|
|
if PlayerRef.GetItemCount(Gold001) < 10
|
|
|
|
;Debug.Notification("You do not have enough gold to play again.")
|
|
|
|
QuitGame()
|
|
|
|
elseif Opponent.GetReference().GetItemCount(Gold001) < 10
|
|
|
|
;Debug.Notification(Opponent.GetReference().GetDisplayName()+" does not have enough gold to play again.")
|
|
|
|
QuitGame()
|
|
|
|
else
|
|
|
|
int play = PlayAgain.Show(PlayerRef.GetItemCount(Gold001), Opponent.GetReference().GetItemCount(GOld001))
|
|
|
|
if play == 0
|
|
|
|
Step01()
|
|
|
|
else
|
|
|
|
QuitGame()
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Function QuitGame()
|
|
|
|
Game.SetGameSettingString("sCharGenControlsDisabled", s_chargeninitialtext)
|
|
|
|
ORandomDice1.Disable()
|
|
|
|
ORandomDice2.Disable()
|
|
|
|
PRandomDice1.Disable()
|
|
|
|
PRandomDice2.Disable()
|
|
|
|
if Opponent.GetReference().IsDisabled()
|
|
|
|
Opponent.GetReference().Enable()
|
|
|
|
endif
|
2024-02-15 15:20:20 +00:00
|
|
|
|
|
|
|
if initialFurn
|
|
|
|
PlayerRef.MoveTo(initialFurn)
|
|
|
|
else
|
|
|
|
PlayerRef.MoveTo(PlayerPosition)
|
|
|
|
endif
|
|
|
|
|
2021-10-05 22:15:58 +00:00
|
|
|
Game.EnablePlayerControls()
|
|
|
|
game.SetInChargen(false, false, false)
|
|
|
|
Opponent.Clear()
|
|
|
|
EndFunction
|
|
|
|
|
|
|
|
Message Property PlayAgain Auto
|
|
|
|
Message Property PlayerLost Auto
|
2024-02-15 15:20:20 +00:00
|
|
|
Message Property PlayerWon Auto
|
|
|
|
Message Property _SAG_SelectBetMessage Auto
|