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 3 utilisateurs et 163 invités en ligne.

Utilisateurs en ligne

  • Pham Nuwen
  • crazydog
  • Sanderlee

Languages

  • English English
  • French French

Parcourir les archives

« Juillet 2008  
Lu Ma Me Je Ve Sa Di
  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

AI Script, planet max population capacity (or "Earth that was could no longer sustain our numbers, we were so many.")

Soumis par Gideon le Mar, 2007-11-06 12:57

I was rather surprised to find out that the AI script has no system function to get the maximum population capcity for a planet. So, I made my own. I hope someone finds this useful.

First, I added these constants to Script_AI_GlobalConstants_General.txt:


  AI_PLANET_SIZE_TINY:                                      string    := "Tiny"
  AI_PLANET_SIZE_SMALL:                                     string    := "Small"
  AI_PLANET_SIZE_MEDIUM:                                    string    := "Medium"
  AI_PLANET_SIZE_LARGE:                                     string    := "Large"
  AI_PLANET_SIZE_HUGE:                                      string    := "Huge"
  AI_PLANET_SIZE_RING:                                      string    := "Ringworld"
  AI_PLANET_SIZE_SPHERE:                                    string    := "Sphereworld"

  AI_PLANET_POP_TINY:                                       long      := 500
  AI_PLANET_POP_SMALL:                                      long      := 1000
  AI_PLANET_POP_MEDIUM:                                     long      := 2000
  AI_PLANET_POP_LARGE:                                      long      := 4000
  AI_PLANET_POP_HUGE:                                       long      := 8000
  AI_PLANET_POP_RING:                                       long      := 32000
  AI_PLANET_POP_SPHERE:                                     long      := 64000

  AI_PLANET_POP_TINY_DOMED:                                 long      := 125
  AI_PLANET_POP_SMALL_DOMED:                                long      := 250
  AI_PLANET_POP_MEDIUM_DOMED:                               long      := 500
  AI_PLANET_POP_LARGE_DOMED:                                long      := 1000
  AI_PLANET_POP_HUGE_DOMED:                                 long      := 2000
  AI_PLANET_POP_RING_DOMED:                                 long      := 8000
  AI_PLANET_POP_SPHERE_DOMED:                               long      := 16000


If you use non-default population maximums, or there are any non-default planet sizes in your game, then you should adjust the above constants accordingly.

Then all I had to do was add the following function to whatever script file I wanted to call it from:


//------------------------------------------------------------------------
// Planet_Max_Population
//------------------------------------------------------------------------
function Planet_Max_Population returns long
params
  planet_id:         long
vars
  planet_size:       string
  is_domed:          boolean
  planet_max_pop:    long

begin
  set planet_size := Sys_Get_Planet_Size(planet_id)
  set is_domed := Is_Colony_Domed(planet_id)
  set planet_max_pop := 0

  if is_domed then
    case planet_size
      AI_PLANET_SIZE_TINY:
        set planet_max_pop := AI_PLANET_POP_TINY_DOMED
      AI_PLANET_SIZE_SMALL:
        set planet_max_pop := AI_PLANET_POP_SMALL_DOMED
      AI_PLANET_SIZE_MEDIUM:
        set planet_max_pop := AI_PLANET_POP_MEDIUM_DOMED
      AI_PLANET_SIZE_LARGE:
        set planet_max_pop := AI_PLANET_POP_LARGE_DOMED
      AI_PLANET_SIZE_HUGE:
        set planet_max_pop := AI_PLANET_POP_HUGE_DOMED
      AI_PLANET_SIZE_RING:
        set planet_max_pop := AI_PLANET_POP_RING_DOMED
      AI_PLANET_SIZE_SPHERE:
        set planet_max_pop := AI_PLANET_POP_SPHERE_DOMED
    endcase
  else
    case planet_size
      AI_PLANET_SIZE_TINY:
        set planet_max_pop := AI_PLANET_POP_TINY
      AI_PLANET_SIZE_SMALL:
        set planet_max_pop := AI_PLANET_POP_SMALL
      AI_PLANET_SIZE_MEDIUM:
        set planet_max_pop := AI_PLANET_POP_MEDIUM
      AI_PLANET_SIZE_LARGE:
        set planet_max_pop := AI_PLANET_POP_LARGE
      AI_PLANET_SIZE_HUGE:
        set planet_max_pop := AI_PLANET_POP_HUGE
      AI_PLANET_SIZE_RING:
        set planet_max_pop := AI_PLANET_POP_RING
      AI_PLANET_SIZE_SPHERE:
        set planet_max_pop := AI_PLANET_POP_SPHERE
    endcase
  endif

  return planet_max_pop
end


If you have any non-default planet sizes in your game, then you should make a new case entry for them. Be sure to add one for domed and one for not, and don't forget to have updated your list of constants.

When you feed this function the ID of a planet you want to know the max population of, it spits back the approriate number. The function Is_Colony_Domed() is explained in a previous blog entry. Note that if a planet does not have a colony on it, Is_Colony_Domed() returns FALSE (un-domed).

I've attached a .txt file with the above code, as the formatting will be better in it.

Good hunting!


---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
PlanetMaxPop.txt3.4 Ko
» Le blogue de Gideon | Vous devez vous identifier ou créer un compte pour écrire des commentaires

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
  • Space Empires V 1.74
  • Governmet mod/patch/addon
  • Tweaking the planet art without going all the way to FQM
  • Shipsets, Empires, and dead AIs

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 :

  • Does the latest patch remember fogged colonies?
  • Troubles with multiplayer SE-5
  • Less than Minimum # of computer players
  • New Dark Nova game on PBW
  • Disco=Stu VS. UnderLord
(c) Strategy First, Inc. All rights reserved.