mirror of
https://github.com/afritz1/OpenTESArena.git
synced 2026-09-11 12:56:41 +02:00
Page:
Thieving
Pages
Character Generation
Chasms
City Generation
Combat
Dialogue
Diseases
Dungeon Generation
Home
Interiors
Items
Light levels
Loot
Movement
NPCs
Name generation
Player stats
Resting
Save File Formats
Services
Shops
Sky behavior
Skybox
Spellmaker
Spells
Thieving
Time and Calendar
Timing
Travel
User interface
Weather
Wilderness
No results
4
Thieving
Allofich edited this page 2020-11-01 04:47:34 +09:00
Table of contents
Looking at a lock & lockpick formula
void LookAtLock(unsigned short lockDifficulty)
{
ThievingTargetDifficulty = lockDifficulty;
if (TopOfScreenTextCounter == 0 || TopOfScreenText != "Failure...")
{
unsigned short chanceOfSuccess;
AttemptThieving(chanceOfSuccess);
chanceOfSuccess /= 5;
int index = chanceOfSuccess - 6;
if (chanceOfSuccess < 6)
{
index = 0;
}
if (index >= 12)
{
index = 12;
}
char[] displayString;
if (lockDifficulty >= 20)
{
displayString = "This is a magically held lock...";
}
else
{
displayString = lockMessages[index];
}
TopOfScreenTextCounter = 15;
TopOfScreenText = displayString;
}
return;
}
// The same function is used both to get the chance of success for showing the lockpicking message and for actual attempts. It is also used for pickpocketing.
bool AttemptThieving(unsigned short& chanceOfSuccess)
{
unsigned char playerSkill = Convert256Valueto100Value(PlayerCurrentIntelligence + PlayerCurrentAgility);
chanceOfSuccess = ((playerSkill / LockpickingDivisors[PlayerClass & ID_Mask] * (PlayerLevel + 1)) * 100) / (ThievingTargetDifficulty * 100);
int random = rand() % 100;
if (chanceOfSuccess < 0)
{
chanceOfSuccess = 0;
}
if (chanceOfSuccess > 100)
{
chanceOfSuccess = 100;
}
if (chanceOfSuccess < random)
{
return true; // Thieving failed
}
return false; // Thieving succeeded
}
Lockpicking messages @3B304.
Pickpocketing
void AttemptPickpocket(void)
{
ThievingTargetDifficulty = 4 - CityType;
unsigned short chanceOfSuccess;
bool attemptFailed = AttemptThieving(chanceOfSuccess);
if (!attemptFailed)
{
if (arenaRand() < 20000)
{
int random = randomBetweenMinMax(0,4);
PlayerGold = PlayerGold + random + 1;
TemplateDatIndex = random + 1379; // You stole -- gold pieces
}
else
{
TemplateDatIndex = 1384; // You stole useless item
}
// Show message from TEMPLATE.DAT
return;
}
bool guardsCanSpawn = IsFailedStealNoticed(chanceOfSuccess); // TODO
if (guardsCanSpawn) {
SetGuardSpawningForTheft(); // TODO
return;
}
TopOfScreenText = "You are not successful...";
TopOfScreenTextCounter = 15;
return;
}