Alpha Centauri 2

Sid Meier's Alpha Centauri & Alien Crossfire => Modding => Topic started by: Mart on January 03, 2015, 12:04:29 PM

Title: Empty facilities and secret projects, more technologies
Post by: Mart 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,
...
Title: Re: Empty facilities and secret projects
Post by: Yitzi 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...
Title: Re: Empty facilities and secret projects
Post by: vonbach 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.
Title: Re: Empty facilities and secret projects
Post by: Yitzi 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...
Title: Re: Empty facilities and secret projects
Post by: vonbach on February 05, 2015, 12:28:23 PM
Thanks maybe I'll try it sometime.
Title: Re: Empty facilities and secret projects
Post by: Mart 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?
Title: Re: Empty facilities and secret projects
Post by: Yitzi 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.
Title: Re: Empty facilities and secret projects
Post by: Mart 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?
Title: Re: Empty facilities and secret projects
Post by: Yitzi 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.
Title: Re: Empty facilities and secret projects
Post by: Mart 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?
Title: Re: Empty facilities and secret projects
Post by: Yitzi 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).
Title: Re: Empty facilities and secret projects
Post by: Mart 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.
Title: Re: Empty facilities and secret projects
Post by: Yitzi 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.
Title: Re: Empty facilities and secret projects
Post by: Mart 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
Title: Re: Empty facilities and secret projects
Post by: Yitzi 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.
Title: Re: Empty facilities and secret projects, more technologies
Post by: Mart on March 27, 2015, 02:09:11 AM
In this case, with no extension of memory allocated for technology array, we get:
89*44/24 = 163.17
163 technologies.
...but changing all the references still means it's not trivial.
You mean references to the array data only?
With extension of memory for the array, reference change would be needed for everything "after" the array. Meaning even much more work?

Title: Re: Empty facilities and secret projects, more technologies
Post by: Yitzi on March 27, 2015, 02:27:48 AM
In this case, with no extension of memory allocated for technology array, we get:
89*44/24 = 163.17
163 technologies.
...but changing all the references still means it's not trivial.
You mean references to the array data only?
With extension of memory for the array, reference change would be needed for everything "after" the array. Meaning even much more work?

To actually extend the memory and shift everything subsequent over would indeed mean that, which is why there's absolutely no way it's happening (at least not without decompiled code to modify).  If the total array size is to be extended, it will be moved completely, almost certainly to dynamically allocated memory.
Title: Re: Empty facilities and secret projects, more technologies
Post by: gwillybj on March 27, 2015, 12:09:54 PM
163 technologies.
:o

edit: Instead of a small Pine, Deirdre would have a Sequoia!
Title: Re: Empty facilities and secret projects, more technologies
Post by: Mart on March 28, 2015, 03:41:55 PM
SMACX can be enhanced in so many ways, but in order to have something significant, like expanding gamepley experience, these would be on the top of the list, I think:
- more technologies
- more facilities, with more effects, also optionally more than 64 of them (though now, there seem to 69 slots).
- more SP, like facilities, new effects, optionally more than 64. (now 64 slots), but needs to be checked.
- more chassis types
- more move domains: combined/selective like: "ocean shelf and flat terrain only" for true hooverboats, etc.
- play with more than 7 factions.

First 3 would be already a lot. Having expended tech tree with new facilities and SPs, that would be like SMACX 1.5. Having more chassis is like close to SMACX 2.0
Just added more than 7 factions, ... forgot this one.
Title: Re: Empty facilities and secret projects, more technologies
Post by: Yitzi on March 29, 2015, 12:57:35 PM
SMACX can be enhanced in so many ways, but in order to have something significant, like expanding gamepley experience, these would be on the top of the list, I think:
- more technologies
- more facilities, with more effects, also optionally more than 64 of them (though now, there seem to 69 slots).

More than 64 would probably mean moving to heap memory, especially if you want a reasonable degree of effect customizability (as that increases the space taken), and those last 5 slots are for satellites and stockpile energy.

Quote
- more SP, like facilities, new effects, optionally more than 64. (now 64 slots), but needs to be checked.
- more chassis types

These would mean moving to heap memory.

Quote
- more move domains: combined/selective like: "ocean shelf and flat terrain only" for true hooverboats, etc.

That should be more doable, though somewhat tricky.

Quote
- play with more than 7 factions.

That would be extremely difficult.
Title: Re: Empty facilities and secret projects, more technologies
Post by: Mart on March 30, 2015, 06:17:23 PM
- play with more than 7 factions.

That would be extremely difficult.
It looks like something for AC2 (that Firaxis or other company may want to make someday) or simply a clone game, like in public domain, or game with mod of SMACX (for the rights issue).
It was done, for example in the case of Birth of the Empires game - free available online game, that has a mod made by fans of Birth of the Federation game to that Star Trek franchise. BotE is completely new code. But this is topic for another thread.
Title: Re: Empty facilities and secret projects, more technologies
Post by: Mart on June 20, 2015, 02:37:56 AM
Trying some new things in an old mod.
So, in short, I somehow made AI to start a SP, that is empty.
I enabled it, by giving it "None" as tech requirement and setting "SP count as scenario objective" option.
The only benefit is +25 victory points in the score, but apparently, that was sufficient :)
However, I had to wait hitting end turn till 2196 for Lal to do it... And this SP is made to cost only 4 rows.

Anyway, this is something new.
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 31 - 840KB. (show)
Queries used: 17.

[Show Queries]