Difference between revisions of "Talk:WillIntimidateSucceed - Actor"
Jump to navigation
Jump to search
imported>DavidJCobb m (correction) |
imported>DavidJCobb m (typo in method name) |
||
Line 1: | Line 1: | ||
I found this function in a disassembler; the calculations translate as follows: | I found this function in a disassembler; the calculations translate as follows: | ||
<source lang="cpp">SInt16 TESActorBaseData:: | <source lang="cpp">SInt16 TESActorBaseData::Subroutine0044D4D0() { | ||
if (!(this->flags & kFlag_PCLevelMult)) | if (!(this->flags & kFlag_PCLevelMult)) | ||
return this->level; | return this->level; |
Revision as of 10:35, 7 August 2018
I found this function in a disassembler; the calculations translate as follows:
SInt16 TESActorBaseData::Subroutine0044D4D0() {
if (!(this->flags & kFlag_PCLevelMult))
return this->level;
SInt32 result = this->level;
float a = this->level / 1000.0;
if ((*g_thePlayer)->baseForm) {
SInt32 playerLevel = (*g_thePlayer)->baseForm->actorData.level;
result = (playerLevel * a);
}
if (this->minLevel > 0 && result < this->minLevel)
return this->minLevel;
if (this->maxLevel > 0 && result > this->maxLevel)
return this->maxLevel;
return result;
};
bool Actor::WillIntimidateSucceed() {
double speechPlayer = (*g_thePlayer)->actorValueOwner->GetCurrent(0x11); // SpeechCraft
float speechTarget = this->actorValueOwner.GetCurrent(0x11);
float a = (speechPlayer - speechTarget) / 100.0;
float c = pow(1.0 + max(-1.0, a), GMST:fIntimidateSpeechcraftCurve);
SInt16 levelDataPlayer = (*g_thePlayer)->baseForm->actorData.TESV_0044D4D0();
SInt32 levelDataTarget = this->baseForm->actorData.TESV_0044D4D0();
//
float esp0C = levelDataPlayer * c;
CalculatePerkData(kEntryPoint_Mod_Player_Intimidation, *g_thePlayer, this, &esp0C);
//
// CalculatePerkData took a perk type, two actors, and a pointer to esp0C. This
// means that it can read and modify esp0C however it wishes. That function
// handles EVERY perk, so I'm not gonna even try to figure out what it's doing
// here, lol
//
// Based on later usage, esp0C == how scary the player is.
//
float esp04 = levelDataTarget; // how scary is the NPC?
float confidenceMult;
SInt32 confidence = this->baseForm->aiForm.GetConfidence();
switch (confidence) {
case 0:
esp04 *= GMST:fIntimidateConfidenceMultCowardly;
break;
case 1:
esp04 *= GMST:fIntimidateConfidenceMultCautious;
break;
case 2:
esp04 *= GMST:fIntimidateConfidenceMultAverage;
break;
case 3:
esp04 *= GMST:fIntimidateConfidenceMultBrave;
break;
case 4:
esp04 *= GMST:fIntimidateConfidenceMultFoolhardy;
break;
}
return (esp04 <= esp0C); // NPC less scary than player?
}
First draft, mind you.
DavidJCobb (talk) 2018-08-07T09:03:00 (EDT)