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
Specific hook for all meleeAttacks
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Specific hook for all meleeAttacks
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
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
A trip of a thousand leagues starts with a step.
Re: Specific hook for all meleeAttacks
It's trivial, actually. PartyComponent.onAttack() provides the component used to make the attack; it's the third argument.
There is one caveat: PartyComponent.onAttack() is not called at all for bare-handed attacks.
Code: Select all
onAttack = function(self, champion, action, slot)
if action and action:getClass() == "MeleeAttackComponent" then
-- do your stuff here
end
end,Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Specific hook for all meleeAttacks
Amazing, my deterioration system will make much more sense now. Thank you so much 
A trip of a thousand leagues starts with a step.
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Specific hook for all meleeAttacks
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 ...
Hopefully I can make myself clear ...
A trip of a thousand leagues starts with a step.
Re: Specific hook for all meleeAttacks
Sorry, the only hook for that is MeleeAttackComponent.onHitMonster().
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Specific hook for all meleeAttacks
Yes I know. Is there a way to apply a function to all onHitMonster, without doing it individually for each and every weapon type ?
A trip of a thousand leagues starts with a step.
Re: Specific hook for all meleeAttacks
no, but you can use this to possibly make it a little more convenient
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- cromcrom
- Posts: 549
- Joined: Tue Sep 11, 2012 7:16 am
- Location: Chateauroux in a socialist s#!$*&% formerly known as "France"
Re: Specific hook for all meleeAttacks
Thanks for the info, and not being as lazy as me 
A trip of a thousand leagues starts with a step.