Accueil

Connexion utilisateur

  • Créer un nouveau compte
  • Demander un nouveau mot de passe

Navigation

  • news
    • archive
    • blogs
    • books
    • forums
    • recent posts
    • groups
  • image galleries
  • projects & downloads
  • search
  • create content
  • agrégateur de nouvelles

Rechercher

Qui est en ligne

Il y a actuellement 2 utilisateurs et 168 invités en ligne.

Utilisateurs en ligne

  • TheChin
  • listerofsmeg

Languages

  • English English
  • French French

Parcourir les archives

« January 2009  
Mo Tu We Th Fr Sa Su
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Accueil » news » forums » Support & Feedback » Scenarios & Mods » SE:V MODs

Unit Groups and AI

Soumis par Gideon le Sam, 2007-04-21 16:40 SE:V MODs

I've been trying, and I have yet to discover how to have the AI look inside a unit group.

Has anyone here had any success? I want to count the number of units inside the unit group, but I can't seem to find a way to do it.

Thanks.

‹ ship constuction mods Minor mount idea ›
» Vous devez vous identifier ou créer un compte pour écrire des commentaires

Options d'affichage des commentaires

Sélectionnez la méthode d'affichage des commentaires que vous préférez, puis cliquez sur "Sauvegarder les paramètres" pour activer vos changements.

Re: Unit Groups and AI

Soumis par nesrall le Lun, 2007-04-23 19:57

Sys_Get_Number_of_Units_In_Space_Sector

returns number of visible units in a specific system and sector.
returns a number count on a specific vehicle type(fighters or satellites etc. etc.) or if desired a number count of all units in sector.

» Vous devez vous identifier ou créer un compte pour écrire des commentaires
Mod Designer

Re: Unit Groups and AI

Soumis par Gideon le Mar, 2007-04-24 15:07

I tried this, and it doesn't do what I want. I need to be able to check the design_id, or the general_type. This returns the unit type, as defined in VehicleSizes.txt. Unfortunatly, this means that it sees all satellites (for example, Recon Satellites) as exactly the same thing, Satellite.

Thanks for the suggestion, however.

» Vous devez vous identifier ou créer un compte pour écrire des commentaires
Image de Captain Kwok
Mod Designer

Re: Unit Groups and AI

Soumis par Captain Kwok le Mer, 2007-04-25 07:39

Try identifying the space object as a unitgroup, then you might be able to cycle through the units as individual cargo items (Sys_Get_Space_Object_Cargo_Item_ID) which would give the the item ID that you could use to get the design ID etc.

-----

Space Empires Depot | SE:V Balance Mod

» Vous devez vous identifier ou créer un compte pour écrire des commentaires
Mod Designer

Re: Unit Groups and AI

Soumis par Gideon le Mer, 2007-04-25 19:52

Captain Kwok wrote:
Try identifying the space object as a unitgroup, then you might be able to cycle through the units as individual cargo items (Sys_Get_Space_Object_Cargo_Item_ID) which would give the the item ID that you could use to get the design ID etc.

-----

Space Empires Depot | SE:V Balance Mod

Hrm, I'll give this a shot. I don't think it counts member units as cargo, but maybe it does.

» Vous devez vous identifier ou créer un compte pour écrire des commentaires
Mod Designer

Re: Unit Groups and AI

Soumis par Gideon le Mer, 2007-04-25 23:11

That did it, thanks Kwok.

If anyone is interested, this bit of code will tell the AI to count objects by general type.

Count_Units_In_Cargo

Desired_cargo is the general_type of the desired object, as set in Script_AI_DesignCreation.txt and defined in Script_AI_GlobalConstants_DesignTypes.txt.
Object_id is the object id of the object holding the cargo.

//------------------------------------------------------------------------
// Count_Units_In_Cargo
//------------------------------------------------------------------------
function Count_Units_In_Cargo returns long
params
desired_cargo: string
object_id: long
vars
cargo_count: long
cargo_index: long
cargo_item_id: long
cargo_design_id: long
cargo_general_type: string
total_count: long
begin
set total_count := 0

// --- Count the ammount of cargo on the object.
set cargo_count := Sys_Get_Space_Object_Cargo_Item_Count(object_id)
if (cargo_count > 0) then
for cargo_index := 1 to cargo_count do

// --- Check each object against the desired type, and count the number present
set cargo_item_id := Sys_Get_Space_Object_Cargo_Item_ID(object_id, cargo_index)
set cargo_design_id := Sys_Get_Space_Object_Cargo_Item_Design_ID(object_id, cargo_item_id)
set cargo_general_type := Sys_Get_Vehicle_Design_General_Type(sys_long_Player_ID, cargo_design_id)

if (cargo_general_type = desired_cargo) then
set total_count := total_count + 1
endif

endfor
endif
return total_count
end

Returns total count in the target cargo.
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Count_Units_In_Space_Sector counts the units in a space sector by general type.

Target_design_type is the general_type of the desired object, as set in Script_AI_DesignCreation.txt and defined in Script_AI_GlobalConstants_DesignTypes.txt.
Target_system is the system you want to check.
Target_sector is the sector in the above system you want to check.

If it encounters a unitgroup, it calls Count_Units_In_Cargo, with the id of the unit group and the general type of the desired object.

Returns total count in the target sector.

//------------------------------------------------------------------------
// Count_Units_In_Space_Sector
//------------------------------------------------------------------------
function Count_Units_In_Space_Sector returns long
params
target_design_type: string
target_system: long
target_sector: long
vars
object_list: longlist
object_count: long
object_index: long
object_id: long
object_sector: long
object_owner: long
object_design_id: long
object_general_type: string
total_count: long
begin
set total_count := 0

// --- List the objects in the system.
call Sys_Get_All_Visible_Space_Objects_In_System(sys_long_Player_ID, target_system, object_list)

// --- Fill up our object stats.
set object_count := object_list.count()
if (object_count > 0) then
for object_index := 1 to object_count do
set object_id := object_list.get(object_index)
set object_sector := Sys_Get_Space_Object_Sector_Location(object_id)
set object_owner := Sys_Get_Space_Object_Owner(object_id)
set object_design_id := Sys_Get_Space_Object_Vehicle_Design_ID(object_id)
set object_general_type := Sys_Get_Vehicle_Design_General_Type(sys_long_Player_ID, object_design_id)

// --- Check if it is in our desired sector, if we own it, and if it's the kind we want. If so, increment count.
if (object_sector = target_sector) and (object_owner = sys_long_Player_ID) and (object_general_type = target_design_type) then
set total_count := total_count + 1
endif

// --- If its a unit group, count all the units as cargo.
if (Sys_Get_Space_Object_Type(object_id) = SPACE_OBJECT_TYPE_UNITGROUP) then
set total_count := total_count + Count_Units_In_Cargo(target_design_type, object_id)
endif
endfor
endif

return total_count
end

Anyone is free to use any part of this code in their mods.

» Vous devez vous identifier ou créer un compte pour écrire des commentaires
Image de Captain Kwok
Mod Designer

Re: Unit Groups and AI

Soumis par Captain Kwok le Jeu, 2007-04-26 07:46

I'm glad it worked out. I had used a variation on my suggestion to return the type of unitgroup in order to give it orders, but I hadn't had the opportunity to see if it actually worked as intended.

-----

Space Empires Depot | SE:V Balance Mod

» Vous devez vous identifier ou créer un compte pour écrire des commentaires
Mod Designer

Re: Unit Groups and AI

Soumis par Gideon le Jeu, 2007-04-26 11:40

Cool, I'm using this as part of a separate build queue for units, so the AI builds them more often and efficiently.

» Vous devez vous identifier ou créer un compte pour écrire des commentaires

Options d'affichage des commentaires

Sélectionnez la méthode d'affichage des commentaires que vous préférez, puis cliquez sur "Sauvegarder les paramètres" pour activer vos changements.

Now on STEAM

Now on STEAM!Space Empires V via STEAMSpace Empires IV via STEAMSTEAM online by Valve Corporation

Contenu populaire

Aujourd'hui :

  • Politic Game Crash
  • Research By Percentage SUCKS
  • Space Empires V 1.77
  • Space Empires V
  • Defensive Minister not working since SEV 1.58 and BM 1.10 - Help!

Depuis toujours :

  • Space Empires V and VI: Expansions and the Future: Tell the Company What's on Your Wish List
  • Space Empires V
  • Gritty Galaxy Fleet Clash
  • Damn Dirty Bugs/Annoyances
  • Space Empires V: General Thoughts, Observations, and Suggestions

Dernier accès :

  • Population Transport problem
  • Super Noob never played this game, Any good guides out there?
  • Ship sets and races
  • Colony vessels not automatically loading population with Balance Mod
  • How do I Mod my own ship models
(c) Strategy First, Inc. All rights reserved.