Author Topic: AI question  (Read 2372 times)

Offline Nighthawk

  • |______[o]_|
  • Posts: 750
  • Cookies: 18
AI question
« on: July 10, 2008, 08:42:14 PM »
is there any AI (or script) to load ships in QB without a specific team or side, kinda like deathmatch?

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: AI question
« Reply #1 on: July 11, 2008, 01:03:39 AM »
Not that I know off...

But it shouldn't be hard to make.
Make your "CreateAI" function, without passing in a ObjectGroup of enemy ships.
Instead, in the same function, before creating the AI, create a ObjectGroup and add in it the name of ALL ships in the game.  (for starbases, make sure there is at least 1 name, even if it is the name of the starbase itself. after creating and setting the AI for a ship you can remove the name of that group.
Only problem I can see with this is updating the ObjectGroup, when new ships enter, or others exit the game. I dunno if it needs to be done somehow, and if it does, I dunno how this update occurs for the regular ObjectGroups, the Friendly/Enemy/Neutral sides.
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline Nighthawk

  • |______[o]_|
  • Posts: 750
  • Cookies: 18
Re: AI question
« Reply #2 on: July 11, 2008, 01:38:46 AM »
if it doesn't get updated, couldn't I just put a simple "if not target, then target again" code?
or a self-entry-delete function that removes the name of the ship as an available target when a ship gets destroyed? there must be plenty of those functions in the stock scripts...

the problem it might have, if it works, is lots of processing time. updating every list of every ship..... dunno.....

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: AI question
« Reply #3 on: July 11, 2008, 03:46:15 AM »
The question is, do you want to make everyone an enemy?
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline Nighthawk

  • |______[o]_|
  • Posts: 750
  • Cookies: 18
Re: AI question
« Reply #4 on: July 11, 2008, 04:00:56 AM »
The question is, do you want to make everyone an enemy?
not towards me, but towards them.
as I said, sort of deathmatch.

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: AI question
« Reply #5 on: July 11, 2008, 04:09:21 AM »
Well, with FedAttack and NonFedAttack you can pass in all the targets.

Normally, it gets it's targets from the QuickBattleAI.
So, basicly, you need your own AI (or copy and modify the one from QB).
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.

Offline Nighthawk

  • |______[o]_|
  • Posts: 750
  • Cookies: 18
Re: AI question
« Reply #6 on: July 11, 2008, 04:20:23 AM »
ok, I'll give that a try....
I'm not that skilled with AI, but I guess I can figure it out

Offline USS Frontier

  • Posts: 176
  • Cookies: 562
Re: AI question
« Reply #7 on: July 11, 2008, 06:39:12 PM »
hey i'm not that skilled either and i'm managing to make a "fleet based" AI =P
"Revenge is a dish best served cold"
                    -Old Klingon Proverb
GravityFX Download
Galaxy Charts Download

Offline jayce

  • Posts: 20
  • Cookies: 2
Re: AI question
« Reply #8 on: July 11, 2008, 09:04:26 PM »
As far as I know, quickbattle only defaults to either friend or foe and that always is dependent on the player.

If I had to guess, I'd say you would probably have more of a better chance at looking into one of the multiplayer folder files

This looks promising and hope it helps:

Code: [Select]
def ResetEnemyFriendlyGroups():
# Go through all the ships in the world and make them enemies

# Go through player list, trying to find all the ships
pNetwork = App.g_kUtopiaModule.GetNetwork ()
pGame = App.MultiplayerGame_Cast (App.Game_GetCurrentGame ())

if (pNetwork and pGame):
pMission = MissionLib.GetMission ()
pEnemyGroup = pMission.GetEnemyGroup ()

# First clear the groups.  We will be readding everybody
# so we want to start with an empty group.
pEnemyGroup.RemoveAllNames ()

pPlayerList = pNetwork.GetPlayerList ()
iNumPlayers = pPlayerList.GetNumPlayers ()

for i in range(iNumPlayers):
pPlayer = pPlayerList.GetPlayerAtIndex (i)
iPlayerID = pPlayer.GetNetID ()
pShip = pGame.GetShipFromPlayerID (iPlayerID)

if (pShip and iPlayerID != pNetwork.GetLocalID ()):
# Good, there is a ship for this player
# debug("adding to enemy group: %s" % pShip.GetName())
pEnemyGroup.AddName (pShip.GetName ())

Offline MLeo

  • Retired Staff
  • Posts: 3636
  • Cookies: 833
  • Software Simian
    • the Programming Pantheon
Re: AI question
« Reply #9 on: July 12, 2008, 09:03:31 AM »
QuickBattle passes a list of enemies (of a particular ship) to the ship.

So if the list contains every ship execpt for itself, then it effectively targets any ship it can find.
I still can't read peoples minds, nor can I read peoples computers, even worse, I can't combine the two to read what is going wrong with your BC install...

"It was filed under 'B' for blackmail." - Morse, Inspector Morse - The dead of Jericho.