Accueil Crush your enemies... and create an EMPIRE!!! Space Empires V -- BUY NOW!!!

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 1 utilisateur et 178 invités en ligne.

Utilisateurs en ligne

  • Blubel

Languages

  • English English
  • French French

Parcourir les archives

« October 2008  
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 » blogs » Le blogue de Gideon

Domed colonies in the AI script (or "Is there air?!? You don't know!")

Soumis par Gideon le Mer, 2007-10-31 17:25

A while back I found that I needed to detect whether a colony is domed. After sifting through the docs for a while, I realized that there is no way to directly check this. The function Sys_Is_Planet_Breathable() checks the planet against your Empire's primary race, but doesn't take in to account whether a colony is actually domed.

I created a script function that has since served me very well in many other script files. I thought I would post it here in case anyone wants to use or modify it themselves. I've also attached a .txt file with this information, as it might be hard to read here due to formatting.

First, I put this in the Script_AI_GlobalConstants_General.txt file:


  AI_ATMOSPHERE_TYPE_NONE:                                  string    := "None"
  AI_ATMOSPHERE_TYPE_OXYGEN:                                string    := "Oxygen"
  AI_ATMOSPHERE_TYPE_METHANE:                               string    := "Methane"
  AI_ATMOSPHERE_TYPE_HYDROGEN:                              string    := "Hydrogen"
  AI_ATMOSPHERE_TYPE_CARBON_DIOXIDE:                        string    := "Carbon Dioxide"

  AI_ATMOSPHERE_NUMBER_NONE:                                long      := 1
  AI_ATMOSPHERE_NUMBER_OXYGEN:                              long      := 2
  AI_ATMOSPHERE_NUMBER_METHANE:                             long      := 3
  AI_ATMOSPHERE_NUMBER_HYDROGEN:                            long      := 4
  AI_ATMOSPHERE_NUMBER_CARBON_DIOXIDE:                      long      := 5


Next, I made the following function, which can be placed in other Script_AI files:

//------------------------------------------------------------------------
// Is_Colony_Domed
//------------------------------------------------------------------------
function Is_Colony_Domed returns boolean
params
  planet_id:                   long
vars
  is_domed:                    boolean
  cargo_item_count:            long
  cargo_index:                 long
  cargo_item_id:               long
  cargo_item_type:             long
  planet_atmosphere:           long
  population_atmo:             string
  atmosphere_number:           long

begin
  set is_domed := FALSE
  set cargo_item_count := Sys_Get_Space_Object_Cargo_Item_Count(planet_id)
  set planet_atmosphere := Sys_Get_Planet_Atmosphere_Type(planet_id)

  if (cargo_item_count > 0) and (Sys_Get_Space_Object_Cargo_Item_Type_Count(planet_id, CARGO_ITEM_TYPE_POPULATION, "") > 0) then
    set cargo_index := 0

    loop
      set cargo_index := cargo_index + 1
      set cargo_item_id := Sys_Get_Space_Object_Cargo_Item_ID(planet_id, cargo_index)
      set cargo_item_type := Sys_Get_Space_Object_Cargo_Item_Type(planet_id, cargo_item_id)

      if (cargo_item_type = CARGO_ITEM_TYPE_POPULATION) then
        set population_atmo := Sys_Get_Space_Object_Cargo_Item_Population_Atmosphere_Breathed(planet_id,cargo_item_id)
        case population_atmo
          AI_ATMOSPHERE_TYPE_NONE:
            set atmosphere_number := AI_ATMOSPHERE_NUMBER_NONE
          AI_ATMOSPHERE_TYPE_OXYGEN:
            set atmosphere_number := AI_ATMOSPHERE_NUMBER_OXYGEN
          AI_ATMOSPHERE_TYPE_METHANE:
            set atmosphere_number := AI_ATMOSPHERE_NUMBER_METHANE
          AI_ATMOSPHERE_TYPE_HYDROGEN:
            set atmosphere_number := AI_ATMOSPHERE_NUMBER_HYDROGEN
          AI_ATMOSPHERE_TYPE_CARBON_DIOXIDE:
            set atmosphere_number := AI_ATMOSPHERE_NUMBER_CARBON_DIOXIDE
        endcase
      else
        set atmosphere_number := 0
      endif

      if (atmosphere_number <> planet_atmosphere) and (atmosphere_number > 0) then
        set is_domed := TRUE
      endif
    exitwhen (cargo_index >= cargo_item_count) or is_domed
    endloop
  endif

  return is_domed
end

This goes through all the population on a planet, and checks what they breathe against the planet's atmosphere. If any one of the population does not breathe the planet's atmosphere, it returns TRUE. Otherwise, it returns FALSE.

Hope this helps.

EDIT: It should also be noted that if the planet has no population (no colony) then it returns FALSE (un-domed).


---Permission is granted to duplicate, whole or in part, and/or modify any of the code here for any purposes that does not violate Malfador Machination's intellectual property rights. Credit to the author of the specific code here is not required.---

Fichier attachéTaille
Is_Colony_Domed.txt2.94 Ko
» Le blogue de Gideon | 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: Domed colonies in the AI script (or "Is there air?!? You do

Soumis par the_weregamer le Mer, 2008-06-11 20:46

This is exactly something I'll need if I'm to work on making the Pop Transport minister less brain-dead.

I find myself torn over doing this, because I am on a budget for home computer time (my wife wants some of my attention, heh) and I code all day at work. Perhaps you would be interested in turning the algorithm I worked out while waiting for compiles at work, into working code? I posted my thoughts in the main forum, including the algorithm outline. One of the big problems I can see is that I'll need to know a lot more about the system-supplied functions to be able to answer exactly the sort of question you have here.

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

Re: Domed colonies in the AI script (or "Is there air?!? You do

Soumis par Captain Kwok le Mer, 2008-06-11 21:18

There's actually a built-in script function added in the latest patch, Sys_Is_Planet_Domed, that returns whether or not a planet is domed.


Space Empires Depot | SE:V Balance Mod

» 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 :

  • Research By Percentage SUCKS
  • More organic stuff is needed.
  • Nebula Storm
  • No Point Defence in Technology in Balance mod
  • Space Dock suggestion

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 :

  • evil gate guards
  • CSM vs Torpedos
  • How to Design Tech Trees ?
  • Robotech Shipset! (For Someone Else)
  • Invisible Warp Points/Variable Sensors
(c) Strategy First, Inc. All rights reserved.