From 879882b17263348494ff424b665f9d564fa1c6f1 Mon Sep 17 00:00:00 2001 From: hexall90 <hexall90@gmail.com> Date: Fri, 15 Sep 2017 15:47:12 +0200 Subject: [PATCH] Adding base code --- src/SecExp/attackHandler.tw | 244 ++++++++++++++++-- src/SecExp/secInit.tw | 118 +++++++++ src/SecExp/widgets/unitsDescriptionWidgets.tw | 13 + src/init/storyInit.tw | 29 +-- 4 files changed, 357 insertions(+), 47 deletions(-) create mode 100644 src/SecExp/secInit.tw create mode 100644 src/SecExp/widgets/unitsDescriptionWidgets.tw diff --git a/src/SecExp/attackHandler.tw b/src/SecExp/attackHandler.tw index e480826adb8..4a70e89d1fa 100644 --- a/src/SecExp/attackHandler.tw +++ b/src/SecExp/attackHandler.tw @@ -83,46 +83,248 @@ The ominous message dominates the screens of your office. <<print $assistantName It seems your troops and your adversary will fight <<if $battleTerrain == "urban">> - in the streets of the arcology. + in @@.yellow;the streets of the arcology.@@ <<elseif $battleTerrain == "rural">> - in the farms surrounding the free city. + in @@.yellow;the rural land@@ surrounding the free city. <<elseif $battleTerrain == "hills">> - on the hills around the free city. + on @@.yellow;the hills@@ around the free city. <<elseif $battleTerrain == "sea">> - in the sea surrounding the city. + in @@.yellow;the sea@@ surrounding the city. <<elseif $battleTerrain == "coast">> - along the coast just outside the free city. + along @@.yellow;the coast@@ just outside the free city. +<<elseif $battleterrain == "outskirts">> + right against @@.yellow;the walls of the arcology.@@ <<elseif $battleTerrain == "mountains">> - in the mountains overlooking the arcology. + in @@.yellow;the mountains@@ overlooking the arcology. <<elseif $battleTerrain == "wasteland">> - in the wastelands outside the free city territory. + in @@.yellow;the wastelands@@ outside the free city territory. <</if>> -<br> <<if $riskSim == 1 && $riskSimExpectedAttack == $attackType>> - Your sophisticated virtual simulations allows you to accurately predict the numbers you're about to face. <<print $assistantName>> sends you the data: approximately <<print Math.round($attackTroops * (1 + random(-1,1) * 0.1))>> men are coming. + Your sophisticated virtual simulations and advanced recon drones allows you to accurately predict the numbers you're about to face. <<print $assistantName>> sends you the data: approximately @@.yellow;<<print Math.round($attackTroops * (1 + random(-1,1) * 0.1))>> men@@ are coming. <<elseif $perimeterDrones ==1>> - Thanks to your drones you have a rough estimate of the numbers you're about to face. <<print $assistantName>> sends you the data: around <<print Math.round($attackTroops * (1 + random(-3,3) * 0.1))>> men are coming + Thanks to your drones you have a rough estimate of the numbers you're about to face. <<print $assistantName>> sends you the data: around @@.yellow;<<print Math.round($attackTroops * (1 + random(-3,3) * 0.1))>> men@@ are coming <<else>> - <<print Math.round($attackTroops * (1 + random(-5,5) * 0.1))>> men, - Unfortunately you have no good information on what is coming your way, the confused reports of your citizens gives you only a vague number. <<print $assistantName>> sends you the data: around <<print Math.round($attackTroops * (1 + random(-5,5) * 0.1))>> men are coming. + Unfortunately you have no good information on what is coming your way, the confused reports of your citizens gives you only a vague number. @@.yellow;<<print $assistantName>> sends you the data: around <<print Math.round($attackTroops * (1 + random(-5,5) * 0.1))>> men@@ are coming. <</if>> -For what you know they are +They seems to be <<if $riskSim == 1 && $riskSimExpectedAttack == $attackType>> - <<if $attackEquip == 0>> - just lightly armed, mostly small arms with some repurposed civilian vehicles and a scattered few machine guns. There's no sign of heavy vehicles, artillery or aircrafts. - <<elseif $attackEquip == 0>> - - + <<set $expectedEquip = $attackEquip>> +<<elseif $perimeterDrones == 1>> + <<set $expectedEquip = $attackEquip + random(-1,1)>> +<<else>> + <<set $expectedEquip = $attackEquip + random(-2,2)>> +<</if>> +<<if $expectedEquip == 0>> + @@.yellow;poorly armed@@: old rusty small arms are the norm with just a few barely working civilian vehicles. +<<elseif $expectedEquip == 1>> + @@.yellow;lightly armed@@: mostly small arms with some repurposed civilian vehicles and a scattered few machine guns. There's no sign of heavy vehicles, artillery or aircrafts. +<<elseif $expectedEquip == 2>> + @@.yellow;decently armed@@: good quality small arms, machine guns a few mortars. There seems to be some heavy military vehicles coming as well. +<<elseif $expectedEquip == 3>> + @@.yellow;well armed@@: high quality small arms, snipers, demolitions teams, heavy duty machine guns and mortars. Heavy military vehicles are numerous and a few artillery piecies are accompaning the detachment. +<<elseif $expectedEquip == 4>> + extremely well armed: excellent small arms and specialized teams with heavy duty infantry support weapons. Heavy presence of armored military vehicles, artillery pieces and even some attack helicopters. +<</if>> +<hr> +<br><br> -<br> You quickly lay down a plan of action: <br> <<link "Let the assistant handle this attack">> - <<if $assistantPower == 0>> + <<if $assistantPower == 2>> <<elseif $assistantPower == 1>> <<else>> <</if>> <</link>> +<<set $leadingTroops = "assistant">> +<br> //$assistantName will handle leaders, tactics and troop deployment to the best of her abilities.// + +<br><br> + +/* leader assignment */ +<span id="leader"><strong>$assistantName</strong></span> will lead your troops. + <br> + <<if $leadingTroops != "PC">> + <<link "Personally join the battle">> + <<set $leadingTroops = "PC">> + <<replace "#leader">><strong>$PC.name</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <<else>> + Personally join the battle + <</if>> + <<if $Bodyguard != 0>> + | + <<if $leadingTroops != "assistant">> + <<link "Let $assistantName lead the troops">> + <<set $leadingTroops = "assistant">> + <<replace "#leader">><strong>$assistantName</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <<else>> + Personally join the battle + <</if>> + <<if $Bodyguard != 0 && $slavesInArmy == 1>> + | + <<if $leadingTroops != "bodyguard">> + <<link "Let your bodyguard lead your troops">> + <<set $leadingTroops = "bodyguard">> + <<replace "#leader">><strong>$Bodyguard.slaveName</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <<else>> + Let your bodyguard lead your troops + <</if>> + <</if>> + <<if $HeadGirl != 0 && $slavesInArmy == 1>> + | + <<if $leadingTroops != "headgirl">> + <<link "Let your head girl lead your troops">> + <<set $leadingTroops = "headGirl">> + <<replace "#leader">><strong>$HeadGirl.slaveName</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <<else>> + Let your head girl lead your troops + <</if>> + <</if>> + <<if $militiaCreated == 1>> + | + <<if $leadingTroops != "citizen">> + <<link "Let the citizens' militia officers lead the troops">> + <<set $leadingTroops = "citizen">> + <<replace "#leader">><strong>The citizens' militia commander</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <<else>> + Let the citizens' militia officers lead the troops. + <</if>> + <</if>> + <<if $mercenaries > 0>> + | + <<if $leadingTroops != "mercenary">> + <<link "Let the mercenary officers lead the troops">> + <<set $leadingTroops = "mercenary">> + <<replace "#leader">><strong>The mercenary commander</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <<else>> + Let the mercenary officers lead the troops. + <</if>> + <</if>> + +/* troop deployment */ +<br><br> +With your current readiness level you can still send <span id="deploUni"><strong>$deployableUnits</strong></span>. Available units: +<<set _mL = $militiaUnits.length>> +<br> +<<for _i = 0; _i < _mL; _i++>> + <<if $deployableUnits == 0>> + Unit roster full. + <<break>> + <<else>> + <<if $militiaUnits[_i].isDeployed == 0>> + <br> + <<militiaUnitsDescription $militiaUnits[_i]>> + <br> + <<link "Deploy the unit">> + <<set $militiaUnits[_i].isDeployed = 1>> + <<set $deployableUnits-->> + <<set $deployedUnits++>> + <<replace "#deploUni">><strong>$deployableUnits</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <</if>> + <</if>> +<</for>> +<<set _ms $slaveUnits.length>> +<br> +<<for _i = 0; _i < _mL; _i++>> + <<if $deployableUnits == 0>> + Unit roster full. + <<break>> + <<else>> + <<if $slaveUnits[_i].isDeployed == 0>> + <br> + <<slaveUnitsDescription $slaveUnits[_i]>> + <br> + <<link "Deploy the unit">> + <<set $slaveUnits[_i].isDeployed = 1>> + <<set $deployableUnits-->> + <<set $deployedUnits++>> + <<replace "#deploUni">><strong>$deployableUnits</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <</if>> + <</if>> +<</for>> +<<set _mL = $mercUnits.length>> +<<for _i = 0; _i < _mL; _i++>> + <<if $deployableUnits == 0>> + Unit roster full. + <<break>> + <<else>> + <<if $mercUnits[_i].isDeployed == 0>> + <br> + <<mercUnitsDescription $mercUnits[_i]>> + <br> + <<link "Deploy the unit">> + <<set $mercUnits[_i].isDeployed = 1>> + <<set $deployableUnits-->> + <<set $deployedUnits++>> + <<replace "#deploUni">><strong>$deployableUnits</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <</if>> + <</if>> +<</for>> + +<br><br> + +Units about to be deployed: +<br> +<<for _i = 0; _i < _mL; _i++>> + <<if $militiaUnits[_i].isDeployed == 1>> + <br> + <<militiaUnitsDescription $militiaUnits[_i]>> + <br> + <<link "Remove the unit">> + <<set $militiaUnits[_i].isDeployed = 0>> + <<set $deployableUnits++>> + <<set $deployedUnits-->> + <<replace "#deploUni">><strong>$deployableUnits</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <</if>> +<</for>> +<<for _i = 0; _i < _mL; _i++>> + <<if $slaveUnits[_i].isDeployed == 1>> + <br> + <<slaveUnitsDescription $slaveUnits[_i]>> + <br> + <<link "Remove the unit">> + <<set $slaveUnits[_i].isDeployed = 0>> + <<set $deployableUnits++>> + <<set $deployedUnits-->> + <<replace "#deploUni">><strong>$deployableUnits</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <</if>> +<</for>> +<<for _i = 0; _i < _mL; _i++>> + <<if $mercUnits[_i].isDeployed == 1>> + <br> + <<mercUnitsDescription $mercUnits[_i]>> + <br> + <<link "Remove the unit">> + <<set $mercUnits[_i].isDeployed = 0>> + <<set $deployableUnits++>> + <<set $deployedUnits-->> + <<replace "#deploUni">><strong>$deployableUnits</strong><</replace>> + <<goto "attackHandler">> + <</link>> + <</if>> +<</for>> -Troop deployment: \ No newline at end of file +/* tactics */ diff --git a/src/SecExp/secInit.tw b/src/SecExp/secInit.tw new file mode 100644 index 00000000000..48a3a785938 --- /dev/null +++ b/src/SecExp/secInit.tw @@ -0,0 +1,118 @@ +:: secInit [nobr] + +/* base vars */ +<<set $authority = 1000>> +<<set $security = 50>> +<,set $readiness = 0>> +<<set $attackPhase = 0>> +<<set $attackType = "none">> + +/* attacks progress stats */ +<<set $raidersProgress = 0>> +<<set $slaveProgress = 0>> +<<set $citizenProgress = 0>> +<<set $arcologyProgress = 0>> +<<set $freeCityProgress = 0>> +<<set $oldWorldProgress = 0>> +<<set $freedomProgress = 0>> + +/* armed forces stats */ +<<set $militiaCreated = 0>> +<<set $$slavesInArmy = 0>> +<<set $slaveManpower = 0>> +<<set $citizenManpower = 0>> +<<set $mercManpower = 0>> +<<set $slaveunits = 0>> +<<set $mercUnits = 0>> +<<set $militiaLoyalty = 0>> +<<set $slaveArmyLoyalty = 0>> +<<set $mercLoyalty = 0>> + +/* enhancements and improvements */ +<<set $riskSim = 0>> +<<set $riskSimExpectedAttack = "none">> +<<set $perimeterDrones = 0>> + +/* battle relevant variables */ +<<set $attackTroops = 0>> +<<set $attackEquip = 0>> +<<set $attackTraining = 0>> +<<set $deployableUnits = 0>> +<<set $deployedUnits = 0>> + +/* Units */ +<<if def $militiaUnits>> + <<set _mL = $militiaUnits.length>> + <<for _i = 0; _i < _mL; _i++>> + <<if _i == 1>> + <<set $militiaUnits[_i].name = _i + "st Citizens' Division">> + <<elseif _i == 2>> + <<set $militiaUnits[_i].divisionName = _i + "nd Citizens' Division">> + <<elseif _i == 3>> + <<set $militiaUnits[_i].divisionName = _i + "rd Citizens' Division">> + <<else>> + <<set $militiaUnits[_i].divisionName = _i + "th Citizens' Division">> + <</if>> + <<set $militiaUnits[_i].isDeployed = 0>> + <<set $militiaUnits[_i].isTired = 0>> + <<set $militiaUnits[_i].troops = 0>> + <<set $militiaUnits[_i].equip = 0>> + <<set $militiaUnits[_i].training = 0>> + <<set $militiaUnits[_i].rep = 0>> + <<set $militiaUnits[_i].loyalty = 0>> + <<set $militiaUnits[_i].medics = 0>> + <<set $militiaUnits[_i].engineers = 0>> + <</for>> +<<else>> + <<set $militiaUnits = []>> +<</if>> +<<if def $slaveUnits>> + <<set _mL = $slaveUnits.length>> + <<for _i = 0; _i < _mL; _i++>> + <<if _i == 1>> + <<set $slaveUnits[_i].name = _i + "st slave Division">> + <<elseif _i == 2>> + <<set $slaveUnits[_i].divisionName = _i + "nd slave Division">> + <<elseif _i == 3>> + <<set $slaveUnits[_i].divisionName = _i + "rd slave Division">> + <<else>> + <<set $slaveUnits[_i].divisionName = _i + "th slave Division">> + <</if>> + <<set $slaveUnits[_i].isDeployed = 0>> + <<set $slaveUnits[_i].isTired = 0>> + <<set $slaveUnits[_i].troops = 0>> + <<set $slaveUnits[_i].equip = 0>> + <<set $slaveUnits[_i].training = 0>> + <<set $slaveUnits[_i].rep = 0>> + <<set $slaveUnits[_i].loyalty = 0>> + <<set $slaveUnits[_i].medics = 0>> + <<set $slaveUnits[_i].engineers = 0>> + <</for>> +<<else>> + <<set $slaveUnits = []>> +<</if>> +<<if def $mercUnits>> + <<set _mL = $mercUnits.length>> + <<for _i = 0; _i < _mL; _i++>> + <<if _i == 1>> + <<set $mercUnits[_i].name = _i + "st mercenary Division">> + <<elseif _i == 2>> + <<set $mercUnits[_i].divisionName = _i + "nd mercenary Division">> + <<elseif _i == 3>> + <<set $mercUnits[_i].divisionName = _i + "rd mercenary Division">> + <<else>> + <<set $mercUnits[_i].divisionName = _i + "th mercenary Division">> + <</if>> + <<set $mercUnits[_i].isDeployed = 0>> + <<set $mercUnits[_i].isTired = 0>> + <<set $mercUnits[_i].troops = 0>> + <<set $mercUnits[_i].equip = 0>> + <<set $mercUnits[_i].training = 0>> + <<set $mercUnits[_i].rep = 0>> + <<set $mercUnits[_i].loyalty = 0>> + <<set $mercUnits[_i].medics = 0>> + <<set $mercUnits[_i].engineers = 0>> + <</for>> +<<else>> + <<set $mercUnits = []>> +<</if>> \ No newline at end of file diff --git a/src/SecExp/widgets/unitsDescriptionWidgets.tw b/src/SecExp/widgets/unitsDescriptionWidgets.tw new file mode 100644 index 00000000000..91df19b0a01 --- /dev/null +++ b/src/SecExp/widgets/unitsDescriptionWidgets.tw @@ -0,0 +1,13 @@ +:: unitsDescriptionWidgets [widget nobr] + +<<widget "militiaUnitsDescription">> + +<</widget>> + +<<widget "slaveUnitsDescription">> + +<</widget>> + +<<widget "mercUnitsDescription">> + +<</widget>>:: unitsDescriptionWidget [widget nobr] \ No newline at end of file diff --git a/src/init/storyInit.tw b/src/init/storyInit.tw index fd7af2abbd2..e8ab5e56192 100644 --- a/src/init/storyInit.tw +++ b/src/init/storyInit.tw @@ -1071,32 +1071,6 @@ FertilityAge($fertilityAge) <<set $pubertyLength = 5>> <<set $maxGrowthAge = 24>> -/* Security Expansion */ -/* base vars */ -<<set $authority = 1000>> -<<set $security = 50>> -<<set $attackType = "none">> -/* attacks progress stats */ -<<set $raidersProgress = 0>> -<<set $slaveRebellionProgress = 0>> -<<set $citizenRebellionProgress = 0>> -<<set $arcologyAttackProgress = 0>> -<<set $freeCityProgress = 0>> -<<set $oldWorldProgress = 0>> -/* armed forces stats */ -<<set $militiaForces = 0>> -<<set $slaveArmyForces =0>> -<<set $mercForces = 0>> -<<set $militiaLoyalty = 0>> -<<set $slaveArmyLoyalty = 0>> -<<set $mercLoyalty = 0>> -/* enhancements and improvements */ -<<set $riskSim = 0>> -<<set $riskSimExpectedAttack = "none">> -<<set $perimeterDrones = 0>> -/* battle relevant variables */ -<<set $attackTroops = 0>> -<<set $attackEquip = 0>> /% Begin mod section: toggle whether slaves lisp. %/ @@ -1233,4 +1207,7 @@ ocularImplant: 0, erectileImplant: 0 } >> +/* Security Expansion */ +<<include "secInit">> + <<goto "Alpha disclaimer">> -- GitLab