mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added support for integer values to abs() math function.
Minor code refactoring in Skills.cpp.
This commit is contained in:
@@ -292,7 +292,7 @@ Some utility/math functions are available:
|
|||||||
> float sqrt(float x)
|
> float sqrt(float x)
|
||||||
- square root of x
|
- square root of x
|
||||||
|
|
||||||
> float abs(float x)
|
> int/float abs(int/float x)
|
||||||
- absolute (positive) value of x
|
- absolute (positive) value of x
|
||||||
|
|
||||||
> float sin(float x)
|
> float sin(float x)
|
||||||
|
|||||||
@@ -38,7 +38,11 @@ void sf_sqrt(OpcodeContext& ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void sf_abs(OpcodeContext& ctx) {
|
void sf_abs(OpcodeContext& ctx) {
|
||||||
ctx.setReturn(abs(ctx.arg(0).asFloat()));
|
if (ctx.arg(0).isInt()) {
|
||||||
|
ctx.setReturn(abs(ctx.arg(0).asInt()));
|
||||||
|
} else {
|
||||||
|
ctx.setReturn(abs(ctx.arg(0).asFloat()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sf_sin(OpcodeContext& ctx) {
|
void sf_sin(OpcodeContext& ctx) {
|
||||||
|
|||||||
+13
-11
@@ -56,7 +56,7 @@ static SkillModifier baseSkillMax;
|
|||||||
|
|
||||||
static BYTE skillCosts[512 * fo::SKILL_count];
|
static BYTE skillCosts[512 * fo::SKILL_count];
|
||||||
static DWORD basedOnPoints;
|
static DWORD basedOnPoints;
|
||||||
static double* multipliers;
|
static double* multipliers = nullptr;
|
||||||
|
|
||||||
static std::vector<ChanceModifier> pickpocketMods;
|
static std::vector<ChanceModifier> pickpocketMods;
|
||||||
static ChanceModifier basePickpocket;
|
static ChanceModifier basePickpocket;
|
||||||
@@ -136,7 +136,7 @@ static int __fastcall GetStatBonus(fo::GameObject* critter, const fo::SkillInfo*
|
|||||||
}
|
}
|
||||||
result += points * info->skillPointMulti;
|
result += points * info->skillPointMulti;
|
||||||
result += info->base;
|
result += info->base;
|
||||||
return (int)result;
|
return static_cast<int>(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
//On input, ebx/edx contains the skill id, ecx contains the critter, edi contains a SkillInfo*, ebp contains the number of skill points
|
//On input, ebx/edx contains the skill id, ecx contains the critter, edi contains a SkillInfo*, ebp contains the number of skill points
|
||||||
@@ -145,9 +145,9 @@ static const DWORD StatBonusHookRet = 0x4AA5D6;
|
|||||||
static void __declspec(naked) skill_level_hack_bonus() {
|
static void __declspec(naked) skill_level_hack_bonus() {
|
||||||
__asm {
|
__asm {
|
||||||
push ecx;
|
push ecx;
|
||||||
push ebp;
|
push ebp; // points
|
||||||
push ebx;
|
push ebx; // skill
|
||||||
mov edx, edi;
|
mov edx, edi; // info
|
||||||
call GetStatBonus; // ecx - critter
|
call GetStatBonus; // ecx - critter
|
||||||
mov esi, eax;
|
mov esi, eax;
|
||||||
pop ecx;
|
pop ecx;
|
||||||
@@ -253,13 +253,14 @@ void Skills::init() {
|
|||||||
SafeWrite8(0x4ABC67, 0x89); // mov [esp + 0x54], eax
|
SafeWrite8(0x4ABC67, 0x89); // mov [esp + 0x54], eax
|
||||||
SafeWrite32(0x4ABC6B, 0x90909090);
|
SafeWrite32(0x4ABC6B, 0x90909090);
|
||||||
|
|
||||||
char buf[512], key[16], file[64];
|
char buf[512], key[16];
|
||||||
auto skillsFile = GetConfigString("Misc", "SkillsFile", "");
|
auto skillsFile = GetConfigString("Misc", "SkillsFile", "");
|
||||||
if (skillsFile.size() > 0) {
|
if (!skillsFile.empty()) {
|
||||||
fo::SkillInfo *skills = fo::var::skill_data;
|
fo::SkillInfo *skills = fo::var::skill_data;
|
||||||
sprintf(file, ".\\%s", skillsFile.c_str());
|
|
||||||
multipliers = new double[7 * fo::SKILL_count];
|
skillsFile = ".\\" + skillsFile;
|
||||||
memset(multipliers, 0, 7 * fo::SKILL_count * sizeof(double));
|
const char* file = skillsFile.c_str();
|
||||||
|
multipliers = new double[7 * fo::SKILL_count]();
|
||||||
|
|
||||||
for (int i = 0; i < fo::SKILL_count; i++) {
|
for (int i = 0; i < fo::SKILL_count; i++) {
|
||||||
sprintf(key, "Skill%d", i);
|
sprintf(key, "Skill%d", i);
|
||||||
@@ -276,7 +277,8 @@ void Skills::init() {
|
|||||||
case 'i': multipliers[i * 7 + 4] = m; break;
|
case 'i': multipliers[i * 7 + 4] = m; break;
|
||||||
case 'a': multipliers[i * 7 + 5] = m; break;
|
case 'a': multipliers[i * 7 + 5] = m; break;
|
||||||
case 'l': multipliers[i * 7 + 6] = m; break;
|
case 'l': multipliers[i * 7 + 6] = m; break;
|
||||||
default: continue;
|
default:
|
||||||
|
dlogr("Warning : Invalid character for SPECIAL stats in the skills file.", DL_INIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tok = strtok(0, "|");
|
tok = strtok(0, "|");
|
||||||
|
|||||||
Reference in New Issue
Block a user