XRWS           sî   N  s ext_01.cat ext_01.dat md/dfunskillsincreasing.xml 29600 1592043162 f5e2bb7b5af7b348987cd4fcaaad2921
<?xml version="1.0" encoding="utf-8"?>

<mdscript name="DFunSkillsIncreasing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
	<cues>
		<cue name="DFSI_Base">
			<conditions>
				<check_any>
					<event_cue_signalled cue="md.Setup.GameStart"/>
					<event_player_created/>
					<event_cue_signalled/>
				</check_any>
			</conditions>
			<actions>
				<set_value name="$debug" exact="0"/>
				<set_value name="$Faction" exact="faction.player"/>

				<include_actions ref="DFSI_Gauss"/>
				<set_value name="$MedianAbility" exact="0.64"/>
				<set_value name="$Class" exact="[class.ship_s, class.ship_m, class.ship_l, class.ship_xl, class.station]"/>
				<set_value name="$SubordinatesNumber" exact="[1, 2, 4, 6, 8]"/>
				<set_value name="$ClassFactor" exact="[1, 1.1, 1.25, 1.5, 1]"/>
				<set_value name="$ContextFactor" exact="[0.6, 0.8, 1, 1.25, 1.5]"/>
				<set_value name="$EntityRoles" exact="[entityrole.service, entityrole.marine]"/>
				<set_value name="$Skilltype" exact="[skilltype.management, skilltype.piloting, skilltype.engineering, skilltype.boarding, skilltype.morale]"/>
				<set_value name="$SkillsSequence" exact="table[$Pilot = [skilltype.morale, skilltype.piloting, skilltype.management, skilltype.engineering, skilltype.boarding], $Manager = [skilltype.morale, skilltype.management, skilltype.boarding, skilltype.engineering, skilltype.piloting], $Engineer = [skilltype.morale, skilltype.engineering, skilltype.boarding, skilltype.management, skilltype.piloting], $Marine = [skilltype.morale, skilltype.boarding, skilltype.management, skilltype.engineering, skilltype.piloting]]"/>
				<set_value name="$SkillWeight" exact="[1.0, 1.0, 0.3, 0.2, 0.15]"/>

				<!--UPDATE / MISE A JOUR-->
				<set_value name="$VersionNumber" exact="3.11"/>
				<do_if value="event.param">
					<show_help duration="15s" custom="'DFSI update to v%1 complete.\n\nRatings on Steam are welcome :)'.[$VersionNumber]"/>
				</do_if>
				<do_else>
					<show_help duration="15s" custom="'DFSI v%1 installed.\n\nRatings on Steam are welcome :)'.[$VersionNumber]"/>
				</do_else>
			</actions>
			<cues>

							<!--                                             checkinterval 
																				   ||      
																				   \/      -->
				<cue name="DFSI_FindProperties" instantiate="true" checkinterval="10min" checktime="player.age + 5s">
					<actions>
						<do_if value="$PointsWin? and $IntervalCounter?">
							<do_all exact="$PointsWin.count" counter="$n">
								<set_value name="$IntervalPointsWin.{$n}" operation="add" exact="$PointsWin.{$n}"/>
								<set_value name="$IntervalTotalPointsWin" operation="add" exact="$PointsWin.{$n}"/>
							</do_all>
							<set_value name="$IntervalPointsLoose" operation="add" exact="$PointsLoose"/>
							<do_if value="$IntervalPropertiesCounter lt $PropertiesCounter">
								<set_value name="$IntervalPropertiesCounter" exact="$PropertiesCounter"/>
							</do_if>
							<do_if value="$IntervalEntitiesCounter lt $EntitiesCounter">
								<set_value name="$IntervalEntitiesCounter" exact="$EntitiesCounter"/>
							</do_if>
							<debug_text chance="$debug" text="' '"/>
							<debug_text chance="$debug" text="'*******************************************************'"/>
							<debug_text chance="$debug" text="'************* Properties processed = ' + $PropertiesCounter"/>
							<debug_text chance="$debug" text="'*************** Entities processed = ' + $EntitiesCounter"/>
							<debug_text chance="$debug" text="'********* Points win -> Management = ' + $PointsWin.{1}"/>
							<debug_text chance="$debug" text="'*********                 Piloting = ' + $PointsWin.{2}"/>
							<debug_text chance="$debug" text="'*********              Engineering = ' + $PointsWin.{3}"/>
							<debug_text chance="$debug" text="'*********                 Boarding = ' + $PointsWin.{4}"/>
							<debug_text chance="$debug" text="'*********                   Morale = ' + $PointsWin.{5}"/>
							<debug_text chance="$debug" text="'********* Points loose ->   Morale = ' + $PointsLoose"/>
							<debug_text chance="$debug" text="'*******************************************************'"/>
							<debug_text chance="$debug" text="' '"/>
							<set_value name="$IntervalCounter" operation="add"/>
						</do_if>
						<include_actions ref="DFSI_IntervalReport"/>
						<set_value name="$PointsWin" exact="[0, 0, 0, 0, 0]"/>
						<set_value name="$PointsLoose" exact="0"/>
						<set_value name="$PropertiesCounter" exact="0"/>
						<set_value name="$EntitiesCounter" exact="0"/>

						<set_value name="$Properties" exact="[]"/>
						<find_station_by_true_owner name="$Stations" faction="$Faction" multiple="true" space="player.galaxy"/>
						<append_list_elements name="$Properties" other="$Stations"/>
						<find_ship_by_true_owner name="$Properties" append="true" faction="$Faction" multiple="true" docked="false" class="[class.ship_s, class.ship_m, class.ship_l, class.ship_xl]" deployable="false" space="player.galaxy"/>
						<find_ship_by_true_owner name="$Properties" append="true" faction="$Faction" multiple="true" docked="true" class="[class.ship_s, class.ship_m, class.ship_l, class.ship_xl]" deployable="false" space="player.galaxy"/>
						<do_all exact="$Properties.count" counter="$n">
							<set_value name="$Property" exact="$Properties.{$n}"/>
							<!--                                                             checkinterval 
																								   ||      
																								   \/      -->
							<set_value name="$Delay" exact="1.0s + ((($n)f / $Properties.count) * (10min - 2s))s"/>
							<do_if value="$Property.isclass.station">
								<set_value name="$Param" exact="[$Delay, $Property, $Stations.count, $n]"/>
								<signal_cue_instantly cue="DFSI_PropertyProcessing" param="$Param"/>
							</do_if>
							<do_elseif value="$Property.isclass.ship">
								<set_value name="$Param" exact="[$Delay, $Property, ($Properties.count - $Stations.count), ($n - $Stations.count)]"/>
								<signal_cue_instantly cue="DFSI_PropertyProcessing" param="$Param"/>
							</do_elseif>
						</do_all>
					</actions>
				</cue>

				<library name="DFSI_IntervalReport">
					<actions>
						<!--                             checkinterval (10min) * 6 = Report interval (1h) 
																			   ||                         
																			   \/                         -->
						<do_if value="$IntervalCounter? and $IntervalCounter == 6">
							<debug_text chance="$debug" text="' '"/>
							<debug_text chance="$debug" text="'*******************************************************'"/>
							<debug_text chance="$debug" text="'*****************    In the interval    ***************'"/>
							<debug_text chance="$debug" text="'************* Properties processed = ' + $IntervalPropertiesCounter"/>
							<debug_text chance="$debug" text="'*************** Entities processed = ' + $IntervalEntitiesCounter"/>
							<debug_text chance="$debug" text="'*********      Points win -> Total = ' + $IntervalTotalPointsWin"/>
							<debug_text chance="$debug" text="'*********               Management = ' + $IntervalPointsWin.{1}"/>
							<debug_text chance="$debug" text="'*********                 Piloting = ' + $IntervalPointsWin.{2}"/>
							<debug_text chance="$debug" text="'*********              Engineering = ' + $IntervalPointsWin.{3}"/>
							<debug_text chance="$debug" text="'*********                 Boarding = ' + $IntervalPointsWin.{4}"/>
							<debug_text chance="$debug" text="'*********                   Morale = ' + $IntervalPointsWin.{5}"/>
							<debug_text chance="$debug" text="'********* Points loose ->   Morale = ' + $IntervalPointsLoose"/>
							<debug_text chance="$debug" text="'*******************************************************'"/>
							<debug_text chance="$debug" text="' '"/>

							<do_if value="$IntervalEntitiesCounter gt 0">
								<set_value name="$Report" exact="[]"/>
								<do_if value="$IntervalEntitiesCounter gt 1">
									<append_to_list name="$Report" exact="'%1 personnel members on'.[$IntervalEntitiesCounter]"/>
									<append_to_list name="$Report" exact="'have gained'"/>
								</do_if>
								<do_else>
									<append_to_list name="$Report" exact="'One personnel member on'"/>
									<append_to_list name="$Report" exact="'has gained'"/>
								</do_else>
								<do_if value="$IntervalPropertiesCounter gt 1">
									<append_to_list name="$Report" exact="'%1 properties'.[$IntervalPropertiesCounter]"/>
								</do_if>
								<do_else>
									<append_to_list name="$Report" exact="'one property'"/>
								</do_else>
								<do_if value="$IntervalTotalPointsWin == 0">
									<append_to_list name="$Report" exact="'no skill points during the last hour.'"/>
								</do_if>
								<do_else>
									<do_all exact="$IntervalPointsWin.count" counter="$n">
										<do_if value="$IntervalTotalPointsWin == 1 and $IntervalPointsWin.{$n} == $IntervalTotalPointsWin">
											<append_to_list name="$Report" exact="'one %1 point.'.[$Skilltype.{$n}]"/>
										</do_if>
										<do_elseif value="$IntervalTotalPointsWin gt 1 and $IntervalPointsWin.{$n} == $IntervalTotalPointsWin">
											<append_to_list name="$Report" exact="'%1 %2 points.'.[$IntervalPointsWin.{$n}, $Skilltype.{$n}]"/>
										</do_elseif>
									</do_all>
								</do_else>
								<do_if value="$Report.{4}?">
									<set_value name="$Text" exact="'%1 %2 %3 %4'.[$Report.{1}, $Report.{3}, $Report.{2}, $Report.{4}]"/>
								</do_if>
								<do_else>
									<append_to_list name="$Report" exact="$IntervalTotalPointsWin + ' skill points during the last hour :'"/>
									<set_value name="$Text" exact="'%1 %2 %3 %4'.[$Report.{1}, $Report.{3}, $Report.{2}, $Report.{4}]"/>
									<do_all exact="$IntervalPointsWin.count" counter="$n">
										<do_if value="$IntervalPointsWin.{$n} gt 1">
											<set_value name="$Text" operation="add" exact="'\n     %1 %2 points'.[$IntervalPointsWin.{$n}, $Skilltype.{$n}]"/>
										</do_if>
										<do_elseif value="$IntervalPointsWin.{$n} == 1">
											<set_value name="$Text" operation="add" exact="'\n     One %1 point'.[$Skilltype.{$n}]"/>
										</do_elseif>
									</do_all>
								</do_else>
								<do_if value="$IntervalPointsLoose gt 1">
									<set_value name="$Text" operation="add" exact="'\n%1 morale points have been lost.'.[$IntervalPointsLoose]"/>
								</do_if>
								<do_elseif value="$IntervalPointsLoose == 1">
									<set_value name="$Text" operation="add" exact="'\nOne morale point has been lost.'"/>
								</do_elseif>
								<do_else>
									<set_value name="$Text" operation="add" exact="'\nNo morale points have been lost !'"/>
								</do_else>
								<write_to_logbook category="news" text="$Text" title="'DFSI report'" faction="faction.player"/>
								<show_notification text="[{10002, 2004}, '', 'DFSI report available']"/>
							</do_if>
						</do_if>
							<!--                            checkinterval (10min) * 6 = Report interval (1h) 
																				  ||                         
																				  \/                         -->
						<do_if value="not $IntervalCounter? or $IntervalCounter == 6">
							<set_value name="$IntervalCounter" exact="0"/>
							<set_value name="$IntervalPointsWin" exact="[0, 0, 0, 0, 0]"/>
							<set_value name="$IntervalTotalPointsWin" exact="0"/>
							<set_value name="$IntervalPointsLoose" exact="0"/>
							<set_value name="$IntervalPropertiesCounter" exact="0"/>
							<set_value name="$IntervalEntitiesCounter" exact="0"/>
						</do_if>
					</actions>
				</library>

				<cue name="DFSI_PropertyProcessing" instantiate="true" namespace="this">
					<conditions>
						<event_cue_signalled/>
					</conditions>
					<delay exact="event.param.{1}"/>
					<actions>
						<set_value name="$Property" exact="event.param.{2}"/>
						<set_value chance="parent.$debug" name="$Count" exact="event.param.{3}"/>
						<set_value chance="parent.$debug" name="$Counter" exact="event.param.{4}"/>
						<do_if chance="parent.$debug" value="$Counter == 1 and $Property.isclass.station">
							<debug_text chance="parent.$debug" text="' '"/>
							<debug_text chance="parent.$debug" text="'*******************************************************'"/>
							<debug_text chance="parent.$debug" text="'********* ' + $Count + ' station(s) found in the galaxy!'"/>
							<debug_text chance="parent.$debug" text="'*******************************************************'"/>
							<debug_text chance="parent.$debug" text="' '"/>
						</do_if>
						<do_elseif chance="parent.$debug" value="$Counter == 1">
							<debug_text chance="parent.$debug" text="' '"/>
							<debug_text chance="parent.$debug" text="'*******************************************************'"/>
							<debug_text chance="parent.$debug" text="'********* ' + $Count + ' ship(s) found in the galaxy!'"/>
							<debug_text chance="parent.$debug" text="'*******************************************************'"/>
							<debug_text chance="parent.$debug" text="' '"/>
						</do_elseif>

						<do_if value="$Property.exists">
							<set_value name="parent.$PropertiesCounter" operation="add"/>
							<do_if chance="parent.$debug" value="$Property.isclass.station">
								<debug_text chance="parent.$debug" text="'(%1/%2) Delay = %3 | %4 [%5] | Workers : %6/%7 | Subordinates : %8'.[$Counter, $Count, event.param.{1}, $Property.knownname, $Property.idcode, $Property.workforce.amount, $Property.workforce.optimal, $Property.subordinates.count]"/>
							</do_if>
							<do_else>
								<debug_text chance="parent.$debug" text="'(%1/%2) Delay = %3 | %4 [%5] | Class : %6 | Crew : %7/%8 | Subordinates : %9'.[$Counter, $Count, event.param.{1}, $Property.knownname, $Property.idcode, $Property.class, $Property.people.count, $Property.people.capacity, $Property.subordinates.count]"/>
							</do_else>
							<include_actions ref="DFSI_Context"/>
							<include_actions ref="DFSI_MoraleFactor"/>
							<include_actions ref="DFSI_Populate"/>
						</do_if>
						<do_else>
							<debug_text chance="parent.$debug" text="'(%1/%2) Delay = %3 | Property has been destructed ?'.[$Counter, $Count, event.param.{1}]"/>
						</do_else>
					</actions>
				</cue>
				
				<library name="DFSI_Context">
					<actions>
						<do_if value="$Property.station.exists">
							<set_value name="$Context" exact="$Property.station"/>
							<debug_text chance="parent.$debug" text="'          Ship is docked and context is the station : %1 [%2]'.[$Context.knownname, $Context.idcode]"/>
						</do_if>
						<do_elseif value="$Property.ship.exists">
							<set_value name="$Context" exact="$Property.ship"/>
							<do_while value="$Context.exists">
								<do_if value="$Context.ship.exists">
									<set_value name="$Context" exact="$Context.ship"/>
								</do_if>
								<do_else>
									<break/>
								</do_else>
							</do_while>
							<debug_text chance="parent.$debug" text="'          Ship is docked and context is the ship : %1 [%2] | Class : %3'.[$Context.knownname, $Context.idcode, $Context.class]"/>
						</do_elseif>
					</actions>
				</library>

				<library name="DFSI_MoraleFactor">
					<actions>
						<do_if value="$Property.isclass.station">
							<set_value name="$SubordinatesFactor" exact="[($Property.subordinates.count)f / (parent.$SubordinatesNumber.{parent.$Class.indexof.{$Property.class}})f, 1.0].min"/>
							<do_if value="$Property.workforce.optimal gt 0">
								<set_value name="$PeopleFactor" exact="[($Property.workforce.amount)f / ($Property.workforce.optimal)f, 1.0].min"/>
								<set_value name="$MoraleFactor" exact="-0.25 + (1.25 * $PeopleFactor) + ( 0.5 * $SubordinatesFactor)"/>
							</do_if>
							<do_else>
								<set_value name="$PeopleFactor" exact="0.0"/>
								<set_value name="$MoraleFactor" exact="-0.25 + (1.25 * $SubordinatesFactor)"/>
							</do_else>
						</do_if>
						<do_else>
							<do_if value="$Property.people.capacity gt 0">
								<set_value name="$PeopleFactor" exact="[($Property.people.count)f / ($Property.people.capacity)f, 1.0].min"/>
							</do_if>
							<do_else>
								<set_value name="$PeopleFactor" exact="1.0"/>
							</do_else>
							<do_if value="$PeopleFactor gt 0.25">
								<set_value name="$SubordinatesFactor" exact="[($Property.subordinates.count)f / (parent.$SubordinatesNumber.{parent.$Class.indexof.{$Property.class}})f, 1.0].min"/>
							</do_if>
							<do_else>
								<set_value name="$SubordinatesFactor" exact="0.00"/>
							</do_else>
							<set_value name="$MoraleFactor" exact="-0.25 + ($PeopleFactor * (1.25 + 0.5 * $SubordinatesFactor))"/>
						</do_else>
						<do_if value="$Property == player.container and $MoraleFactor gt 0">
								<set_value name="$MoraleFactor" operation="add" exact="0.25 * $MoraleFactor"/>
								<debug_text chance="parent.$debug" text="'          PeopleFactor = %1 | SubordinatesFactor = %2 | MoraleFactor = %3 (player bonus)'.[$PeopleFactor, $SubordinatesFactor, $MoraleFactor]"/>
						</do_if>
						<do_else>
							<debug_text chance="parent.$debug" text="'          PeopleFactor = %1 | SubordinatesFactor = %2 | MoraleFactor = %3'.[$PeopleFactor, $SubordinatesFactor, $MoraleFactor]"/>
						</do_else>
					</actions>
				</library>

				<library name="DFSI_Populate">
					<actions>
						<get_control_entities name="$ControlEntities" object="$Property"/>
						<do_all exact="$ControlEntities.count" counter="$n">
							<do_if value="$ControlEntities.{$n}.isclass.npc">
								<set_value name="parent.$EntitiesCounter" operation="add"/>
								<set_value name="$Entity" exact="$ControlEntities.{$n}"/>
								<do_if value="$Property.isclass.station">
									<set_value name="$Role" exact="'Manager'"/>
								</do_if>
								<do_else>
									<set_value name="$Role" exact="'Pilot'"/>
								</do_else>
								<set_value name="$Seed" exact="$Entity.seed"/>
								<debug_text chance="parent.$debug" text="'     %1 : %2 (%3)'.[$Role, $Entity.name, $Entity.seed]"/>
								<include_actions ref="DFSI_SeedProcessing"/>
								<include_actions ref="DFSI_EntityProcessing"/>
							</do_if>
						</do_all>
						<do_if value="$Property.isclass.ship">
							<do_all exact="parent.$EntityRoles.count" counter="$i">
								<do_if value="$Property.people.{parent.$EntityRoles.{$i}}.count">
									<set_value chance="parent.$debug" name="$EntitiesCount" exact="$Property.people.{parent.$EntityRoles.{$i}}.count"/>
									<do_if value="parent.$EntityRoles.{$i} == entityrole.service">
										<set_value name="$Role" exact="'Engineer'"/>
									</do_if>
									<do_elseif value="parent.$EntityRoles.{$i} == entityrole.marine">
										<set_value name="$Role" exact="'Marine'"/>
									</do_elseif>
									<do_all exact="$Property.people.{parent.$EntityRoles.{$i}}.list.count" counter="$m">
										<set_value name="parent.$EntitiesCounter" operation="add"/>
										<set_value name="$Entity" exact="$Property.people.{parent.$EntityRoles.{$i}}.list.{$m}"/>
										<set_value name="$Seed" exact="$Property.people.{$Entity}.seed"/>
										<debug_text chance="parent.$debug" text="'     %1 (%2/%3) : %4 (%5)'.[$Role, $m, $EntitiesCount, $Property.people.{$Entity}.name, $Seed]"/>
										<include_actions ref="DFSI_SeedProcessing"/>
										<include_actions ref="DFSI_EntityProcessing"/>
									</do_all>
								</do_if>
							</do_all>
						</do_if>
					</actions>
				</library>

				<library name="DFSI_SeedProcessing">
					<actions>
						<set_value name="$SkillsAbility" exact="[]"/>
						<append_to_list name="$SkillsAbility" exact="($Seed-($Seed/10^2)i*10^2)i"/>
						<append_to_list name="$SkillsAbility" exact="(($Seed/10^2)i-($Seed/10^4)i*10^2)i"/>
						<append_to_list name="$SkillsAbility" exact="(($Seed/10^4)i-($Seed/10^6)i*10^2)i"/>
						<append_to_list name="$SkillsAbility" exact="(($Seed/10^6)i-($Seed/10^8)i*10^2)i"/>
						<append_to_list name="$SkillsAbility" exact="($SkillsAbility.{1}+$SkillsAbility.{2}+$SkillsAbility.{3}+$SkillsAbility.{4}) - (($SkillsAbility.{1}+$SkillsAbility.{2}+$SkillsAbility.{3}+$SkillsAbility.{4})/100)i*100"/>
						<do_all exact="$SkillsAbility.count" counter="$k">
							<set_value name="$SkillsAbility.{$k}" exact="parent.$Gauss.{$SkillsAbility.{$k} + 1}"/>
						</do_all>
						<debug_text chance="parent.$debug" text="'          Ability for : Management = %1 | Piloting = %2 | Engineering = %3 | Boarding = %4 | Morale = %5'.[$SkillsAbility.{1}, $SkillsAbility.{2}, $SkillsAbility.{3}, $SkillsAbility.{4}, $SkillsAbility.{5}]"/>
					</actions>
				</library>

				<library name="DFSI_EntityProcessing">
					<actions>
						<set_value chance="parent.$debug" name="$DebugText" exact="'          '"/>
						<set_value name="$EntityMoraleFactor" exact="$MoraleFactor + (3 * $SkillsAbility.{5})"/>
						<do_all exact="parent.$SkillsSequence.{'$' + $Role}.count" counter="$x">
							<set_value name="$Skill" exact="parent.$SkillsSequence.{'$' + $Role}.{$x}"/>
							<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="'%1 ('.[$Skill]"/>
							<do_if value="$Role == 'Pilot' or $Role == 'Manager'">
								<set_value name="$SkillLevel" exact="$Entity.skill.{$Skill}"/>
							</do_if>
							<do_else>
								<set_value name="$SkillLevel" exact="$Property.people.{$Entity}.skill.{$Skill}"/>
							</do_else>
							<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="'%1) '.[$SkillLevel]"/>
							<do_if value="$SkillLevel lt 15">
								<do_if value="$Skill == skilltype.morale and $EntityMoraleFactor gt 0.0">
									<set_value name="$Chance" exact="100 * $EntityMoraleFactor * (($SkillsAbility.{5} + parent.$MedianAbility) ^ $SkillLevel)"/>
									<set_value name="$AddSkill" exact="1"/>
									<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="'[%1 * %2 ^ %3 = %4 (1)] '.[$EntityMoraleFactor, ($SkillsAbility.{5} + parent.$MedianAbility), $SkillLevel, $Chance]"/>
								</do_if>
								<do_elseif value="$Skill == skilltype.morale and $EntityMoraleFactor lt 0.0 and $SkillLevel gt 0">
									<set_value name="$Chance" exact="-100 * $EntityMoraleFactor * ((- $SkillsAbility.{5} + parent.$MedianAbility + 0.1) ^ $SkillLevel)"/>
									<set_value name="$AddSkill" exact="-1"/>
									<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="'[%1 * %2 ^ %3 = %4 (-1)] '.[-$EntityMoraleFactor, (-$SkillsAbility.{5} + parent.$MedianAbility + 0.1), $SkillLevel, $Chance]"/>
								</do_elseif>
								<do_elseif value="$Skill != skilltype.morale">
									<set_value name="$Ability" exact="$SkillsAbility.{parent.$Skilltype.indexof.{$Skill}} + parent.$MedianAbility"/>
									<do_if value="$Role != 'Manager' and ($Skill == skilltype.boarding or $Skill == skilltype.management)">
										<do_if value="$Context?">
											<set_value name="$ClassAndContext" exact="parent.$ContextFactor.{parent.$Class.indexof.{$Context.class}}"/>
											<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="'[%1(Cxt) * '.[$ClassAndContext]"/>
										</do_if>
										<do_else>
											<set_value name="$ClassAndContext" exact="parent.$ContextFactor.{parent.$Class.indexof.{$Property.class}}"/>
											<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="'[%1(Prop) * '.[$ClassAndContext]"/>
										</do_else>
									</do_if>
									<do_else>
										<do_if value="$Context?">
											<set_value name="$ClassAndContext" exact="parent.$ClassFactor.{parent.$Class.indexof.{$Property.class}} * 0.8"/>
											<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="'[%1(*0.8) * '.[$ClassAndContext]"/>
										</do_if>
										<do_else>
											<set_value name="$ClassAndContext" exact="parent.$ClassFactor.{parent.$Class.indexof.{$Property.class}}"/>
											<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="'[%1 * '.[$ClassAndContext]"/>
										</do_else>
									</do_else>
									<do_if value="$Role == 'Pilot' or $Role == 'Manager'">
										<set_value name="$Chance" exact="parent.$SkillWeight.{$x} * 10 * $Entity.skill.{skilltype.morale} * $ClassAndContext * ($Ability ^ $SkillLevel)"/>
										<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="(($Entity.skill.{skilltype.morale})f / 10.0) + ' * '"/>
									</do_if>
									<do_else>
										<set_value name="$Chance" exact="parent.$SkillWeight.{$x} * 10 * $Property.people.{$Entity}.skill.{skilltype.morale} * $ClassAndContext * ($Ability ^ $SkillLevel)"/>
										<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="(($Property.people.{$Entity}.skill.{skilltype.morale})f / 10.0) + ' * '"/>
									</do_else>
									<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="'%1 * %2 ^ %3 = %4] '.[parent.$SkillWeight.{$x}, ($SkillsAbility.{parent.$Skilltype.indexof.{$Skill}} + parent.$MedianAbility), $SkillLevel, $Chance]"/>
									<set_value name="$AddSkill" exact="1"/>
								</do_elseif>
								<do_else>
									<set_value name="$Chance" exact="0"/>
									<set_value name="$AddSkill" exact="0"/>
								</do_else>
								<do_if value="$Role == 'Pilot' or $Role == 'Manager'">
									<add_skill object="$Property" entity="$Entity" type="$Skill" exact="$AddSkill" chance="$Chance"/>
									<set_value name="$NewSkillLevel" exact="$Entity.skill.{$Skill}"/>
								</do_if>
								<do_else>
									<add_skill object="$Property" template="$Entity" type="$Skill" exact="$AddSkill" chance="$Chance"/>
									<set_value name="$NewSkillLevel" exact="$Property.people.{$Entity}.skill.{$Skill}"/>
								</do_else>
								<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="'-> ' + $NewSkillLevel"/>
								<do_if value="$NewSkillLevel - $SkillLevel == 1">
									<set_value name="parent.$PointsWin.{parent.$Skilltype.indexof.{$Skill}}" operation="add"/>
									<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="' (WIN)'"/>
								</do_if>
								<do_elseif value="$NewSkillLevel - $SkillLevel == -1">
									<set_value name="parent.$PointsLoose" operation="add"/>
									<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="' (LOOSE)'"/>
								</do_elseif>
							</do_if>
							<set_value chance="parent.$debug" name="$DebugText" operation="add" exact="' | '"/>
						</do_all>
						<debug_text chance="parent.$debug" text="$DebugText"/>
					</actions>
				</library>

				<cue name="DFSI_VersionCheck" instantiate="false">
					<conditions>
						<check_any>
						  <event_player_created/>
						  <event_game_loaded/>
						  <event_cue_signalled cue="md.Setup.GameStart" />
						  <event_cue_signalled/>
						</check_any>
					</conditions>
					<actions>
						<!--UPDATE / MISE A JOUR-->
						<set_value name="$NewVersionNumber" exact="3.11"/>

						<do_if value="$VersionNumber != $NewVersionNumber or $VersionNumber == null or $VersionNumber == 0">
						  <signal_cue_instantly cue="DFSI_KeepAlive" param="true"/>
						  <reset_cue cue="DFSI_Base"/>
						</do_if>
						<reset_cue cue="this"/>
					</actions>
				</cue>
			</cues>
		</cue>

		<cue name="DFSI_KeepAlive" instantiate="false">
			<conditions>
				<check_any>
					<event_cue_signalled/>
				</check_any>
			</conditions>
			<delay exact="2s"/>
			<actions>
				<do_if value="event.param">
				  <signal_cue_instantly cue="DFSI_Base" param="event.param"/>
				</do_if>
				<do_else>
				  <signal_cue cue="DFSI_Base"/>
				</do_else>
				<reset_cue cue="this"/>
			</actions>
		</cue>

		<library name="DFSI_Gauss">
			<actions>
				<set_value name="$Gauss" exact="[]"/>
				<do_all exact="100" counter="$k">
					<do_if value="$k == 1">
						<append_to_list name="$Gauss" exact="-0.05"/>
					</do_if>
					<do_elseif value="$k lt 5">
						<append_to_list name="$Gauss" exact="-0.04"/>
					</do_elseif>
					<do_elseif value="$k lt 11">
						<append_to_list name="$Gauss" exact="-0.03"/>
					</do_elseif>
					<do_elseif value="$k lt 23">
						<append_to_list name="$Gauss" exact="-0.02"/>
					</do_elseif>
					<do_elseif value="$k lt 41">
						<append_to_list name="$Gauss" exact="-0.01"/>
					</do_elseif>
					<do_elseif value="$k lt 61">
						<append_to_list name="$Gauss" exact="0.0"/>
					</do_elseif>
					<do_elseif value="$k lt 77">
						<append_to_list name="$Gauss" exact="0.01"/>
					</do_elseif>
					<do_elseif value="$k lt 89">
						<append_to_list name="$Gauss" exact="0.02"/>
					</do_elseif>
					<do_elseif value="$k lt 97">
						<append_to_list name="$Gauss" exact="0.03"/>
					</do_elseif>
					<do_elseif value="$k lt 100">
						<append_to_list name="$Gauss" exact="0.04"/>
					</do_elseif>
					<do_else>
						<append_to_list name="$Gauss" exact="0.05"/>
					</do_else>
				</do_all>
			</actions>
		</library>
	</cues>
</mdscript><?xml version="1.0" encoding="utf-8"?>
<content id="" name="" description="" author="DFun" version="311" date="2020-06-13" save="0" lastupdate="">
  <text language="7" name="DFun Skills Increasing (DFSI)" description="Each NPC of your faction can learn and practice, and thus increase its skills by means of its own abilities. Morale can also be increased, or decreased, according to certain conditions." author="DFun"/>
  <text language="33" name="DFun Skills Increasing (DFSI)" description="Chaque NPC de votre faction peut apprendre et s'entrainer, et ainsi augmenter ses competences a l'aide d'aptitudes qui lui sont propres. Son moral peut egalement augmenter, ou diminuer, en fonction de certaines conditions." author="DFun"/>
  <text language="34" name="DFun Skills Increasing (DFSI)" description="Each NPC of your faction can learn and practice, and thus increase its skills by means of its own abilities. Morale can also be increased, or decreased, according to certain conditions." author="DFun"/>
  <text language="39" name="DFun Skills Increasing (DFSI)" description="Each NPC of your faction can learn and practice, and thus increase its skills by means of its own abilities. Morale can also be increased, or decreased, according to certain conditions." author="DFun"/>
  <text language="44" name="DFun Skills Increasing (DFSI)" description="Each NPC of your faction can learn and practice, and thus increase its skills by means of its own abilities. Morale can also be increased, or decreased, according to certain conditions." author="DFun"/>
  <text language="49" name="DFun Skills Increasing (DFSI)" description="Each NPC of your faction can learn and practice, and thus increase its skills by means of its own abilities. Morale can also be increased, or decreased, according to certain conditions." author="DFun"/>
  <text language="55" name="DFun Skills Increasing (DFSI)" description="Each NPC of your faction can learn and practice, and thus increase its skills by means of its own abilities. Morale can also be increased, or decreased, according to certain conditions." author="DFun"/>
  <text language="81" name="DFun Skills Increasing (DFSI)" description="Each NPC of your faction can learn and practice, and thus increase its skills by means of its own abilities. Morale can also be increased, or decreased, according to certain conditions." author="DFun"/>
  <text language="82" name="DFun Skills Increasing (DFSI)" description="Each NPC of your faction can learn and practice, and thus increase its skills by means of its own abilities. Morale can also be increased, or decreased, according to certain conditions." author="DFun"/>
  <text language="86" name="DFun Skills Increasing (DFSI)" description="Each NPC of your faction can learn and practice, and thus increase its skills by means of its own abilities. Morale can also be increased, or decreased, according to certain conditions." author="DFun"/>
  <text language="88" name="DFun Skills Increasing (DFSI)" description="Each NPC of your faction can learn and practice, and thus increase its skills by means of its own abilities. Morale can also be increased, or decreased, according to certain conditions." author="DFun"/>
</content>
