enderalse/source/scripts/_00e_taverngames_gamlingtablesc.psc

233 lines
7.0 KiB
Plaintext
Raw Normal View History

Scriptname _00E_TavernGames_GamlingTableSC extends ObjectReference
; Tavern Game-Mechanics based on sagittarius22 "Tavern Games"-mods!
Import Math
;=====================================================================================
; EVENTS
;=====================================================================================
Event OnInit()
objCashContainer = Self.GetLinkedRef(_00E_TavernGames_Bank) as ObjectReference
objCashContainer.AddItem(Gold001, __Config_iGamblingMoney)
EndEvent
Event OnActivate(ObjectReference akActionRef)
if !bSystemRunning
bSystemRunning = True
PlayerChair = Self.GetLinkedRef()
If PlayerChair.IsFurnitureInUse()
If __Config_bTableType_GoldenQueensCourt
If Self.GetLinkedRef(_00E_TavernGames_Opponent_01).GetDistance(Self) >= 300
_00E_TavernGames_NoOpponent.Show()
bSystemRunning = False
Else
int iButton = _00E_TavernGames_StartGame_BattleOfTreomarMSG.Show()
If iButton == 0
StartGoldenQueensCourtGame()
Elseif iButton == 1
PlayerChair.Activate(PlayerREF, True)
bSystemRunning = False
Return
EndIf
EndIf
Elseif __Config_bTableType_MoralasDice
If Self.GetLinkedRef(_00E_TavernGames_Opponent_01).GetDistance(Self) >= 300
_00E_TavernGames_NoOpponent.Show()
bSystemRunning = False
Else
int iButton = _00E_TavernGames_StartGame_MoralasDiceMSG.Show()
If iButton == 0
StartMoralasDiceGame()
Elseif iButton == 1
PlayerChair.Activate(PlayerREF, True)
bSystemRunning = False
Return
EndIf
EndIf
EndIf
Else
_00E_TavernGames_sShouldSitDown.Show()
bSystemRunning = False
EndIf
EndIf
EndEvent
Event OnUpdateGameTime()
objCashContainer.AddItem(Gold001, __Config_iGamblingMoney)
EndEvent
;=====================================================================================
; FUNCTIONS
;=====================================================================================
Function StartGoldenQueensCourtGame()
akOpponent = Self.GetLinkedRef(_00E_TavernGames_Opponent_01) as Actor
_SAG_LetsPlayCards_Quest_Opponent.ForceRefTo(akOpponent)
_SAG_LetsPlayCards_Quest_Opponent_Thief.ForceRefTo(Self.GetLinkedRef(_00E_TavernGames_OpponentThief) as Actor)
TransferGoldToNPC()
If (akOpponent.GetItemCount(Gold001) < 10)
_00E_TavernGames_sOpponentNotEnoughGold.Show()
TransferGoldToChest()
RegisterForCashRespawn()
PlayerChair.Activate(PlayerREF, True)
bSystemRunning = False
Elseif (PlayerREF.GetItemCount(Gold001) < 10)
_00E_TavernGames_sPlayerNotEnoughGold.Show()
PlayerChair.Activate(PlayerREF, True)
bSystemRunning = False
Else
_SAG_LetsPlayCards_Quest.OpenCardInterface(Self as _00E_TavernGames_GamlingTableSC)
EndIf
EndFunction
Function StartMoralasDiceGame()
akOpponent = Self.GetLinkedRef(_00E_TavernGames_Opponent_01) as Actor
_SAG_Activ_BlackJackDiceQuest_Opponent.ForceRefTo(akOpponent)
TransferGoldToNPC()
If (akOpponent.GetItemCount(Gold001) < 10)
_00E_TavernGames_sOpponentNotEnoughGold.Show()
TransferGoldToChest()
RegisterForCashRespawn()
PlayerChair.Activate(PlayerREF, True)
bSystemRunning = False
Elseif (PlayerREF.GetItemCount(Gold001) < 10)
_00E_TavernGames_sPlayerNotEnoughGold.Show()
PlayerChair.Activate(PlayerREF, True)
bSystemRunning = False
Else
_SAG_Activ_BlackJackDiceQuest.InitiateGame(Self as _00E_TavernGames_GamlingTableSC)
EndIf
EndFunction
Function RegisterForCashRespawn()
RegisterForSingleUpdateGameTime((__Config_iRespawnCashTime*24))
EndFunction
Function TransferGoldToNPC()
iCurrentGold = objCashContainer.GetItemCount(Gold001)
objCashContainer.RemoveItem(Gold001, iCurrentGold)
akOpponent.AddItem(Gold001, iCurrentGold)
iNPCStartGold = akOpponent.GetItemCount(Gold001)
iPlayerStartGold = PlayerREF.GetItemCount(Gold001)
EndFunction
Function TransferGoldToChest()
iCurrentGold = akOpponent.GetItemCount(Gold001)
int toTransfer = (iCurrentGold * (1 - __Config_fGoldCarryPercentage)) as Int
akOpponent.RemoveItem(Gold001, toTransfer)
objCashContainer.AddItem(Gold001, toTransfer)
EndFunction
Function SendGameFinishedEvent()
TransferGoldToChest()
PlayerChair.Activate(PlayerREF, True)
bSystemRunning = False
if objCashContainer.GetItemCount(Gold001) <= iNPCStartGold
if objCashContainer.GetItemCount(Gold001) <= 10
akOpponent.Say(GenericDialogue_Terminate_NPCLostMuchGoldTopic)
Else
akOpponent.Say(GenericDialogue_Terminate_NPCLostALittleGoldTopic)
EndIf
Else
akOpponent.Say(GenericDialogue_Termintae_NPCWonGoldTopic)
EndIf
EndFunction
;=====================================================================================
; PROPERTIES
;=====================================================================================
bool bSystemRunning
;======================================== BATTLE OF TREOMAR ==========================
_SAG_PlayCards_MainScript Property _SAG_LetsPlayCards_Quest Auto
_SAG_Activ_DiceBlackJackMainsScript Property _SAG_Activ_BlackJackDiceQuest Auto
float Property __Config_fGoldCarryPercentage = 0.30 Auto
{How much gold the NPC should carry around with him/her after completing a game.}
int Property __Config_iRespawnCashTime = 2 Auto
{How many days in game-time the player has to wait until a broke actor regains his money.}
int Property __Config_iGamblingMoney = 525 Auto
{How much money is available for the player to win on this table}
bool Property __Config_bTableType_GoldenQueensCourt Auto
{Check this if this table is of the type "Battle of Treomar". Check only ONE box per table!}
bool Property __Config_bTableType_MoralasDice Auto
{Check this if this table is of the type "Moralas Dice". Check only ONE box per table!}
ObjectReference objCashContainer
ObjectReference PlayerChair
int iPlayerStartGold
int iNPCStartGold
Actor akCashActor
Actor akOpponent
int iCurrentGold
Actor Property PlayerREF Auto
MiscObject Property Gold001 Auto
Topic Property GenericDialogue_Termintae_NPCWonGoldTopic Auto
Topic Property GenericDialogue_Terminate_NPCLostMuchGoldTopic Auto
Topic Property GenericDialogue_Terminate_NPCLostALittleGoldTopic Auto
ReferenceAlias Property _SAG_LetsPlayCards_Quest_Opponent Auto
ReferenceAlias Property _SAG_LetsPlayCards_Quest_Opponent_Thief Auto
ReferenceAlias Property _SAG_Activ_BlackJackDiceQuest_Opponent Auto
Keyword Property _00E_TavernGames_Opponent_01 Auto
Keyword Property _00E_TavernGames_OpponentThief Auto
Keyword Property _00E_TavernGames_Bank Auto
Message Property _00E_TavernGames_ChooseGameMSG Auto
Message Property _00E_TavernGames_StartGame_BattleOfTreomarMSG Auto
Message Property _00E_TavernGames_StartGame_MoralasDiceMSG Auto
Message Property _00E_TavernGames_StartGame_KetaronsTrialMSG Auto
Message Property _00E_TavernGames_NoOpponent Auto
Message Property _00E_TavernGames_sOpponentNotEnoughGold Auto
Message Property _00E_TavernGames_sShouldSitDown Auto
Message Property _00E_TavernGames_sPlayerNotEnoughGold Auto