Page 1 of 1

2 Questions about Monster Scripts

Posted: Mon May 23, 2016 8:36 am
by Dunkler
Hello everyone!

My first question is about attack sequences of certain monsters.

I noticed for example that the Ratling with the Gun (ratling3) fires sometimes 2 or 3 times in a row but sometimes only once.
I did not find anything in the monster.lua that refers to this.
Is this hardcoded? Or is it placed in another script somewhere? Is it possible to change it or script something similar?

-----

My next question is about monster-pairs. I did create a pair of 2 ratlings with a pistol. But no matter what i do these 2 ratling always fire at the same time and never fire 2 or 3 times like the solo ratling3 does.
I even created 2 different pistol-ratlings that have 2 different cooldowns on their attack, and used them in the monster-group....but they still attack at the same time with the same cooldown.
Anyone can explain this to me :)?
I also noticed that the freeze condition does not work on monster-groups...only on single monsters.

Re: 2 Questions about Monster Scripts

Posted: Fri Jul 08, 2016 8:57 am
by minmay
I forgot to reply to this when I first saw it...
Dunkler wrote:My first question is about attack sequences of certain monsters.

I noticed for example that the Ratling with the Gun (ratling3) fires sometimes 2 or 3 times in a row but sometimes only once.
I did not find anything in the monster.lua that refers to this.
Is this hardcoded? Or is it placed in another script somewhere? Is it possible to change it or script something similar?
All MonsterAttackComponents have a repeat chance. This is 25 by default. This means that 25% of the time, after finishing the attack, the monster will immediately try to perform the same attack again. You can use the repeatChance property or MonsterAttackComponent:setRepeatChance() to change this. For example, skeleton_commander's summonUndead attack has a repeatChance of 0 so it never repeats and always has to wait out its lengthy cooldown.
Dunkler wrote:My next question is about monster-pairs. I did create a pair of 2 ratlings with a pistol. But no matter what i do these 2 ratling always fire at the same time and never fire 2 or 3 times like the solo ratling3 does.
I even created 2 different pistol-ratlings that have 2 different cooldowns on their attack, and used them in the monster-group....but they still attack at the same time with the same cooldown.
Anyone can explain this to me :)?
I also noticed that the freeze condition does not work on monster-groups...only on single monsters.
Monsters that are in groups have to act together. If one monster moves or turns, the whole group has to move or turn. If one monster wants to attack, the other monsters have to attack at the same time. I believe that as a side effect of how this is implemented, MonsterAttackComponent repeat attempts in monster groups will always fail. This is also why monsters with differing animation lengths and/or attack types don't work well in groups (e.g. the herder in herder_twigroot_pair can't actually use its ranged attack unless it's in melee range) and is a part of why actions like MonsterMoveAttackComponent screw up catastrophically in groups.