Alpha Centauri 2

Sid Meier's Alpha Centauri & Alien Crossfire => Modding => Topic started by: Mart on December 09, 2017, 06:53:42 PM

Title: Specialists not going obsolete
Post by: Mart on December 09, 2017, 06:53:42 PM

When working on a mod, I got the idea, that specialists may never go obsolete. Initially I wanted to decrease ICS strategy effectiveness, and it was supposed to be by tweaking specialists, so player would prefer to have more workers in a base, but with many modifications, I have them around the same total yield, though rearranged.




Recently I try these settings and all specialists can never go obsolete:




Code: [Select]


#CITIZENS
Technician,       Technicians,         None,    Disable, 3, 0, 1, 0000000
Doctor,           Doctors,             None,    Disable,-2, 4, 1, 0000000
Librarian,        Librarians,          InfNet,  Disable,-1, 0, 5, 0000000
Engineer,         Engineers,           Fusion,  Disable, 2, 0, 3, 0000000
Empath,           Empathi,             CentMed, Disable, 2, 3, 0, 0000000
Thinker,          Thinkers,            MindMac, Disable,-1, 3, 3, 0000000
Transcend,        Transcendi,          AlphCen, Disable, 1, 2, 4, 0000000




First 3 have larger yield by 1, not 3-2-3, but 4-3-4 with taking into account negatives.


Technician - best energy (ops in alphax.txt)
Doctor - best psych
Librarian - best research


Engineer has the same yield of 5, but switched from 3-0-2 to 2-0-3.
Engineer - best energy+research combination


Next 2 have also best combinations of energy+psych and psych+research, and yields of 5.
Empath - best energy+psych combination
Thinker - best psych+research combination


And the last one, in vanila it was ultimate specialist/citizen, but now, although the highest yield of 7 (in vanila 8 .) the particular areas are always worse than some previous specialist.
Transcend - combination: 1-2-4


The reason of negative energy is to nerf energy in mid-late game.
Title: Re: Specialists not going obsolete
Post by: Geo on December 09, 2017, 10:12:46 PM
Ah, negative energy is possible. Was pondering about that the other day.
Do you know if the same counts for negative psych and labs?

Have you ever experimented if those seven 'flags' (the zeros) after each specialist are active?

Also, can drones, talents, and workers increase labs, psych, and energy?
Title: Re: Specialists not going obsolete
Post by: Mart on December 09, 2017, 11:12:32 PM
Let me check negative psych and research, but I think it was working deducting points.
The only problem is that on the button in the game there is the plus sign, so the doctor shows +-2 for example.


[Edit]
Yes, negatives psych and research are deducted too. It works, though I saw -4 as -3 effect, not sure why.

Those zeros, I remember trying it, but there was no effect, that I would notice. There was more about them in the SMAC Academy on CGN?
Title: Re: Specialists not going obsolete
Post by: Buster's Uncle on December 10, 2017, 12:41:50 AM
I made up negative energy icons for scient about a million years ago, but he never got around to implementing whatever he was planning to do with it.  -Maybe he could be persuaded if many ask...
Title: Re: Specialists not going obsolete
Post by: scient on December 10, 2017, 06:10:26 AM
Do you still have the newicons.pcx with the negative icons? I thought I saved it, but I couldn't find it in my archives. Unlike a few years ago, I now have a much deeper understanding of how the internals all piece together. So let's see if we can do this!  :)

The exact location where the pcx and the resource icons are parsed in is as follows (using v2.0 of SMACX exe):
void __cdecl load_icons() : 0x454922 ; loops through 8 times calling 'Buffer::change_color' and 'Sprite::extract' for '1' to '8+'.

The sprites are then stored at this offset in an array: 0x007A72A0. This is a 4 x 8 array containing nutrients, minerals and energy. The good news is, the part of the array at the end is unused. The loop parses in a fourth resource that doesn't exist after minerals. So we have memory to store up to 8 sprites! I don't think tweaking the references should be too hard.

Title: Re: Specialists not going obsolete
Post by: scient on December 10, 2017, 06:50:45 AM
I tweaked the offsets to get the legacy resource icons loaded. Adding in the negatives will require some additional changes in the BaseWin drawing functions but I think should be doable.
Title: Re: Specialists not going obsolete
Post by: Buster's Uncle on December 10, 2017, 03:57:31 PM
I'll find or make a .pcx copy later when I'm awake.
Title: Re: Specialists not going obsolete
Post by: scient on December 10, 2017, 07:10:16 PM
Sounds good. Are negative resources impactful all the way up to -8+? If we need 3x8 Sprites, then there won't be enough in the existing memory location. We have up to 8 additional icons for all 3 resources so really only 2 additional per resource. I'll see if I can find a memory location that would support an additional 3x8 sprites for just negatives.
Title: Re: Specialists not going obsolete
Post by: Buster's Uncle on December 10, 2017, 08:25:07 PM
That what you asked for at the time, I think.   They're placed side by side, but I could certainly do up a copy with those moved up to replace the legacy resource icons above that you enabled.  You can, of course, only use as many as needed...
Title: Re: Specialists not going obsolete
Post by: scient on December 10, 2017, 08:54:09 PM
Let me do some more investigation into negative resources. I would say putting them above would work as well. You could just shift legacy drone, talent and citizen icons over or something.
Title: Re: Specialists not going obsolete
Post by: Buster's Uncle on December 10, 2017, 09:04:21 PM
Here's what you had me do back in March of 09.  Let me know if you need changes...
Title: Re: Specialists not going obsolete
Post by: scient on December 11, 2017, 02:05:14 AM
That should work. I think I found some space I could load the Sprites into. I'm digging a bit more into negative resource calculation. What happens when you click on a base:

BaseWin::on_redraw() =>
BaseWin::draw_farm(int) =>
resource_yield(int,int,int,int,int) => called for each tile with resources for base
crop_yield(int,int,int,int,int) ; mine_yield(int,int,int,int,int) ; energy_yield(int,int,int,int,int);

Each of the individual yield values get stored into an array inside BaseWin::draw_farm. Then there is a bounds check to see if it is < 0, set to 0 or > 7, set to 7. It then uses this zero offset value to pull up a Sprite for the particular resource ('1', '8+').  I'll have think about the best way to stitch them all together, whether 2 x 3 x 8 or 3 x 16 array.

Unlike before, I'm pretty certain I can figure out how to get this all working. So hopefully I can provide some patch data to roll into Yitzi or whoever's patch. :)

On another note, inside newicons.pcx I've highlighted the only areas the game parses.

Top left: It looks like while it loads a 16 Sprite array, it only references the yellow shield (0,1) inside BaseWin::draw_supported(BaseWin *this, int). Might be possible to steal some of this memory for negative resources.
 
Null resource icon: If yield for a particular tile equals zero. Used by BaseWin::draw_farm.

Peace symbols: Used by BaseWin::draw_supported, adds icon badge to units in bottom left panel if flag is met.

Resource icons: Used by BaseWin::draw_farm.

Citizen, Specialist "cursors": These are considered cursors rather than icons internally. Used in a couple different places. These are broken down into two groups of female/male citizens (talent, worker, drone 1, drone 2; 2x4x2=16 total) and specialists (2x7=14 total). Alien Sprites are in aliencit.pcx.

The rest is unused and never even touched by the game.


Title: Re: Specialists not going obsolete
Post by: scient on December 11, 2017, 07:20:35 AM
There is an issue with the modified PCX alpha layer compared to the original. I have no idea about the creation of PCX files, so I'll leave that for someone with more modding experience to work out. Otherwise, all the logic is there and working from what I can tell. I don't have a saved game with negative resources, so I just forced a few of the yield values to return negative for the screenshot.

I had to shift around some Texture, Sprite, and CaviarData global memory locations along with disabling the allocation of unused Sprites. The unused Sprites were allocated, but never actually loaded with Sprite data or referenced. There is one Sprite that is referenced, but it is all zeroed data so effectively does nothing. There are quite a few modified bytes to get this to work (289 bytes, in 51 different locations), but most are just shifting of addresses so I could expand the resource icon Sprite vector variable. This wasn't put through extensive testing, but everything should be working okay. The only code area that had more significant patching done to it is BaseWin::draw_farm. I redirected the offset calculation logic into some dead code space formally used by one of the unused Sprite allocations.

The attached exe is SMACX v2.0 binary without any other patches applied.  Yitzi is welcome to roll this into his binary (or anyone else for that matter with credit attributed). I haven't looked to see if my Sprite optimizations would interfere with the changes he has done.

I know this has been a requested mod for some time. While I haven't done much in the way of actual fixes or mods for the community in many years, I've made significant progress with my analysis of the SMACX binary. So this is an early holiday present for everyone with hopefully more things to come in the future!  :D
Title: Re: Specialists not going obsolete
Post by: Buster's Uncle on December 11, 2017, 01:13:44 PM
This is the 'blue box around my bases' problem.  I know what I did wrong this time.  I'll have to dig up my copy of Photoshop CS, and I'll have a fixed copy up in a few hours.
Title: Re: Specialists not going obsolete
Post by: Mart on December 11, 2017, 07:01:10 PM
color palette problem?
Title: Re: Specialists not going obsolete
Post by: Buster's Uncle on December 11, 2017, 08:05:29 PM
Yep.  I changed a credit detail and resaved it in in GIMP - which messes up the palette.  I'll have to do some pasting in Photoshop, which handles all that under the hood.
Title: Re: Specialists not going obsolete
Post by: Buster's Uncle on December 12, 2017, 12:49:16 AM
Hmph.  Can't get Photoshop to run, but here's the unaltered original...
Title: Re: Specialists not going obsolete
Post by: scient on December 12, 2017, 01:41:37 AM
It looks like there is still an issue with this one as well. You can test using the exe in post #12.

On another note, I think I might be able to streamline the patch. I'm going to look into applying it to Yitzi's latest.
Title: Re: Specialists not going obsolete
Post by: Buster's Uncle on December 12, 2017, 01:55:41 AM
I. will. be. dipped.

Back then, I would have done it in Photoshop, which didn't have these kinds of problems.  -All I can guess is that it's something to do with you making me change the background color to pink, or this file has a different palette than the faction files, which is the one I'd load on a .pcx mod.

I can't fix this unless I can get a copy of Photoshop running, which I'm guessing I can't.  Does anyone have PS and know their way around this kind of thing a little?  I can probably talk someone through it...
Title: Re: Specialists not going obsolete
Post by: scient on December 12, 2017, 05:18:10 AM
I used photoshop to put together a version that doesn't seem to have the pink halo problem. Although, there is another issue with icon shadows I'll need to work out. I believe this is a Sprite code issue, not PCX issue.

I found a large amount of memory that is never referenced or used. Yitzi isn't using it for any of his patch as well. I'll put together a revised patch sometime later this week.
Title: Re: Specialists not going obsolete
Post by: Mart on December 12, 2017, 07:38:35 AM
Paint.net has option 'keep original palette' or something like that. But I remember once I had problems with something anyway. Few times it worked ok though.
https://www.getpaint.net/download.html (https://www.getpaint.net/download.html)
Title: Re: Specialists not going obsolete
Post by: scient on December 15, 2017, 06:17:06 AM
Here is a tweaked version. All the issues should be sorted. I revised the patching method to reduce the amount of bytes required (now: 14 locations, 207 bytes vs original: 51 locations, 289 bytes). This patch shouldn't interfere with Yitzi's. You should be able to merge the patched bytes without any problems.

Make sure to use the PCX from post #19. Any testing and feedback would be appreciated. I didn't have a saved game that used negative resources.
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: 33 - 892KB. (show)
Queries used: 19.

[Show Queries]