예제 #1
0
        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();
            }
        }
 public TSFightbrokerDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("a fight broker");
 }
 public TSAuctioneerDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("an auctioneer");
 }
 public TSTownCrierDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("the town crier");
 }
 public TSLookoutDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("a lookout");
 }
 public TSEvocatorDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("an evocator");
 }
 public TSInnkeeperDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("an innkeeper");
 }
 public TSRogueTrainerDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("a rogue trainer");
 }
 public TSEmissaryDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("an emissary");
 }
 public TSArmsTrainerDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("an arms trainer");
 }
 public TSMageTrainerDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("a mage trainer");
 }
 public TSProvisionerDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("a provisioner");
 }
 public TSAlchemistDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("an alchemist");
 }
 public TSMageDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("a mage");
 }
 public TSAnimalTrainerDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("an animal trainer");
 }
 public TSBankerDeed(Guilds.Guild guild)
     : base(guild)
 {
     SetName("a banker");
 }