akroma222 wrote:Minmay, thank you for pointing out exactly what was wrong!
Drakkan, thank you for reporting this!
This now works with saves... it was completely unnecessary to use a champ ref as a key in a table
Code: Select all
-------------------------------------------------------- Trait lists
TRAIT_LIST = {
woodcutter = true,
master_axeman = true,
grandmaster_axeman = true,
skullcrusher = true,
master_maceman = true,
grandmaster_maceman = true
}
axe_TRAITS = {
woodcutter = true,
master_axeman = true,
grandmaster_axeman = true
}
mace_TRAITS = {
skullcrusher = true,
master_maceman = true,
grandmaster_maceman = true
}
--------------------------------------------------------- Modifier list
modList = {}
----------------------------------------------------------gatherModifierTraits(self, champion, weapontype1, weapontype2)
function gatherModifierTraits(self, champion, weapontype1, weapontype2)
local c = party.party:getChampion(champion)
if weapontype1 == "axe"
or weapontype2 == "axe" then
for trait,dummy in pairs(axe_TRAITS) do
if c:hasTrait(trait) then
modList[trait] = 1
print(modList[trait])
else
modList[trait] = nil
print(modList[trait])
end
end
end
if weapontype1 == "mace"
or weapontype2 == "mace" then
for trait,dummy in pairs(mace_TRAITS) do
if c:hasTrait(trait) then
modList[trait] = 1
print(modList[trait])
else
modList[trait] = nil
print(modList[trait])
end
end
end
end
---------------------------------------------------------addWeaponModifiers(self, champion, weapontype1, weapontype2)
trueAttack = 0
truePierce = 1
function addWeaponModifiers(self, champion, weapontype1, weapontype2)
local c = party.party:getChampion(champion)
trueAttack = self:getAttackPower()
truePierce = self:getPierce()
if truePierce == nil then
print("you must define weapon with 'pierce = 0'")
print("pierce = 1")
truePierce = 1
end
gatherModifierTraits(weaponName, champion, weapontype1, weapontype2)
if weapontype1 == "axe"
or weapontype2 == "axe" then
local cutterAttack = 0
local masterAttack = 0
local grandmasterAttack = 0
if modList["woodcutter"] == 1 then
local dx,dy = getForward(party.facing)
for i in party.map:entitiesAt(party.x + dx,party.y + dy) do
if i and i.monster then
if i.monster:hasTrait("plant") then
cutterAttack = 100
self:setAttackPower(trueAttack + cutterAttack + masterAttack + grandmasterAttack)
print(""..self:getAttackPower().."")
end
end
end
end
if modList["master_axeman"] == 1 then
masterAttack = 20
self:setAttackPower(trueAttack + cutterAttack + masterAttack + grandmasterAttack)
print(""..self:getAttackPower().."")
end
if modList["grandmaster_axeman"] == 1 then
grandmasterAttack = 50
self:setAttackPower(trueAttack + cutterAttack + masterAttack + grandmasterAttack)
print(""..self:getAttackPower().."")
end
end
if weapontype1 == "mace"
or weapontype2 == "mace" then
local crusherPierce = 0
local masterPierce = 0
local grandmasterPierce = 0
if modList["skullcrusher"] == 1 then
crusherPierce = 10
self:setPierce(truePierce + crusherPierce + masterPierce + grandmasterPierce)
print(""..self:getPierce().."")
end
if modList["master_maceman"] == 1 then
masterPierce = 20
self:setPierce(truePierce + crusherPierce + masterPierce + grandmasterPierce)
print(""..self:getPierce().."")
end
if modList["grandmaster_maceman"] == 1 then
grandmasterPierce = 50
self:setPierce(truePierce + crusherPierce + masterPierce + grandmasterPierce)
print(""..self:getPierce().."")
end
end
end
function removeWeaponModifiers(self, champion, weapontype1, weapontype2)
local c = party.party:getChampion(champion)
local aP = self:getAttackPower()
if weapontype1 == "axe"
or weapontype2 == "axe" then
for trait,dummy in pairs(axe_TRAITS) do
modList[trait] = nil
end
self:setAttackPower(trueAttack)
print(""..self:getAttackPower().."")
end
if weapontype1 == "mace"
or weapontype2 == "mace" then
for trait,dummy in pairs(mace_TRAITS) do
modList[trait] = nil
end
self:setPierce(truePierce)
print(""..self:getPierce().."")
end
end
-------------------------------------------------------------------------------------stunstrikeCleanup(champion, weapon, stun, stunChance)
function stunstrikeCleanup(champion, weapon, stun, stunChance)
local tempStunChance = weapon.go.meleeattack:getConditionChance("stunned")
if stun == false then
weapon.go.meleeattack:setCauseCondition("")
weapon.go.meleeattack:setConditionChance(0)
--print(weapon.go.meleeattack:getConditionChance())
else
weapon.go.meleeattack:setCauseCondition("stunned")
weapon.go.meleeattack:setConditionChance(stunChance)
--print(weapon.go.meleeattack:getConditionChance())
end
end
Checked on skillManager and traitManager too and they seem to save fine
Akroma
thanks for correction !
Do i also somehow rewrite onAttack hook on axe / mace weapons or thats ok ?
--axe
onAttack = function(self, champion, action, slot)
weaponModManager.script.addWeaponModifiers(self, champion:getOrdinal(), "axe")
delayedCall("weaponModManager", 0.2, "removeWeaponModifiers", self, champion:getOrdinal(), "axe")
end,
--mace
onAttack = function(self, champion, action, slot)
weaponModManager.script.addWeaponModifiers(self, champion:getOrdinal(), "mace")
delayedCall("weaponModManager", 0.2, "removeWeaponModifiers", self, champion:getOrdinal(), "mace")
end,