Page 1 of 1

Error in define Trait (Solved)

Posted: Mon Dec 22, 2014 1:49 am
by Dunkler
Hello.

I want to change a Trait for a class so that he gains +1% critChance for every second Level he gains Starting at level 1.

onRecomputeStats = function(champion, level)
if level > 0 then
level = champion:getLevel()
champion:addStatModifier("critChance", 1+(level/2) )
end

This script works fine with other stats like healths or energy or strenght. But when i try it with critChance and run the Game i get an error that he doesnt know this Stat.

My Question is..

Did i simply write the script wrong? i tried it with critChance,CritChance but both didnt work.

Or is increasing Critchance not possible on level up?

Or if it is possible is there another way to do it?

Thanks for any help :)

Re: Error in define Trait

Posted: Mon Dec 22, 2014 1:53 am
by Dr.Disaster
Maybe just "critical" or "CriticalChance"?

Re: Error in define Trait

Posted: Mon Dec 22, 2014 1:57 am
by Dunkler
same error InvalidStat

Re: Error in define Trait

Posted: Mon Dec 22, 2014 4:42 am
by Grimfan
This code is from another thread that gives you an example critical trait:

Code: Select all

defineTrait{
name = "master_daggerman",
uiName = "Dagger Master",
icon = 94,
description = "Dagger master !",

onComputeCritChance = function(self, champion, weapon, attack, attackType)
      if weapon:hasTrait("dagger") or weapon:hasTrait("dagger") then return 10 end
 end
end,
So there is basically no critical stat. It's a modification to your attack instead (based on your traits, etc.)

Re: Error in define Trait

Posted: Mon Dec 22, 2014 5:54 am
by minmay
Stats that I know of are cooldown_rate, dexterity, energy_regeneration_rate, exp_rate, food_rate, health, health_regeneration_rate, max_health, max_load, strength, vitality, willpower, energy, max_energy, evasion, protection, resist_poison, resist_shock, resist_cold, resist_fire.
If you want to change critical chance, accuracy, or apply a cooldown multiplier that stacks multiplicatively with others, you want to use onComputeAccuracy, onComputeCritChance and onComputeCooldown.

Re: Error in define Trait

Posted: Mon Dec 22, 2014 10:54 am
by Dunkler
Hm thank you. That is the answer i was scared about.

So basicly i can only modify the crit chance on an attack but i cant give it directly to the stats and it wont show in the attribute screen.

Re: Error in define Trait

Posted: Mon Dec 22, 2014 11:14 am
by Dunkler
Hello again.

I tried this now

onComputeCritChance = function(champion, weapon, attack, attackType, level)
if level > 0 then return 1+(level/2) end
end,

And surprisingly! It does show in the charakter screen!

So everything is fine :D