Save Our SOTS2 - A Fan Made Patch

Moderator: Makail

Post Reply
Bompa
Posts: 10
Joined: Wed Nov 16, 2011 8:36 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by Bompa » Fri Dec 13, 2019 4:11 pm

ah hadn't gotten to that part yet.
so there will have to be a few new things added,
for now i tried a lobbyself with just a copy of the code from lobbyfriendly and lobbyenemy in getlobbyviability, since it there is no difference between the two. they all return 0.0f

also upon reading the code for executediplomatic action, there is no code for savings demand. but the AI uses it anyway :| so i guess the code for demand slaves is used there since there is no "break;"

added some more TraceVerbose to let it show on the console when it uses certain functions.

edit: added some code for ExecuteDiplomacyAction with a case for treaties and allowed the AI to actually get a weight for them.
nothing happens yet, as the code only outputs to the console, but i can see the AI offering incorporate treaties to other AI. a step in the right direction i think.
+ what i said about the ai offering treaties, 5-9 thingy, wasn't correct. there are two conditions that can lead to the AI offering a treaty. one is round-robin, and the other is a random roll.

edit 2:
tried to add actual treaties to offer, somehow crashed when it tried to get the cost for an armistice treaty. my skill in programming is far too lacking to find out why...
getting the cost should work, as the game does it when a player looks to offer an armistice AND i have now observed it using said function successfully with output to the log.
getting this to work without a decompiled sots2.exe is a bitch since you can't see what is in all the variables

edit 3:
issue is resolved. the AI can now get the cost.
however... the issue with getting the weights for a diplomatic action (specifically a treaty) remains. but ONLY when the second condition to offer a treaty is used. the case being that the round-robin method only compares the current diplomatic state to the preferred one (based on current relations), and directly offers a treaty without getting weights for its actions.
i've tried adding every possible treaty to the diplomacyweight.xml in every diplomacyreaction, but to no avail... i'll keep working on it.

Bompa
Posts: 10
Joined: Wed Nov 16, 2011 8:36 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by Bompa » Mon Dec 16, 2019 4:33 pm

the issue is as follows:
the code it crashes on:

Code: Select all

public float GetWeight(DiplomacyAction action, DiplomaticMood mood, object type = null)
{		
	{
	if (DiplomacyActionWeights.RequiresType(action) && type == null)
		throw new Exception("Action requires a type.");
	DiplomacyActionWeights.DiplomacyActionWeight diplomacyActionWeight = type != null ? this.Weights.FirstOrDefault<DiplomacyActionWeights.DiplomacyActionWeight>((Func<DiplomacyActionWeights.DiplomacyActionWeight, bool>)(x =>
	{
		if (x.DiplomacyAction == action && x.Mood == mood)
		{
			string message = " getting weights with action: " + (object)action.ToString() +", mood: " + (object)mood.ToString() +" & type: " + (object)type.ToString();
			App.Log.Trace(message, "Dip", Kerberos.Sots.Engine.LogLevel.Normal);
			message = "and checking against x.type: " + (object)x.Type.ToString();
			App.Log.Trace(message, "Dip", Kerberos.Sots.Engine.LogLevel.Normal);
			return x.Type.Equals(type); // crashes here when type = armistice
		}
		else return false;
	})) : this.Weights.FirstOrDefault<DiplomacyActionWeight>((Func<DiplomacyActionWeights.DiplomacyActionWeight, bool>)(x =>
	{
				if (x.DiplomacyAction == action)
					return x.Mood == mood;
				return false;
		}));
		if (diplomacyActionWeight == null)
			return 1f;
		string m1 = " weight is: " + (object)diplomacyActionWeight.Value.ToString();
		App.Log.Trace(m1, "Dip", Kerberos.Sots.Engine.LogLevel.Normal);
		return diplomacyActionWeight.Value;
}
all possible treatytypes it could check against :

Code: Select all

Armistice, Trade, Limitation, Protectorate, Incorporate, FleetSize, ShipClass, Weapon, ResearchTree, ResearchTech, EmpireSize, ForgeGemWorlds, StationType,
and somehow it can get past the first 2, but crashes when it gets to the third.
as observed in the log,

Code: Select all

 (2019/12/16 17:01:19) [Dip]  getting weights with action: TREATY, mood: Love & type: Armistice
T (2019/12/16 17:01:19) [Dip] and checking against x.type: FleetSize
T (2019/12/16 17:01:19) [Dip]  getting weights with action: TREATY, mood: Love & type: Armistice
T (2019/12/16 17:01:19) [Dip] and checking against x.type: ShipClass
T (2019/12/16 17:01:19) [Dip]  getting weights with action: TREATY, mood: Love & type: Armistice
W (2019/12/16 17:01:19) [game] System.NullReferenceException: Object reference not set to an instance of an object.

   at Kerberos.Sots.PlayerFramework.DiplomacyActionWeights.<>c__DisplayClass6_0.<GetWeight>b__0(DiplomacyActionWeight x) in D:\Program Files (x86)\Steam\steamapps\common\sword of the stars ii\Kerberos\Sots\PlayerFramework\DiplomacyActionWeights.cs:line 146
i have all possible treaties in the faction's diplomacyweight.xml so that shouldn't be an issue. including the Armistice it is looking for, which isn't listed in the xml as a possibility but does exist as a treatytype in code.

Edit:
FINALLY, i fixed the issue with the getweight... turns out the code to load in the weights from the xml in the database only parsed limitation treaties, not regular treaties.
simmed with 3 AIs that love oneanother... and they won the game by entering an alliance with eachother after about 50 turns in
SO... diplomacy works now i guess... color me surprized xD

User avatar
Rossinna-Sama
Posts: 1815
Joined: Sun Nov 11, 2012 5:38 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by Rossinna-Sama » Mon Dec 16, 2019 10:16 pm

That's great news. One of the main differences between the AI in SOTS1 and 2 is that the AI in 1 actually did diplomacy while 2 doesn't. You're making great strides in closing that gap. :D
Sword of the Stars 2 : Project Hiver Modder
Creator of the Work-In-Progress Seimei Visual Novel series.
My dream game: Combination of Sword of the Stars 2, Angels Fall First, Conquest: Frontier Wars and Warzone 2100.

Bompa
Posts: 10
Joined: Wed Nov 16, 2011 8:36 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by Bompa » Tue Dec 17, 2019 12:19 pm

somewhere, someone explained that at relations 1000 there is a 9% chance of the AI declaring war on you. turns out that it is a 91%, so i chided the AI for being a bully and told it to behave.
=> getting your relation above approx 1500 negates the chance of them going to war with you. at 1000 the chance is 9% as mentioned; and at relation 0 the chance is 100%, nothing random there (the cointoss autoresolves).

trade agreements are in, with the morrigi having double the weight of other races and start offering at NAP, while others start at PEACE. As intended by the original creator of this mod. (i assume)
lobbying is in, code was already there, just set the viability weight returned from 0 to 1.
protectorate and incorporate treaties are offered if they are near the AI. but only to non-standard players (which i assume implies they are independents)

though, within the code i got from zerk's github upload , there exists an issue with the VN. so had to disable them from the game to prevent crashing whenever they try to attack.
and the notch thing you did crashes whenever you move the slider to a notch in the tradeview. reverted to the old code for now.

sqw82
Posts: 28
Joined: Sun Jul 08, 2018 7:54 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by sqw82 » Wed Dec 18, 2019 11:44 pm

Fantastic news. The diplomacy is the weakest aspect of SOTS 2 (heck, I can't even understand the UI most of the time) and fixing it goes goes a long way to making the game fun. Looking forward to the new patch.

There's one more nagging issue for me. The AI doesn't respond when you are hitting them with polaris missiles right at the edge of max range during accelerated mode. Basically two bombardment CR can wreck a entire home system with LV. Is there anyway to make the tactical AI realize it's getting hit and search for the aggressors? Or I could just stop using this cheese but that removes long range options for the missile tree as well as a few ship sections.

Bompa
Posts: 10
Joined: Wed Nov 16, 2011 8:36 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by Bompa » Thu Dec 19, 2019 12:31 pm

sqw82 wrote:
Wed Dec 18, 2019 11:44 pm
There's one more nagging issue for me. The AI doesn't respond when you are hitting them with polaris missiles right at the edge of max range during accelerated mode. Basically two bombardment CR can wreck a entire home system with LV. Is there anyway to make the tactical AI realize it's getting hit and search for the aggressors? Or I could just stop using this cheese but that removes long range options for the missile tree as well as a few ship sections.
best i can tell is that the AI splits its fleet into different taskgroups depending on use of the ships in the fleet. a group to evade, with all passive ships in; like the supply and command ship. an aggressive group, to attack targets. a planetairy assault group. etc.
most importantly for your problem: a scout group. however, since you attack their fleets the AI puts heavy emphasis on the "defend" task, and not on the "scout" task. (which i assume it only does when you attack their fleet on a survey mission...) defend behavior is largely static in orbit of owned planets, and only move when enemies are detected.
at the edge of their range they lack the detection power to penetrate the passive stealth ships have going on to conceal their movement. (which can be observed by the player as well, ships sometimes don't show on the sensors untill after they are well into the detectable range... this is NOT the game loading in assets!)
in essence the static nature of the AI with tactical task of "defend" causes you to remain undetected.
simplest solution would be to force the AI to go to slowest speed setting in defensive stance, to force detection without altering too much. ("running silent" and with it gain detection range and power while reducing their signature) IF that is actually implemented in the game, like it mentions on a certain research.
not going to mess with it for the time being. simply a possible diagnosis.

sqw82
Posts: 28
Joined: Sun Jul 08, 2018 7:54 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by sqw82 » Fri Dec 20, 2019 1:52 am

Bompa wrote:
Thu Dec 19, 2019 12:31 pm
sqw82 wrote:
Wed Dec 18, 2019 11:44 pm
There's one more nagging issue for me. The AI doesn't respond when you are hitting them with polaris missiles right at the edge of max range during accelerated mode. Basically two bombardment CR can wreck a entire home system with LV. Is there anyway to make the tactical AI realize it's getting hit and search for the aggressors? Or I could just stop using this cheese but that removes long range options for the missile tree as well as a few ship sections.
best i can tell is that the AI splits its fleet into different taskgroups depending on use of the ships in the fleet. a group to evade, with all passive ships in; like the supply and command ship. an aggressive group, to attack targets. a planetairy assault group. etc.
most importantly for your problem: a scout group. however, since you attack their fleets the AI puts heavy emphasis on the "defend" task, and not on the "scout" task. (which i assume it only does when you attack their fleet on a survey mission...) defend behavior is largely static in orbit of owned planets, and only move when enemies are detected.
at the edge of their range they lack the detection power to penetrate the passive stealth ships have going on to conceal their movement. (which can be observed by the player as well, ships sometimes don't show on the sensors untill after they are well into the detectable range... this is NOT the game loading in assets!)
in essence the static nature of the AI with tactical task of "defend" causes you to remain undetected.
simplest solution would be to force the AI to go to slowest speed setting in defensive stance, to force detection without altering too much. ("running silent" and with it gain detection range and power while reducing their signature) IF that is actually implemented in the game, like it mentions on a certain research.
not going to mess with it for the time being. simply a possible diagnosis.
Then what would happen if we double the sensor range just for AI (can't do it with player or normal speed would engage way too far from target)? Would the AI still sit still in a defensive position if it can see me bombarding them from extreme range?

Bompa
Posts: 10
Joined: Wed Nov 16, 2011 8:36 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by Bompa » Fri Dec 20, 2019 8:05 am

sqw82 wrote:
Fri Dec 20, 2019 1:52 am
Then what would happen if we double the sensor range just for AI (can't do it with player or normal speed would engage way too far from target)? Would the AI still sit still in a defensive position if it can see me bombarding them from extreme range?
either it won't work because something else is the issue, or it works and the player loses all capabilities of stealth. cloaking might still work.

sqw82
Posts: 28
Joined: Sun Jul 08, 2018 7:54 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by sqw82 » Sat Dec 21, 2019 1:01 am

Bompa wrote:
Fri Dec 20, 2019 8:05 am
sqw82 wrote:
Fri Dec 20, 2019 1:52 am
Then what would happen if we double the sensor range just for AI (can't do it with player or normal speed would engage way too far from target)? Would the AI still sit still in a defensive position if it can see me bombarding them from extreme range?
either it won't work because something else is the issue, or it works and the player loses all capabilities of stealth. cloaking might still work.
I don't think stealth, short of actual cloaking tech, exists or is functional in this game. Personally, I'm willing to sacrifice a poorly implemented stealth system for some better AI tactical response.

User avatar
Rossinna-Sama
Posts: 1815
Joined: Sun Nov 11, 2012 5:38 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by Rossinna-Sama » Sat Dec 21, 2019 1:53 am

It is implemented, just poorly explained. All ships have a Signature rating, the higher said rating is, the easier it is for that ship to be detected by sensors, which is the Sensor View (space bar). The lower it is, the harder it is to detect by sensors to the point where really low (ships with negative Signature rating due to stuff like Stealth Armor) signatures do not show up on the sensor manager until they are really close, if they show up at all.

Electronic Warfare sections create a bubble which is visible on the Sensor View which does the same thing - hides ships from the sensor view but can hide other ships. Ships also have an ECM and ECCM rating which contribute to their ability to hide from sensors and to actually find them in the first place - ECCM also helps detecting cloaked and invisible ships.

While harder to notice in vanilla gameplay, it is there. Stealth Armor though is really not a good choice, so the AI almost never uses it.
Sword of the Stars 2 : Project Hiver Modder
Creator of the Work-In-Progress Seimei Visual Novel series.
My dream game: Combination of Sword of the Stars 2, Angels Fall First, Conquest: Frontier Wars and Warzone 2100.

sqw82
Posts: 28
Joined: Sun Jul 08, 2018 7:54 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by sqw82 » Sat Dec 21, 2019 2:01 pm

I remember how ECM worked in SOTS but in SOTS II, there just doesn't seem to have a use. Since you can't really see the effectiveness of your lower sensor rating and there's really no point to sneak outside of multiplayer, it's just a pointless mechanic.

Compared to how a few polaris CRs can wreck everything against the AI, I'd think fixing that exploit would be more important than keeping the existing sensor range for a never-used stealth mechanic.

obimark
Posts: 12
Joined: Tue Mar 24, 2015 10:16 pm

Re: Save Our SOTS2 - A Fan Made Patch

Post by obimark » Tue Dec 31, 2019 6:44 am

First of all, thank you all for your efforts. It is very much appreciated what you're all doing.
I got SOTS2 itch again, and this seems like a perfect mod to try out.

Once agian, thank you all.

EDIT: I haven't really check how much RAM SOTS2 uses, but would it benefit from large address aware utility?

sqw82
Posts: 28
Joined: Sun Jul 08, 2018 7:54 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by sqw82 » Wed Jan 01, 2020 12:20 am

obimark wrote:
Tue Dec 31, 2019 6:44 am
First of all, thank you all for your efforts. It is very much appreciated what you're all doing.
I got SOTS2 itch again, and this seems like a perfect mod to try out.

Once agian, thank you all.

EDIT: I haven't really check how much RAM SOTS2 uses, but would it benefit from large address aware utility?
This is a great mod but I'd wait for the diplomacy one to be included before a new play through. Total war with every one every time gets old quickly.

obimark
Posts: 12
Joined: Tue Mar 24, 2015 10:16 pm

Re: Save Our SOTS2 - A Fan Made Patch

Post by obimark » Thu Jan 09, 2020 7:55 pm

Well, I couldn't wait. :) Anyhow, just a few thoughts, piracy needs to be reduced, badly. I have around a dozen star systems in my current playthrough and every other turn I get raided by pirates and police cutters don't have firepower to destroy even a single ship. Even a three dreadnought armada barely manages to destroy them when spawned next to pirates. Building a Naval station pretty much reduces piracy to zero, but it's unpractical to build naval station in every system.
Human dreadnoughts need more supply. Even when equipped with all the supply modules, you can't fit every hardpoint with a ballistic weapon/missile. That goes for megefreighters and qships as well.
AI behaves much better. LiirZuul use quite a lot of psionics and my ships just retreat most of the time. Lost a couple of colonies to them that way.
Still, they seem skittish to engage fixed defense. I had a single missile platform defending world and two Liir dreads just lurked at the edge of platform range, not doing anything.
Maybe they were afraid of mighty missile platform, who knows?!
If anything pops up, I'll post.

sqw82
Posts: 28
Joined: Sun Jul 08, 2018 7:54 am

Re: Save Our SOTS2 - A Fan Made Patch

Post by sqw82 » Sun Jan 12, 2020 1:00 am

obimark wrote:
Thu Jan 09, 2020 7:55 pm
Well, I couldn't wait. :) Anyhow, just a few thoughts, piracy needs to be reduced, badly. I have around a dozen star systems in my current playthrough and every other turn I get raided by pirates and police cutters don't have firepower to destroy even a single ship. Even a three dreadnought armada barely manages to destroy them when spawned next to pirates. Building a Naval station pretty much reduces piracy to zero, but it's unpractical to build naval station in every system.
Human dreadnoughts need more supply. Even when equipped with all the supply modules, you can't fit every hardpoint with a ballistic weapon/missile. That goes for megefreighters and qships as well.
AI behaves much better. LiirZuul use quite a lot of psionics and my ships just retreat most of the time. Lost a couple of colonies to them that way.
Still, they seem skittish to engage fixed defense. I had a single missile platform defending world and two Liir dreads just lurked at the edge of platform range, not doing anything.
Maybe they were afraid of mighty missile platform, who knows?!
If anything pops up, I'll post.
Increase drive tech bumps up supply I believe. Have a mix of supply-lite energy weapons and ballistics/missile so you don't gimp yourself in your fleet endurance. Human are suppose to be jack of all trade so shouldn't focus on one tech tree. What I love about SOTS is every race is different and even their ships, from armor, weapon mounts to supply, reflects that so you can't say design Humans ships the way you could with Hiver or Morrigi.

As far as fix defenses, I don't think the AI is even capable of backing off. Most likely what happen is the AI bug that makes it fly to one point in the map and stay there - something I've pointed out a few times in this thread. If you have polaris missiles, you can sit and lop missiles at the AI ships at max range without fear of retaliation.

Post Reply

Return to “Modding”

Who is online

Users browsing this forum: No registered users and 2 guests