Merlijn, on Jan 21 2010, 09:52 AM, said:
If this has been brought up before, my apolegies.
Anyway, I'm constructing a sequence for the Imperium episode with bot-allies and newbeasts. And for some reason all of the newbeasts only move to attack the bots and they never attack me. I should mention that I gave the newbeasts the 'melee attack only' tag. Is this how all monsters behave when there are botallies in the game? If so, is there a way to fix this behavior? To be honest, I never really noticed this before..
I have changed the code so it should be fixed as of the next update.
Here's an explanation of what was happening (which admittedly may not interest anyone). By default, monsters don't have a designated target sprite; they automatically treat the nearest player as the target. To make them shoot at a bot or other player ally, I must make them find a suitable target sprite. When they have a target, it overrides their normal behavior and they attack it instead of the player. Here's where the bug comes in. If the monster does not have a target sprite, and it knows that there are nonplayer targets around, it will look for one. Once it finds one, it stays on that target until there is some reason not to. This means that if there are nonplayer targets around, the monsters will quickly find them and stay on them, overriding their normal behavior to attack them instead of the player.
One solution would have been to treat the player as another possible target sprite, so the monsters would be as likely to find the player when looking for targets as any other enemy. The problem is that would change and in some ways simplify the monster AI, because the player would be treated in the way that nonplayer targets are normally treated (all of the commands normally directed towards the player, such as faceplayerslow, ifcanshoottarget, etc. would become irrelevant). So instead of doing that, I simply made it so that if the player is visible, shootable and nearby, then there is a large probability that the monsters will not search for a target (and if they already have one, there is a large probability that they will drop it to go after the player after a few seconds).