AI Objective Questions

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

AI Objective Questions

Post by Nedarb7 »

I have a couple questions regarding AI objectives.

First, is it possible to make the AI attack a region instead of an object? And second, can I do something like this:

Code: Select all

AIlobby = AddAIGoal(Team, "type", 100)

-- After a certain amount of time
AIlobby = AddAIGoal(Team, "type", 10)
So in other words, change the objective weight without deleting the goal?
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: AI Objective Questions

Post by Maveritchell »

Pretty sure all your second line there is going to do is give that AI goal a weight of 110. Since weights are all relative, that won't mean anything in isolation, but if you've got two different types set up, you'll obviously be adjusting the ratio there. (In short, no, you can't change absolute weight without clearing goals first.)

AI have two "goto"-type goals, "defend" and "destroy." Destroy is more precise, so if you want your AI to really go to a place, use that one. If you're okay with your AI hanging out in a very general area, you can use defend. Defend is very loose, though.
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: AI Objective Questions

Post by Nedarb7 »

Maveritchell wrote:Pretty sure all your second line there is going to do is give that AI goal a weight of 110. Since weights are all relative, that won't mean anything in isolation, but if you've got two different types set up, you'll obviously be adjusting the ratio there. (In short, no, you can't change absolute weight without clearing goals first.)

AI have two "goto"-type goals, "defend" and "destroy." Destroy is more precise, so if you want your AI to really go to a place, use that one. If you're okay with your AI hanging out in a very general area, you can use defend. Defend is very loose, though.
So in theory, this would make the weight lower?

Code: Select all

AIlobby = AddAIGoal(Team, "type", -90)
But I guess that leaves the question of whether or not it's filling up the objective cap.

Also, how loose? I kind of want the AI to swarm near or at the area directed... say the area of one and a half Utapau hangars.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: AI Objective Questions

Post by Maveritchell »

You're going to have to see if it'll use negative numbers. It appears to work additively, and I see your logic, but I can't tell you if that works. I've never tried. There's no reason you can't simply store your weights as variables and clear and reset them if it doesn't work, though.

"Defend" is probably fine for that large an area. Again, test it and see if it does exactly what you want. If it works, great (because it's a lot more logical behavior once the AI is there). If not, use "Destroy."
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: AI Objective Questions

Post by [RDH]Zerted »

change the objective weight without deleting the goal
Not possible.
Pretty sure all your second line there is going to do is give that AI goal a weight of 110
No, it will add a second goal with a weight of 10. Since both goals are the same, it's similar to one goal with a weight of 110, but it's taking up an extra goal slot. Remember, only a limited number of AI goals are allowed.
So in theory, this would make the weight lower?
No, I'm fairly certain negative weights will crash the game. At the very least it won't do what you want it to do.

Notice how you're not using AIlobby? If you were tweaking a goal you'd be doing something with the variable AIlobby.

Reread the AI goal documentation and play around with Defend/Destroy/Follow goals. See which gives you the results you want. I've never tried attacking a region. It might be easier to try them out using the Fake Console. If you do, make sure to kill all the bots after resetting the goals. Only when an AI dies or completes its goal does it get a new one.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: AI Objective Questions

Post by Maveritchell »

[RDH]Zerted wrote:If you do, make sure to kill all the bots after resetting the goals. Only when an AI dies or completes its goal does it get a new one.
I believe you're off-the-mark here. I've cleared and swapped AI goals midstream based on player action, and the AI has responded to the new goal accordingly (without killing the AI).
Post Reply