From 088d73d31479b74c1deb4274b14cf7d433938589 Mon Sep 17 00:00:00 2001 From: Allofich Date: Sun, 10 Sep 2017 01:57:18 +0900 Subject: [PATCH] Only allow one pickpocket attempt per target --- Assets/Scripts/Game/Entities/EnemyEntity.cs | 7 +++++ Assets/Scripts/Game/Formulas/FormulaHelper.cs | 7 ++--- Assets/Scripts/Game/MobilePersonNPC.cs | 7 +++++ Assets/Scripts/Game/PlayerActivate.cs | 29 ++++++++++++------- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/Assets/Scripts/Game/Entities/EnemyEntity.cs b/Assets/Scripts/Game/Entities/EnemyEntity.cs index 6e65497203..c77c738e4f 100644 --- a/Assets/Scripts/Game/Entities/EnemyEntity.cs +++ b/Assets/Scripts/Game/Entities/EnemyEntity.cs @@ -32,6 +32,7 @@ public class EnemyEntity : DaggerfallEntity int careerIndex = -1; EntityTypes entityType = EntityTypes.None; MobileEnemy mobileEnemy; + bool pickpocketByPlayerAttempted = false; #endregion @@ -52,6 +53,12 @@ public MobileEnemy MobileEnemy get { return mobileEnemy; } } + public bool PickpocketByPlayerAttempted + { + get { return (pickpocketByPlayerAttempted); } + set { pickpocketByPlayerAttempted = value; } + } + #endregion #region Public Methods diff --git a/Assets/Scripts/Game/Formulas/FormulaHelper.cs b/Assets/Scripts/Game/Formulas/FormulaHelper.cs index 953f0440bb..24c1205b0c 100644 --- a/Assets/Scripts/Game/Formulas/FormulaHelper.cs +++ b/Assets/Scripts/Game/Formulas/FormulaHelper.cs @@ -132,14 +132,13 @@ public static int CalculateExteriorLockpickingChance(int lockvalue, int lockpick } // Calculate chance of successfully pickpocketing a target - public static int CalculatePickpocketingChance(Entity.PlayerEntity player, Entity.DaggerfallEntityBehaviour target) + public static int CalculatePickpocketingChance(Entity.PlayerEntity player, Entity.EnemyEntity target) { int chance = player.Skills.Pickpocket; // If target is an enemy mobile, apply level modifier. - if (target) + if (target != null) { - Entity.EnemyEntity enemyEntity = target.Entity as Entity.EnemyEntity; - chance += 5 * ((player.Level) - (enemyEntity.Level)); + chance += 5 * ((player.Level) - (target.Level)); } return Mathf.Clamp(chance, 5, 95); } diff --git a/Assets/Scripts/Game/MobilePersonNPC.cs b/Assets/Scripts/Game/MobilePersonNPC.cs index 54046733fa..5a4679b43b 100644 --- a/Assets/Scripts/Game/MobilePersonNPC.cs +++ b/Assets/Scripts/Game/MobilePersonNPC.cs @@ -48,6 +48,7 @@ public enum DisplayRaces private string nameNPC; // name of the npc private int personOutfitVariant; // which basic outfit does the person wear private int personFaceRecordId; // used for portrait in talk window + private bool pickpocketByPlayerAttempted = false; // player can only attempt pickpocket on a mobile NPC once private MobilePersonBillboard billboard; // billboard for npc private MobilePersonMotor motor; // motor for npc @@ -93,6 +94,12 @@ public int PersonFaceRecordId get { return (personFaceRecordId); } } + public bool PickpocketByPlayerAttempted + { + get { return (pickpocketByPlayerAttempted); } + set { pickpocketByPlayerAttempted = value; } + } + public MobilePersonBillboard Billboard { get { return (billboard); } diff --git a/Assets/Scripts/Game/PlayerActivate.cs b/Assets/Scripts/Game/PlayerActivate.cs index fbbc41f767..cfeb9f4ef5 100644 --- a/Assets/Scripts/Game/PlayerActivate.cs +++ b/Assets/Scripts/Game/PlayerActivate.cs @@ -346,12 +346,16 @@ void Update() Talk(mobileNpc); break; case PlayerActivateModes.Steal: - if (hit.distance > (PickpocketDistance * MeshReader.GlobalScale)) + if (!mobileNpc.PickpocketByPlayerAttempted) { - DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway); - break; + if (hit.distance > (PickpocketDistance * MeshReader.GlobalScale)) + { + DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway); + break; + } + mobileNpc.PickpocketByPlayerAttempted = true; + Pickpocket(); } - Pickpocket(); break; } } @@ -360,12 +364,12 @@ void Update() DaggerfallEntityBehaviour mobileEnemyBehaviour; if (MobileEnemyCheck(hit, out mobileEnemyBehaviour)) { + EnemyEntity enemyEntity = mobileEnemyBehaviour.Entity as EnemyEntity; switch (currentMode) { case PlayerActivateModes.Info: case PlayerActivateModes.Grab: case PlayerActivateModes.Talk: - EnemyEntity enemyEntity = mobileEnemyBehaviour.Entity as EnemyEntity; if (enemyEntity != null) { MobileEnemy mobileEnemy = enemyEntity.MobileEnemy; @@ -386,12 +390,17 @@ void Update() // For now, the only enemy mobiles being allowed by DF Unity are classes. if (mobileEnemyBehaviour && (mobileEnemyBehaviour.EntityType != EntityTypes.EnemyClass)) break; - if (hit.distance > (PickpocketDistance * MeshReader.GlobalScale)) + // Classic doesn't set any flag when pickpocketing enemy mobiles, so infinite attempts are possible + if (enemyEntity != null && !enemyEntity.PickpocketByPlayerAttempted) { - DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway); - break; + if (hit.distance > (PickpocketDistance * MeshReader.GlobalScale)) + { + DaggerfallUI.SetMidScreenText(HardStrings.youAreTooFarAway); + break; + } + enemyEntity.PickpocketByPlayerAttempted = true; + Pickpocket(enemyEntity); } - Pickpocket(mobileEnemyBehaviour); break; } } @@ -738,7 +747,7 @@ void QuestorCheck(StaticNPC npc) } // Player has clicked on a pickpocket target in steal mode - void Pickpocket(DaggerfallEntityBehaviour target = null) + void Pickpocket(EnemyEntity target = null) { const int foundNothingValuableTextId = 8999;