Author Topic: Empty facilities and secret projects, more technologies  (Read 5507 times)

0 Members and 1 Guest are viewing this topic.

Offline Mart

Empty facilities and secret projects, more technologies
« on: January 03, 2015, 12:04:29 PM »
There were maybe some discussions before, but I could not find any good references.
What are the findings about these unused slots: empty facility and empty secret projet?

Empty facility - can be enabled, and the only benefit/use in-game is its maintenance.
For a human player an incentive to build it might be negative maintenance, thus giving you EC.
AI does not seem to recognize it, so far I could not get AI to build such facilities.

Empty secret project - here maybe the only benefit is score points after the game. Maintenance does not work, since SP has it always 0.

Anyone noticed anything else?

Code: [Select]
; Base Facilities
;
; Name, Cost, Maint, Preq, Free, Effect, (for SPs only) ai-fight, ai-mil, ai-tech, ai-infra, ai-colonize
;
; Name  = Name of facility type
; Cost  = Construction cost in minerals (x Minerals multiplier in RULES)
; Maint = Maintenance cost in energy per turn
; Preq  = Technology prerequisite (see TECHNOLOGY)
; Free  = No longer supported.
; Effect= Brief description of effect
; ai-fight=Corresponds with AI 'aggressiveness' setting of -1, 0, or 1
; ai-mil= military value
; ai-tech= advance-of-knowledge value
; ai-infra= infrastructure value
; ai-colonize= colonization value
...
Empty Facility 42,            10, 2, Disable, Disable,  Do Not Build Me
...
Empty Secret Project 38,      20, 0, Disable, Disable,  End of Real Secret Projects,     0, 0, 2, 2, 2,
...
« Last Edit: March 27, 2015, 01:53:39 AM by Mart »

Offline Yitzi

Re: Empty facilities and secret projects
« Reply #1 on: January 04, 2015, 12:57:19 AM »
.exe modding can be used to give them effects a lot more easily than creating entirely new facilities/projects...

Offline vonbach

Re: Empty facilities and secret projects
« Reply #2 on: February 03, 2015, 09:59:37 PM »
Hi there can you use the empty base facilities to make faction only facilities?
I've never tried it before thanks.

Offline Yitzi

Re: Empty facilities and secret projects
« Reply #3 on: February 05, 2015, 05:20:36 AM »
Hi there can you use the empty base facilities to make faction only facilities?
I've never tried it before thanks.

If effects were given to those facilities, I think a "disable" prerequisite plus free facility (as a faction) would indeed make a faction-only facility...

Offline vonbach

Re: Empty facilities and secret projects
« Reply #4 on: February 05, 2015, 12:28:23 PM »
Thanks maybe I'll try it sometime.

Offline Mart

Re: Empty facilities and secret projects
« Reply #5 on: March 24, 2015, 12:44:46 AM »
R
.exe modding can be used to give them effects a lot more easily than creating entirely new facilities/projects...
How difficult would that be?
Is there a switch command for this? The effects are clearly hardcoded.
Any chance this would be an option for Patch 3.5 or 3.6?
If possible in the near future, it would be good to think of what effects could be added.
Or even more - any chance for creating some "simple parser" which would assign effects based on info in alphax.txt, something like additional digit is after the landmarks in 3.4?

Offline Yitzi

Re: Empty facilities and secret projects
« Reply #6 on: March 24, 2015, 01:49:00 AM »
R
.exe modding can be used to give them effects a lot more easily than creating entirely new facilities/projects...
How difficult would that be?

Depends on what you want the effect to be.

Quote
Is there a switch command for this? The effects are clearly hardcoded.

No, but one could be added for certain facilities.

Quote
Any chance this would be an option for Patch 3.5 or 3.6?

For 3.5, no.  For 3.6, if it's nominated (once that opens up) and gets enough votes.

Quote
If possible in the near future, it would be good to think of what effects could be added.

I've already come up with one: A "spaceport" could be added to have the satellite-related effects of the aerospace complex, and then an option added to make an aerospace complex either count as a spaceport as well (as it does now), not count (in which case it would presumably be renamed to an "airstrip" or the like), or have a built (or faction bonus) aerospace complex count but have the Cloudbase Academy not count.

That's actually on my list, fairly low down, but if nominated it could be raised up.

Quote
Or even more - any chance for creating some "simple parser" which would assign effects based on info in alphax.txt, something like additional digit is after the landmarks in 3.4?

If done with flags and small-number entries (e.g. 1 for +25%, 2 for +50%), it could be done, but would be slightly tricky, and would require a list of the effects to be enabled, and there's a limit on how many effects could be included.  A true parser, such as is used for faction files, would be harder yet, and would mean more limits on the number of effects per facility, but would allow a higher number of allowed effects total.

Offline Mart

Re: Empty facilities and secret projects
« Reply #7 on: March 24, 2015, 02:43:26 AM »
There is like over 20 empty facility slots and over 20 empty SP slots. Being able to mod new items there would be a major game upgrade.

How about more technologies?
Is there a room/possibility in exe to add some more tech slots? Maybe this question was somewhere already. Some techs have their position maybe hardcoded, like Transcendent Thought (?). Some years ago, I remember something about not being able to have more than these 89 tech slots. But maybe this was not right.
===
And maybe I would ask this:
is it, that we have only 89, cause there is a loop, that iterates only 89 times?
how is a tech stored, is it a structure? a c++ class?
I guess SMACX was written in C++, unless it was C?

Offline Yitzi

Re: Empty facilities and secret projects
« Reply #8 on: March 24, 2015, 02:26:10 PM »
How about more technologies?
Is there a room/possibility in exe to add some more tech slots? Maybe this question was somewhere already. Some techs have their position maybe hardcoded, like Transcendent Thought (?). Some years ago, I remember something about not being able to have more than these 89 tech slots. But maybe this was not right.

Adding more techs would be theoretically doable, but a fairly big job.  Best case scenario, it'd be enough to justify going up to 5.1.  Worst case, it still wouldn't be nearly as much as allowing more than 7 factions, but would be the next biggest thing.

Quote
===
And maybe I would ask this:
is it, that we have only 89, cause there is a loop, that iterates only 89 times?
how is a tech stored, is it a structure? a c++ class?
I guess SMACX was written in C++, unless it was C?

It was written in C++, but it's stored as an array, and adding to arrays in assembly gets difficult.  A loop would be easy to change; it's the array that makes it tough.

Offline Mart

Re: Empty facilities and secret projects
« Reply #9 on: March 26, 2015, 12:04:03 PM »
...
It was written in C++, but it's stored as an array, and adding to arrays in assembly gets difficult.  A loop would be easy to change; it's the array that makes it tough.
So this array is part of the (?) main function, then it is created as a part of stack memory? and then other variables of the stack, created 'after' by main function, would need change of (?) reference address to them (?)
and this is difficult - like making sure, that everywhere in the code there is no mistake in this?

Offline Yitzi

Re: Empty facilities and secret projects
« Reply #10 on: March 26, 2015, 07:58:37 PM »
...
It was written in C++, but it's stored as an array, and adding to arrays in assembly gets difficult.  A loop would be easy to change; it's the array that makes it tough.
So this array is part of the (?) main function, then it is created as a part of stack memory? and then other variables of the stack, created 'after' by main function, would need change of (?) reference address to them (?)
and this is difficult - like making sure, that everywhere in the code there is no mistake in this?

The array is a global variable, and one of the startup/new game functions loads it from alphax.txt.  In order to add to it, I would need to either find a way to make it take up less room (if, for instance, something is stored as a long but only needs a char) and change everything to fit that, or otherwise allocate heap memory and put it there (and change everything to reference that).

Offline Mart

Re: Empty facilities and secret projects
« Reply #11 on: March 26, 2015, 09:35:59 PM »
I do not know enough about compiled c++ programs. Not sure, which way is easier.
There are 9 fields, that are shortly described, with my guess of variable:

Name, text - string? declared length?
id, text too, short name, declared length?
ai-mil, positive integer
ai-tech, positive integer
ai-infra, positive integer
ai-colonize, positive integer
preq(1), text, short name, declared length?
preq(2), text, short name, declared length?
flags - bits, but 9 of them...

The strings lengths might be decreased. The longest name is :"Advanced Military Algorithms" which is 28 characters.
Now, I don't know what they have in the code, but if it is more than 29-30, then it could be set at 29 chars (1 byte, or 2 for string termination?)
short names seem to be 7 characters (8 with string termination?)
ai-xxx, could be set to unsigned char (should be 1-byte, afaik), if they are not that. And maybe regular int of length 4-bytes.
Flags... if SMACX can use std::bitset, would use only 9 bits per new tech.

Just for modders, one would need to point to limited name lengths, or the array would not load techs properly.

Offline Yitzi

Re: Empty facilities and secret projects
« Reply #12 on: March 26, 2015, 10:45:21 PM »
I do not know enough about compiled c++ programs. Not sure, which way is easier.
There are 9 fields, that are shortly described, with my guess of variable:

Name, text - string? declared length?

I think the string is stored in heap memory, with only a pointer in the array.

Quote
id, text too, short name, declared length?

I think it's also heap memory, but I don't remember for sure.

Quote
ai-mil, positive integer
ai-tech, positive integer
ai-infra, positive integer
ai-colonize, positive integer

I would need to check for sure, but I think it might be as a 4-byte long (probably signed).  In any case, it only needs a char or even less.

Quote
preq(1), text, short name, declared length?
preq(2), text, short name, declared length?

These are actually stored as a byte, namely the tech number, or -1 for None or -2 for Disable.  Another problem to allowing more than 128 techs, and a big one.

Quote
flags - bits, but 9 of them...

There's probably room for more.

Quote
ai-xxx, could be set to unsigned char (should be 1-byte, afaik), if they are not that. And maybe regular int of length 4-bytes.

Indeed.

Quote
Flags... if SMACX can use std::bitset, would use only 9 bits per new tech.

True, but alignment becomes an issue, and I might want to use some of those bits.

Offline Mart

Re: Empty facilities and secret projects
« Reply #13 on: March 26, 2015, 11:33:19 PM »
Pointers, so if SMACX is 32-bit app. (I guess), are pointers always 4 byte long? Or, if someone uses 64-bit operating system, the application (SMACX) makes 8 byte pointers?

Name, pointer
id, pointer
ai-mil, 1 byte (from 4)
ai-tech, 1 byte (from 4)
ai-infra, 1 byte (from 4)
ai-colonize, 1 byte (from 4)
preq(1), 1 byte, signed char?
preq(2), 1 byte, signed char?
flags - bits, 9-16 bits, don't know present length.

Roughly, present bytes per tech: 6x4 + 2 + 2 = 28 bytes

So we get 12 bytes extra from a tech. 1068/28 = 38.14 new techs.
89+38 = 127 techs total.
Is maximum of signed char/integer 127 ? Then we may have the max here.

Or, I wrong in this estimate. Like, we do not need to worry about pointers, then we actually can get more additional techs than 38.

What about this unlucky signed char.
Let's say we shift values by +2, we make it unsigned char. Then we operate in range 0 to 255.
0 - disabled
1 - none
2 - our first tech in the list
What would need to be changed in the code?
- conditions, x < 0, to x< 2, etc.
- other like: if = -2, or if != -2, or if = -1 etc.
- loops from i = 0 to total_techs to: i = 2 to total_techs; etc
... anything else?

Array indexing... big problem
Any chance we can get a c++ class to offset this indexing by 2?

Actually, how about making:
254 - none
255 - disable

253 would be index of last possible tech
then conditions would check:
i > 253, etc

Offline Yitzi

Re: Empty facilities and secret projects
« Reply #14 on: March 27, 2015, 01:06:47 AM »
Pointers, so if SMACX is 32-bit app. (I guess), are pointers always 4 byte long? Or, if someone uses 64-bit operating system, the application (SMACX) makes 8 byte pointers?

No, they're always 4 bytes long.

Quote
Name, pointer
id, pointer
ai-mil, 1 byte (from 4)
ai-tech, 1 byte (from 4)
ai-infra, 1 byte (from 4)
ai-colonize, 1 byte (from 4)
preq(1), 1 byte, signed char?
preq(2), 1 byte, signed char?
flags - bits, 9-16 bits, don't know present length.

Roughly, present bytes per tech: 6x4 + 2 + 2 = 28 bytes

So we get 12 bytes extra from a tech. 1068/28 = 38.14 new techs.
89+38 = 127 techs total.
Is maximum of signed char/integer 127 ? Then we may have the max here.

Actually, looking at it, I was mistaken: The name is stored in heap memory, but the key is stored in the array and is limited to 7 characters plus the end-of-string null.  Also, I was mistaken; the prerequisites, while they only need bytes, are stored as long ints (there are other places where they're stored as short ints, and in the RULES section I already changed them to bytes, but that can of course be reverted.)  The flags also seem to have a full 32 bits reserved for them, despite not needing nearly that many.  There's also apparently one unused value, probably intended for ai-fight.  The present bytes per tech is therefore 4+8+5X4+2X4+4=44, and even if tech codes are kept as short ints, it could be reduced to 4+8+4+2X2+2=22, although it might be better to increase it to 24 to leave room for more variables.  Still, that would be a large boost, and apparently the cap due to tech-code size isn't 127 but rather 33,535, which should be far more than might be used.

So it'd be a lot easier than I'd first thought...but changing all the references still means it's not trivial.

Quote
What about this unlucky signed char.
Let's say we shift values by +2, we make it unsigned char. Then we operate in range 0 to 255.
0 - disabled
1 - none
2 - our first tech in the list
What would need to be changed in the code?

Apparently it's not an issue, but if it were, it would actually be easier to just have it range from -2 to 253.  I think that wouldn't be too hard (as I think the relevant test is always done via a particular function), but I'm not certain (there might be exceptions).

Quote
Array indexing... big problem
Any chance we can get a c++ class to offset this indexing by 2?

I would have no idea how to add a c++ class to assembly, or even if it could be feasibly done.

 

* User

Welcome, Guest. Please login or register.

Login with username, password and session length

Select language:

* Community poll

SMAC v.4 SMAX v.2 (or previous versions)
-=-
24 (7%)
XP Compatibility patch
-=-
9 (2%)
Gog version for Windows
-=-
103 (32%)
Scient (unofficial) patch
-=-
40 (12%)
Kyrub's latest patch
-=-
14 (4%)
Yitzi's latest patch
-=-
89 (28%)
AC for Mac
-=-
3 (0%)
AC for Linux
-=-
6 (1%)
Gog version for Mac
-=-
10 (3%)
No patch
-=-
16 (5%)
Total Members Voted: 314
AC2 Wiki Logo
-click pic for wik-

* Random quote

And here we tinker with metal, to try to give it a kind of life, and suffer those who would scoff at our efforts. But who's to say that, if intelligence had evolved in some other form in past millennia, the ancestors of these beings would not now scoff at the idea of intelligence residing within meat?
~Prime Function Aki Zeta-5 'The Fallacies of Self-Awareness'

* Select your theme

*
Templates: 5: index (default), PortaMx/Mainindex (default), PortaMx/Frames (default), Display (default), GenericControls (default).
Sub templates: 8: init, html_above, body_above, portamx_above, main, portamx_below, body_below, html_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 45 - 1228KB. (show)
Queries used: 37.

[Show Queries]