Page 3 of 3

Re: some weapon skill help pls

Posted: Fri Feb 27, 2015 5:01 am
by akroma222
and also here is the sword prof skill definition
SpoilerShow

Code: Select all

defineSkill{
    	name = "sword_prof",
    	uiName = "Sword prof",
    	priority = 10,
    	--iconAtlas = "mod_assets/icons/testujuikony.tga",
    	icon = 0,

    	description = "Mastering the sword requires both dexterity and Strength. Each point invested increases your Strength / Hit points or Dexterity / energy. On Level 5 any attack with sword is 20% faster.",

	onRecomputeStats = function(champion, level)
		if level == 1 then
			champion:addStatModifier("dexterity", level)
			champion:addStatModifier("max_energy", level * 5)
		elseif level == 2 then
			champion:addStatModifier("dexterity", level - 1)
			champion:addStatModifier("max_energy", (level - 1) * 5)
			champion:addStatModifier("strength", level - 1)
			champion:addStatModifier("max_health", (level - 1) * 5)
		elseif level == 3 then
			champion:addStatModifier("dexterity", level - 1)
			champion:addStatModifier("max_energy", (level - 1) * 5)
			champion:addStatModifier("strength", level - 2)
			champion:addStatModifier("max_health", (level - 2) * 5)
		elseif level == 4 then
			champion:addStatModifier("dexterity", level - 2)
			champion:addStatModifier("max_energy", (level - 2) * 5)
			champion:addStatModifier("strength", level - 2)
			champion:addStatModifier("max_health", (level - 2) * 5)
		elseif level == 5 then
			champion:addStatModifier("dexterity", level - 3)
			champion:addStatModifier("max_energy", (level - 3) * 5)
			champion:addStatModifier("strength", level - 3)
			champion:addStatModifier("max_health", (level - 3) * 5)
		end
	end,
	traits = { [5] = "grandmaster_sword"   },
 }

Re: some weapon skill help pls

Posted: Fri Feb 27, 2015 7:59 pm
by Drakkan
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
SpoilerShow

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,

Re: some weapon skill help pls

Posted: Fri Feb 27, 2015 11:11 pm
by akroma222
No need for any hook rewriting, just replace the old script with the new one :)

EDIT - simpler solution to this from minmay
viewtopic.php?f=22&t=9966&p=96770#p96770