Path of Exile Wiki

Please consider helping keep the wiki up to date. Check the to-do list of updates needed for version 3.14.0.

Game data exports will becoming later as the technical changes in addition to regular changes take some more time.

READ MORE

Path of Exile Wiki
Advertisement
Template info icon Module documentation[view] [edit] [history] [purge]

Overview

Module for handling skills with semantic media wiki support

Skill templates

Module:Item2

All templates defined in Module:Skill:

Module:Skill link

All templates defined in Module:Skill link:

local p = {}

local g_frame, g_args

local getArgs = require('Module:Arguments').getArgs
local util = require('Module:Util')


--
-- Data
--

local data = {}

data.map = {}
data.map.stats = {
    {
        prefix = '',
        property_prefix = 'Has stat ',
    },
    {
        prefix = 'quality_',
        property_prefix =  'Has quality stat ',
    },
}

data.map.static = {
    -- GrantedEffects.dat
    {
        name = 'skill_id',
        property = 'Is skill id',
        func = tonumber,
    },
    {
        name = 'is_support_gem',
        property = 'Is support gem',
        func = util.cast.bool,
    },
    {
        name = 'support_gem_letter',
        property = 'Has support gem letter',
        func = tonumber,
    },
    -- Active Skills.dat
    {
        name = 'cast_time',
        property = 'Has cast time',
        func = tonumber,
    },
    {
        name = 'description',
        property = 'Has description',
        func = nil,
    },
    {
        name = 'active_skill_name',
        property = 'Has active skill name',
        func = nil,
    },
    {
        name = 'stat_text',
        property = 'Has stat text',
        func = nil,
    },
    {
        name = 'quality_stat_text',
        property = 'Has quality stat text',
        func = nil,
    },
}

data.map.progression = {
    {
        name = 'level_requirement',
        property = 'Has level requirement',
        func = tonumber,
    },
    {
        name = 'dexterity_requirement',
        property = 'Has dexterity requirement',
        func = tonumber,
    },
        {
        name = 'strength_requirement',
        property = 'Has dexterity requirement',
        func = tonumber,
    },
        {
        name = 'intelligence_requirement',
        property = 'Has intelligence requirement',
        func = tonumber,
    },
    {
        name = 'mana_multiplier',
        property = 'Has mana multiplier',
        func = tonumber,
    },
    {
        name = 'critical_strike_chance',
        property = 'Has critical strike chance',
        func = tonumber,
    },
    {
        name = 'mana_cost',
        property = 'Has mana cost',
        func = tonumber,
    },
    {
        name = 'damage_effectiveness',
        property = 'Has damage effectiveness',
        func = tonumber,
    },
    {
        name = 'stored_uses',
        property = 'Has stored uses',
        func = tonumber,
    },
    {
        name = 'cooldown',
        property = 'Has cooldown',
        func = tonumber,
    },
    {
        name = 'vaal_souls_requirement',
        property = 'Has vaal souls requirement',
        func = tonumber,
    },
    {
        name = 'vaal_stored_uses',
        property = 'Has vaal stored uses',
        func = tonumber,
    },
    {
        name = 'damage_multiplier',
        property = 'Has damage multiplier',
        func = tonumber,
    },
    -- from gem experience, optional
    {
        name = 'experience',
        property = 'Has experience requirement',
        func = tonumber,
    },
}

-- 
-- Helper functions 
--
local h = {}

function h.map_to_arg(properties, prefix, map)
    local id
    local val
    for _, row in ipairs(map) do
        id = prefix .. row.name
        val = g_args[id]
        if val ~= nil then
            if row.func ~= nil then
                val = row.func(val)
            end
            g_args[id] = val
            properties[row.property] = val
        end
    end
end

function h.stats(properties, prefix)
    local stat_ids
    local stat_values
    local stat_id
    local stat_id_key
    local stat_val
    local stat_val_key
    local type_prefix
    
    for _, stat_type in ipairs(data.map.stats) do
        type_prefix = string.format('%s_%sstat', prefix, stat_type.prefix)
        stat_ids = {}
        stat_values = {}
        for i=1, 8 do
            stat_id_key = string.format('%s%s_id', type_prefix, i)
            stat_val_key = string.format('%s%s_value', type_prefix, i)
            stat_id = g_args[stat_id_key]
            stat_val = g_args[stat_val_key]
            if stat_id == nil or stat_val == nil then
                break
            end
            stat_ids[#stat_ids+1] = stat_id
            stat_values[#stat_values+1] = stat_val
        end
        g_args[type_prefix .. 's_ids'] = stat_ids
        g_args[type_prefix .. 's_values'] = stat_values
        
        properties[stat_type.property_prefix .. 'id'] = table.concat(stat_ids, ',')
        properties[stat_type.property_prefix .. 'value'] = table.concat(stat_values, ',')
    end
end

--
-- For Template:Skill
--
function p.skill(frame)
    g_args = getArgs(frame, {
		parentFirst = true
	})
    g_frame = util.misc.get_frame(frame)
    
    --
    -- Args
    --
    local properties = {}
    
    
    -- Handle static arguments
    h.map_to_arg(properties, '', data.map.static)
    h.map_to_arg(properties, 'static_', data.map.progression)
    h.stats(properties, 'static_')
    
    g_frame:callParserFunction('#set:', properties)
    
    -- Handle level progression
    local maxlevel = i
    local prefix
    for i=1, 30 do
        properties = {}
        prefix = string.format('level%s_', i) 
        if util.cast.boolean(prefix) then
            h.map_to_arg(properties, prefix, data.map.progression)
            h.stats(properties, prefix)
        
            g_frame:callParserFunction('#subobject: level' .. i , properties)
            
            if g_args[prefix .. 'experience'] ~= nil and g_args[prefix .. 'experience'] > 0 then
                maxlevel = i
            end
        end
    end
    
    properties = {
        ['Has maximum skill level'] = maxlevel
    }
    g_frame:callParserFunction('#set:', properties)
    
end

return p
Advertisement