Code: Select all
-- USAGE: Instead of calling champion:addTrait and
-- champion:removeTrait, call traitManager.addTrait and
-- traitManager.removeTrait. This will prevent equipment swapping
-- from destroying permanent traits and the like.
-- For example, instead of champion:addTrait("tough",true) call
-- traitManager.addTrait(champion,"tough",true).
-- Note: You shouldn't (and can't) use this script for skill
-- traits (such as quick_strike) as the counts would be
-- rendered inaccurate anyway by players increasing their skills.
TRAIT_LIST = {
-- Regular traits.
head_hunter = true,
skilled = true,
fast_learner = true,
rage = true,
fast_metabolism = true,
endure_elements = true,
poison_immunity = true,
chitin_armor = true,
quick = true,
mutation = true,
aggressive = true,
agile = true,
healthy = true,
athletic = true,
strong_mind = true,
aura = true,
tough = true,
cold_resistant = true,
evasive = true,
fire_resistant = true,
weapon_specialization = true,
endurance = true,
lightning_speed = true,
natural_armor = true,
poison_resistant = true,
uncanny_speed = true,
leadership = true,
nightstalker = true,
-- Skill traits. Currently excluded.
--[["pack_mule",
"meditation",
"two_handed_mastery",
"light_armor_proficiency",
"heavy_armor_proficiency",
"armor_expert",
"shield_expert",
"staff_defence",
"improved_alchemy",
"bomb_expert",
"backstab",
"assassin",
"firearm_mastery",
"dual_wield",
"improved_dual_wield",
"piercing_arrows",
"double_throw",
"reach",
"uncanny_speed",
"fire_mastery",
"air_mastery",
"earth_mastery",
"water_mastery"]]
--LoG1 skill traits
--[["greater_lightning_bolt",
"air_circle",
"light_armor",
"heavy_armor",
"shield_expert",
"backstab",
"reach_attack",
"improved_backstab",
"quick_strike",
"improved_critical",
"piercing_attack",
"improved_quick_strike",
"assassin_master",
"endurance",
"porter",
"chop",
"cleave",
"rampage",
"axe_master",
"stab",
"piercing_strike",
"flurry_slashes",
"dagger_master",
"stealth",
"light_armor",
"improved_stealth",
"improved_poison_bolt",
"earth_circle",
"greater_fireball",
"fire_circle",
"improved_frostbolt",
"ice_circle",
"bash",
"crushing_blow",
"devastating_blow",
"mace_master",
"quick_shot",
"improved_quick_shot",
"volley",
"master_archer",
"combat_caster",
"improved_combat_caster",
"archmage",
"light_armor",
"slash",
"parry",
"thrust",
"flurry_slashes",
"sword_master",
"quick_throw",
"improved_quick_throw",
"double_throw",
"throwing_master",
"jab",
"kick",
"three_point_technique"]]
}
traits = {}
-- add a trait and increase "level" of that trait by 1
function addTrait(champion,trait,silent)
if not TRAIT_LIST[trait] then
print("warning: invalid trait: "..trait)
end
if traits[champion:getOrdinal()][trait] == 0 then
champion:addTrait(trait,silent)
end
traits[champion:getOrdinal()][trait] = traits[champion:getOrdinal()][trait] + 1
end
-- decrease "level" of a trait by 1, removing it if it reaches 0
function removeTrait(champion,trait)
--local name = champion:getName()
if traits[champion:getOrdinal()][trait] == 1 then
champion:removeTrait(trait)
--hudPrint(""..name.." gained the agile trait.")
end
traits[champion:getOrdinal()][trait] = traits[champion:getOrdinal()][trait] - 1
end
-- get the traits the party started with
function gatherInitialTraits()
for i = 1, 4 do
local champion = party.party:getChampion(i)
traits[champion:getOrdinal()] = {}
for trait,dummy in pairs(TRAIT_LIST) do
if champion:hasTrait(trait) then
traits[champion:getOrdinal()][trait] = 1
else
traits[champion:getOrdinal()][trait] = 0
end
end
end
end
gatherInitialTraits()