"Turn attacks" are just MonsterAttackComponents with the turnToAttackDirection field set. The turnAttackLeft, turnAttackRight, and turnAroundAttack animations, if they exist, will then be used for attacks in those directions, and the monster will turn as soon as the attack begins. If you haven't provided a turnAttackLeft animation, the monster won't be able to make turn attacks to the left, and so on. Unless you set it with setAnimations() below:
DaggorathMaster wrote:With turn attacks, I also did not want the single action default way of handling it, which decides on its own terms which animation to use.
MonsterAttackComponent:setAnimations() may be used at any time to change the animations it uses. It takes one argument, a table with animation names:
Code: Select all
function MonsterAttackComponent:setAnimations(anims)
self.attackAnim = anims.front
self.attackLeftAnim = anims.left
self.attackRightAnim = anims.right
self.attackBackAnim = anims.back
self.attackFrontLeftAnim = anims.frontLeft
self.attackFrontRightAnim = anims.frontRight
end
The left/right/back animations are also used for turn attacks in those directions. You could call this function in your onThink hook right before telling the monster to attack, for example.
DaggorathMaster wrote: the party is not the only target in existence ever, and it may be out of melee range.
Both MonsterAttackComponent and MonsterMoveAttackComponent, except when the attackType is "projectile", are designed for the purpose of attacking the party. So if you want to use their animation logic etc., but "attack" things that are not the party (or attack the party in a particularly odd location), you'll need to return false from the onAttack hook and do your own "attack" logic.
For that, refer to the source files in the umod pack: the function you'll want to use as a reference for this is MonsterAttackComponent:attackParty(). You'll also need to reimplement Champion:getProtectionForBodyPart(). Don't worry about the onMonsterHitChampion message, it's only used by the lindworm boss fight.
If you mean to have monsters "attack" other monsters, you'll also need to reimplement much of MonsterComponent:onAttackedByChampion() and MonsterComponent:findImpactPosition(). For the latter, it's helpful to know that you can get the location of a node on a monster ("capsule" in this case) by using MonsterComponent:shootProjectile() from that node and then inspecting the position of the returned object (just remember to destroy it afterwards).
MonsterMoveAttackComponent requires an animation event named "move_forward" (the monster's object will move to the new square when this event is encountered). If you use MonsterMoveAttackComponent with an animation that does not have such an event, it will not work.