Page 1 of 1
Specific hook for all meleeAttacks
Posted: Fri Aug 21, 2015 10:33 am
by cromcrom
Hello there,
I feel a little lazy, could anybody tell me if there is an easy way to apply a function (checkDeterioration, for instance) to all meleeAttacksComponents, without doing it for each item ? And if yes, either the code, or a serious hint or link would be amazing, please

Re: Specific hook for all meleeAttacks
Posted: Fri Aug 21, 2015 7:50 pm
by minmay
It's trivial, actually. PartyComponent.onAttack() provides the component used to make the attack; it's the third argument.
Code: Select all
onAttack = function(self, champion, action, slot)
if action and action:getClass() == "MeleeAttackComponent" then
-- do your stuff here
end
end,
There is one caveat: PartyComponent.onAttack() is not called
at all for bare-handed attacks.
Re: Specific hook for all meleeAttacks
Posted: Fri Aug 21, 2015 8:04 pm
by cromcrom
Amazing, my deterioration system will make much more sense now. Thank you so much

Re: Specific hook for all meleeAttacks
Posted: Sat Aug 22, 2015 8:32 am
by cromcrom
Actually, I checked, the deterioraton system for weapons was already played on the onAttack hook from the partycomponent. However, this checks the deterioraton every time a character attacks. I would like to have it checked only when a monster is hit, so that would be the onMonsterHit hook from the meleeAttackComponent. However, my issue is to set this deteriorationCheck function on all meleeAttackcomponnts for all melee weapons, without doing it hand by hand for each weapon.
Hopefully I can make myself clear ...
Re: Specific hook for all meleeAttacks
Posted: Sat Aug 22, 2015 9:00 am
by minmay
Sorry, the only hook for that is MeleeAttackComponent.onHitMonster().
Re: Specific hook for all meleeAttacks
Posted: Sat Aug 22, 2015 9:07 am
by cromcrom
Yes I know. Is there a way to apply a function to all onHitMonster, without doing it individually for each and every weapon type ?
Re: Specific hook for all meleeAttacks
Posted: Sat Aug 22, 2015 5:52 pm
by minmay
no, but you can
use this to possibly make it a little more convenient
Re: Specific hook for all meleeAttacks
Posted: Sun Aug 23, 2015 3:00 pm
by cromcrom
Thanks for the info, and not being as lazy as me
