 ZVSE

!?TM2&$day$=1/$once$=1; // only once at day 1
!!DO1337/0/43/1&v225<>0:P; [Change building positions]
!!DO1343/112/158/1&v225<>0:P; [elementals throguh sacred phoenix map creatures]

!!UN:P133/?y9; // check for rule "Some dwellings have upgr. creatures"

!!VRy2:S59; // Magic Latern
!!VRy3:S101;
!!VRy4:S0;
!!VRy5:S101;
!!VRy6:S0; // Spirit
!!VRy7:S197;
!!VRy8:S198; // grunts/grunt heroes
!!UN:U17/y2/?y1; // get number of dwellings
!!DO6111/1/y1/1:P0/y2/y3/y4/y5/y6/y7/y8/y9; // call replace routine

!!VRy2:S69; // Altar Air
!!VRy3:S102; !!VRy4:S0; !!VRy5:S102; !!VRy6:S0; // Phantom
!!VRy7:S199; !!VRy8:S200; // jackals/majors
!!UN:U17/y2/?y1; // get number of dwellings
!!DO6111/1/y1/1:P0/y2/y3/y4/y5/y6/y7/y8/y9; // call replace routine

!!VRy2:S72; // Altar Water
!!VRy3:S103; !!VRy4:S0; !!VRy5:S103; !!VRy6:S0; // Corvette
!!VRy7:S201; !!VRy8:S202; // buggers/drones
!!UN:U17/y2/?y1; // get number of dwellings
!!DO6111/1/y1/1:P0/y2/y3/y4/y5/y6/y7/y8/y9; // call replace routine

!!VRy2:S71; // Altar Fire
!!VRy3:S104; !!VRy4:S0; !!VRy5:S104; !!VRy6:S0; // Brute Drop Pod
!!VRy7:S203; !!VRy8:S1204; // brutes/chieftans
!!UN:U17/y2/?y1; // get number of dwellings
!!DO6111/1/y1/1:P0/y2/y3/y4/y5/y6/y7/y8/y9; // call replace routine

!!VRy2:S70; // Altar Earth
!!VRy3:S105; !!VRy4:S0; !!VRy5:S105; !!VRy6:S0; // Elite Drop Pod
!!VRy7:S205; !!VRy8:S205; // Elites/Sword Elites
!!UN:U17/y2/?y1; // get number of dwellings
!!DO6111/1/y1/1:P0/y2/y3/y4/y5/y6/y7/y8/y9; // call replace routine

!!VRy2:S60; // Altar Thought
!!VRy3:S106; !!VRy4:S0; !!VRy5:S106; !!VRy6:S0; // Portal of Te
!!VRy7:S207; !!VRy8:S208; // Hunters/Huragok's Hunters
!!UN:U17/y2/?y1; // get number of dwellings
!!DO6111/1/y1/1:P0/y2/y3/y4/y5/y6/y7/y8/y9; // call replace routine

!!VRy2:S61; // Pyre
!!VRy3:S107; !!VRy4:S0; !!VRy5:S107; !!VRy6:S0; // Summit
!!VRy7:S209; !!VRy8:S210; // Ghosts/Wraiths
!!UN:U17/y2/?y1; // get number of dwellings
!!DO6111/1/y1/1:P0/y2/y3/y4/y5/y6/y7/y8/y9; // call replace routine

!!VRy2:S88; // Spirit Pyre
!!VRy3:S108; !!VRy4:S0; !!VRy5:S108; !!VRy6:S0; // Prophet's Workshop
!!VRy7:S211; !!VRy8:S211; // AA Wraiths
!!UN:U17/y2/?y1; // get number of dwellings
!!DO6111/1/y1/1:P0/y2/y3/y4/y5/y6/y7/y8/y9; // call replace routine

!?TM2&$day$=1
!!OW&v225<>0:C?y1;                [current player]
!!OW&v225<>0:Oy1/0/?y3;           [current player's active hero]
!!OW&v225<>0:Gy1/?y2;             [current player is human, and active]
!!DL100&y3>=127/y2=1/v225<>0:N^1338.txt^;      [dialogue box stuff]
!!DL100&y3>=127/y2=1/v225<>0:H1/z182040;
!!DL100&y3>=127/y2=1/v225<>0:S1;
!!UN&y-1<>0:R5/0/1;  [try to fix pointer]

!?GM0&v225=1; /If the game was loaded
!!DO1337/0/43/1:P;  [still change positions (memory is still cached)]
!!FU1229:P;

!#UN:P82/?v225; [check if script is enabled: y-1]
!#UN&v225=1:C6781560/1/67;    [C]
!#UN&v225=1:C6781848/1/67;    [C]
!#UN&v225=1:C6781704/1/67;    [C]


!?PI;
!!FU|v225<>1:E;
!!FU1229:P;
--------------------------------------------------------------------------------
[Replace all conflux buildings if selected]
!?FU1229;
[Replace building TBCsmage.def]

!!UN:C6853202/1/67; [C]
!!UN:C6853203/1/86; [V]

[Replace building TBCsmag2.def]

!!UN:C6853190/1/67; [C]
!!UN:C6853191/1/86; [V]

[Replace building TBCsmag3.def]

!!UN:C6853178/1/67; [C]
!!UN:C6853179/1/86; [V]

[Replace building TBCsmag4.def]

!!UN:C6853166/1/67; [C]
!!UN:C6853167/1/86; [V]

[Replace building TBCsmag5.def]

!!UN:C6853154/1/67; [C]
!!UN:C6853155/1/86; [V]

[Replace building TBCstvrn.def]

!!UN:C6853142/1/67; [C]
!!UN:C6853143/1/86; [V]

[Replace building TBCsdock.def]

!!UN:C6853130/1/67; [C]
!!UN:C6853131/1/86; [V]

[Replace building TBCscstl.def]

!!UN:C6853118/1/67; [C]
!!UN:C6853119/1/86; [V]

[Replace building TBCscas2.def]

!!UN:C6853106/1/67; [C]
!!UN:C6853107/1/86; [V]

[Replace building TBCscas3.def]

!!UN:C6853094/1/67; [C]
!!UN:C6853095/1/86; [V]

[Replace building TBCshall.def]

!!UN:C6853082/1/67; [C]
!!UN:C6853083/1/86; [V]

[Replace building TBCshal2.def]

!!UN:C6853070/1/67; [C]
!!UN:C6853071/1/86; [V]

[Replace building TBCshal3.def]

!!UN:C6853058/1/67; [C]
!!UN:C6853059/1/86; [V]

[Replace building TBCshal4.def]

!!UN:C6853046/1/67; [C]
!!UN:C6853047/1/86; [V]

[Replace building TBCsmark.def]

!!UN:C6853034/1/67; [C]
!!UN:C6853035/1/86; [V]

[Replace building TBCssilo.def]

!!UN:C6853022/1/67; [C]
!!UN:C6853023/1/86; [V]

[Replace building TBCsblak.def]

!!UN:C6853010/1/67; [C]
!!UN:C6853011/1/86; [V]

[Replace building TBCsspec.def]

!!UN:C6852998/1/67; [C]
!!UN:C6852999/1/86; [V]

[Replace building TBCsboat.def]

!!UN:C6852962/1/67; [C]
!!UN:C6852963/1/86; [V]

[Replace building TBCsext0.def]

!!UN:C6852950/1/67; [C]
!!UN:C6852951/1/86; [V]
!!UN:C6852957/1/54; [6]

[Replace building TBCsext1.def]

!!UN:C6852938/1/67; [C]
!!UN:C6852939/1/86; [V]

[Replace building TBCsext2.def]

!!UN:C6852926/1/67; [C]
!!UN:C6852927/1/86; [V]

[Replace building TBCsholy.def]

!!UN:C6852914/1/67; [C]
!!UN:C6852915/1/86; [V]

[Replace building TBCshrd3.def]

!!UN:C6852902/1/67; [C]
!!UN:C6852903/1/86; [V]

[Replace building TBCshrd4.def]

!!UN:C6852890/1/67; [C]
!!UN:C6852891/1/86; [V]

[Replace building TBCsext3.def]

!!UN:C6852878/1/67; [C]
!!UN:C6852879/1/86; [V]

[Replace building TBCsext4.def]

!!UN:C6852866/1/67; [C]
!!UN:C6852867/1/86; [V]

[Replace building TBCsext5.def]

!!UN:C6852854/1/67; [C]
!!UN:C6852855/1/86; [V]

[Replace building TBCsDw_0.def]

!!UN:C6852842/1/67; [C]
!!UN:C6852843/1/86; [V]

[Replace building TBCsDw_1.def]

!!UN:C6852830/1/67; [C]
!!UN:C6852831/1/86; [V]

[Replace building TBCsDw_2.def]

!!UN:C6852818/1/67; [C]
!!UN:C6852819/1/86; [V]

[Replace building TBCsDw_3.def]

!!UN:C6852806/1/67; [C]
!!UN:C6852807/1/86; [V]

[Replace building TBCsDw_4.def]

!!UN:C6852794/1/67; [C]
!!UN:C6852795/1/86; [V]

[Replace building TBCsDw_5.def]

!!UN:C6852782/1/67; [C]
!!UN:C6852783/1/86; [V]

[Replace building TBCsDw_6.def]

!!UN:C6852770/1/67; [C]
!!UN:C6852771/1/86; [V]

[Replace building TBCsUp_0.def]

!!UN:C6852758/1/67; [C]
!!UN:C6852759/1/86; [V]

[Replace building TBCsUp_1.def]

!!UN:C6852746/1/67; [C]
!!UN:C6852747/1/86; [V]

[Replace building TBCsUp_2.def]

!!UN:C6852734/1/67; [C]
!!UN:C6852735/1/86; [V]

[Replace building TBCsUp_3.def]

!!UN:C6852722/1/67; [C]
!!UN:C6852723/1/86; [V]

[Replace building TBCsUp_4.def]

!!UN:C6852710/1/67; [C]
!!UN:C6852711/1/86; [V]

[Replace building TBCsUp_5.def]

!!UN:C6852698/1/67; [C]
!!UN:C6852699/1/86; [V]

[Replace building TBCsUp_6.def]

!!UN:C6852686/1/63; [C]
!!UN:C6852687/1/87; [V]

--------------------------------------------------------------------------------
[Replace building TBCshrd1.def]

!!UN:C6852986/1/67; [C]
!!UN:C6852987/1/86; [V]

[Replace building TBCshrd2.def]

!!UN:C6852974/1/67; [C]
!!UN:C6852975/1/86; [V]

[Replace itpa.def with itpb.def]

!!UN:C6681371/1/98; [b]
!!UN:C6865439/1/98; [b]

[Replace ITPT.def with ITPx.def]

!!UN:C6685031/1/120; [x]

[Replace HallElem.def with HallCvnt.def

!!UN:C6865556/1/67;    [C]
!!UN:C6865557/1/118;   [v]
!!UN:C6865558/1/110;   [n]
!!UN:C6865559/1/116;   [t]

!!UN:C6813180/1/67;    [C]
!!UN:C6813181/1/118;   [v]
!!UN:C6813182/1/110;   [n]
!!UN:C6813183/1/116;   [t]

[Replace TBELback with TBCVback]

!!UN:C6857438/1/67;    [C]
!!UN:C6857439/1/86;    [V]

[Replace Crbkgele with crbkgcvt]

!!UN:C6826377/1/99;   [c]
!!UN:C6826378/1/118;  [v]
!!UN:C6826379/1/116;  [t]

[Replace TPCasele with TPCascvt]

!!UN:C6865161/1/99;   [c]
!!UN:C6865162/1/118;  [v]
!!UN:C6865163/1/116;  [t]

[Replace AVChforX,Z 0 with CVChforX,Z,0]

!!UN:C6781560/1/67;    [C]
!!UN:C6781848/1/67;    [C]
!!UN:C6781704/1/67;    [C]

[Replace TPMageEl.pcx (pic inside mage guild]

!!UN:C6865018/1/67;  [C]
!!UN:C6865019/1/86;  [V]

--------------------------------------------------------------------------------
[Replace outlines of buildings in conflux town]

!!UN:C6862086/1/67; [C]
!!UN:C6862087/1/86; [V]

[Replace building TBCsmag2.def]

!!UN:C6862074/1/67; [C]
!!UN:C6862075/1/86; [V]

[Replace building TBCsmag3.def]

!!UN:C6862062/1/67; [C]
!!UN:C6862063/1/86; [V]

[Replace building TBCsmag4.def]

!!UN:C6862050/1/67; [C]
!!UN:C6862051/1/86; [V]

[Replace building TBCsmag5.def]

!!UN:C6862038/1/67; [C]
!!UN:C6862039/1/86; [V]

[Replace building TBCstvrn.def]

!!UN:C6862026/1/67; [C]
!!UN:C6862027/1/86; [V]

[Replace building TBCsdock.def]

!!UN:C6862014/1/67; [C]
!!UN:C6862015/1/86; [V]

[Replace building TBCscstl.def]

!!UN:C6862002/1/67; [C]
!!UN:C6862003/1/86; [V]

[Replace building TBCscas2.def]

!!UN:C6861990/1/67; [C]
!!UN:C6861991/1/86; [V]

[Replace building TBCscas3.def]

!!UN:C6861978/1/67; [C]
!!UN:C6861979/1/86; [V]

[Replace building TBCshall.def]

!!UN:C6861966/1/67; [C]
!!UN:C6861967/1/86; [V]

[Replace building TBCshal2.def]

!!UN:C6861954/1/67; [C]
!!UN:C6861955/1/86; [V]

[Replace building TBCshal3.def]

!!UN:C6861942/1/67; [C]
!!UN:C6861943/1/86; [V]

[Replace building TBCshal4.def]

!!UN:C6861930/1/67; [C]
!!UN:C6861931/1/86; [V]

[Replace building TBCsmark.def]

!!UN:C6861918/1/67; [C]
!!UN:C6861919/1/86; [V]

[Replace building TBCssilo.def]

!!UN:C6861906/1/67; [C]
!!UN:C6861907/1/86; [V]

[Replace building TBCsblak.def]

!!UN:C6861894/1/67; [C]
!!UN:C6861895/1/86; [V]

[Replace building TBCsspec.def]

!!UN:C6861882/1/67; [C]
!!UN:C6861883/1/86; [V]

[Replace building TBCshrd1.def]

!!UN:C6861870/1/67; [C]
!!UN:C6861871/1/86; [V]

[Replace building TBCshrd2.def]

!!UN:C6861858/1/67; [C]
!!UN:C6861859/1/86; [V]

[Replace building TBCsboat.def]

!!UN:C6861846/1/67; [C]
!!UN:C6861847/1/86; [V]

[Replace building TBCsext0.def]

!!UN:C6861834/1/67; [C]
!!UN:C6861835/1/86; [V]

[Replace building TBCsext1.def]

!!UN:C6861822/1/67; [C]
!!UN:C6861823/1/86; [V]

[Replace building TBCDw_0.def]

!!UN:C6861810/1/67; [C]
!!UN:C6861811/1/86; [V]

[Replace building TBCsDw_1.def]

!!UN:C6861798/1/67; [C]
!!UN:C6861799/1/86; [V]

[Replace building TBCsDw_2.def]

!!UN:C6861786/1/67; [C]
!!UN:C6861787/1/86; [V]

[Replace building TBCDw_3.def]

!!UN:C6861774/1/67; [C]
!!UN:C6861775/1/86; [V]

[Replace building TBCDw_4.def]

!!UN:C6861762/1/67; [C]
!!UN:C6861763/1/86; [V]

[Replace building TBCsDw_5.def]

!!UN:C6861750/1/67; [C]
!!UN:C6861751/1/86; [V]

[Replace building TBCsDw_6.def]

!!UN:C6861738/1/67; [C]
!!UN:C6861739/1/86; [V]

[Replace building TBCsUp_0.def]

!!UN:C6861726/1/67; [C]
!!UN:C6861727/1/86; [V]

[Replace building TBCsUp_1.def]

!!UN:C6861714/1/67; [C]
!!UN:C6861715/1/86; [V]

[Replace building TBCsUp_2.def]

!!UN:C6861702/1/67; [C]
!!UN:C6861703/1/86; [V]

[Replace building TBCsUp_3.def]

!!UN:C6861690/1/67; [C]
!!UN:C6861691/1/86; [V]

[Replace building TBCsUp_4.def]

!!UN:C6861678/1/67; [C]
!!UN:C6861679/1/86; [V]

[Replace building TBCsUp_5.def]

!!UN:C6861666/1/67; [C]
!!UN:C6861667/1/86; [V]

[Replace building TBCsUp_6.def]

!!UN:C6861654/1/67; [C]
!!UN:C6861655/1/86; [V]

--------------------------------------------------------------------------------

[Replace all seige .pxc files from El to CV]

!!UN:C6738282/1/67; [SGELBACK]
!!UN:C6738283/1/86;

!!UN:C6746138/1/67; [SGELWA61]
!!UN:C6746139/1/86;

!!UN:C6745874/1/67; [SGELTW2C]
!!UN:C6745875/1/86;

!!UN:C6745890/1/67; [SGELTW1C]
!!UN:C6745891/1/86;

!!UN:C6745906/1/67; [SGELMANC]
!!UN:C6745907/1/86;

!!UN:C6745922/1/67; [SGELMAN1]
!!UN:C6745923/1/86;

!!UN:C6745938/1/67; [SGELMAN2]
!!UN:C6745939/1/86;

!!UN:C6745954/1/67; [SGELTW11]
!!UN:C6745955/1/86;

!!UN:C6745970/1/67; [SGELTW11]
!!UN:C6745971/1/86;

!!UN:C6745986/1/67; [SGELTW12]
!!UN:C6745987/1/86;

!!UN:C6746002/1/67; [SGELWAL1]
!!UN:C6746003/1/86;

!!UN:C6746018/1/67; [SGELWAL2]
!!UN:C6746019/1/86;

!!UN:C6746034/1/67; [SGELWA2]
!!UN:C6746035/1/86;

!!UN:C6746046/1/67; [SGELWA31 CHANGE +16 HERE]
!!UN:C6746047/1/86;

!!UN:C6746062/1/67; [SGELWA32]
!!UN:C6746063/1/86;

!!UN:C6746078/1/67; [SGELARCH]
!!UN:C6746079/1/86;

!!UN:C6746094/1/67; [SGELWA41]
!!UN:C6746095/1/86;

!!UN:C6746110/1/67; [SGELWA42]
!!UN:C6746111/1/86;

!!UN:C6746126/1/67; [SGELWA5]
!!UN:C6746127/1/86;

!!UN:C6746138/1/67; [SGELWA61 CHANGED AGAIN]
!!UN:C6746139/1/86;

!!UN:C6746154/1/67; [SGELWA62]
!!UN:C6746155/1/86;

!!UN:C6746170/1/67; [SGELTW21]
!!UN:C6746171/1/86;

!!UN:C6746186/1/67; [SGELTW22]
!!UN:C6746187/1/86;

!!UN:C6746202/1/67; [SGELTPWL]
!!UN:C6746203/1/86;

!!UN:C6746218/1/67; [SGELMLIP]
!!UN:C6746219/1/86;

!!UN:C6746234/1/67; [SGELMOAT]
!!UN:C6746235/1/86;

!!UN:C6746266/1/67; [SGELDRW1]
!!UN:C6746267/1/86;

!!UN:C6746282/1/67; [SGELDRW2]
!!UN:C6746283/1/86;

!!UN:C6746298/1/67; [SGELDRW3]
!!UN:C6746299/1/86;

!!UN:C6541448/4/212; [brutes in castle towers]

!!UN:C6684351/1/56;  [ah17 -> ah18.def]
!!UN:C6684363/1/57;  [ah16 -> ah19.def]

!!UN:C6749687/1/57; [ch16 -> ch19.def]
!!UN:C6749675/1/56; [ch17 -> ch18.def]

!!UN:C7894228/1/51; [ZM182NPC.def -> ZM183NPC.def]
!!UN:C7894444/1/51;
!!VRz543:S^Tolberti^;
!!UN:G1/182/0/z543;
!!UN:G1/182/1/z543;
!!UN:G1/191/0/z543;
!!UN:G1/191/1/z543;

!!UN:C6734648/1/67; [elemtown.mp3 -> Clemtown.mp3]
--------------------------------------------------------------------------------

[change Dwellings in the town]

!!MA:U197/198; [upg grunt to grunt hero]
!!MA:U199/200; [upg jackal to jackal major]
!!MA:U201/202; [upg buggers to drones]
!!MA:U203/204U204/-2; [upg brute to brute chieftan]
!!MA:U205/206; [upg elite to sword elite]
!!MA:U207/208U208/-2; [upg hunter to hurgoloks hunter]
!!MA:U209/210; [upg ghost to wraith]
!!MA:U210/211; [upg wraith to AA wraith]

!!UN:T8/0/0/197; [level 1 no upg - Grunt]
!!UN:T8/0/1/198; [level 1    upg - Grunt Hero]
!!UN:T8/1/0/199; [level 2 no upg - Jackal]
!!UN:T8/1/1/200; [level 2    upg - Jackal Major]
!!UN:T8/2/0/201; [level 3 no upg - Buggers]
!!UN:T8/2/1/202; [level 3    upg - Drones]
!!UN:T8/3/0/203; [level 4 no upg - Brute]
!!UN:T8/3/1/204; [level 4    upg - Brute Chieftan]
!!UN:T8/4/0/205; [level 5 no upg - Elite]
!!UN:T8/4/1/206; [level 5    upg - Sword Elite]
!!UN:T8/5/0/207; [level 6 no upg - Hunter]
!!UN:T8/5/1/208; [level 6    upg - Hurgolok's Hunter]
!!UN:T8/6/0/209; [level 7 no upg - Ghost]
!!UN:T8/6/1/210; [level 7    upg - Wraith]

!!MA:L197/0;
!!MA:L198/0;
!!MA:L199/1;
!!MA:L200/1;
!!MA:L201/2;
!!MA:L202/2;
!!MA:L203/3;
!!MA:L204/3;
!!MA:L205/4;
!!MA:L206/4;
!!MA:L207/5;
!!MA:L208/5;
!!MA:L209/6;
!!MA:L210/6;
!!MA:L211/6;

!!MA:O112/-1; [these creatures all count as being neutral troops now]
!!MA:O113/-1;
!!MA:O114/-1;
!!MA:O115/-1;
!!MA:O118/-1;
!!MA:O119/-1;
!!MA:O120/-1;
!!MA:O121/-1;
!!MA:O123/-1;
!!MA:O125/-1;
!!MA:O127/-1;
!!MA:O129/-1;
!!MA:O130/-1;
!!MA:O131/-1;
!!MA:O158/-1;

!!CD:B1/8/17/0/128; [Artifact merchant requires upgrade level 3 to work]
!!CD:B1/8/21/32768/0; [Prophet's Blessing requires resource silo]

!!EA209:B0/1/102/98/1/1/1/1/1/1/1/1/1/1/1; [ghosts strike and return]

!!UN:C6976892/4/9649128; [Conflux --> Covenant]

--------------------------------------------------------------------------------

 [adjust conflux hero specialties]

!!HE128:L1^thelS.pcx^; [Paris --> Thel]
!!HE128:L2^thelL.pcx^;
!!HE128:B0/z182040;
!!HE128:B1/z182041;
!!HE128:X5/2; [master of speed]
!!VRz169:Sz182044;
!!UN:G2/128/1/144;
!!UN:G2/128/2/169; [specialty text]
!!UN:G2/128/3/144; [standard specialty pic]

!!HE129:L1^falS.pcx^; [Thunar --> Fal Chavum]
!!HE129:L2^falL.pcx^;
!!HE129:B0/z182042;
!!HE129:B1/z182043;
!!HE129:R6/1; [maximum luck set]
!!VRz170:Sz182045;
!!UN:G2/129/1/299;  [luck picture]
!!UN:G2/129/2/170;  [specialty text]
!!UN:G2/129/3/299;

!!HE130:L1^rtasS.pcx^; [Ignissa --> Rtas Vadum]
!!HE130:L2^rtasL.pcx^;
!!HE130:B0/z182046;
!!HE130:B1/z182047;
!!HE130:X0/13; [master of estates]
!!VRz171:Sz182048;
!!UN:G2/130/1/4;  [luck picture]
!!UN:G2/130/2/171;  [specialty text]
!!UN:G2/130/3/4;

!!HE131:L1^rethS.pcx^; [Lacus --> Reth]
!!HE131:L2^rethL.pcx^;
!!HE131:B0/z182049;
!!HE131:B1/z182050;
!!HE131:X1/199; [master of jackals]
!!HE131:X1/200; [master of upg. jackals]
!!VRz172:Sz182051;
!!UN:G2/131/1/357;  [jackal picture picture]
!!UN:G2/131/2/172;  [specialty text]
!!UN:G2/131/3/357;

!!HE132:L1^tartS.pcx^; [Monere --> Tartarus]
!!HE132:L2^tartL.pcx^;
!!HE132:B0/z182052;
!!HE132:B1/z182053;
!!HE132:X0/26;        [master of resistance]
!!VRz173:Sz182054;
!!UN:G2/132/1/20;     [resistance pic]
!!UN:G2/132/2/173;     [specialty text]
!!UN:G2/132/3/20;

!!HE133:L1^certS.pcx^; [Erdamon --> Ceretus]
!!HE133:L2^certL.pcx^;
!!HE133:B0/z182055;
!!HE133:B1/z182056;
!!HE133:X1/203;        [master of brutes, chieftans]
!!HE133:X1/204;
!!VRz174:Sz182057;
!!UN:G2/133/1/358;     [brute pic]
!!UN:G2/133/2/174;     [specialty text]
!!UN:G2/133/3/358;

!!HE134:L1^paruS.pcx^; [Fiur --> Paruto]
!!HE134:L2^paruL.pcx^;
!!HE134:B0/z182058;
!!HE134:B1/z182059;
!!HE134:A1/5/14;       [starts with an ammo cart]
!!VRz175:Sz182060;
!!UN:G2/134/1/249;     [ammo cart pic]
!!UN:G2/134/2/175;     [specialty text]
!!UN:G2/134/3/249;

!!HE135:L1^yayaS.pcx^; [Kalt --> Yayab]
!!HE135:L2^yayaL.pcx^;
!!HE135:B0/z182061;
!!HE135:B1/z182062;
!!HE135:X1/197;        [master of grunts, grunt heroes]
!!HE135:X1/198;
!!VRz176:Sz182063;
!!UN:G2/135/1/359;     [grunt pic]
!!UN:G2/135/2/176;     [specialty text]
!!UN:G2/135/3/359;

!!HE136:L1^regretS.pcx^; [LUNA Changes --> Regret]
!!HE136:L2^regretL.pcx^;
!!HE136:B0/z182038;
!!HE136:B1/z182039;
!!HE136:X3/27; [master of shield]
!!HE136:M27/1; [give shield]
!!VRz177:Sz182064;
!!UN:G2/135/1/329;     [shield pic]
!!UN:G2/135/2/177;     [specialty text]
!!UN:G2/135/3/329;

!!HE137:L1^paraS.pcx^; [Brissa --> Parabum]
!!HE137:L2^paraL.pcx^;
!!HE137:B0/z182065;
!!HE137:B1/z182066;
!!HE137:X3/7; [master of water walk]
!!HE137:M7/1; [give water walk]
!!VRz178:Sz182067;
!!UN:G2/137/1/350;     [ww pic]
!!UN:G2/137/2/178;     [specialty text]
!!UN:G2/137/3/350;

!!HE138:L1^virgS.pcx^; [Ciele --> Virgil]
!!HE138:L2^virgL.pcx^;
!!HE138:B0/z182068;
!!HE138:B1/z182069;
!!HE138:X0/21; [master of learning]
!!HE138:X6/207/207/208; [can always upgrade hunters]
!!VRz179:Sz182070;
!!UN:G2/138/1/298;     [shield pic]
!!UN:G2/138/2/179;     [specialty text]
!!UN:G2/138/3/298;

!!HE139:L1^uszeS.pcx^; [Labetha --> Usze]
!!HE139:L2^uszeL.pcx^;
!!HE139:B0/z182071;
!!HE139:B1/z182072;
!!HE139:X3/17; [master of lightning bolt]
!!HE139:M17/1; [give lightning bolt]
!!VRz180:Sz182073;
!!UN:G2/139/1/315;     [lightning pic]
!!UN:G2/139/2/180;     [specialty text]
!!UN:G2/139/3/315;

!!HE140:L1^sesaS.pcx^; [Inteus --> Sesa]
!!HE140:L2^sesaL.pcx^;
!!HE140:B0/z182074;
!!HE140:B1/z182075;
!!HE140:X0/25; [master of sorcery]
!!VRv897:S30R4; [random number 30-34]
!!HE140:Mv897/1; [give random protection spell]
!!VRz181:Sz182076;
!!UN:G2/140/1/62;     [sorcery pic]
!!UN:G2/140/2/181;     [specialty text]
!!UN:G2/140/3/62;

!!HE141:L1^ripaS.pcx^; [Aenaen --> Ripa]
!!HE141:L2^ripaL.pcx^;
!!HE141:B0/z182077;
!!HE141:B1/z182078;
!!HE141:X0/11; [master of eagle eye]
!!HE141:M3/1M5/1; [give view earth, view air]
!!VRz182:Sz182079;
!!UN:G2/141/1/13;     [eagle eye pic]
!!UN:G2/141/2/182;     [specialty text]
!!UN:G2/141/3/13;

!!HE142:L1^brakS.pcx^; [Gelare --> Bracktanus]
!!HE142:L2^brakL.pcx^;
!!HE142:B0/z182080;
!!HE142:B1/z182081;
!!HE142:X3/56; [master of frenzy]
!!HE142:M56/1; [give frenzy]
!!VRz183:Sz182082;
!!UN:G2/142/1/335;     [eagle eye pic]
!!UN:G2/142/2/183;     [specialty text]
!!UN:G2/142/3/335;

!!HE143:L1^hopS.pcx^; [Grindan --> Hopalong]
!!HE143:L2^hopL.pcx^;
!!HE143:B0/z182083;
!!HE143:B1/z182084;
!!HE143:X3/53; [master of haste]
!!HE143:M53/1; [give haste]
!!VRz184:Sz182085;
!!UN:G2/143/1/46;     [haste pic]
!!UN:G2/143/2/184;     [specialty text]
!!UN:G2/143/3/46;

!!DO6103/0/155/1:P; [iterate through all heroes to fix starting troops]
!!DO6104/128/143/1:P; [set future starting troops for conflux heroes]

!!HE134:H0/207/1/1H1/-1/0/0H2/-1/0/0; [Reset Paruto to start with a single hunter]
!!HE134:C1/197/207/1C1/199/-1/0C1/201/-1/0; [Start with a hunter]

!!HE135:H0/197/15/25H1/197/15/25H2/197/15/25; [reset starting troops to grunts for Yayab
!!HE135:C1/199/197/21C1/201/197/17;           [start Yayab with all grunts]

!!VRz777:S^Slipspacer^;
!!VRz778:S^Councillor^;
!!FU1342:P16/777;
!!FU1342:P17/778;

!!VRv226:S-5; !!VRv227:S-5;

[end of function 1229 to switch over]

--------------------------------------------------------------------------------
!?FU1343; [map unit switch]
!!UN:U54/x16/?y1; [set y1 to number of x16's (type of creatures)]
!!VRv776:Sx16;
!!DO1344/1/y1/1&y1>0:P; [loop through all of them]

!?FU1344;
!!UN:U54/v776/1/911; [get x/y/l of yellow square of monster into v911-v913]
!!MO911:G?y1;             [old number of monsters]
!!UN:Ov911/v912/v913;
!!VRv775&v776=118:S197;
!!VRv775&v776=119:S198;
!!VRv775&v776=112:S199;
!!VRv775&v776=127:S200;
!!VRv775&v776=115:S201;
!!VRv775&v776=123:S202;
!!VRv775&v776=114:S203;
!!VRv775&v776=129:S204;
!!VRv775&v776=113:S205;
!!VRv775&v776=125:S206;
!!VRv775&v776=120:S207;
!!VRv775&v776=121:S208;
!!VRv775&v776=130:S209;
!!VRv775&v776=131:S210;
!!VRv775&v776=158:S211;
!!UN:Iv911/v912/v913/54/v775; [place new stack, no redraw]
--------------------------------------------------------------------------------

!?FU6103;

!!DO6102/0/6/1:Px16; [iterate through creature slots]

** end of function


** function to fix one slot

!?FU6102;

!!HEx1:C0/x16/?y1/?y2; [get y1 type y2 qty]
!!VRy1&y1=118:S197; [pixie -> grunt]
!!VRy1&y1=112:S199; [air elemental -> jackal]
!!VRy1&y1=115:S201; [water elemental -> bugger]
!!HEx1:C0/x16/y1/y2; [set creature type/qty]

** end of function


** function to set starting troops for hero

!?FU6104;

!!HEx16:H0/197/20/30; [20-30 grunts]
!!HEx16:H1/199/3/6; [3-6 jackals]
!!HEx16:H2/201/0/3; [0-3 buggers]

** end of function

--------------------------------------------------------------------------------
[Make the magic university allow for two buildings to be built a day]

!?TM1; [Daily timer for all players]
!!VRv898:Sc0; [The current day: v898]

!?TH1; [Exit Town Hall trigger]
!!CA-1:T?y-1; [Town type (y-1)]
!!VRy-3:Sc0;
!!CA-1:B3/21; [Set Flag 1 to TRUE if magic university is built]
!!FU|y-1<>8/-1/v225<>1:E; [Exit if not covenant town or if no magic university built]
!!CA-1:R?y-2; [Read build flag value for town: y-2]

!!VRv898&y-2=1:+1; [Set a number equal to the current day plus any builds: y-4]
!!VRy-6:Sy-3+2; [Equal to the day plus two or the max number of builds]

!!CA-1&v898<y-6:R0; [If the day plus builds is less than two, can build]
!!UN&y-7=1:R4; [Redraw town screen]

 [Trigger is Town screen mouse-click]
!?CM1;
!!CM:S?y-1 I?y-2; [Subtype of click: y-1, Location of click: y-2]
!!CA-1:T?y-3; [Town Type: y-3]

!!FU|y-1<>12/y-2<>21/y-3<>8/v225<>1:E; [Exit if not a left-click, not the magic university, or not a coventnat Town]
!!CM:R0; [Disable standard click reaction]
!!IF:Q1/30/21/1^{The Prophet's Blessing}

The Prophet's Blessing allows two structures to be built per turn. Do you sway from the path of the Great Journey?^;

--------------------------------------------------------------------------------

**Function to change building position.
!?FU1337;

!!VRy1:S8; //city
!!VRy2:Sx16; //building ID
!!VRy6:S0; //frames num in new def
!!VRy3:S0; //new x
!!VRy4:S0; //new y

!!VRy5:Sy1 *44 +y2 *6 +6859276;

!!UN:Cy5/2/y6;
!!VRy5:+2;
!!UN:Cy5/2/y3;
!!VRy5:+2;
!!UN:Cy5/2/y4;

--------------------------------------------------------------------------------

[Make the artifact merchant allow for grunt heroes to upgrade into jackals and vice versa]

[Make sure it works properly even if it is already built without clicking on hall]
!?CM1&v225=1;
!!VRv1:S0;
!!CM:S?y1 I?y2; [Subtype of click: y-1, Location of click: y-2]
!!CA-1:T?y-1; [Town type (y-1)]
!!CA-1:B3/17; [Set Flag 1 to TRUE if artifact merchant is built]
!!VRv1&1:S1337;
!!MA|y2<115/y2>146:C199/6/120;
!!FU|y-1<>8/v1<>1337/y2<115/y2>146:E; [Exit if not covenant town or if no artifact merchant built]
!!MA:U198/199; [Grunt heroes now upgrade to normal jackals]
!!MA:U200/197; [Jackal majors can be upgraded to grunts]
!!MA:C199/6/50;

[Trigger is Town screen mouse-click]
!?CM1&v225=1;
!!CM:S?y-1 I?y-2; [Subtype of click: y-1, Location of click: y-2]
!!CA-1:T?y-3; [Town Type: y-3]

!!FU|y-1<>12/y-2<>17/y-3<>8/v225<>1:E; [Exit if not a left-click, not the artifact, or not a covenant Town]
!!CM:R0; [Disable standard click reaction]
!!IF:Q1/30/17/1^{The Slipspace Gravlift}

The Slipspace Gravlift allows for the exchange of lowly troops. Grunt Heroes may be upgraded to Jackals and Jackal Majors may be freely demoted to Grunts.^;
--------------------------------------------------------------------------------


[This lets brutes stick their oponents and brute chieftans do their lunge attack]

!?BG0&1000/v225=1; [before each action]
!!BG:N?v909; [current stack]
!!BMv909:T?v910; [current type]
!!FU&v910<>203/v910<>204:E;

[for normal brutes]
!!BMv909&v910=203:T65;    [set to power lich]
!!VRz155&v910=203:S^Brutes^;
!!VRz156&v910=203:S^Brute^;
!!UN&v910=203:G1/65/0/156;   [Set the name of power lichs to brutes for this action]
!!UN&v910=203:G1/65/1/155;
!!UN&v910=203:C6835548/1/88; [change sp04_.def to Xp04_.def -> sticky grenade]
!!UN&v910=203:C6687080/1/88; [change PLich.def to XLich.def -> sticky grenade]
!!UN&v910=203:C6848456/1/89; [change deathcld.wav to Yeathcld.wav]

[for brute chieftans]
!!BMv909&v910=204:T65;    [set to power lich]
!!VRz140&v910=204:S^Brute Chieftans^;
!!VRz141&v910=204:S^Brute Chieftan^;
!!UN&v910=204:G1/65/0/141;   [Set the name of power lichs to brutes for this action]
!!UN&v910=204:G1/65/1/140;
!!BG:Q?v912; [hero side]
!!UN&v910=204/v912=0:C6835548/1/89; [change sp04_.def to Yp04_.def -> jumper]
!!UN&v910=204/v912=1:C6835548/1/90; [change sp04_.def to Zp04_.def -> jumper mirrored]
!!UN&v910=204:C6687080/1/89; [change PLich.def to YLich.def -> jumper]
!!UN&v910=204:C6848456/1/89; [change deathcld.wav to Yeathcld.wav]

!!BMv909:O?v911; [indicator of troop position]
!!VRv911&v910=203:S d10;     [10-16 for brutes]
!!VRv911&v910=204:S d20;    [20-26 for chieftans]

!?BG1&1000/v910>202/v910<205; [after each action, for brutes]
!!BMv909:Tv910; [set back type]
!!UN:G1/65/0/0; [restore names]
!!UN:G1/65/1/0;
!!UN:C6835548/1/115; [restore lich spells]
!!UN:C6687080/1/80;
!!UN:C6848456/1/100;

!?BA1&1000/v225=1/v910>202/v910<205; [after battle if ended on a brute]
!!BA:O?v1/?v2;
!!FU&v909<21/v1<0:E;
!!FU&v909>20/v2<0:E;
!!VRy1&v911<19:Sv911 - 10;
!!VRy1&v911>19:Sv911 - 20;
!!HE-1&y1>0:C0/y1/?y2/?y3/?y4/?y5;  [get the current hero's power liches
!!HE-1&y2=65/v911<19/y1>0:C0/y1/203/y3/y4/y5;
!!HE-1&y2=65/v911>19/y1>0:C0/y1/204/y3/y4/y5;

--------------------------------------------------------------------------------
 [This makes Sword Elites able to fix Ghosts/Wraiths]
!?BG0&v226=-5/v227=-5/v225=1;
!!VRv3:S-2; !!VRv5:S-2; [initialize to false]
!!BU:E20/?v1;           [stack #s]
!!BU:E30/?v2;
!!BMv1&v1<>-1:G4/?v3/?v4;      [if has disguise, is henchman]
!!BMv2&v2<>-1:G4/?v5/?v6;
!!VRv226&v3>0:Sv1;             [set if a henchman > 0 to stack #]
!!VRv227&v5>0:Sv2;

!?CM4&v225=1;
!!VRv8:S-1; !!VRv11:S-1; [reset variables]
!!CM:S?v891 D?v3; [Get type of click and position of click]
!!FU|v3<0/v3>186:E; [break if not in grid]
!!BG:N?v894; [current creature stack]
!!BMv894:N?v896; [current number of sword elites]
!!BMv894:T?v893; [creature type to 893]
!!FU|v893<>206/v891<>12:E; [exit if not a sword elite]
!!BMv894:I?v901; [get side of creature]
!!BMv894:P?v905; [get position of sword elites]
!!BU:Dv3/?v2; [stack # at clicked position]
!!FU|v2<0/v2>41:E; [break if not a stack]
!!FU&v2<21/v894>20:E; [wrong side]
!!FU&v2>20/v894<21:E; [wrong side]

!!BMv2:P?y2 T?y4 N?v906 O?v902; [position type number and army slot num]

!!BU&y2<>v3:Ey2/?v8; [check other hex if clicked front of creature]
!!VRv10&v901=0:S 1 + v3; !!VRv10&v901=1:S -1 + v3;
!!BU&y2=v3:Ev10/?v11;  [check other hex if clicked back of creature]
!!FU|v8<>-1/v11<>-1:E; [break if someone standing there]

!!CM|y4=209/y4=210/y4=211:R0; [disable standard reaction]
!!FU&y4<>209/y4<>210/y4<>211:E; [break if not a ghost/wraith/aa]

!!IF&v226=v2/v894<21:M^The Elites have not yet developed the technology to repair {Henchmen}.^;
!!IF&v227=v2/v894>20:M^The Elites have not yet developed the technology to repair {Henchmen}.^;
!!FU|v226=v2/v227=v2:E;

!!IF&v896<3/y4=209:M^Upon entering the wreckage, it seems you have too few Sword Elites to repair the Ghosts^;
!!IF&v896<3/y4=210:M^Upon entering the wreckage, it seems you have too few Sword Elites to repair the Wraiths^;
!!IF&v896<6/y4=211:M^Upon entering the wreckage, it seems you have too few Sword Elites to repair the AA Wraiths^;
!!FU&v896<3:E; [if too few break after displaying message]
!!FU&v896<6/y4=211:E;  [break for AA]

!!BMv2:B?v904; [number of ghosts/wraiths at the start]
!!VRv898&y4=209:Sv904 * 2; [number of sword elites needed for full ghost fix]
!!VRv898&y4=210:Sv904 * 3; [number of sword elites needed for full wraith fix]
!!VRv898&y4=211:Sv904 * 6; [number of sowrd elites needed for full AA fix]
!!VRv899:Sv896 - v898; [number left after fixing vehicle]
!!IF&v899<0/y4=209:M^Too few Sword Elites to fix the %V904 Ghosts.^;
!!IF&v899<0/y4=210:M^Too few Sword Elites to fix the %V904 Wraiths.^;
!!IF&v899<0/y4=211:M^Too few Sword Elites to fix the %V904 AA Wraiths.^;
!!FU&v899<0:E; [break if too few]
!!IF&y4=209:Q1/21/209/2^It will take %V898 Sword Elites to fix %V904 Ghost(s). Proceed?^;
!!IF&y4=210:Q1/21/210/2^It will take %V898 Sword Elites to fix %V904 Wraith(s). Proceed?^;
!!IF&y4=211:Q1/21/211/2^It will take %V898 Sword Elites to fix %V904 AA Wraith(s). Proceed?^;
!!FU&-1:E;

!!BHv901:N?y5; [current hero number]
!!HEy5:F?y6/?y7/?y8/?y9; [hero primary skills]
!!HEy5:B0/?z1; [hero name]
!!IF&y8<7:Q1/33/0/1^%Z1 needs at least 7 {Spell Power} to persuade Sword Elites^;
!!FU&y8<7:E;

!!BMv894&1:Nv899; [sword elites new number]
!!VRz123:S^The Sword Elites have variable efficiency, but they report at least^;
!!BU:Mz123;
!!BG:A0;

!!HEy5:S17/?y10;          [earth magic]
!!HEy5:A2/0/?y11/?y12;    [spell book number to y11]
!!HEy5&y11=0:A1/0/17;     [if no spellbook, add one]
!!HEy5&y10<>3:S17/3;

!!HEy5:Fy6/y7/1000/y9;
!!BHv901:C38/y2/3/0;
!!BMv2:Nv904;
!!BG:A12;
!!BU:R;
!!HEy5:Fy6/y7/y8/y9;
!!HEy5:S17/y10;
!!HEy5&y11=0:A3/0/1/1; [delete spellbook if didn't have one]
!!FU:E;
--------------------------------------------------------------------------------

!?FU6111; // replaces conflux by neutral town dwellings (by Thomas Franz (samot))
** x1 = level
** x2 = old object subtype
** x3 = new object subtype (non upgr)
** x4 = move object one field to left (-1) or right (1), no change by 0
** x5 = new object subtype (upgr)
** x6 = move object one field to left (-1) or right (1), no change by 0
** x7 = new creature (non upgr)
** x8 = new creature (upgr)
** x9 = Rule "some dwellings have upgr. creatures" is on or off

** y8 = MapSize (x=y)

** change passability of fields, referending to the origin entrace (ignore the move by x6)
** 0 means no change, 1 = make passable, -1 make inpassable
** v900 = field left of entrace (non upgr. dwelling)
** v901 = entrace
** v902 = right of entrace
** v903 = left over the entrace
** v904 = over the entrace
** v905 = right over the entrace
** v906 = field left of entrace (upgr. dwelling)
** v907 = entrace
** v908 = right of entrace
** v909 = left over the entrace
** v910 = over the entrace
** v911 = right over the entrace

!!UN:X?y8/?y9; // get size of map

!!VRv912&x16=1:S-1; // initialize for first loop
!!UN:U17/x2/-1/912; // get coordinates to v912-v914
!!VRy99:S0 R3; // Random 0-3
!!VRy99&x9=0:S0; // set to 0 if Rule for upgr. creatures is of
!!VRy11:Sv912 +1; !!VRy12:Sv912 -1;
!!POv912/v913/v914:N?y98 N0; // check if is already replaced (y98 will be 1) and reset the flag
!!POy11/v913/v914&y98=0/y11<y8:N?y98 N0; // check if is already replaced (y98 will be 1) and reset the flag
!!POy12/v913/v914&y98=0/y12>-1:N?y98 N0; // check if is already replaced (y98 will be 1) and reset the flag

!!FU&y98=1:E; // exit if Object has been already replaced before

!!DWv912/v913/v914:O?y1 M1/?y2/?y3; // get owner and creature in the second slot (map rule Boars)
!!UN:Ov912/v913/v914/1; // delete old dwelling incl. hint

!!VRy10:Sv912+x4; !!VRy10&x9=0/y99=3:Sv912+x6; // set y10 to insert position
!!VRy10&y10<0:S0; !!VRy10&y10=>y8:Sy8 -1; // set y10 to min 0 / max MapSize

!!VRy4:Sx3; !!VRy4&y99=3:Sx5; // set new dwelling (25 % Chance for upgr. if Rule is on)
!!VRy5:Sx7; !!VRy5&y99=3:Sx8; // set new creature (25 % Chance for upgr. if Rule is on)

!!UN:Iy10/v913/v914/17/y4; // create new object
!!DWv912/v913/v914:Oy1; // set owner
!!POv912/v913/v914:N1 Oy1; // mark it as replaced
!!POy10/v913/v914:N1 Oy1; // mark it as replaced
!!MA:Gy5/?y6; // get growth rate of new creature
!!DWv912/v913/v914:M0/y5/y6 M1/y2/y3; // set new creature to hire and the boars / air elementals to the second stack
!!DWv912/v913/v914&x1>3:G0/y5/d; // set new guards for L5-7, do not change their number

!!VRy1:Sv900; !!VRy1&x9=0/y99=3:Sv906;
!!VRy2:Sv901; !!VRy2&x9=0/y99=3:Sv907;
!!VRy3:Sv902; !!VRy3&x9=0/y99=3:Sv908;
!!VRy4:Sv903; !!VRy4&x9=0/y99=3:Sv909;
!!VRy5:Sv904; !!VRy5&x9=0/y99=3:Sv910;
!!VRy6:Sv905; !!VRy6&x9=0/y99=3:Sv911;
!!FU&y1=0/y2=0/y3=0/y4=0/y5=0/y6=0:E; // exit if no changes at passability necessary


!!VRy7:Sv912 -1; // left of entrace
!!UN&y1=-1/y7>-1:Iy7/v913/v914/153/0; // set inpassable (create stump)
!!TRy7/v913/v914&y1=1/y7>-1:P1; // set passable

!!VRy7:Sv912; // original entrace
!!UN&y2=-1:Iy7/v913/v914/153/0; // set inpassable
!!TRy7/v913/v914&y2=1:P1; // set passable

!!VRy7:Sv912 +1; // right of entrace
!!UN&y3=-1/y7<=y8:Iy7/v913/v914/153/0; // set inpassable
!!TRy7/v913/v914&y3=1/y7<=y8:P1; // set passable

!!VRy9:Sv913 -1; // the line above the entrace
!!FU&y9<0:E; // if not on map

!!VRy7:Sv912 -1; // left above the entrace
!!UN&y4=-1/y7>-1:Iy7/y9/v914/153/0; // set inpassable
!!TRy7/y9/v914&y4=1/y7>-1:P1; // set passable

!!VRy7:Sv912; // above the entrace
!!UN&y5=-1:Iy7/y9/v914/153/0; // set inpassable
!!TRy7/y9/v914&y5=1:P1; // set passable

!!VRy7:Sv912 +1; // right above the entrace
!!UN&y6=-1/y7<=y8:Iy7/y9/v914/153/0; // set inpassable
!!TRy7/y9/v914&y6=1/y7<=y8:P1; // set passable

********* end of function FU6111 **************

--------------------------------------------------------------------------------
[Beginning Dialogue Box]

!?DL&v998=100/v999<=16/v999>=1/v1000=13; [any hero button pressed]
!!DL:C1000;
!!VRv952:Sv999+127;       [make appropriate number the hero clicked]
!!OW:C?y1;                [current player]
!!HEv952:O?y6;            [owner of chosen hero]
!!OW:Vy1/?y7/?y8;
!!IF|y6<>-1/v952=y7/v952=y8:M^Sorry, this {Hero} is already in the game^;
!!FU|y6<>-1/v952=y7/v952=y8:E;
!!OW:Oy1/0/?y2;           [current player's active hero]
!!HEy2:P?y3/?y4/?y5;      [hero's x y level]
!!HEy2:K;                 [kill current hero there]
!!HEv952:Py3/y4/y5;       [bring clicked hero onto original space]
!!HEv952:Oy1;             [set owner]
!!OW:A-1/v952;            [set active]
!!DO1340/7/170/1:Py2/v952;[check for artifacts]
!!DL:C1;                  [close dialogue]


!?FU1340&v225=1;                 [function to give starting artifact to new hero]
!!HEx1:A2/x16/?y1/?y2;    [y1 number of artifacts this hero has]
!!HEx2&y1<>0:A1/x16/19;   [equip in backpack]

--------------------------------------------------------------------------------

[Make AA Wraiths attack twice when shooting flyers]

!?CM4&v225=1;
!!VRv918:S0; [make sure initial flag is 0]
!!VRv919:S0; [make sure initial flag is 0]
!!CM:S?y1 D?y2; [Get type of click and position of click]

!!BG:N?v917; [current creature stack]
!!BMv917:T?v444; [creature type]
!!FU|v444<>211/y1<>12:E; [exit if not an AA wraith]
!!BMv917:I?y5; [get side of creature]
!!DO1341/0/20/1&y5=1:Py2;  [Run through all creature stacks on p1 side]
!!DO1341/21/41/1&y5=0:Py2; [Run through all creature stacks on p2 side]

!?FU1341;  [function to check enemy unit for flying, give AA wraith ability]

!!BMx16:P?v917; [position of stack]
!!VRy3:Sv917-1; [take care of double hex units]
!!FU&x1<>v917/x1<>y3:E; [break if stack position not clicked position]
!!BMx16:F?i;  [creature flags to i]
!!VRi:&1;     [check if double hex]
!!FU&x1=y3/i<>1:E; [break if clicked hex in front of unit but not a double hex]
!!BMx16:F?i;  [creature flags to i]
!!VRi:&2;     [0 if not flying, 1 if is flying]
!!VRv918&i>0:S1; [flag for if its an AA wraith attacking a flier]

!?BG&v918=1/v225=1/v444=211;  [before action, make sure it's a shot]
!!VRv919:S0;  [flag for shot]
!!BG:A?y1;    [type of action, shot = 7]
!!VRv919&y1=7:S1;  [set flag]

!?MF1&v919=1/v918=1/v225=1/v444=211;    [if a shot and a flier and aa wraith]
!!MF:D?y1;              [original damage]
!!VRz3:S^DEATHBLO.wav^;  [play death blow]
!!SN:Pz3;
!!BMv917:N?v915;          [number of aa wraiths]
!!VRz1:Sz182086;        [DB phrase for single]
!!VRz2:Sz182087;        [DB phrase for multiple]
!!MM&v915=1:Sz1;          [add messages]
!!MM&v915>1:Sz2;
!!MF:N?y3;                 [stack]
!!BMy3:V73;                [show deathblow on stack]
!!VRv916:S 2 * y1;           [double the damage]
!!MF:Fv916;
!!VRv918:S0;               [reset flier flag]
!!VRv919:S0;               [reset shot flag]
--------------------------------------------------------------------------------

[function to change hero classes for all covenant heroes]

!?FU1342;

!!UN:C6806764/4/?v1; 67DCEC -> table of heroes
!!VRy1:Sx1 *64 + v1 +4; calculate pointer to class name
!!VRy2:Sx2 -1 *512 +9597928; calculate address of Z var
!!UN:Cy1/4/y2; write new pointer
--------------------------------------------------------------------------------
[make sure jacakls cost the right amount]
!?CM5&v225=1;
!!MA:C199/6/120;
--------------------------------------------------------------------------------
!?CM1&v225=1;

[Rename all buildings, other text things]

!!VRz126:S^Spirit^;
!!VRz581:S^The Spirit allows you to recruit Grunts.^;
!!VRz127:S^Phantom^;
!!VRz582:S^The Phantom allows you to recruit Jackals.^;
!!VRz128:S^Corvette^;
!!VRz583:S^The Corvette allows you to recruit Buggers.^;
!!VRz129:S^Brute Drop Pod^;
!!VRz584:S^The Brute Drop Pod allows you to recruit Brutes.^;
!!VRz130:S^Elite Drop Pod^;
!!VRz585:S^The Elite Drop Pod allows you to recruit Elites.^;
!!VRz131:S^Portal of Te^;
!!VRz586:S^The Portal of Te allows you to recruit Hunters.^;
!!VRz132:S^Summit^;
!!VRz587:S^The Summit allows you to recruit Ghosts.^;
!!VRz133:S^Upg. Spirit^;
!!VRz588:S^The Eayn Overlord allows you to recruit Grunt Heroes.^;
!!VRz134:S^Upg. Phantom^;
!!VRz589:S^The Phatom Gunboat allows you to recruit Jackal Majors.^;
!!VRz135:S^Upg. Corvette^;
!!VRz590:S^The Battle Cruiser allows you to recruit Drones.^;
!!VRz136:S^Upg. Brute Drop Pod^;
!!VRz591:S^The Chieftan's Pod allows you to recruit Brute Chieftans.^;
!!VRz137:S^Upg. Elite Drop Pod^;
!!VRz592:S^The General's Pod allows you to recruit Sword Elites.^;
!!VRz138:S^Upg. Portal of Te^;
!!VRz593:S^The Huragok's Pitstop allows you to recruit Huragok's Hunters.^;
!!VRz139:S^Upg. Summit^;
!!VRz594:S^The Prophet's Workshop allows you to recruit Wraiths.^;
!!VRz101:S^Covenant^;
!!VRz153:S^Slipespace Gravlift^;
!!VRz154:S^Spirit Capacity Boost^;
!!VRz157:S^Prophet's Blessing^;
!!VRz162:S^Forerunner Construct^;
!!VRz471:S^The Slipspace Gravlift allows you to exchange lowly Covenant troops for one another.^;
!!VRz472:S^This structure increases weekly production of Grunts by 10 per week.^;
!!VRz473:S^This structure increases weekly production of Grunt Heroes by 10 per week.^;
!!VRz475:S^The Prophet's Blessing allows two structures to be built in this town per day.^;
!!VRz480:S^The Forerunner Construct allows the knowledge of the {Ancients} to be shared.^;

!!UN:C6972624/4/9661928; [z var 126 to index 1126  buildings and upgrades]
!!UN:C6972628/4/9662440;
!!UN:C6972632/4/9662952;
!!UN:C6972636/4/9663464;
!!UN:C6972640/4/9663976;
!!UN:C6972644/4/9664488;
!!UN:C6972648/4/9665000;
!!UN:C6972652/4/9665512; [begin upgraded buildings]
!!UN:C6972656/4/9666024;
!!UN:C6972660/4/9666536;
!!UN:C6972664/4/9667048;
!!UN:C6972668/4/9667560;
!!UN:C6972672/4/9668072;
!!UN:C6972676/4/9668584; [z var 139 to index 1139 end of upgraded buildings]

!!UN:C6974444/4/9894888; [z var 581 to index 1581 start of building descriptions]
!!UN:C6974448/4/9895400;
!!UN:C6974452/4/9895912;
!!UN:C6974456/4/9896424;
!!UN:C6974460/4/9896936;
!!UN:C6974464/4/9897448;
!!UN:C6974468/4/9897960;
!!UN:C6974472/4/9898472; [begin upgraded descriptions]
!!UN:C6974476/4/9898984;
!!UN:C6974480/4/9899496;
!!UN:C6974484/4/9900008;
!!UN:C6974488/4/9900520;
!!UN:C6974492/4/9901032;
!!UN:C6974496/4/9901544; [end building descriptions]

!!UN:C6968732/4/9675752; [z var 153 to index 153 naming artifact merchant
!!UN:C6968736/4/9676264;
!!UN:C6968740/4/9676264; [Upgrade is named the same if have upgraded spirit]
!!UN:C6968748/4/9677800;
!!UN:C6968768/4/9680360; [end with naming grail]

!!UN:C6978004/4/9838568; [z var 471 to index 1471 artifact merchant description]
!!UN:C6978008/4/9839080;
!!UN:C6978012/4/9839592;
!!UN:C6978020/4/9840616;
!!UN:C6978040/4/9843176; [down to grail]
--------------------------------------------------------------------------------

