Aller au contenu

Photo

More battle AI issues...


  • Veuillez vous connecter pour répondre
9 réponses à ce sujet

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
In one battle area, there are locations where defenders can attack from ambush spots.  I want the attackers to ignore these defenders and move to the main attack location. 


I was thinking about using a local int that if set to TRUE would bypass the entire OnPerception and OnDamaged scripts, so that the attackers will proceed to the waypoint that they are scripted to go to.  Once there, they will hit a trigger that sets the integer to FALSE and allow the scripts to start working again.

Has anyone done this before?  Are there better ways? 

#2
MasterChanger

MasterChanger
  • Members
  • 686 messages
I don't think bypassing the OnPerception will really work, because it's only going to fire once for the same Perceiver-Perceived pair. After that, OnHB will check for nearby enemies and proceed with AI from there.

A potential trick might be to use placeables that block sight and then emerging from behind those. After all, that's what an ambush (surprise attack) usually involves, right? Or having the defenders jump to a spot that's unreachable by walkmesh? Then they could be hit by archers but not by melee fighters, similar to sniping from rooftops or somesuch.

#3
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
Probably the best way to go about this is using custom factions and/or Groups. Have them be a faction neutral to the attackers until you want them to attack and then change their faction to one hostile towards the attackers. If you add them all to a Group (include ginc_groups), you can easily swap their faction around with a simple line of code.

#4
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
What I'm trying to do is have archers on a cliff take pot shots at a passing group of enemies. Master Changer is right that any melee fighters will have to pass the spot since it is inaccessible, so it may not even be an issue. I am concerned because I know all the archers and spellcasters will stop and attack there until one or the other is dead. I guess that's not all that unrealistic, so it may work.

It would be nice if I could get the enemies to march past in ranks instead of the mob that will result from the AI taking over, though...

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
...well that didn't work! I tried just using the regular AI and it was pretty ridiculous. Apparently the route to the defenders was too far for the AI to figure out, so the enemies just stood at the bottom of the cliff getting slaughtered.

I need a way for the enemies without ranged weapons to "know" to keep going along the path to the main battle and ignore the unreachable defenders, while the defenders are still able to damage them.

I could use the faction idea, but then the defenders wouldn't be able to attack any of the ones that weren't hostile.

#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I changed the following scripts:

On Heartbeat, On perception, On Spell Cast At, On Physically Attacked, On Damaged

And added code that checked for a certain integer. If it is 0, then I put in code to make the enemies run to a waypoint and return out of the rest of the script. It sort of worked, but the enemies kept on trying to come back to the defenders on the ridge and would spend lots of time standing around and furtively moving, then stopping again. Eventually they all made it, but it didn't look like like a determined army charge. Looked more like deciding what to say as they walk upt to their house after forgetting mother's day....not that I forgot...

#7
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I wonder if I could just forego changing the scripts and set the AI level to Very Low for the ones I want to bypass, then set it back to normal after they get where they belong.

#8
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
It still isn't working.

Here is the snippet of code I added to the event scripts:


object oSelf= OBJECT_SELF;

int nStopToFight = GetLocalInt(oSelf,"nStopToFight");

if (nStopToFight == 0)
{
ClearAllActions(TRUE);
ActionForceMoveToObject(GetWaypointByTag("204_wpt_invader_run_to"),TRUE);
return;
}


Mostly the invaders just stand around. They moved better before I threw in the ClearAllActions().

#9
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I took out the ClearAllActions() and moved the waypoint closer and the performance improved considerably. Initially, I had the WP pretty far away. Could the AI have been having difficulty plotting a path to the WPT? There aren't any significant obstacles.

#10
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Just to see what would happen, I deleted all the event scripts and just put in my snippet for the on heartbeat script. Worked just like I wanted it to. So there must be something happening in one of the unmodified scripts that is messing everything up.

Maybe the on End combat round script. I didn't mess with that.