#!/bin/bash # A script that creates a DropTeam mod by copying and modifying the # game's XML files. # $RCSfile: mkmod,v $ $Revision: 1.39 $ # $Author: pjb $ $Date: 2008/11/10 21:54:48 $ # $Locker: $ # Phil Brooke, April 2007. # There is absolutely no warranty associated with this script. # Instructions: # - This script needs Cygwin to run, including xsltproc. # - Create a mod directory, say, DropTeam/Mods/P180M2 # - Copy this file to your new mod directory. # - If you have Creature Zoo, then check that CZMOD is set to the # correct location. # - Run it, choosing your modifications via the config or switches. set -e DESC=data/Description.txt ORIGPARAMS="$@" CZMOD=../Creature_Zoo_7 configCZ=0 configFastCutter=0 configNoATGM=0 configNoIon=0 configNoThorIon=0 config20mmShrike=0 configPaladinMortarCoax=0 configApolloMortarCoax=0 configThorMortarCoax=0 configHurricaneCoax=0 configThorDF=0 configThorSpecial=0 configPointDefenceTurret=0 configWeakTowers=0 configLow=0 configArtillerySquad=0 configShowDiff=0 function defaultConfig () { configCZ=1 configFastCutter=1 configNoATGM=0 configNoIon=0 configNoThorIon=0 config20mmShrike=1 configPaladinMortarCoax=1 configApolloMortarCoax=1 configThorMortarCoax=1 configHurricaneCoax=1 configThorDF=1 configThorSpecial=1 configPointDefenceTurret=1 configWeakTowers=1 configLow=0 configArtillerySquad=1 configShowDiff=0 } function help () { cat < defaultConfig ) EOF exit 0 } # Sort out the command line. if test $# = 0; then defaultConfig else while test "Q$1" != Q; do case "$1" in -help) help ;; -default) defaultConfig ;; -CZ) configCZ=1 ;; -fastCutter) configFastCutter=1 ;; -noATGM) configNoATGM=1 ;; -noIon) configNoIon=1 ;; -noTI) configNoThorIon=1 ;; -S20) config20mmShrike=1 ;; -PMcoax) configPaladinMortarCoax=1 ;; -AMcoax) configApolloMortarCoax=1 ;; -TMcoax) configThorMortarCoax=1 ;; -HMcoax) configHurricaneCoax=1 ;; -coax) configPaladinMortarCoax=1; configApolloMortarCoax=1; configThorMortarCoax=1; configHurricaneCoax=1;; -TDF) configThorDF=1 ;; -TS) configThorSpecial=1 ;; -PDT) configPointDefenceTurret=1 ;; -weak) configWeakTowers=1 ;; -low) configLow=1 ;; -artsquad) configArtillerySquad=1;; -showdiff) configShowDiff=1 ;; esac shift done fi # The actual working. function applyxsl () { # applyxsl (file to modify) cat > temp.xsl echo "Applying XSL to file $1..." xsltproc temp.xsl "$1" | xmllint --format - > "$1".new test "${configShowDiff}" = 1 && diff "$1" "$1".new || true mv "$1".new "$1" rm temp.xsl } echo "Moving to directory: " $(dirname "$0") cd $(dirname "$0") if which xsltproc > /dev/null; then echo "Using xsltproc: " $(which xsltproc) else echo "Can't find xsltproc!" exit 1 fi if which xmllint > /dev/null; then echo "Using xmllint: " $(which xmllint) else echo "Can't find xmllint!" exit 1 fi if test ! -e data; then echo "Creating the 'data' directory..." mkdir data elif test ! -d data; then echo "'data' already exists, but is not a directory." exit 1 else echo "Looks like the 'data' directory already exists." fi echo "Initial files..." cp ../../data/Inventory.xml data cat >${DESC} < EOF applyxsl data/Inventory.xml < M9Engineer.physicalobjectgroup EOF echo " - Added Creature Zoo modifications.~" >> ${DESC} fi # The M9 cutter is too slow. if test "${configFastCutter}" = 1; then applyxsl data/M9Engineer.physicalobjectgroup < EOF echo " - Cutter is as fast as an Apollo.~" >> ${DESC} fi # Don't always want ATGMs in the game. if test "${configNoATGM}" = 1; then applyxsl data/Inventory.xml < EOF echo " - Modified inventory to remove ATGMs.~" >> ${DESC} fi # Don't always want Ion cannon/beams in the game. if test "${configNoIon}" = 1; then applyxsl data/Inventory.xml < EOF echo " - Modified inventory to remove Ion cannons and beams.~" >> ${DESC} fi # Don't always want the Thor IC in the game. if test "${configNoThorIon}" = 1; then applyxsl data/Inventory.xml < EOF echo " - Modified inventory to remove Thor IC.~" >> ${DESC} fi # Add the 20mm Shrike KC-L to the game. if test "${config20mmShrike}" = 1; then applyxsl data/Inventory.xml < Shrike KC-L PanelShrike.png ShrikeA.physicalobjectgroup 10 7 1 9 20mm Gun Recon true EOF echo " - Modified inventory to add 20mm Shrike (KC-L).~" >> ${DESC} fi # Want a coaxial gun on the Paladin mortar. if test "${configPaladinMortarCoax}" = 1; then applyxsl data/IFV-MC.physicalobjectgroup < EOF echo " - Paladin mortar has 14mm coaxial gun.~" >> ${DESC} fi # Want a coaxial gun on the Apollo mortar. if test "${configApolloMortarCoax}" = 1; then applyxsl data/SPMortar.physicalobjectgroup < EOF echo " - Apollo mortar has 14mm coaxial gun.~" >> ${DESC} fi # Want a coaxial gun on the Thor mortar. if test "${configThorMortarCoax}" = 1; then applyxsl data/MBT-MC.physicalobjectgroup < EOF echo " - Thor mortar has 20mm coaxial gun.~" >> ${DESC} fi # Want a coaxial gun on the Hurricane. if test "${configHurricaneCoax}" = 1; then applyxsl data/Hurricane.physicalobjectgroup < EOF echo " - Hurricane has 14mm coaxial gun.~" >> ${DESC} fi # Want a Thor with the Hurricane's artillery. if test "${configThorDF}" = 1; then applyxsl data/MBT-DF.physicalobjectgroup < EOF applyxsl data/MBT-DF.physicalobjectgroup < 30 EOF applyxsl data/Inventory.xml < Thor MC-HD PanelThor-MC.png MBT-DF.physicalobjectgroup 4 10 9 3 Heavy Mortar Direct Support false EOF echo " - Added Thor with Hurricane direct fire artillery (30 rounds, not 10).~" >> ${DESC} fi # Want a special Thor. if test "${configThorSpecial}" = 1; then applyxsl data/MBT-SP.physicalobjectgroup < True 60 60 50 TOWe.physicalobjectgroup AmmoHEAT.png 1500.0 0.003 ATGM 25 HEAT MissileLaunch.wav 20mmHE.physicalobjectgroup AmmoHE.png 900.0 0.01 HE 600 HE 5 30mmHV.physicalobjectgroup AmmoAP.png 4000.0 0.001 HV 600 AP 5 EOF applyxsl data/Inventory.xml < Thor Special PanelMBT120.png MBT-SP.physicalobjectgroup 10 10 9 3 120mm Gun Main Battle Tank false EOF echo " - Added Thor Special (antiair gun from Hermes, can capture, command electronics, faster, more ammo, more types of ammo).~" >> ${DESC} fi # Turret with point defence gun. if test "${configPointDefenceTurret}" = 1; then applyxsl data/PDTurret.physicalobjectgroup < EOF applyxsl data/Inventory.xml < Point Defence Turret PanelAATurret.png PDTurret.physicalobjectgroup 8 5 1 1 true AA Gun Air Defense true true EOF echo " - Added point defence turret (Hermes antiair gun).~" >> ${DESC} fi # I get bored of trying to blow up some towers. if test "${configWeakTowers}" = 1; then applyxsl data/AirDefenseTower.physicalobjectgroup < 390 EOF applyxsl data/MissileAirDefenseTower.physicalobjectgroup < 390 EOF echo " - Weaker AA towers.~" >> ${DESC} fi # Artillery squad if test "${configArtillerySquad}" = 1; then applyxsl data/ArtillerySquadLeader.physicalobjectgroup < Artillery Squad Leader SpecialistArtillery.physicalobjectgroup EOF applyxsl data/SpecialistArtillery.physicalobjectgroup < CommandElectronicsSuite EOF applyxsl data/Inventory.xml < Artillery Squad 20mmSquadPanel.png ArtillerySquadLeader.physicalobjectgroup 6 3 1 1 10mm Rifle Infantry true true EOF echo " - Added artillery squad.~" >> ${DESC} fi # Reduce the inventories. if test "${configLow}" = 1; then applyxsl data/Inventory.xml < 1 6 8 8 2 2 2 2 5 6 2 4 5 4 2 6 4 1 1 1 1 1 2 1 1 1 2 2 EOF echo " - Modified inventory to reduce limits.~" >> ${DESC} fi # Original parameters. echo "$ORIGPARAMS" > last.params # TODO: # - New Thor KC-M variant with 76mm and 20mm. # - New Apollo KC-M variant with 76mm and 14mm. # - New Apollo variant with Hurricane mortar and 14mm. # - Make it quicker to capture some buildings. # Done! echo "Tidy up..." cat >>${DESC} <