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 153 invités en ligne.

Utilisateurs en ligne

  • Faithful

Languages

  • English English
  • French French

Parcourir les archives

« Novembre 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
Accueil » news » forums » Support & Feedback » Scenarios & Mods » SE:V MODs

Sys_Resources_Divide error...

Soumis par Gideon le Sam, 2007-11-17 16:29 SE:V MODs

So, I've been wracking my brains about a problem I've been having.

In my mod, the AI builds units on planets. I've been having a pecuiliar problem with this. Namely, that it will only build satellites one at a time...EVER...

After messing with numbers, changing various things (and swearing a lot) I tracked the issue's origination to the following function:

      ITEM_TO_CONSTRUCT_UNIT_DESIGN:       
        set usage_rate := Sys_Get_Construction_Queue_Resource_Usage_Rate(queue_id)

        if (max_per_loc > 0) then
          set item_cost := Sys_Get_Vehicle_Design_Cost(item_id)
          set item_number := Sys_Max_Long(Sys_Trunc(Sys_Resources_Divide(usage_rate, item_cost)), 1)
          set item_amount := Sys_Min_Long(item_number, max_per_loc)
          return Sys_Add_Vehicle_Design_To_Construction_Queue(queue_id, item_id, item_amount)
        endif

And from there, to this:

          set item_number := Sys_Max_Long(Sys_Trunc(Sys_Resources_Divide(usage_rate, item_cost)), 1)
          set item_amount := Sys_Min_Long(item_number, max_per_loc)

However, the formula still seemed corret. I changed values, plugged various things in, and it STILL didn't work right. It would only build ONE satellite at a time.

I remembered that there is a DebugSettings.txt file, and decided to use it to track this down. This showed me the problem.

Here is the bit from above:

Script_AI_Construction.txt(0787):             Case ((item_type(long[3])))
Script_AI_Construction.txt(0809):               long[3]: TRUE
Script_AI_Construction.txt(0832):             Call Sys_Get_Construction_Queue_Resource_Usage_Rate(long[2870])
Script_AI_Construction.txt(0832):             Set usage_rate([]) := resources[(5,060, 5,060, 5,060)]
Script_AI_Construction.txt(0834):             long[200] > long[0]  = boolean[TRUE]
Script_AI_Construction.txt(0834):             If ((max_per_loc(long[200]) > long[0])) = TRUE
Script_AI_Construction.txt(0835):             Call Sys_Get_Vehicle_Design_Cost(long[6])
Script_AI_Construction.txt(0835):             Set item_cost([]) := resources[(750, 0, 100)]
Script_AI_Construction.txt(0836):             Call Sys_Resources_Divide(resources[(5,060, 5,060, 5,060)], resources[(750, 0, 100)])
Script_AI_Construction.txt(0836):             Call Sys_Trunc(real[0])
Script_AI_Construction.txt(0836):             Call Sys_Max_Long(long[0], long[1])
Script_AI_Construction.txt(0836):             Set item_number(long[0]) := long[1]
Script_AI_Construction.txt(0837):             Call Sys_Min_Long(long[1], long[200])
Script_AI_Construction.txt(0837):             Set item_amount(long[0]) := long[1]
Script_AI_Construction.txt(0838):             Call Sys_Add_Vehicle_Design_To_Construction_Queue(long[2870], long[6], long[1])
Script_AI_Construction.txt(0838):             Return boolean[TRUE]

And zoomed in on the specific culperate:

Script_AI_Construction.txt(0836):             Call Sys_Resources_Divide(resources[(5,060, 5,060, 5,060)], resources[(750, 0, 100)])
Script_AI_Construction.txt(0836):             Call Sys_Trunc(real[0])
Script_AI_Construction.txt(0836):             Call Sys_Max_Long(long[0], long[1])

You see, it seems that if you use Sys_Resources_Divide, and any of the resource values in either of the operators is zero, then Sys_Resources_Divide will always return zero. ALWAYS...

After changing the small satellite (the vehicle size being used for this experiment) to have an organics value of 1, the above culperate became:

Script_AI_Construction.txt(0836):             Call Sys_Resources_Divide(resources[(5,060, 5,060, 5,060)], resources[(750, 1, 100)])
Script_AI_Construction.txt(0836):             Call Sys_Trunc(real[6.74666656995213])
Script_AI_Construction.txt(0836):             Call Sys_Max_Long(long[6], long[1])

And so returned a correct number of constructions of 6.

The lessons:

First, if any of the values going in to Sys_Resources_Divide are zero, it will always return zero. It will not default to another resource value in the resources variable, ignoring the division by zero.

Second, until this error is corrected, make sure everything you do that is used in a Sys_Resources_Divide has a resource value of at least 1 in each resource.

"Only by being constantly at war with evil in all things, including yourself, can you truely know peace."
Download my mod here: GidMod

‹ Custom Unit Types What about creating asteroids... ›
» 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 Dock suggestion
  • Star Trek Trailers.....
  • Balance Mod v1.15 Available!
  • drone combat?!

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 :

  • Solar Collector Base please?
  • Colony Type
  • planet VII
  • BM 1.05+?
  • Way To Points?
(c) Strategy First, Inc. All rights reserved.