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

User login

  • Create new account
  • Request new password

Navigation

  • news
    • archive
    • blogs
    • books
    • forums
    • recent posts
    • groups
  • image galleries
  • projects & downloads
  • search
  • create content
  • news aggregator

Search

Who's online

There are currently 3 users and 181 guests online.

Online users

  • bighouse
  • Fyron
  • koniu

Languages

  • English English
  • French French

Browse 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    
Home » news » blogs » Gideon's blog

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

Submitted by Gideon on Wed, 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.---

AttachmentSize
Is_Colony_Domed.txt2.94 KB
» Gideon's blog | login or register to post comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

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

Submitted by the_weregamer on Wed, 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.

» login or register to post comments
Captain Kwok's picture
Mod Designer

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

Submitted by Captain Kwok on Wed, 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

» login or register to post comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Now on STEAM

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

Popular content

Today's:

  • Star Wars SEV ship set available
  • No Point Defence in Technology in Balance mod
  • Research By Percentage SUCKS
  • New Engine System
  • Space Empires V and VI: Expansions and the Future: Tell the Company What's on Your Wish List

All time:

  • 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

Last viewed:

  • Pursuit space battles
  • 1.17 Bugs and Issues
  • Colonization Levels
  • Babylon 5 Wars SEV Mod Update
  • home world start pop?
(c) Strategy First, Inc. All rights reserved.