skillGain as a table

pull/3234/head
Mads Buvik Sandvei 12 months ago
parent 80e9631abd
commit e1a22242d9

@ -604,14 +604,13 @@ namespace MWLua
skillT["attribute"] = sol::readonly_property([](const ESM::Skill& rec) -> std::string {
return ESM::Attribute::indexToRefId(rec.mData.mAttribute).serializeText();
});
skillT["skillGain1"]
= sol::readonly_property([](const ESM::Skill& rec) -> float { return rec.mData.mUseValue[0]; });
skillT["skillGain2"]
= sol::readonly_property([](const ESM::Skill& rec) -> float { return rec.mData.mUseValue[1]; });
skillT["skillGain3"]
= sol::readonly_property([](const ESM::Skill& rec) -> float { return rec.mData.mUseValue[2]; });
skillT["skillGain4"]
= sol::readonly_property([](const ESM::Skill& rec) -> float { return rec.mData.mUseValue[3]; });
skillT["skillGain"] = sol::readonly_property([lua](const ESM::Skill& rec) -> sol::table {
sol::table res(lua, sol::create);
int index = 1;
for (auto skillGain : rec.mData.mUseValue)
res[index++] = skillGain;
return res;
});
auto schoolT = context.mLua->sol().new_usertype<ESM::MagicSchool>("MagicSchool");
schoolT[sol::meta_function::to_string]

@ -77,24 +77,6 @@ local function tableHasValue(table, value)
return false
end
local function getSkillGainValue(skillid, useType, scale)
local skillRecord = Skill.record(skillid)
local skillGain = 0
if useType == 0 then
skillGain = skillRecord.skillGain1
elseif useType == 1 then
skillGain = skillRecord.skillGain2
elseif useType == 2 then
skillGain = skillRecord.skillGain3
elseif useType == 3 then
skillGain = skillRecord.skillGain4
end
if scale ~= nil then skillGain = skillGain * scale end
return skillGain
end
local function getSkillProgressRequirementUnorm(npc, skillid)
local npcRecord = NPC.record(npc)
local class = NPC.classes.record(npcRecord.class)
@ -128,7 +110,9 @@ local function skillUsed(skillid, useType, scale)
-- Compute skill gain
local skillStat = NPC.stats.skills[skillid](self)
local skillGainUnorm = getSkillGainValue(skillid, useType, scale)
local skillRecord = Skill.record(skillid)
local skillGainUnorm = skillRecord.skillGain[useType + 1]
if scale then skillGainUnorm = skillGainUnorm * scale end
local skillProgressRequirementUnorm = getSkillProgressRequirementUnorm(self, skillid)
local skillGain = skillGainUnorm / skillProgressRequirementUnorm

Loading…
Cancel
Save