protected void ConfirmGettingScammed_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton) { int playerIntell = player.Stats.LiveIntelligence; if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd)) { investedFlag = sd.InvestedIn; shopAttitude = sd.ShopAttitude; } CloseWindow(); if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes) { Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; if (playerEntity.GetGoldAmount() >= investOffer) { playerEntity.DeductGoldAmount(investOffer); DaggerfallUI.Instance.PlayOneShot(SoundClips.GoldPieces); tokens = LGSTextTokenHolder.ShopTextTokensNeutral(3); if (investedFlag) { tokens = LGSTextTokenHolder.ShopTextTokensNeutral(4); } DaggerfallUI.MessageBox(tokens); investOffer = 0; LimitedGoldShops.LimitedGoldShops.UpdateInvestAmount(investOffer); } else { DaggerfallUI.MessageBox("Good joke there, you really got me there, ya jerk..."); } } else if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.No) { DaggerfallUI.MessageBox("Yeah, I was just joking as well, haha..."); } }
public override void Update() { base.Update(); if (state == 0) // Starting { regionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex; int crimeType = (int)playerEntity.CrimeCommitted - 1; int legalRep = playerEntity.RegionData[regionIndex].LegalRep; // Get whether punishment is normal (fine/prison) or a severe punishment (banishment/execution) int threshold1 = 0; int threshold2 = 0; if (legalRep < 0) { threshold1 = -legalRep; if (threshold1 > 75) { threshold1 = 75; } threshold2 = -legalRep / 2; if (threshold2 > 75) { threshold2 = 75; } } if (UnityEngine.Random.Range(1, 101) > threshold2 && UnityEngine.Random.Range(1, 101) > threshold1) { punishmentType = 2; // fine/prison } else { punishmentType = 0; // banishment or execution } // Calculate penalty amount int penaltyAmount = 0; if (legalRep >= 0) { penaltyAmount = PenaltyPerLegalRepPoint[crimeType] * legalRep + BasePenaltyAmounts[crimeType]; } else { penaltyAmount = BasePenaltyAmounts[crimeType] - PenaltyPerLegalRepPoint[crimeType] * legalRep; } if (penaltyAmount > MaximumPenaltyAmounts[crimeType]) { penaltyAmount = MaximumPenaltyAmounts[crimeType]; } else if (penaltyAmount < MinimumPenaltyAmounts[crimeType]) { penaltyAmount = MinimumPenaltyAmounts[crimeType]; } penaltyAmount /= 40; // Calculate days of prison and fine daysInPrison = 0; fine = 0; for (int i = 0; i < penaltyAmount; i++) { if ((DFRandom.rand() & 1) != 0) { fine += 40; } else { daysInPrison += 3; } } // If player can't pay fine, limit fine and add to prison sentence int playerGold = playerEntity.GetGoldAmount(); if (playerGold < fine) { daysInPrison += (fine - playerGold) / 40; fine = playerGold; } DaggerfallMessageBox messageBox; if (crimeType == 4 || crimeType == 3) // Assault or murder { // If player is a member of the Dark Brotherhood, they may be rescued for a violent crime Guilds.Guild guild = GameManager.Instance.GuildManager.GetGuild((int)FactionFile.FactionIDs.The_Dark_Brotherhood); if (guild.IsMember()) { if (guild.Rank >= UnityEngine.Random.Range(0, 20)) { messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextDB)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); playerEntity.FillVitalSigns(); playerEntity.RaiseReputationForDoingSentence(); state = 100; return; } } } if (crimeType <= 2 || crimeType == 11) // Attempted breaking and entering, trespassing, breaking and entering, pickpocketing { // If player is a member of the Thieves Guild, they may be rescued for a thieving crime Guilds.Guild guild = GameManager.Instance.GuildManager.GetGuild((int)FactionFile.FactionIDs.The_Thieves_Guild); if (guild.IsMember()) { if (guild.Rank >= UnityEngine.Random.Range(0, 20)) { messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextTG)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); playerEntity.FillVitalSigns(); playerEntity.RaiseReputationForDoingSentence(); state = 100; return; } } } messageBox = new DaggerfallMessageBox(uiManager, this, false, 105); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextStart)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Guilty); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.NotGuilty); messageBox.OnButtonClick += GuiltyNotGuilty_OnButtonClick; messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; uiManager.PushWindow(messageBox); state = 1; // Done with initial message } else if (state == 2) // Found guilty { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextFoundGuilty)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); state = 3; } else if (state == 3) // Serve prison sentence { PositionPlayerAtLocationEntrance(); ServeTime(daysInPrison); playerEntity.RaiseReputationForDoingSentence(); state = 100; } else if (state == 4) // Banished { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextBanished)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); playerEntity.RegionData[regionIndex].SeverePunishmentFlags |= 1; PositionPlayerAtLocationEntrance(); state = 100; } // Note: Seems like an execution sentence can't be given in classic. It can't be given here, either. else if (state == 5) // Execution { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextExecuted)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); playerEntity.RegionData[regionIndex].SeverePunishmentFlags |= 2; state = 6; } else if (state == 6) // Reposition player at entrance { PositionPlayerAtLocationEntrance(); state = 100; } else if (state == 100) // Done { ReleaseFromJail(); } }
protected void ConfirmInvestment_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton) { int playerIntell = player.Stats.LiveIntelligence; if (LimitedGoldShops.LimitedGoldShops.ShopBuildingData.TryGetValue(currentBuildingID, out sd)) { investedFlag = sd.InvestedIn; shopAttitude = sd.ShopAttitude; } CloseWindow(); if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes) { Entity.PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; if (playerEntity.GetGoldAmount() >= investOffer) { playerEntity.DeductGoldAmount(investOffer); DaggerfallUI.Instance.PlayOneShot(SoundClips.GoldPieces); if (buildQual <= 3) // 01 - 03 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("I'll do my best, partner."); } else { DaggerfallUI.MessageBox("Thanks for the gold, ya nutter."); } } else if (buildQual <= 7) // 04 - 07 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("Ya won't be disappointed, boss."); } else { DaggerfallUI.MessageBox("Really care for those fish, huh?"); } } else if (buildQual <= 17) // 08 - 17 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("Not a bad signature, do you practice?"); } else { DaggerfallUI.MessageBox("Your signature is atrocious, by the way."); } } else if (buildQual >= 18) // 18 - 20 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("I never disappoint when it comes to turning a profit."); } else { DaggerfallUI.MessageBox("Wipe your feet next time, you're tracking sludge in, lamprey."); } } LimitedGoldShops.LimitedGoldShops.UpdateInvestAmount(investOffer); } else { if (buildQual <= 3) // 01 - 03 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("I think you counted wrong, you don't have that much."); } else { DaggerfallUI.MessageBox("I know you don't have that much, stop lyin' ya idiot!"); } } else if (buildQual <= 7) // 04 - 07 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("Might want to recount, boss, cause I don't see that amount."); } else { DaggerfallUI.MessageBox("Who ya tryna impress, huh? I know you don't have that much."); } } else if (buildQual <= 17) // 08 - 17 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("Sorry, but it appears your funds are less than you suggest."); } else { DaggerfallUI.MessageBox("Quit wasting my damn time, you dolt, you don't have that much!"); } } else if (buildQual >= 18) // 18 - 20 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("I think you need to hire a new accountant, because you don't have that."); } else { DaggerfallUI.MessageBox("I need to charge more for my time, so leeches like you won't waste it so often!"); } } } } else if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.No) { if (buildQual <= 3) // 01 - 03 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("I understand your reluctance, just look around, haha!"); } else { DaggerfallUI.MessageBox("Why you gettin' my hopes up, just to dash them down?"); } } else if (buildQual <= 7) // 04 - 07 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("That's fine, I would not take such a gamble myself either."); } else { DaggerfallUI.MessageBox("Why you tryna bait me in just to pull away the line?"); } } else if (buildQual <= 17) // 08 - 17 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("Very well, thankfully parchment is cheap around here."); } else { DaggerfallUI.MessageBox("What's with the indecisive always wasting my time in this town?"); } } else if (buildQual >= 18) // 18 - 20 { if (shopAttitude == 0) { DaggerfallUI.MessageBox("So be it, ask again when you are ready to commit."); } else { DaggerfallUI.MessageBox("The parasite sucks my precious time away once again, a pity."); } } } }
public override void Update() { base.Update(); // Close immediately if no crime assigned to player if (playerEntity.CrimeCommitted == Entity.PlayerEntity.Crimes.None) { CloseWindow(); return; } if (state == 0) // Starting { regionIndex = GameManager.Instance.PlayerGPS.CurrentRegionIndex; int crimeType = (int)playerEntity.CrimeCommitted - 1; int legalRep = playerEntity.RegionData[regionIndex].LegalRep; // Get whether punishment is normal (fine/prison) or a severe punishment (banishment/execution) int threshold1 = 0; int threshold2 = 0; if (legalRep < 0) { threshold1 = -legalRep; if (threshold1 > 75) { threshold1 = 75; } threshold2 = -legalRep / 2; if (threshold2 > 75) { threshold2 = 75; } } if (Dice100.FailedRoll(threshold2) && Dice100.FailedRoll(threshold1)) { punishmentType = 2; // fine/prison } else { punishmentType = 0; // banishment or execution } // Calculate penalty amount int penaltyAmount = 0; if (legalRep >= 0) { penaltyAmount = PenaltyPerLegalRepPoint[crimeType] * legalRep + BasePenaltyAmounts[crimeType]; } else { penaltyAmount = BasePenaltyAmounts[crimeType] - PenaltyPerLegalRepPoint[crimeType] * legalRep; } if (penaltyAmount > MaximumPenaltyAmounts[crimeType]) { penaltyAmount = MaximumPenaltyAmounts[crimeType]; } else if (penaltyAmount < MinimumPenaltyAmounts[crimeType]) { penaltyAmount = MinimumPenaltyAmounts[crimeType]; } penaltyAmount /= 40; // Calculate days of prison and fine daysInPrison = 0; fine = 0; for (int i = 0; i < penaltyAmount; i++) { if ((DFRandom.rand() & 1) != 0) { fine += 40; } else { daysInPrison += 3; } } // If player can't pay fine, limit fine and add to prison sentence int playerGold = playerEntity.GetGoldAmount(); if (playerGold < fine) { daysInPrison += (fine - playerGold) / 40; fine = playerGold; } DaggerfallMessageBox messageBox; if (crimeType == 4 || crimeType == 3) // Assault or murder { // If player is a member of the Dark Brotherhood, they may be rescued for a violent crime Guilds.IGuild guild = GameManager.Instance.GuildManager.GetGuild((int)FactionFile.FactionIDs.The_Dark_Brotherhood); if (guild.IsMember()) { if (guild.Rank >= UnityEngine.Random.Range(0, 20)) { messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextDB)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; uiManager.PushWindow(messageBox); playerEntity.FillVitalSigns(); playerEntity.RaiseReputationForDoingSentence(); state = 100; return; } } } if (crimeType <= 2 || crimeType == 11) // Attempted breaking and entering, trespassing, breaking and entering, pickpocketing { // If player is a member of the Thieves Guild, they may be rescued for a thieving crime Guilds.IGuild guild = GameManager.Instance.GuildManager.GetGuild((int)FactionFile.FactionIDs.The_Thieves_Guild); if (guild.IsMember()) { if (guild.Rank >= UnityEngine.Random.Range(0, 20)) { messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextTG)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; messageBox.AllowCancel = false; uiManager.PushWindow(messageBox); playerEntity.FillVitalSigns(); playerEntity.RaiseReputationForDoingSentence(); state = 100; return; } } } messageBox = new DaggerfallMessageBox(uiManager, this, false, 105); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextStart)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Guilty); messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.NotGuilty); messageBox.OnButtonClick += GuiltyNotGuilty_OnButtonClick; messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.AllowCancel = false; uiManager.PushWindow(messageBox); state = 1; // Done with initial message } else if (state == 2) // Found guilty { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextFoundGuilty)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; messageBox.AllowCancel = false; uiManager.PushWindow(messageBox); if (daysInPrison > 0) { state = 3; } else { // Give the reputation raise here if no prison time will be served. playerEntity.RaiseReputationForDoingSentence(); repositionPlayer = true; playerEntity.FillVitalSigns(); ReleaseFromPrison(); state = 100; } } else if (state == 3) // Serve prison sentence { playerEntity.InPrison = true; SwitchToPrisonScreen(); daysInPrisonLeft = daysInPrison; playerEntity.RaiseReputationForDoingSentence(); repositionPlayer = true; state = 100; } else if (state == 4) // Banished { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextBanished)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; messageBox.AllowCancel = false; uiManager.PushWindow(messageBox); playerEntity.RegionData[regionIndex].SeverePunishmentFlags |= 1; repositionPlayer = true; // Refill player vitals after banishment, otherwise player left with 1HP outside city gates playerEntity.FillVitalSigns(); state = 100; } // Note: Seems like an execution sentence can't be given in classic. It can't be given here, either. else if (state == 5) // Execution { DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this, false, 149); messageBox.SetTextTokens(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(courtTextExecuted)); messageBox.ScreenDimColor = new Color32(0, 0, 0, 0); messageBox.ParentPanel.VerticalAlignment = VerticalAlignment.Bottom; messageBox.ClickAnywhereToClose = true; messageBox.AllowCancel = false; uiManager.PushWindow(messageBox); playerEntity.RegionData[regionIndex].SeverePunishmentFlags |= 2; state = 6; } else if (state == 6) // Reposition player at entrance { repositionPlayer = true; state = 100; } else if (state == 100) // Done { if (playerEntity.InPrison) { if (Input.GetKey(exitKey)) // Speed up prison day countdown. Not in classic. { prisonUpdateInterval = 0.001f; } else { prisonUpdateInterval = 0.3f; } if (prisonUpdateTimer == 0) { prisonUpdateTimer = Time.realtimeSinceStartup; } if (Time.realtimeSinceStartup < prisonUpdateTimer + prisonUpdateInterval) { return; } else { prisonUpdateTimer = Time.realtimeSinceStartup; UpdatePrisonScreen(); } } else { ReleaseFromPrison(); } } }