Page 1 of 1

Havens and Lasers

Posted: Fri Jan 27, 2017 2:40 pm
by Arcalane
I was poking around at a few things and... well, I'll just leave this here--

Code: Select all

    if (Loadout == '')
	{
        LoadoutStr = "RebelSoldier";
		if (class'UIUtilities_Strategy'.static.GetXComHQ().IsTechResearched('MagnetizedWeapons'))
		{
			LaserChance += (20 * (Outpost.GetRebelLevel(RebelRef) + 1)); // 20/40/60
		}
		if (class'UIUtilities_Strategy'.static.GetXComHQ().IsTechResearched('GaussWeapons'))
		{
			LaserChance += (20 * (Outpost.GetRebelLevel(RebelRef) + 1)); // 40/80/100
		}
		if (class'UIUtilities_Strategy'.static.GetXComHQ().IsTechResearched('Coilguns'))
		{
			LaserChance = 100;
			MagChance += (20 * (Outpost.GetRebelLevel(RebelRef) + 1)); //20/40/60
		}
		if (class'UIUtilities_Strategy'.static.GetXComHQ().IsTechResearched('AdvancedCoilguns'))
		{
			MagChance += (20 * (Outpost.GetRebelLevel(RebelRef) + 1)); //40/80/100
		}
		if (class'UIUtilities_Strategy'.static.GetXComHQ().IsTechResearched('PlasmaRifle'))
		{
			MagChance += (20 * (Outpost.GetRebelLevel(RebelRef) + 1)); //60/100/100
		}
		if ((class'Engine'.static.GetEngine().SyncRand(100,"Utilities_LW::"$GetFuncName())) < MagChance)
		{
			LoadoutStr $= "3";
		}
		else
		{
			if ((class'Engine'.static.GetEngine().SyncRand(100,"Utilities_LW::"$GetFuncName())) < LaserChance)
			{
				LoadoutStr $= "2";
			}
		}
		iRand = (class'Engine'.static.GetEngine().SyncRand(100,"Utilities_LW::"$GetFuncName()));
		if (iRand < 20)
		{
			LoadoutStr $= "SMG";
		}
		else
		{
			if (iRand < 40 && Outpost.GetRebelLevel(RebelRef) < 2)
			{
				LoadoutStr $= "Shotgun";
			}
		}
		//`LWTRACE ("Rebel Loadout" @ LoadoutStr);
		Loadout = name(LoadOutStr);
	}
(If I'm reading this right: chance of Haven volunteers being armed with lasers and mag weapons hinges primarily on volunteer level and requires the base tech (of course). If you have coilguns, the chance of lasers is 100%. Mag weapons are essentially guaranteed on any high-level volunteers once you hit Adv. Coilguns.)

Re: Havens and Lasers

Posted: Fri Jan 27, 2017 2:51 pm
by 8wayz
Yep, you are reading it right. Their weapons will be upgraded in regards to your tech level and their experience level.

Re: Havens and Lasers

Posted: Fri Jan 27, 2017 7:42 pm
by trihero
It matches my experience as well. It gives some minor bonus to researching for instance magnetics even if you don't have the intention or money to build more of them, to make the haven missions a bit safer.

Re: Havens and Lasers

Posted: Tue Jan 31, 2017 3:43 am
by Mavoc
Now this is not my language, but it seems to be randomizing a number up to 100 and then doing a less than check. Which means even with a 100 chance, you could still fail if the number randomized was a 100 due to it not being a less than or equal to check.

Re: Havens and Lasers

Posted: Wed Feb 01, 2017 2:31 am
by dstar3k
Mavoc wrote:Now this is not my language, but it seems to be randomizing a number up to 100 and then doing a less than check. Which means even with a 100 chance, you could still fail if the number randomized was a 100 due to it not being a less than or equal to check.
It depends on what SyncRand does. For example, python's random.random() returns a number equal to or greater than zero, and _less than_ 1.0. Perl's rand function returns an integer greater than or equal to 0, and less than the argument provided.

So it's entirely possible that the highest value that that call can return is 99.9999 repeating.