questions about ai and lua
Moderator: Moderators
-
nobody3
- Rebel Sergeant

- Posts: 188
- Joined: Wed Jun 15, 2011 8:30 am
questions about ai and lua
this is in every mission lua SetSpawnDelay(10.0, 0.25)
Is it supposed to be how often the ai units spawn after they die? What does the second number mean (0.25) ? Is there any trick to making it work? I tried it and it didn't exactly work out.
Is it possible with the aigoal "follow" (or something similar) make 1 ai unit follow another ai unit or a player? Does it delete the objective goal like "conquest" if the unit or player its following dies?
How come when I set the aigoal to deathmatch, the ai units just walk around and ignore enemies even if they are close to them? This doesnt happen as often in conquest
And what does this do? AISnipeSuitabilityDist(30)
Thx for info
Is it supposed to be how often the ai units spawn after they die? What does the second number mean (0.25) ? Is there any trick to making it work? I tried it and it didn't exactly work out.
Is it possible with the aigoal "follow" (or something similar) make 1 ai unit follow another ai unit or a player? Does it delete the objective goal like "conquest" if the unit or player its following dies?
How come when I set the aigoal to deathmatch, the ai units just walk around and ignore enemies even if they are close to them? This doesnt happen as often in conquest
And what does this do? AISnipeSuitabilityDist(30)
Thx for info
- AnthonyBF2
- Sith

- Posts: 1255
- Joined: Wed Aug 21, 2013 3:55 pm
- Projects :: PS2+PSP Overhaul
Re: questions about ai and lua
AISnipeSui... ability thing, this tells the ai how far away they can be from an enemy before shooting at them.
For regular Tantive the code is set on 30, since there not really any big spaces.
On Hoth code I found SetDefenderSnipeRange(170)
I have to think this is similar, and since it is an open map the code should be higher to tell them how far away they can attack.
For regular Tantive the code is set on 30, since there not really any big spaces.
On Hoth code I found SetDefenderSnipeRange(170)
I have to think this is similar, and since it is an open map the code should be higher to tell them how far away they can attack.
- [RDH]Zerted
- Gametoast Staff

- Posts: 2982
- Joined: Sun Feb 26, 2006 7:36 am
- Projects :: Bos Wars AI - a RTS game
- xbox live or psn: No gamertag set
- Location: USA
- Contact:
Re: questions about ai and lua
Read the first tutorial on making a map and the AI documentation. They'll answer your questions on SetSpawnDelay and Deathmatch. I'm guessing, but it's something like after a 10 second delay 25% of the dead AI will respawn. In Deathmatch I think the AI are tweaked to focus on human players more than other bots. Reread the docs to verify.
For follow, you can't make a specific AI unit follow something else unless you put the follower on its own team, but otherwise yes. The bots will follow the thing with the specific id you told it to follow. When that id isn't alive, the bots do nothing. When it is alive, they basically try to stand on the exact same spot. Use the Fake Console to make the AI follow you. You'll be surrounded quickly. Then blow yourself up, respawn, and see what happens.
For follow, you can't make a specific AI unit follow something else unless you put the follower on its own team, but otherwise yes. The bots will follow the thing with the specific id you told it to follow. When that id isn't alive, the bots do nothing. When it is alive, they basically try to stand on the exact same spot. Use the Fake Console to make the AI follow you. You'll be surrounded quickly. Then blow yourself up, respawn, and see what happens.
-
nobody3
- Rebel Sergeant

- Posts: 188
- Joined: Wed Jun 15, 2011 8:30 am
Re: questions about ai and lua
I see, I read the docs few times before... I don't know how I missed the thing about deathmatch
I still have some questions but I will experiment myself first before asking them here. Thanks
I still have some questions but I will experiment myself first before asking them here. Thanks
-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: questions about ai and lua
Yep. Exactly what Zerted said. For the follow goal, you have to make sure you clear the goal when the follow target dies. Using OnCharacterDeath should suffice.
-
nobody3
- Rebel Sergeant

- Posts: 188
- Joined: Wed Jun 15, 2011 8:30 am
Re: questions about ai and lua
what is the specific id? How do I make ai unit follow another ai unit?[RDH]Zerted wrote:The bots will follow the thing with the specific id you told it to follow.
- Maveritchell
- Jedi Admin

- Posts: 7366
- Joined: Mon Aug 21, 2006 11:03 pm
Re: questions about ai and lua
No, you don't. Assuming you're targeting an ID (e.g. "GetTeamMember(3,0)"), the goal remains active because the ID is relative, not specific.Marth8880 wrote:Yep. Exactly what Zerted said. For the follow goal, you have to make sure you clear the goal when the follow target dies. Using OnCharacterDeath should suffice.
You target a team member with your follow goal. Here are three examples from my VIP mode, which tell teams 1 (attackteam) and 2 (defendteam) (the playable teams) to either attack or follow the first member of team 3 (the VIP).nobody3 wrote:what is the specific id? How do I make ai unit follow another ai unit?
Code: Select all
AddAIGoal(defendteam, "Follow", 50, GetTeamMember(3, 0))
AddAIGoal(defendteam, "Defend", 100, GetTeamMember(3, 0))
AddAIGoal(attackteam, "Destroy", 200, GetTeamMember(3, 0))-
nobody3
- Rebel Sergeant

- Posts: 188
- Joined: Wed Jun 15, 2011 8:30 am
Re: questions about ai and lua
so 3 is the team in "GetTeamMember(3, 0))" and 0 is the first player on the team? So is "0" a human player's number? And 1,2,3 and so on are the AI number ID? And what if there are more than 1 human players?
- Maveritchell
- Jedi Admin

- Posts: 7366
- Joined: Mon Aug 21, 2006 11:03 pm
Re: questions about ai and lua
GetTeamMember(teamnumber, ID number)
Here's an awkward explanation - let's call the AI units "Alice," "Bob," "Chris," and "Doug" and call our IDs "0," "1," and "2." At the beginning of the game, Alice gets 0, Bob gets 1, Chris gets 2, and Doug is waiting. Bob dies, opening ID 1 up, which Doug takes (he's waiting first). Now Bob's waiting for an ID, Alice is 0, Chris is 2, and Doug is 1. You can see how, with a few cycles, you can end up with AI using IDs very different from what they originally started with.
It's essentially impossible to really assure that an AI is using the same ID unless they're the only person on the team (because in that case, as soon as they die, they recycle back into their own ID slot, because it's the only one). If you want to track a specific AI (instead of just the ID spot, which could have different AI) as described in the above posts, you should be tracking AI on a team size of 1.
You have one other use case for tracking specific characters, and that's when a human is on the team. In single player, the human player is always on ID slot 0 (the first one) on his given team. In multiplayer, I believe the host is always ID slot 0 on his given team. If you have more than 1 human player, you're up a creek trying to track more than the single player that uses slot 0, because I don't think it's a fixed assignment (just like multiple AI).
Here's an awkward explanation - let's call the AI units "Alice," "Bob," "Chris," and "Doug" and call our IDs "0," "1," and "2." At the beginning of the game, Alice gets 0, Bob gets 1, Chris gets 2, and Doug is waiting. Bob dies, opening ID 1 up, which Doug takes (he's waiting first). Now Bob's waiting for an ID, Alice is 0, Chris is 2, and Doug is 1. You can see how, with a few cycles, you can end up with AI using IDs very different from what they originally started with.
It's essentially impossible to really assure that an AI is using the same ID unless they're the only person on the team (because in that case, as soon as they die, they recycle back into their own ID slot, because it's the only one). If you want to track a specific AI (instead of just the ID spot, which could have different AI) as described in the above posts, you should be tracking AI on a team size of 1.
You have one other use case for tracking specific characters, and that's when a human is on the team. In single player, the human player is always on ID slot 0 (the first one) on his given team. In multiplayer, I believe the host is always ID slot 0 on his given team. If you have more than 1 human player, you're up a creek trying to track more than the single player that uses slot 0, because I don't think it's a fixed assignment (just like multiple AI).
-
nobody3
- Rebel Sergeant

- Posts: 188
- Joined: Wed Jun 15, 2011 8:30 am
Re: questions about ai and lua
I think I get it but can't I just make them follow a certain class ? Like wookie or dark trooper or does it only work with ID numbers
- Maveritchell
- Jedi Admin

- Posts: 7366
- Joined: Mon Aug 21, 2006 11:03 pm
Re: questions about ai and lua
Let me back up and tell you that I was wrong and we both learned something here today. Don't use "GetTeamMember," since that doesn't return the pointer that the "Follow" goal needs. You want to instead set your goals up like this:nobody3 wrote:I think I get it but can't I just make them follow a certain class ? Like wookie or dark trooper or does it only work with ID numbers
Code: Select all
AddAIGoal(1, "Follow", 500, GetObjectPtr(GetCharacterUnit(player)))Each individual goal, though, only targets one entity. If you wanted to try and target a specific class, you'd have to check to see when an entity of a class spawns and then add a goal that asks a team to follow that entity. I'd make sure that your targeted entity is on a different team, though (or is the human player). If (for example), you tell team 1 to follow Dark Trooper entity #1, and Dark Trooper entity #1 is on team 1, he'll try to follow himself, which is pretty useless.
-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: questions about ai and lua
I've never used GetTeamMember as far as I can remember. I'm talking about using GetCharacterUnit, which I suppose I should have made clear.Maveritchell wrote:No, you don't. Assuming you're targeting an ID (e.g. "GetTeamMember(3,0)"), the goal remains active because the ID is relative, not specific.Marth8880 wrote:Yep. Exactly what Zerted said. For the follow goal, you have to make sure you clear the goal when the follow target dies. Using OnCharacterDeath should suffice.
-
nobody3
- Rebel Sergeant

- Posts: 188
- Joined: Wed Jun 15, 2011 8:30 am
Re: questions about ai and lua
Code: Select all
AddAIGoal(1, "Follow", 500, GetObjectPtr(GetCharacterUnit(player)))I used this code to make AI follow me (which I learned from docs)
Code: Select all
AddAIGoal (ATT, "Follow",50, 0)I found similar thing here http://www.gametoast.com/viewtopic.php?f=27&t=30199
I don't know how the final code would look but nevermind I think Im done with this anyway
I have a new question regarding AI. How do I allow the AI units to use weapons they normally don't? For example they never seem to use mortar launcher (grenade launcher wookie/officer have)
It's like they ignore they even have it and just use the primary weapon but even when I remove the primary weapon and they have the launcher only, they don't use it... any ideas?
