haganinc Posted March 24, 2012 Share Posted March 24, 2012 Anyone know if it is possible through scripting to change combat target priorities? For example, say I have an actor variable named Bob and two actor enemies called Enemy1 and Enemy2 that Bob is in combat with. How can I make it so Enemy2 is the higher priority target to attack and only attack Enemy1 if Enemy2 is dead or unreachable? I'm not sure how the AI chooses a target when multiple options are available. Link to comment Share on other sites More sharing options...
elseagoat Posted March 24, 2012 Share Posted March 24, 2012 (edited) I have found this to work well Event OnInit() RegisterForSingleUpdate(0.5) EndEvent Event OnUpdate() If (SomeCondition==true) If (YourActor.GetCombatTarget() !=YourEnemy1) YourActor.StopCombat() YourActor.StartCombat(YourEnemy1) EndIf EndIf RegisterForSingleUpdate(0.5) EndEvent So basically, this periodically checks to see if the target is attacking the wrong target, and if it is, it tries to initiate combat with the right target. The target you want attacked, in this case, being YourEnemy1. The first if statement is basically some variable, possibly a global var that you could use to turn on or off this "prioritization." That second if statement will actually try to make your actor attack enemy 1 no matter how many other enemies there are, because any enemy other than YourEnemy1 that the actor is attacking will meet the requirement of that if statement. StopCombat() seems to be effective at clearing aggro, I found StartCombat() didn't always work without using StopCombat() right in front of it. Usually, the actor has gained the aggro of the target that it is attacking so well that the enemy will be attacking back, and thus hold your actors attention after a few updates. You could probably use another if statement and a count to see if the past X checks to see if the actor is attacking the right target came up ok, then you could probably turn off the looping onupdates. What are you trying to do exactly? It sounds interesting. Controlling combat mechanics is fascinating to me. Edited March 24, 2012 by elseagoat Link to comment Share on other sites More sharing options...
haganinc Posted March 24, 2012 Author Share Posted March 24, 2012 Thanks for the help, unfortunately I've tried this method all ready and haven't gotten it to work successfully. The problem is I don't want the enemy to attack back so it isn't drawing any attention at all even if I stop combat and restart it. Basically I am trying some type of taunting spell where I force an enemy to attack a different non-violent target other than the player. I guess I could try having the non-violent actor keep casting a detrimental area affect spell with no effect and see if that draws aggro. Link to comment Share on other sites More sharing options...
fg109 Posted March 24, 2012 Share Posted March 24, 2012 Have you taken a look at the RemoteCast() function? It might be what you're looking for. Link to comment Share on other sites More sharing options...
elseagoat Posted March 24, 2012 Share Posted March 24, 2012 Ok, what you need to do is mess with factions then. Stop the targets combat and then Chang his factions Link to comment Share on other sites More sharing options...
barnard401 Posted March 25, 2012 Share Posted March 25, 2012 don't know if it would work or not, but perhaps messing with the behaviour files of the actors might help :S Link to comment Share on other sites More sharing options...
haganinc Posted March 28, 2012 Author Share Posted March 28, 2012 So I was able to get this to work by having the target I want attacked casting a zero magnitude invisible hostile spell along with the StopCombat and StartCombat commands on the attacker. Link to comment Share on other sites More sharing options...
Recommended Posts