Skip to content

Commit

Permalink
Only allow one pickpocket attempt per target
Browse files Browse the repository at this point in the history
  • Loading branch information
Allofich committed Sep 9, 2017
1 parent aa1e49f commit 088d73d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 14 deletions.
7 changes: 7 additions & 0 deletions Assets/Scripts/Game/Entities/EnemyEntity.cs
Expand Up @@ -32,6 +32,7 @@ public class EnemyEntity : DaggerfallEntity
int careerIndex = -1;
EntityTypes entityType = EntityTypes.None;
MobileEnemy mobileEnemy;
bool pickpocketByPlayerAttempted = false;

#endregion

Expand All @@ -52,6 +53,12 @@ public MobileEnemy MobileEnemy
get { return mobileEnemy; }
}

public bool PickpocketByPlayerAttempted
{
get { return (pickpocketByPlayerAttempted); }
set { pickpocketByPlayerAttempted = value; }
}

#endregion

#region Public Methods
Expand Down
7 changes: 3 additions & 4 deletions Assets/Scripts/Game/Formulas/FormulaHelper.cs
Expand Up @@ -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);
}
Expand Down
7 changes: 7 additions & 0 deletions Assets/Scripts/Game/MobilePersonNPC.cs
Expand Up @@ -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
Expand Down Expand Up @@ -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); }
Expand Down
29 changes: 19 additions & 10 deletions Assets/Scripts/Game/PlayerActivate.cs
Expand Up @@ -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;
}
}
Expand All @@ -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;
Expand All @@ -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;
}
}
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 088d73d

Please sign in to comment.