enderalse/source/scripts/_sag_acitv_julianoschallenge_script.psc

280 lines
8.9 KiB
Plaintext
Raw Normal View History

Scriptname _SAG_Acitv_JulianosChallenge_Script extends Quest
Message Property _SAG_OpponentGotAnswerRightMessage Auto
Int Property MaxCases = 62 AutoReadOnly Hidden
Int Property Start = 0 AutoReadOnly Hidden
Message Property CorrectionMagic Auto
ReferenceAlias Property MagicSchoolRefAlias Auto
ObjectReference Property NameHolderMagicSchool Auto
String[] Property MagicSchools Auto
ReferenceAlias Property NameHolder Auto
ObjectReference Property NameHolderRef Auto
FormList Property SpellList Auto
Message Property QuestionMagic Auto
ReferenceAlias Property Opponent Auto
String s_chargeninitialtext
Int CurrentPlayerPosition = 0
Int CurrentOpponentPosition = 0
Int DicePlayerResult = 0
Int DicePlayer1 = 0
Int DicePlayer2 = 0
Int DiceOpponentResult = 0
Int DiceOpponent1 = 0
Int DiceOpponent2 = 0
ObjectReference Property PLayerPosition Auto
ObjectReference Property Marker Auto
Actor Property Commentator Auto
Actor Property PlayerRef Auto
ObjectReference InitialFurn
ObjectReference[] Property PLayerDice01 Auto
ObjectReference[] Property PlayerDice02 Auto
ObjectReference[] Property OpponentDice01 Auto
ObjectReference[] Property OpponentDice02 Auto
ObjectReference[] Property PlayerChip Auto
ObjectReference[] Property OpponentChip Auto
Int[] Property DeathCases Auto
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)
PlayGame()
EndFunction
Function PlayGame()
if CurrentPlayerPosition != 0
PlayerDice01[DicePlayer1].Disable()
PlayerDice02[DicePlayer2].Disable()
PlayerChip[0].Enable()
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition = 0
OpponentDice01[DicePlayer1].Disable()
OpponentDice02[DicePlayer2].Disable()
OpponentChip[0].Enable()
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = 0
endif
OpponentTurn()
EndFunction
Function OpponentTurn()
OpponentDice01[DiceOpponent1].Disable()
OpponentDice02[DiceOpponent2].Disable()
DiceOpponent1 = Utility.RandomInt(0,5)
DiceOpponent2 = Utility.RandomInt(0,5)
OpponentDice01[DiceOpponent1].Enable(true)
OpponentDice02[DiceOpponent2].Enable(true)
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition += DiceOpponent1+DiceOpponent2+2
OpponentChip[CurrentOpponentPosition].Enable()
Utility.Wait(2.0)
if DeathCases.Find(CurrentOpponentPosition) >= 0
if Utility.RandomInt(0,3) < 2
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = 0
OpponentChip[CurrentOpponentPosition].Enable()
else
_SAG_OpponentGotAnswerRightMessage.Show()
endif
endif
if CurrentOpponentPosition == 57
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = 28
OpponentChip[CurrentOpponentPosition].Enable()
elseif CUrrentOpponentPosition == 39
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = 4
OpponentChip[CurrentOpponentPosition].Enable()
elseif CurrentOpponentPosition == 43
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = 8
OpponentChip[CurrentOpponentPosition].Enable()
elseif CurrentOpponentPosition == 47
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = 13
OpponentChip[CurrentOpponentPosition].Enable()
elseif CurrentOpponentPosition == 52
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = 21
OpponentChip[CurrentOpponentPosition].Enable()
elseif CurrentOpponentPosition == 54
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = 22
OpponentChip[CurrentOpponentPosition].Enable()
endif
Utility.Wait(2.0)
if CurrentOpponentPosition < MaxCases
PlayerTurn()
endif
if CurrentOpponentPosition >= MaxCases
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = MaxCases
OpponentChip[CurrentOpponentPosition].Enable()
OpponentWin()
Return
endif
EndFunction
Function OpponentWin()
_SAG_Activ_Board_OpponentWon.Show()
PlayAgain()
EndFunction
Function PlayerTurn()
PlayerDice01[DicePlayer1].Disable()
PlayerDice02[DicePlayer2].Disable()
DicePlayer1 = Utility.RandomInt(0,5)
DicePlayer2 = Utility.RandomInt(0,5)
PlayerDice01[DicePlayer1].Enable(true)
PlayerDice02[DicePlayer2].Enable(true)
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition += DicePlayer1+DicePlayer2+2
PlayerChip[CurrentPlayerPosition].Enable()
if DeathCases.Find(CurrentPlayerPosition) >= 0
AskQuestion()
endif
if CurrentPlayerPosition == 57
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition = 28
PlayerChip[CurrentPlayerPosition].Enable()
elseif CUrrentPlayerPosition == 39
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition = 4
PlayerChip[CurrentPlayerPosition].Enable()
elseif CurrentPlayerPosition == 43
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition = 8
PlayerChip[CurrentPlayerPosition].Enable()
elseif CurrentPlayerPosition == 47
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition = 13
PlayerChip[CurrentPlayerPosition].Enable()
elseif CurrentPlayerPosition == 52
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition = 21
PlayerChip[CurrentPlayerPosition].Enable()
elseif CurrentPlayerPosition == 54
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition = 22
PlayerChip[CurrentPlayerPosition].Enable()
endif
Utility.Wait(2.0)
if CurrentPlayerPosition < MaxCases
OpponentTurn()
endif
if CurrentPlayerPosition >= MaxCases
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition = MaxCases
PlayerChip[CurrentPlayerPosition].Enable()
PlayerWon()
Return
endif
EndFunction
Function PlayerWon()
PlayerRef.Additem(LotteryTicket, 2)
_SAG_Activ_BoardGame_PlayerWon.ShowAsHelpMessage("_sag_boardgameplayerwon", 2.0, 1.0, 1)
Message.ResetHelpMessage("_sag_boardgameplayerwon")
PlayAgain()
EndFunction
Function PlayAgain()
Utility.Wait(2.0)
if PlayerRef.GetItemCount(Gold001) < 10
if initialfurn
PlayerRef.MoveTo(initialfurn)
else
PlayerRef.MoveTo(Playerposition)
endif
if initialfurn
PLayerRef.MoveTo(initialfurn)
else
PlayerRef.MoveTo(PlayerPosition)
endif
Game.EnablePlayerControls()
Game.SetInChargen(abDisableSaving = false, abDisableWaiting = false, abShowControlsDisabledMessage = false)
Opponent.Clear()
PlayerDice01[DicePlayer1].Disable()
PlayerDice02[DicePlayer2].Disable()
PlayerChip[0].Enable()
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition = 0
OpponentDice01[DicePlayer1].Disable()
OpponentDice02[DicePlayer2].Disable()
OpponentChip[0].Enable()
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = 0
Return
else
int playagain = playagainmessage.Show()
if playagain == 0
PlayGame()
else
if initialfurn
PLayerRef.MoveTo(initialfurn)
else
PlayerRef.MoveTo(PlayerPosition)
endif
Game.EnablePlayerControls()
Game.SetInChargen(abDisableSaving = false, abDisableWaiting = false, abShowControlsDisabledMessage = false)
Opponent.Clear()
PlayerDice01[DicePlayer1].Disable()
PlayerDice02[DicePlayer2].Disable()
PlayerChip[0].Enable()
PlayerChip[CurrentPlayerPosition].Disable()
CurrentPlayerPosition = 0
OpponentDice01[DicePlayer1].Disable()
OpponentDice02[DicePlayer2].Disable()
OpponentChip[0].Enable()
OpponentChip[CurrentOpponentPosition].Disable()
CurrentOpponentPosition = 0
Return
endif
endif
EndFunction
Function AskQuestion()
Int Malus = Utility.RandomInt(2,12)
NameHolder.Clear()
MagicSchoolRefAlias.Clear()
Spell ChosenSpell = (SpellList.GetAt(Utility.RandomInt(0,SpellList.GetSize() - 1)) as BOOK).GetSpell()
Int ME_Index = ChosenSpell.GetCostliestEffectIndex()
String MagicSchool = ChosenSpell.GetNthEffectMagicEffect(ME_Index).GetAssociatedSkill()
NameHolderRef.GetBaseObject().SetName(ChosenSpell.GetName())
NameHolderMagicSchool.GetBaseObject().SetName(MagicSchool)
MagicSchoolRefAlias.ForceRefTo(NameHolderMagicSchool)
NameHolder.ForceRefTo(NameHolderRef)
if MagicSchool == "" || MagicSchool == " "
AskQuestion()
Return
endif
Int Answer = QuestionMagic.Show()
if MagicSchools[Answer] == MagicSchool
else
CorrectionMagic.Show()
PlayerChip[CurrentPlayerPosition].Disable(true)
CurrentPlayerPosition = 0
PlayerChip[CurrentPlayerPosition].Enable(true)
endif
EndFunction
Book Property LotteryTicket Auto
Message Property _SAG_Activ_Board_OpponentWon Auto
Message Property playagainmessage Auto
Message Property _SAG_Activ_BoardGame_PlayerWon Auto
MiscObject Property Gold001 Auto