Combat a/i!

i put together a little script to direct an arbitrary creature to run to an object and start bashing on it. the approach i used was simple :

AssignCommand(creature, ActionMoveToObject(target, TRUE));
AssignCommand(creature, DetermineCombatRound(target));

for some strange reason, this wouldn’t work if the target object wasn’t a creature. in fact, none of it would work [i.e., the directed creature wouldn’t even run to the target]. everything went fine if the target was a creature. if i removed the attack directive, then the directed creature would move quite dilligently up to the placeable. ActionDoCommand() solved the sequencing bit, but there’s still the question of the lazy goblin.

next i tried this on a familiar. here, everything worked fine in all cases ; the familiar attacked the target creature as the goblin did before, but it was also willing to run up to the placeable object and dutifully start bashing away on it, where the goblin had just stood there w/drool on its face.

so here’s my question. does anyone know enough about the various creature scripts to tell me why DetermineCombatRound() vs. a placeable works for companions but not for your average everyday joe goblin ?

1 Like

Better to use ActionAttack when you know which object you want to target. That will make NPCs hit all classes of object that can be bashed.

DetermineCombatRound is used when you want the creature to select the most appropriate target (or none). It doesn’t necessarily attack the target you pass as a parameter.

Associate AI is designed to help PCs to bash doors, chests etc.

NPC AI is not designed to bash stuff.

1 Like

Better to use ActionAttack when you know which object you want to target.

ActionAttack isn’t ideal in this case, as it’s too indiscriminate. circumstances may change while the npc is enroute, and the target creature may no longer be an enemy by the time the directed creature arrives. it looked like DetermineCombatRound would take care of this eventuality. i could write around this, but i’d like to avoid re-inventing the wheel if possible.

Associate AI is designed to help PCs to bash doors, chests etc.
NPC AI is not designed to bash stuff.

this is the nub of it, yes. i realise now that my question wasn’t as clear as it could’ve been, i was in a rush to leave… :blush: basically what i’d like to know is if anyone can point me to the scripts that encode this behaviour difference. what code gives companions the edge over default npc’s ? i haven’t found anything obvious in the on-spawn scripts, so still digging.

Have you tried running DetermineCombatRound without passing it the target object?

Try

	SetIsTemporaryEnemy(target, creature);
    AssignCommand(creature, ActionAttack(target));
    AssignCommand(creature, DetermineCombatRound(target));

instead. My (limited compared to others who’ve replied here) experience is that without SetIsTemporaryEnemy() the other 2 commands sometimes fail. No idea why though.

TR

many thanks to all of you for your input. :slight_smile:
this has now morphed into a very intriguing class of problems – w/even more interesting solutions for a more intelligent, general-purpose way of directing npc’s. hopefully i’ll be able to accomplish something useful w/o having to code a library to do it. ;p