// FinalAlert2:YR Script file
// Name: FlyingZ Random Survival Map Script v1.4
// Written By: James Zais aka FlyingZ

GetIniKey("%Once%","RUN","0");
Is("%Once%","=", "1", "GE");
Message("You cannot run script twice on the same map", "FlyingZ", "GE");
Cancel("GE");

RequiresMP();

Is("%PlayerCount%",">", "4", "TooManyPlayers");
AskContinue("You must delete all waypoints curriently on the map","TooManyPlayers");
Cancel("TooManyPlayers");

Message("FlyingZ Random Survival Map Script v2.0", "FlyingZ");

// Loop
UInputGetInteger("%Level%","What Level? {1-14}","1","14");
SetVariable("%LoopCount%","8");
Multi("%LoopCount%","%Level%");

AllowAdd("--------------------------------------------------------------------- Necessary to edit the map ---------------------------------------------------------------------");
Is("%AddAllowed%","=","0","%NoAdd%");
Message("Adding must be allowed for this script to run!", "FlyingZ", "%NoAdd%");
Cancel("%NoAdd%");

SetSafeMode("FALSE","------------------------------------------------------------------- Necessary to edit the map -------------------------------------------------------------------");
Is("%SafeMode%","!=","0","%NoSet%");
Message("SafeMode must be disabled for this script to run!", "FlyingZ", "%NoSet%");
Cancel("%NoSet%");

SetAutoUpdate("FALSE");

// Basic map info
// SetIniKey("RUN","0","1");
// SetIniKey("Basic","Name","FlyingZ Random Survival v2.1 Level %Level%");
// SetIniKey("Authorfscript","0","This map has used FlyingZ Random Survival Map fscript vs2.1");
// SetIniKey("Authorfscript","1","Created by James Zais aka FlyingZ");

// Cash and Fast Build
SetIniKey("General","BuildSpeed","0.3");
SetIniKey("HARV","TechLevel","11");
SetIniKey("HARV","CrateGoodie","no");
SetIniKey("CMIN","TechLevel","11");
SetIniKey("CMIN","CrateGoodie","no");
SetIniKey("SMIN","TechLevel","11");
SetIniKey("SMIN","CrateGoodie","no");
SetIniKey("GAREFN","TechLevel","11");
SetIniKey("NAREFN","TechLevel","11");
SetIniKey("GAOREP","TechLevel","11");
SetIniKey("YAREFN","TechLevel","11");
SetIniKey("NAWEAP","Prerequisite","CAOILD,NAHAND,NACNST");
SetIniKey("GAWEAP","Prerequisite","CAOILD,GAPILE,GACNST");
SetIniKey("NARADR","Prerequisite","CAOILD,NACNST");
SetIniKey("NARADR","SuperWeapon","none");
SetIniKey("GAAIRC","Prerequisite","CAOILD,GACNST");
SetIniKey("AMRADR","Prerequisite","CAOILD,GACNST");
SetIniKey("NAINDP","Prerequisite","CAOILD,NATECH,NACNST");
SetIniKey("NAPSIS","Prerequisite","CAOILD,YACNST");
SetIniKey("YAWEAP","Prerequisite","CAOILD,YABRCK,YACNST");
SetIniKey("General","PrerequisiteProc","CAOILD,CAOILD,CAOILD");
SetIniKey("NAPSIS","SuperWeapon","none");
SetIniKey("NAPSIS","SensorArray","no");
SetIniKey("NAPSIS","HasRadialIndicator","false");
SetIniKey("NAPSIS","PsychicDetectionRadius","0");
SetIniKey("CAOILD","Prerequisite","POWER");
SetIniKey("CAOILD","BuildCat","Resource");
SetIniKey("CAOILD","Owner","British,French,Germans,Americans,Alliance,Russians,Confederation,Africans,Arabs,YuriCountry");
SetIniKey("CAOILD","ProduceCashDelay","20");
SetIniKey("CAOILD","ProduceCashAmount","140");
SetIniKey("CAOILD","LeaveRubble","no");
SetIniKey("CAOILD","Insignificant","no");
SetIniKey("CAOILD","BuildLimit","1");
SetIniKey("CAOILD","NeedsEngineer","no");
SetIniKey("CAOILD","TechLevel","1");
SetIniKey("CAOILD","AIBuildThis","yes");
SetIniKey("CAOILD","Cost","200");
SetIniKey("CAOILD","FreeUnit","HOWI");
SetIniKey("HowitzerWH","AnimList","XGRYSML1,XGRYSML2,EXPLOSML,XGRYMED1,XGRYMED2,EXPLOMED,EXPLOLRG,TWLT070");

// Lag Reduction and misc.
SetIniKey("GACNST","Strength","5000");
SetIniKey("GACNST","ImmuneToPsionics","yes");
SetIniKey("NACNST","Strength","5000");
SetIniKey("NACNST","ImmuneToPsionics","yes");
SetIniKey("YACNST","Strength","5000");
SetIniKey("YACNST","ImmuneToPsionics","yes");
SetIniKey("Difficult","BuildSlowdown","no");
SetIniKey("Difficult","Armor","1.0");
SetIniKey("Difficult","ROF","1.0");
SetIniKey("Difficult","RepairDelay",".02");
SetIniKey("Difficult","BuildDelay",".03");
SetIniKey("IQ","RepairSell","0");
SetIniKey("General","Stray","5.0");
SetIniKey("General","WarpOut","none");
SetIniKey("General","VeteranCombat","2");
SetIniKey("General","VeteranArmor","3");
SetIniKey("General","VeteranRatio","7.0");
SetIniKey("General","DeadBodies","INVISO");
SetIniKey("General","ChronoDelay","0");
SetIniKey("General","CreditTicks","null");
SetIniKey("General","ChronoSparkle1","none");
SetIniKey("AudioVisual","ChronoInSound","Dummy");
SetIniKey("AudioVisual","ExtraUnitLight","0");
SetIniKey("AudioVisual","DiskLaserChargeUp","Dummy");
SetIniKey("AudioVisual","ExtraAircraftLight","0");
SetIniKey("AudioVisual","ExtraInfantryLight","0");
SetIniKey("AudioVisual","IdleActionFrequency","50");
SetIniKey("ZEP","MaxDebris","0");
SetIniKey("YTNK","MaxDebris","0");
SetIniKey("V3","MaxDebris","0");
SetIniKey("TTNK","MaxDebris","0");
SetIniKey("TNKD","MaxDebris","0");
SetIniKey("TELE","MaxDebris","0");
SetIniKey("FV","MaxDebris","0");
SetIniKey("DRON","MaxDebris","0");
SetIniKey("APOC","MaxDebris","0");
SetIniKey("SREF","MaxDebris","0");
SetIniKey("MGTK","MaxDebris","0");
SetIniKey("MGTK","DisguiseWhenStill","no");
SetIniKey("DISK","MaxDebris","0");
SetIniKey("DISK","MoveSound","Dummy");
SetIniKey("MirageGun","Bright","no");
SetIniKey("MirageGunE","Bright","no");
SetIniKey("SuperComet","Bright","no");
SetIniKey("Comet","Bright","no");
SetIniKey("CometWH","AnimList","XGRYSML1");
SetIniKey("GAYARD","TechLevel","11");
SetIniKey("NAYARD","TechLevel","11");
SetIniKey("YAYARD","TechLevel","11");
SetIniKey("GTGCAN","TurretRecoil","no");
SetIniKey("GTGCAN","TurretRotateSound","Dummy");
SetIniKey("GrandCannonWH","AnimList","XGRYSML1");
SetIniKey("GrandCannonWH","Verses","100%,100%,100%,100%,100%,100%,1%,1%,1%,100%,100%");
SetIniKey("ROBO","PoweredUnit","no");
SetIniKey("AI","BlockagePathDelay","40");

// No Supers
SetIniKey("GACSPH","TechLevel","11");
SetIniKey("GAWEAT","TechLevel","11");
SetIniKey("NAIRON","TechLevel","11");
SetIniKey("NAMISL","TechLevel","11");
SetIniKey("YAGNTC","TechLevel","11");
SetIniKey("YAPPET","TechLevel","11");

// Reveal
SetIniKey("MultiplayerDialogSettings","Shroud","no");
SetIniKey("GASPYSAT","TechLevel","11");
SetIniKey("GAGAP","TechLevel","11");

// TreeLoop
SetVariable("%TRCounter%","3");
Multi("%TRCounter%","%Level%");

:BeginTree:

GetRandom("%TX%");
Divide("%TX%","380");
Is("%TX%","<","10","%HelpTX%");
Add("%TX%","10","%HelpTX%");
GetRandom("%TY%");
Divide("%TY%","380");
Is("%TY%","<","10","%HelpTY%");
Add("%TY%","10","%HelpTY%");
AddTerrain("TREE01", "%TX%", "%TY%");

GetRandom("%TX%");
Divide("%TX%","380");
Is("%TX%","<","10","%HelpTX%");
Add("%TX%","10","%HelpTX%");
GetRandom("%TY%");
Divide("%TY%","380");
Is("%TY%","<","10","%HelpTY%");
Add("%TY%","10","%HelpTY%");
AddTerrain("TREE02", "%TX%", "%TY%");

GetRandom("%TX%");
Divide("%TX%","380");
Is("%TX%","<","10","%HelpTX%");
Add("%TX%","10","%HelpTX%");
GetRandom("%TY%");
Divide("%TY%","380");
Is("%TY%","<","10","%HelpTY%");
Add("%TY%","10","%HelpTY%");
AddTerrain("TREE03", "%TX%", "%TY%");

GetRandom("%TX%");
Divide("%TX%","380");
Is("%TX%","<","10","%HelpTX%");
Add("%TX%","10","%HelpTX%");
GetRandom("%TY%");
Divide("%TY%","380");
Is("%TY%","<","10","%HelpTY%");
Add("%TY%","10","%HelpTY%");
AddTerrain("TREE04", "%TX%", "%TY%");

GetRandom("%TX%");
Divide("%TX%","380");
Is("%TX%","<","10","%HelpTX%");
Add("%TX%","10","%HelpTX%");
GetRandom("%TY%");
Divide("%TY%","380");
Is("%TY%","<","10","%HelpTY%");
Add("%TY%","10","%HelpTY%");
AddTerrain("TREE05", "%TX%", "%TY%");

GetRandom("%TX%");
Divide("%TX%","380");
Is("%TX%","<","10","%HelpTX%");
Add("%TX%","10","%HelpTX%");
GetRandom("%TY%");
Divide("%TY%","380");
Is("%TY%","<","10","%HelpTY%");
Add("%TY%","10","%HelpTY%");
AddTerrain("TREE06", "%TX%", "%TY%");

Substract("%TRCounter%","1");
Is("%TRCounter%","=","1","%Done%");
JumpTo("EndTree", "%Done%");
JumpTo("BeginTree");
:EndTree:

// Resize
Resize("0","0","39","88");
SetVariable("Size", "%Width%");
Is("Size","!=","39","NoSize");
Message("Map resize is manditory", "FlyingZ", "NoSize");
Message("Random Survival Map FAILED!", "FlyingZ", "NoSize");
Cancel("NoSize");

// Map
SetVariable("%Map%","TEMPERATE");
GetRandom("%TossA%");
Is("%Toss%","<","12000","%MapA%");
Is("%Toss%",">","20000","%MapB%");
SetIniKey("Map","Theater","SNOW","%MapA%");
SetIniKey("Map","Theater","DESERT","%MapB%");

// Player
SetIniKey("Waypoints","0","98085");
SetIniKey("Waypoints","1","91092");
SetIniKey("Waypoints","2","84099");
SetIniKey("Waypoints","3","27028");

// Spawn
SetIniKey("Waypoints","500","44025");
SetIniKey("Waypoints","501","38031");
SetIniKey("Waypoints","502","30039");
SetIniKey("Waypoints","503","24045");

// Behind Player
SetIniKey("Waypoints","505","108089");
SetIniKey("Waypoints","506","88109");
SetIniKey("Waypoints","507","98099");

AddTrigger("%TriggerID%", "Neutral,<none>,AI,0,1,1,1,0", "1,8,0,0", "1,36,0,4478,0,0,0,0,A", "TRUE");
AddTrigger("%TriggerID%", "Neutral,<none>,AI,0,1,1,1,0", "1,13,0,100", "1,11,4,This.map.was.created.with.the,0,0,0,0,A", "TRUE");
AddTrigger("%TriggerID%", "Neutral,<none>,AI,0,1,1,1,0", "1,13,0,104", "1,11,4,Random.Survival.Map.Generator,0,0,0,0,A", "TRUE");
AddTrigger("%TriggerID%", "Neutral,<none>,AI,0,1,1,1,0", "1,13,0,108", "1,11,4,FlyingZ,0,0,0,0,A", "TRUE");
AddTrigger("%TriggerID%", "Neutral,<none>,AI,0,1,1,1,0", "1,13,0,200", "1,11,4,This.map.was.created.with.the,0,0,0,0,A", "TRUE");
AddTrigger("%TriggerID%", "Neutral,<none>,AI,0,1,1,1,0", "1,13,0,204", "1,11,4,Random.Survival.Map.Generator,0,0,0,0,A", "TRUE");
AddTrigger("%TriggerID%", "Neutral,<none>,AI,0,1,1,1,0", "1,13,0,208", "1,11,4,FlyingZ,0,0,0,0,A", "TRUE");

// Light
GetRandom("%Red%");
Divide("%Red%","3640");
Is("%Red%","<","5","%LowRed%");
Add("%Red%","5","%LowRed%");

GetRandom("%Blue%");
Divide("%Blue%","3640");
Is("%Blue%","<","5","%LowBlue%");
Add("%Blue%","5","%LowBlue%");

GetRandom("%Green%");
Divide("%Green%","3640");
Is("%Green%","<","5","%LowGreen%");
Add("%Green%","5","%LowGreen%");

GetRandom("%Amb%");
Divide("%Amb%","3640");
Is("%Amb%","<","7","%LowAmb%");
SetVariable("%Amb%","65","%LowAmb%");

SetIniKey("Lighting","Red","0.%Red%");
SetIniKey("Lighting","Blue","0.%Blue%");
SetIniKey("Lighting","Green","0.%Green%");
SetIniKey("Lighting","Ambient","0.%Amb%");

// Taskforce list
SetIniKey("TaskForces","0","01000500");
SetIniKey("TaskForces","1","01000501");
SetIniKey("TaskForces","2","01000502");
SetIniKey("TaskForces","3","01000503");
SetIniKey("TaskForces","4","01000504");
SetIniKey("TaskForces","5","01000505");
SetIniKey("TaskForces","6","01000506");
SetIniKey("TaskForces","7","01000507");
SetIniKey("TaskForces","8","01000508");
SetIniKey("TaskForces","9","01000509");
SetIniKey("TaskForces","10","01000510");
SetIniKey("TaskForces","11","01000511");
SetIniKey("TaskForces","12","01000512");
SetIniKey("TaskForces","13","01000513");
SetIniKey("TaskForces","14","01000514");
SetIniKey("TaskForces","15","01000515");
SetIniKey("TaskForces","16","01000516");
SetIniKey("TaskForces","17","01000517");
SetIniKey("TaskForces","18","01000518");
SetIniKey("TaskForces","19","01000519");
SetIniKey("TaskForces","20","01000520");
SetIniKey("TaskForces","21","01000521");
SetIniKey("TaskForces","22","01000522");
SetIniKey("TaskForces","23","01000523");
SetIniKey("TaskForces","24","01000524");
SetIniKey("TaskForces","25","01000525");
SetIniKey("TaskForces","26","01000526");
SetIniKey("TaskForces","27","01000527");

// Taskforce
SetVariable("%Unit%","E2");
GetRandom("%UToss%");
Is("%Toss%","<","10922","%UnitA%");
Is("%Toss%",">","21845","%UnitB%");
SetVariable("%Unit%","INIT","%UnitA%");
SetVariable("%Unit%","E1","%UnitB%");
SetIniKey("01000500","0","35,%Unit%");

SetIniKey("01000501","0","35,SHK");
SetIniKey("01000502","0","13,BRUTE");
SetIniKey("01000503","0","5,LTNK");
SetIniKey("01000504","0","18,TANY");
SetIniKey("01000505","0","12,ROBO");
SetIniKey("01000506","0","28,YURI");
SetIniKey("01000507","0","18,DRON");

GetRandom("%UToss%");
Is("%UToss%","<","16384","%UnitA%");
Is("%UToss%",">=","16384","%UnitB%");
SetVariable("%Unit%","YTNK","%UnitA%");
SetVariable("%Unit%","HTK","%UnitB%");
SetIniKey("01000508","0","15,%Unit%");

SetIniKey("01000509","0","18,CAOS");
SetIniKey("01000510","0","24,V3");
SetIniKey("01000511","0","24,MGTK");

SetIniKey("01000512","0","1,FV");
SetIniKey("01000512","1","1,BORIS");

SetIniKey("01000513","0","23,MTNK");
SetIniKey("01000514","0","23,TTNK");

// BF
SetIniKey("01000515","0","1,BFRT");
GetRandom("%UToss%");
Is("%UToss%","<","16384","%UnitA%");
Is("%UToss%",">=","16384","%UnitB%");
SetVariable("%Unit%","GGI","%UnitA%");
SetVariable("%Unit%","FLAKT","%UnitB%");
SetIniKey("01000515","1","3,%Unit%");
GetRandom("%UToss%");
Is("%UToss%","<","16384","%UnitA%");
Is("%UToss%",">=","16384","%UnitB%");
SetVariable("%Unit%","E1","%UnitA%");
SetVariable("%Unit%","SHK","%UnitB%");
SetIniKey("01000515","2","2,%Unit%");

SetIniKey("01000516","0","12,JUMPJET");
SetIniKey("01000517","0","23,APOC");
SetIniKey("01000518","0","23,TELE");

SetIniKey("01000519","0","1,BFRT");
SetIniKey("01000519","1","5,GGI");

SetIniKey("01000520","0","28,TNKD");
SetIniKey("01000521","0","15,SCHP");
SetIniKey("01000522","0","23,SREF");

SetIniKey("01000523","0","1,FV");
SetIniKey("01000523","1","1,IVAN");

SetIniKey("01000524","0","18,MIND");
SetIniKey("01000524","1","18,YURIPR");

SetIniKey("01000525","0","9,ZEP");
SetIniKey("01000526","0","30,HTNK");
SetIniKey("01000527","0","15,DISK");

// Script List
SetIniKey("ScriptTypes","0","01000600");
SetIniKey("ScriptTypes","1","01000601");
SetIniKey("ScriptTypes","2","01000602");
SetIniKey("ScriptTypes","3","01000603");
SetIniKey("ScriptTypes","4","01000604");

// Script
SetIniKey("01000600","0","0,1");
SetIniKey("01000601","0","14,0");  // Load attack
SetIniKey("01000601","1","0,1");
SetIniKey("01000602","0","16,505");
SetIniKey("01000602","1","0,1");
SetIniKey("01000603","0","16,506");
SetIniKey("01000603","1","0,1");
SetIniKey("01000604","0","16,507");
SetIniKey("01000604","1","0,1");

SetVariable("%Team%","01000700");
SetVariable("%Task%","01000500");
SetVariable("%Time%","350");
SetVariable("%Num%","0");
SetVariable("%MT%","350");
SetVariable("%TName%","1");

:BeginLoop:

// Team A
SetIniKey("TeamTypes","%Num%","%Team%");

// Random script
SetVariable("%Script%","01000603");
GetRandom("%Toss%");
Is("%Toss%","<","10922","%TeamB%");
Is("%Toss%",">","21844","%TeamC%");
SetVariable("%Script%","01000602","%TeamB%");
SetVariable("%Script%","01000604","%TeamC%");

Is("%Task%","=","01000515","%LoadA%");
SetVariable("%Script%","01000601","%LoadA%");
Substract("%Time%","80","%LoadA%");

Is("%Task%","=","01000519","%LoadB%");
SetVariable("%Script%","01000601","%LoadB%");
Substract("%Time%","80","%LoadB%");

Is("%Task%","=","01000523","%LoadC%");
SetVariable("%Script%","01000601","%LoadC%");
Substract("%Time%","50","%LoadC%");

Is("%Task%","=","01000510","%V3Pat%");
SetVariable("%Script%","01000604","%V3Pat%");
SetVariable("%Avoid%","yes","%V3Pat%");
Substract("%Time%","50","%V3Pat%");

Is("%Task%","=","01000512","%LoadD%");
SetVariable("%Script%","01000601","%LoadD%");
Substract("%Time%","80","%LoadD%");

Is("%Task%","=","01000518","%MagPat%");
SetVariable("%Script%","01000604","%MagPat%");
SetVariable("%Avoid%","yes","%MagPat%");

SetIniKey("%Team%","House","<Player @ D>");
SetIniKey("%Team%","TaskForce","%Task%");
SetIniKey("%Team%","Script","%Script%");
SetIniKey("%Team%","Max","5");
SetIniKey("%Team%","Full","no");
SetIniKey("%Team%","Group","-1");
SetIniKey("%Team%","Whiner","no");
SetIniKey("%Team%","Droppod","no");
SetIniKey("%Team%","Suicide","no");
SetIniKey("%Team%","Loadable","yes");
SetIniKey("%Team%","Prebuild","no");
SetIniKey("%Team%","Priority","5");
SetIniKey("%Team%","Annoyance","no");
SetIniKey("%Team%","IonImmune","no");
SetIniKey("%Team%","Recruiter","yes");
SetIniKey("%Team%","Reinforce","no");
SetIniKey("%Team%","TechLevel","0");
SetIniKey("%Team%","Aggressive","yes");
SetIniKey("%Team%","Autocreate","no");
SetIniKey("%Team%","GuardSlower","no");
SetIniKey("%Team%","OnTransOnly","no");
SetIniKey("%Team%","AvoidThreats","%Avoid%");
SetIniKey("%Team%","LooseRecruit","no");
SetIniKey("%Team%","VeteranLevel","1");
SetIniKey("%Team%","IsBaseDefense","no");
SetIniKey("%Team%","UseTransportOrigin","no");
SetIniKey("%Team%","MindControlDecision","0");
SetIniKey("%Team%","OnlyTargetHouseEnemy","no");
SetIniKey("%Team%","TransportsReturnOnUnload","no");
SetIniKey("%Team%","AreTeamMembersRecruitable","yes");

SetVariable("%Team1%","%Team%");

Add("%Team%","1");
SetVariable("%Team%","0%Team%");
Add("%Num%","1");
SetVariable("%Avoid%","no");

// Team B
SetIniKey("TeamTypes","%Num%","%Team%");

// Random script
SetVariable("%Script%","01000603");
GetRandom("%Toss%");
Is("%Toss%","<","10922","%TeamB%");
Is("%Toss%",">","21844","%TeamC%");
SetVariable("%Script%","01000602","%TeamB%");
SetVariable("%Script%","01000604","%TeamC%");

Is("%Task%","=","01000515","%LoadA%");
SetVariable("%Script%","01000601","%LoadA%");

Is("%Task%","=","01000519","%LoadB%");
SetVariable("%Script%","01000601","%LoadB%");

Is("%Task%","=","01000523","%LoadC%");
SetVariable("%Script%","01000601","%LoadC%");

Is("%Task%","=","01000510","%V3Pat%");
SetVariable("%Script%","01000604","%V3Pat%");
SetVariable("%Avoid%","yes","%V3Pat%");

Is("%Task%","=","01000512","%LoadD%");
SetVariable("%Script%","01000601","%LoadD%");

Is("%Task%","=","01000518","%MagPat%");
SetVariable("%Script%","01000604","%MagPat%");
SetVariable("%Avoid%","yes","%MagPat%");

SetIniKey("%Team%","House","<Player @ D>");
SetIniKey("%Team%","TaskForce","%Task%");
SetIniKey("%Team%","Script","%Script%");
SetIniKey("%Team%","Max","5");
SetIniKey("%Team%","Full","no");
SetIniKey("%Team%","Group","-1");
SetIniKey("%Team%","Whiner","no");
SetIniKey("%Team%","Droppod","no");
SetIniKey("%Team%","Suicide","no");
SetIniKey("%Team%","Loadable","yes");
SetIniKey("%Team%","Prebuild","no");
SetIniKey("%Team%","Priority","5");
SetIniKey("%Team%","Annoyance","no");
SetIniKey("%Team%","IonImmune","no");
SetIniKey("%Team%","Recruiter","yes");
SetIniKey("%Team%","Reinforce","no");
SetIniKey("%Team%","TechLevel","0");
SetIniKey("%Team%","Aggressive","yes");
SetIniKey("%Team%","Autocreate","no");
SetIniKey("%Team%","GuardSlower","no");
SetIniKey("%Team%","OnTransOnly","no");
SetIniKey("%Team%","AvoidThreats","%Avoid%");
SetIniKey("%Team%","LooseRecruit","no");
SetIniKey("%Team%","VeteranLevel","1");
SetIniKey("%Team%","IsBaseDefense","no");
SetIniKey("%Team%","UseTransportOrigin","no");
SetIniKey("%Team%","MindControlDecision","0");
SetIniKey("%Team%","OnlyTargetHouseEnemy","no");
SetIniKey("%Team%","TransportsReturnOnUnload","no");
SetIniKey("%Team%","AreTeamMembersRecruitable","yes");

SetVariable("%Team2%","%Team%");

Add("%Team%","1");
SetVariable("%Team%","0%Team%");
Add("%Num%","1");
SetVariable("%Avoid%","no");

// Team C
SetIniKey("TeamTypes","%Num%","%Team%");

// Random script
SetVariable("%Script%","01000603");
GetRandom("%Toss%");
Is("%Toss%","<","10922","%TeamB%");
Is("%Toss%",">","21844","%TeamC%");
SetVariable("%Script%","01000602","%TeamB%");
SetVariable("%Script%","01000604","%TeamC%");

Is("%Task%","=","01000515","%LoadA%");
SetVariable("%Script%","01000601","%LoadA%");

Is("%Task%","=","01000519","%LoadB%");
SetVariable("%Script%","01000601","%LoadB%");

Is("%Task%","=","01000523","%LoadC%");
SetVariable("%Script%","01000601","%LoadC%");

Is("%Task%","=","01000510","%V3Pat%");
SetVariable("%Script%","01000604","%V3Pat%");
SetVariable("%Avoid%","yes","%V3Pat%");

Is("%Task%","=","01000512","%LoadD%");
SetVariable("%Script%","01000601","%LoadD%");

Is("%Task%","=","01000518","%MagPat%");
SetVariable("%Script%","01000604","%MagPat%");
SetVariable("%Avoid%","yes","%MagPat%");

SetIniKey("%Team%","House","<Player @ D>");
SetIniKey("%Team%","TaskForce","%Task%");
SetIniKey("%Team%","Script","%Script%");
SetIniKey("%Team%","Max","5");
SetIniKey("%Team%","Full","no");
SetIniKey("%Team%","Group","-1");
SetIniKey("%Team%","Whiner","no");
SetIniKey("%Team%","Droppod","no");
SetIniKey("%Team%","Suicide","no");
SetIniKey("%Team%","Loadable","yes");
SetIniKey("%Team%","Prebuild","no");
SetIniKey("%Team%","Priority","5");
SetIniKey("%Team%","Annoyance","no");
SetIniKey("%Team%","IonImmune","no");
SetIniKey("%Team%","Recruiter","yes");
SetIniKey("%Team%","Reinforce","no");
SetIniKey("%Team%","TechLevel","0");
SetIniKey("%Team%","Aggressive","yes");
SetIniKey("%Team%","Autocreate","no");
SetIniKey("%Team%","GuardSlower","no");
SetIniKey("%Team%","OnTransOnly","no");
SetIniKey("%Team%","AvoidThreats","%Avoid%");
SetIniKey("%Team%","LooseRecruit","no");
SetIniKey("%Team%","VeteranLevel","1");
SetIniKey("%Team%","IsBaseDefense","no");
SetIniKey("%Team%","UseTransportOrigin","no");
SetIniKey("%Team%","MindControlDecision","0");
SetIniKey("%Team%","OnlyTargetHouseEnemy","no");
SetIniKey("%Team%","TransportsReturnOnUnload","no");
SetIniKey("%Team%","AreTeamMembersRecruitable","yes");

SetVariable("%Team3%","%Team%");

Add("%Team%","1");
SetVariable("%Team%","0%Team%");
Add("%Num%","1");
SetVariable("%Avoid%","no");

// Team D
SetIniKey("TeamTypes","%Num%","%Team%");

// Random script
SetVariable("%Script%","01000603");
GetRandom("%Toss%");
Is("%Toss%","<","10922","%TeamB%");
Is("%Toss%",">","21844","%TeamC%");
SetVariable("%Script%","01000602","%TeamB%");
SetVariable("%Script%","01000604","%TeamC%");

Is("%Task%","=","01000515","%LoadA%");
SetVariable("%Script%","01000601","%LoadA%");

Is("%Task%","=","01000519","%LoadB%");
SetVariable("%Script%","01000601","%LoadB%");

Is("%Task%","=","01000523","%LoadC%");
SetVariable("%Script%","01000601","%LoadC%");

Is("%Task%","=","01000510","%V3Pat%");
SetVariable("%Script%","01000604","%V3Pat%");
SetVariable("%Avoid%","yes","%V3Pat%");

Is("%Task%","=","01000512","%LoadD%");
SetVariable("%Script%","01000601","%LoadD%");

Is("%Task%","=","01000518","%MagPat%");
SetVariable("%Script%","01000604","%MagPat%");
SetVariable("%Avoid%","yes","%MagPat%");

SetIniKey("%Team%","House","<Player @ D>");
SetIniKey("%Team%","TaskForce","%Task%");
SetIniKey("%Team%","Script","%Script%");
SetIniKey("%Team%","Max","5");
SetIniKey("%Team%","Full","no");
SetIniKey("%Team%","Group","-1");
SetIniKey("%Team%","Whiner","no");
SetIniKey("%Team%","Droppod","no");
SetIniKey("%Team%","Suicide","no");
SetIniKey("%Team%","Loadable","yes");
SetIniKey("%Team%","Prebuild","no");
SetIniKey("%Team%","Priority","5");
SetIniKey("%Team%","Annoyance","no");
SetIniKey("%Team%","IonImmune","no");
SetIniKey("%Team%","Recruiter","yes");
SetIniKey("%Team%","Reinforce","no");
SetIniKey("%Team%","TechLevel","0");
SetIniKey("%Team%","Aggressive","yes");
SetIniKey("%Team%","Autocreate","no");
SetIniKey("%Team%","GuardSlower","no");
SetIniKey("%Team%","OnTransOnly","no");
SetIniKey("%Team%","AvoidThreats","%Avoid%");
SetIniKey("%Team%","LooseRecruit","no");
SetIniKey("%Team%","VeteranLevel","1");
SetIniKey("%Team%","IsBaseDefense","no");
SetIniKey("%Team%","UseTransportOrigin","no");
SetIniKey("%Team%","MindControlDecision","0");
SetIniKey("%Team%","OnlyTargetHouseEnemy","no");
SetIniKey("%Team%","TransportsReturnOnUnload","no");
SetIniKey("%Team%","AreTeamMembersRecruitable","yes");

SetVariable("%Team4%","%Team%");

Add("%Team%","1");
SetVariable("%Team%","0%Team%");
Add("%Num%","1");
SetVariable("%Avoid%","no");

AddTrigger("%TriggerID%", "Neutral,<none>,%TName%,0,1,1,1,0", "1,13,0,%Time%", "4,107,1,%Team1%,0,0,0,0,SG,107,1,%Team2%,0,0,0,0,SH,107,1,%Team3%,0,0,0,0,SI,107,1,%Team4%,0,0,0,0,SJ","TRUE");

Add("%TName%","1");

Is("%Time%",">","%MT%","%NewMT%");
SetVariable("%MT%","%Time%","%NewMT%");
Not("%NewMT%");

Add("%Task%","1");
SetVariable("%Task%","0%Task%");
Add("%Time%","90");

// Out of taskforces
Is("%Task%","=","01000528","%OverT%");
SetVariable("%Task%","01000502","%OverT%");
SetVariable("%Time%","400","%OverT%");
Not("%OverT%");

Substract("%LoopCount%","1");
Is("%LoopCount%","=","1","%Loops%");
JumpTo("EndLoop", "%Loops%");
JumpTo("BeginLoop");
:EndLoop:

// Timer
Add("%MT%","130");
AddTrigger("%TriggerID%", "Neutral,<none>,Time,0,1,1,1,0", "1,8,0,0", "3,27,0,%MT%,0,0,0,0,A,103,4,vox:csof013,0,0,0,0,A,21,6,EVA_TimerStarted,0,0,0,0,A", "TRUE");
AddTrigger("%TriggerID%", "Neutral,<none>,AI,0,1,1,1,0", "1,14,0,0", "1,119,0,4478,0,0,0,0,A", "TRUE");

// Storm
Is("%Level%",">","6","%Storm%");
SetIniKey("Lighting","IonAmbient","0.650000","%Storm%");
SetIniKey("Lighting","IonRed","0.695000","%Storm%");
SetIniKey("Lighting","IonGreen","0.445000","%Storm%");
SetIniKey("Lighting","IonBlue","0.775000","%Storm%");
SetIniKey("LightningStormSpecial","DisableableFromShell","no","%Storm%");
SetIniKey("General","LightningDamage","40","%Storm%");
SetIniKey("General","LightningDeferment","1","%Storm%");
SetIniKey("General","LightningPrintText","false","%Storm%");
SetIniKey("General","LightningCellSpread","180","%Storm%");
SetIniKey("General","LightningStormDuration","1500","%Storm%");
SetIniKey("General","LightningHitDelay","2000","%Storm%");

SetIniKey("Waypoints","200","58060", "%Storm%");
AddTrigger("%TriggerID%", "Neutral,<none>,Ion Storm,0,1,1,1,0", "1,51,0,1000", "1,102,0,0,0,0,0,0,GS", "FALSE","%Storm%");
AddTag("%newtag1%", "2,Ion Storm,%TriggerID%","%Storm%");


Message("Level %Level% Random Survival Map Successfully Created", "FlyingZ");
