home *** CD-ROM | disk | FTP | other *** search
/ GameStar Special 2004 September / GSSH0904CD1.iso / RiseofNations / PeninsulaWar / Peninsula.exe / Peninsula.bhs < prev    next >
Text File  |  2004-03-06  |  26KB  |  796 lines

  1. /* Peninsula War
  2.    
  3.    This event file controls all the events for the Peninsula War scenario.
  4.   
  5.    Scenario By: Kevin 'DarthVeda' Chulski
  6.    Contact: darthveda@hotmail.com
  7.    Please email any questions/suggestions/comments that you have!   
  8. */
  9.  
  10. scenario
  11. {
  12.   
  13.   set_nation_name("Germans", $S("British"));
  14.   
  15.   // initialize variables
  16.   
  17.   static int month = 7;
  18.   static int day = 1;
  19.   static int year = 1808;
  20.   static int DAYRATE = 3;
  21.   static string monthSt = "July";
  22.   static int i = 0;
  23.   static int j = 0;
  24.   static int X = 0;
  25.   static int Y = 0;
  26.   static int mouseX = 0;
  27.   static int mouseY = 0;
  28.   static int difficulty = -1;
  29.   static int randType = 0;
  30.   static int someGuy = 0;
  31.   static int zen = 0; // variable for whatever
  32.   
  33.   static int CAP_1813 = 50; // default cap rate for French after Russian campaign
  34.   static int tutorMsg = 1;
  35.   
  36.   // RPG kinda stuff
  37.   
  38.   static int level = 1;
  39.   static int general_health = object_max_health( 1, object_max_health( 1, find_unit( 1, "General") ) );
  40.   static int exp_needed = 10;
  41.   static int exp_gained = 0;
  42.   static int exp_modifier = 0;
  43.   static int heal_percent = 0;
  44.   static int heal_count = 0;
  45.   static int whoToHeal = 0;
  46.   static int HEALRADIUS = 5;
  47.   static int explore_percent = 0;
  48.   static int EXPLORERADIUS = 5;
  49.   static int reinforce_count = 0;  
  50.   static int whoToDemoralize = 0;
  51.   static int DEMORALIZERADIUS = 15;
  52.   
  53. labels {
  54.   //Add any constant labels here in a comma separated list.
  55.   
  56. }
  57.  
  58. run_once {
  59.   //Insert commands that should be executed only once when the script is loaded here.
  60.   
  61.   // disable wonders
  62.   
  63.   disable_type( "Pyramids" );
  64.   disable_type( "Colossus" );
  65.   disable_type( "Terra Cotta Army" );
  66.   disable_type( "Colosseum" );
  67.   disable_type( "Temple of Tikal" );
  68.   disable_type( "Porcelain Tower" );
  69.   disable_type( "Angkor Wat" );
  70.   disable_type( "Versailles" );
  71.   disable_type( "Statue of Liberty" );
  72.   disable_type( "Kremlin" );
  73.   disable_type( "Taj Mahal" );
  74.   disable_type( "Eiffel Tower" );
  75.   disable_type( "Supercollider" );
  76.   disable_type( "Space Program" );
  77.   
  78.   // disable certain buildings and guys
  79.   
  80.   disable_type( "Small City" );
  81.   disable_type( "Spy" );
  82.   disable_type( "General" );
  83.   disable_type( "Heavy Fireship" );
  84.   
  85.   // Gain Upgrades 
  86.   
  87.   // disable upgrades 
  88.   
  89.   for ( i = 1; i < 9; i++ )
  90.   {
  91.     disable_tech(i, "Tactics");//Gain research tactics
  92.     disable_tech(i, "Operations");//Gain research operations
  93.     disable_tech(i, "Strategy");//Gain research strategy 
  94.   }
  95.  
  96.   // set timers
  97.   
  98.   set_timer( "cdar", DAYRATE );
  99.   set_timer( "charge_abilities", 1 );
  100.   set_timer( "keep_on_rising", 30 );
  101.  
  102.   // disable triggers
  103.   
  104.   disable_trigger( "heal_you" );
  105.   disable_trigger( "ceiling1813" );
  106.   disable_trigger( "demoralize" );
  107.   
  108.   // miscelaneous 
  109.   
  110.   set_base_rate( 1, "Food", 15 );
  111.   set_base_rate( 1, "Timber", 15 );
  112.   set_base_rate( 1, "Metal", 15 );
  113.   set_base_rate( 1, "Wealth", 15 );
  114.   
  115.   set_victory_message( "The Armies of Napoleon have been defeated!" );
  116.        
  117. }
  118.  
  119. //Main script body.
  120. //Add triggers and other commands to be executed each game frame here.
  121. //Use Edit->Insert Trigger Function to select from the list of available functions
  122. //Use Edit->Insert Trigger Block to add a blank trigger block.
  123. //See ./scenario/sample_script.bhs for additional documentation
  124.  
  125.   trigger opening_cinematic ( )
  126.   {
  127.     set_msg_time(20);//Sets message time to 20 seconds
  128.     scrolling_lock();//Locks scrolling
  129.     zooming_lock();//Locks zooming
  130.     hotkey_selection_disable();//disables hotkey selection
  131.     ui_hide();//Hides the UI
  132.     mouse_selection_disable();//disables mouse selection
  133.     set_music_mood( "winning", 1 );
  134.     print_msg( "Summer 1808 - Napoleon has seized the chance to capitalize on political instability in Spain, and he has installed his brother on the throne.  Britain has sent a force to keep French hegemony from cutting off Mediterranean trade to Britain." ); 
  135.     add_objective_text( "July 1, 1808", "date", "null.wav" );
  136.     set_timer( "opener", 12 );
  137.     
  138.   }
  139.   
  140.   trigger lock_on ( )
  141.   {
  142.     int bombID = find_unit( 1, "Bomb Ketch" );
  143.     X = object_position_x( 1, bombID );
  144.     Y = object_position_y( 1, bombID );
  145.     
  146.     move_camera( X,Y );
  147.     
  148.     enable_trigger( "lock_on" );
  149.   }
  150.  
  151.   trigger opening_dialog ( timer_expired( "opener" ) )
  152.   {
  153.     clear_msg(); //clears text
  154.     disable_trigger( "lock_on" );
  155.     scrolling_unlock();
  156.     zooming_unlock();
  157.     hotkey_selection_enable();
  158.     mouse_selection_enable();
  159.     ui_show();
  160.     move_camera( 240, 370 );
  161.     popup_dialog( "Sir Arthur, we have landed in Portugal.  We must capture Lisbon and drive General Junot's army out." );
  162.     popup_dialog( "NEW OBJECTIVE: Capture Lisbon" );
  163.     add_objective( "Capture Lisbon", "mainobj", "null.wav" );
  164.     popup_dialog( "Also general, you must survive." );
  165.     popup_dialog( "NEW OBJECTIVE: General must survive" );
  166.     add_objective( "General must survive", "survobj", "null.wav" );
  167.     
  168.   }
  169.   
  170.   trigger lisbon_cap( city_assimilate( 1, "Lisbon" ) )
  171.   {
  172.     destroy_building( 1, 2001 );
  173.     for( i = 2009; i < 2013; i++ )
  174.     {
  175.       switch_teams( 1, 2, i );
  176.     }
  177.     
  178.     zen = population( 2 );
  179.     
  180.     for ( i = 0; i < zen; i++ )
  181.     {
  182.       someGuy = find_unit( 2, "Citizen" );
  183.       
  184.       switch_teams( 1, 2, someGuy );
  185.     }
  186.     switch_teams( 1, 2, 2016 );
  187.     switch_teams( 1, 2, 2020 );
  188.     switch_teams( 1, 2, 2023 );
  189.     switch_teams( 1, 2, 2024 );
  190.     switch_teams( 1, 2, 2027 );
  191.     switch_teams( 1, 2, 2028 );
  192.     popup_dialog( "Sir, we have won a major battle against the French and have captured Lisbon, the first step towards securing the Iberian Peninsula.  Portugal is now under our control.  Use it as a base to drive the French out of Spain." );
  193.     popup_dialog( "NEW OBJECTIVE: Drive the French out of Spain." );
  194.     change_objective_text( "mainobj", "Drive the French out of Spain." );
  195.     add_objective_text( "Current Level: " + level, "the_level", "null.wav" );
  196.     add_objective_text( "Experience: [" + exp_gained + "/" + exp_needed + "]", "exp_bar", "null.wav" );
  197.     if ( popup_choice( "General Sir, would you like a briefing about this campaign?", "Yes", "No Thanks" ) == 1 )
  198.     {
  199.       while ( tutorMsg )
  200.       {
  201.         popup_dialog( "Notice 'Current Level' and 'Experience' at the left.  The more enemy troops you defeat in battle, the more seasoned you will become and thus level up.  At higher levels, you can activate special battlefield abilities." );
  202.         popup_dialog( "Skills that will become available will charge slowly to 100%.  When you see that the skill is fully charged, you can press the associated button (surrounded in parenthesis) to activate the skill." );
  203.         popup_dialog( "Some skills are more powerful than others and take a longer time to charge.  The more levels you gain, the more powerful base skills will become." );
  204.         popup_dialog( "Sir, in this campaign troops cost much more than usual.  However, they also have many more hitpoints.  Manage your troops effectively General, as reinforcements are expensive." );
  205.         if ( popup_choice( "Would you like that repeated?", "Yes", "No" ) != 1 )
  206.         {
  207.           tutorMsg = 0;
  208.         }
  209.       }
  210.       popup_dialog( "This concludes the campaign briefing.  You will be briefed again when you gain new skills.  Good luck out there, sir." );
  211.     }
  212.   }
  213.   
  214.   trigger calendar ( timer_expired( "cdar" ) )
  215.   {
  216.     // I wrote this calendar trigger so it will work with any year and date
  217.     // Just a few things are needed:
  218.     // static int DAYRATE - number of seconds that equate to a 'day'
  219.     //   Note: It is possible to change DAYRATE during the run to speed up or slow down the passage of time
  220.     // timer cdar - usually set to DAYRATE
  221.     // and then all the other static variables:
  222.     // day, month, monthSt, year 
  223.     
  224.     // Find out what day it is and see if the month needs to change
  225.     
  226.     if ( ( day == 30 ) && ( ( month == 4 ) ||  ( month == 6 ) || ( month == 9 )|| ( month == 11 ) ) )
  227.     {
  228.       day = 1;
  229.       month++;
  230.     }  
  231.     else if ( ( month == 2 ) && ( day >= 28 ) )
  232.     {
  233.       if ( ( year%4 == 0 ) && ( day == 28 ) )
  234.       {
  235.         day++;
  236.       }
  237.       else
  238.       {
  239.         day = 1;
  240.         month++;
  241.       }
  242.     }
  243.     else if ( day == 31 )
  244.     {
  245.       day = 1;
  246.       if ( month == 12 )
  247.       {
  248.         month = 1;
  249.         year++;
  250.       }
  251.       else
  252.       {
  253.         month++;
  254.       }
  255.     }
  256.     else
  257.     {
  258.       day++;
  259.     }
  260.     
  261.     // Set month string
  262.     
  263.     if ( day == 1 )
  264.     {
  265.       if ( month == 1 )
  266.       {
  267.         monthSt = "January";
  268.       }
  269.       else if ( month == 2 )
  270.       {
  271.         monthSt = "February";
  272.       }
  273.       else if ( month == 3 )
  274.       {
  275.         monthSt = "March";
  276.       }
  277.       else if ( month == 4 )
  278.       {
  279.         monthSt = "April";
  280.       }
  281.       else if ( month == 5 )
  282.       {
  283.         monthSt = "May";
  284.       }
  285.       else if ( month == 6 )
  286.       {
  287.         monthSt = "June";
  288.       }
  289.       else if ( month == 7 )
  290.       {
  291.         monthSt = "July";
  292.       }
  293.       else if ( month == 8 )
  294.       {
  295.         monthSt = "August";
  296.       }
  297.       else if ( month == 9 )
  298.       {
  299.         monthSt = "September";
  300.       }
  301.       else if ( month == 10 )
  302.       {
  303.         monthSt = "October";
  304.       }
  305.       else if ( month == 11 )
  306.       {
  307.         monthSt = "November";
  308.       }
  309.       else
  310.       {
  311.         monthSt = "December";
  312.       }
  313.     }
  314.     
  315.     // update objectives with new date
  316.     
  317.     change_objective_text( "date", monthSt + " "  + day + ", " + year );
  318.            
  319.     set_timer( "cdar", DAYRATE );
  320.     enable_trigger( "calendar" );
  321.   } // end of calendar trigger
  322.   
  323.   trigger spanish_insurgency ( ( month == 9 ) && ( day == 25 ) )
  324.   {
  325.     create_unit( 7, 160, 240, "Musketeers", 6 );
  326.     create_unit( 7, 160, 240, "Royal Tercios", 4 );
  327.     create_unit( 7, 160, 240, "Hussar", 2 );
  328.   }
  329.   
  330.   trigger sir_moore ( month == 10 )
  331.   {
  332.     force_transport_ability( 8 );
  333.     print_msg( "October 1808 - Sir John Moore comes to the aid of Spanish insurgents near Salamanca" );
  334.     ping( 1, 8, 157, 383);
  335.     create_unit( 8, 157, 383, "Musketeers", 10 );
  336.     group_attack_to_order( 8, 163, 255 );
  337.     create_unit( 8, 157, 383, "Hussar", 3 );
  338.     group_attack_to_order( 8, 163, 255 );
  339.     create_unit( 8, 157, 383, "Cuirassier", 2 );
  340.     group_attack_to_order( 8, 163, 255 );
  341.     create_unit( 8, 157, 383, "Cannon", 2 );
  342.     group_attack_to_order( 8, 163, 255 );
  343.     create_unit( 8, 157, 383, "Supply Wagon", 1 );
  344.     group_attack_to_order( 8, 163, 255 );
  345.     create_unit( 8, 157, 383, "General", 1 );
  346.     group_attack_to_order( 8, 163, 255 );
  347.   }
  348.   
  349.   trigger sir_moore_arrives( object_type_near( 8, "General", 1, 163, 255, 10 ) )
  350.   {
  351.     clear_msg();
  352.     print_msg( "Sir John Moore's support has encouraged Spanish rebels in the North to rise up." );
  353.     switch_teams( 7, 5, 2000 );
  354.     switch_teams( 7, 3, 2015 );
  355.     switch_teams( 7, 3, 2014 );
  356.     switch_teams( 7, 5, 2038 );
  357.     switch_teams( 7, 5, 2035 );
  358.     create_unit( 7, 38, 220, "Royal Tercios", 5 );
  359.     create_unit( 7, 39, 329, "Iberian Militia", 10 );
  360.   }
  361.   
  362.   trigger napoleon_takes_charge( month == 11 )
  363.   {
  364.     print_msg( "November 1808 - It is reported that Napoleon has arrived in Spain to personally get things under control once more." );
  365.     create_unit( 3, 100, 221, "Horse Guard Grenadier", 10 );
  366.     group_attack_to_order( 3, 163, 255 );
  367.     create_unit( 3, 100, 221, "Hussar", 5 );
  368.     group_attack_to_order( 3, 163, 255 );
  369.     create_unit( 5, 47, 180, "Horse Guard Grenadier", 3 );
  370.     group_attack_to_order( 5, 48, 342 );
  371.     create_unit( 5, 47, 180, "Musketeers", 10 );
  372.     group_attack_to_order( 5, 48, 342 );
  373.     create_unit( 5, 47, 180, "Cannon", 1 );
  374.     group_attack_to_order( 5, 48, 342 );
  375.     create_unit( 5, 47, 180, "Supply Wagon", 2 );
  376.     group_attack_to_order( 5, 48, 342 );
  377.   }
  378.   
  379.   trigger battle_of_somo_sierra ( ( month == 11 ) && ( day == 30 ) )
  380.   {
  381.     print_msg( "November 30 1808 - The Battle of Somo Sierra is fought between Spanish rebels and Napoleon's Grand ArmΘe" );
  382.     ping ( 1, 7, 131, 147 );    
  383.     
  384.     // Spanish Forces
  385.     create_unit( 7, 125, 158, "Royal Tercios", 1 );
  386.     create_unit( 7, 125, 158, "Iberian Militia", 8 );
  387.     create_unit( 7, 125, 158, "Cannon", 2 );
  388.     create_unit( 7, 125, 158, "Supply Wagon", 1 );
  389.     
  390.     // French Forces
  391.     create_unit( 3, 116, 134, "Musketeers", 10 );
  392.     create_unit( 3, 116, 134, "Hussar", 5 );
  393.     group_attack_to_order( 1, 125, 158 );  
  394.   }
  395.   
  396.   trigger napoleon_is_done( month == 1 )
  397.   {
  398.     print_msg( "January 1809 - Napoleon, satisified with the situation, leaves Spain." );
  399.     DAYRATE = 1; // 1809 is a quick year
  400.     set_base_rate( 1, "Wealth", 30 );
  401.   }
  402.   
  403.   trigger more_trade( year == 1810 )
  404.   {
  405.     DAYRATE = 3; // Slowing it back down
  406.     set_base_rate( 1, "Wealth", 45 );
  407.   }
  408.   
  409.   trigger more_more_trade( year == 1811 )
  410.   {
  411.     set_base_rate( 1, "Wealth", 60 );
  412.   }
  413.   
  414.   trigger more_more_more_trade( year == 1812 )
  415.   {
  416.     set_base_rate( 1, "Wealth", 75 );
  417.   }
  418.   
  419.   trigger napoleon_attacks_russia( month == 7 && year == 1812 )
  420.   {
  421.     print_msg( "July 1812 - News arrives that Napoleon has invaded Russia." );
  422.   }
  423.   
  424.   trigger napoleon_is_defeated( month == 11 && year == 1812 )
  425.   {
  426.     print_msg( "November 1812 - Napoleon's Grand ArmΘe suffers defeat in Russia at the hands of General Winter and is in full retreat." );
  427.   }
  428.   
  429.   trigger more_more_more_more_trade( year == 1813 )
  430.   {
  431.     set_base_rate( 1, "Wealth", 90 );
  432.   }
  433.   
  434.   trigger napoleon_withdraws( month == 3 && year == 1813 )
  435.   {
  436.     print_msg( "March 1813 - Faced with severe manpower shortages, Napoleon has recalled 60,000 men from Spain." );
  437.     for ( int k = 2; k < 7; k++ )
  438.     {
  439.       zen = num_military_units( k );
  440.       zen = (int) (zen / 4);
  441.       for ( i = 0; i < zen; i++ )
  442.       {
  443.         someGuy = find_military( k );
  444.         kill_unit_anim( k, someGuy, 1 );
  445.       }
  446.     }
  447.     enable_trigger( "ceiling1813" );
  448.   }
  449.   
  450.   trigger battle_of_lepzig( month == 11 && year == 1813 )
  451.   {
  452.     print_msg( "November 1813 - After the battle of Leipzig in Germany, Napoleon's routed army flees to France." );
  453.   }
  454.   
  455.   trigger final_trade( year == 1814 )
  456.   {
  457.     set_base_rate( 1, "Wealth", 100 );
  458.   }
  459.   
  460.   trigger napoleon_abdicates( month == 4 && year == 1814 )
  461.   {
  462.     print_msg( "April 1814 - Napoleon has abdicated in the face of Allied armies closing in on France." );
  463.     popup_dialog( "Napoleon has abdicated.  You have until the end of June to capture the remainder of French posessions." );
  464.   }
  465.   
  466.   trigger end_of_scenario( month == 7 && year == 1814 )
  467.   {
  468.     popup_dialog( "Sir, though you have impressed the entire nation with your campaign in the Peninsula, your inability to achieve conclusion has earned your dismissal." );
  469.     set_defeat_message( "You have been recalled!" );
  470.     defeat( 1 );
  471.   }
  472.   
  473.   trigger death_of_sir_moore( unit_type_killed( 8, "General" ) )
  474.   {
  475.     print_msg( "Sir John Moore has been fatally wounded leading his men in battle.  Forces under his command are making a withdrawl from the campaign." );
  476.     defeat( 8 );
  477.   }
  478.   
  479.   trigger exp_updated( exp_gained <= num_units_killed( 1 ) )
  480.   {
  481.     exp_gained = num_units_killed( 1 ) - exp_modifier;
  482.     change_objective_text( "exp_bar", "Experience: [" + exp_gained + "/" + exp_needed + "]" );
  483.     enable_trigger( "exp_updated" );
  484.   }
  485.   
  486.   trigger level_up( ( exp_gained >= exp_needed ) && ( level < 10 ) )
  487.   {
  488.     level++;
  489.     exp_needed = expTable( level );
  490.     change_objective_text( "exp_bar", "Experience: [" + exp_gained + "/" + exp_needed + "]" );
  491.     change_objective_text( "the_level", "Current Level: " + level );
  492.     play_sound( "lvl.wav" );
  493.     print_game_msg( "Leveled Up!" );
  494.     
  495.     if ( level == 2 )
  496.     {
  497.       gain_tech( 1, "Tactics" );
  498.       print_game_msg( "Leadership abilities improved!" );
  499.       popup_dialog( "General, when you level up by gaining experience, your abilities will improve.  In this case, it has increased your talent for leading your men by adding a +2 armor bonus for all soldiers near your general." );
  500.     }
  501.     else if ( level == 3 )
  502.     {
  503.       // Auto Reinforce activate
  504.       reinforce_count = 0;
  505.       force_transport_ability( 1 );
  506.       popup_dialog( "Now that you have established yourself as a reliable force in the Peninsula, you will receive reinforcements from England every 60 days. " );  
  507.     }
  508.     else if ( level == 4 )
  509.     {
  510.       print_game_msg( "General's max health increased!" );
  511.       general_health = (int) ( general_health * 1.25 );
  512.       set_object_type_max_health( "General", general_health );
  513.     }
  514.     else if ( level == 5 )
  515.     {
  516.       print_game_msg( "Gained explore ability" );
  517.       add_objective_text( "E(x)plore: [0% Charged]", "explore_charge", "null.wav" );
  518.       popup_dialog( "Your contacts in the Iberian Peninsula have become well established.  This has given you a new ability to call on them to reveal the entire map at any time.  Press the 'X' key when this ability is charged to temporarily explore the whole map." );
  519.       set_leader_name( 1, "Viscount Wellington" );
  520.       popup_dialog( "In addition, you have been given the title Viscount Wellington to commend you on your services." );
  521.     }
  522.     else if ( level == 6 )
  523.     {
  524.       gain_tech( 1, "Operations");
  525.       print_game_msg( "Leadership abilities improved!" );
  526.     }
  527.     else if ( level == 7 )
  528.     {
  529.       print_game_msg( "Gained demoralize ability" );
  530.       set_timer( "demoralizer", 1 );
  531.       enable_trigger( "demoralize" );
  532.       popup_dialog( "Sir, your presence on the battlefield has a negative effect on enemy troops, sapping 1% of the strength (per second) of nearby enemy units." );
  533.     }
  534.     else if ( level == 8 )
  535.     {
  536.       print_game_msg( "General's max health increased!" );
  537.       general_health = (int) ( general_health * 1.25 );
  538.       set_object_type_max_health( "General", general_health );
  539.     }
  540.     else if ( level == 9 )
  541.     {
  542.       print_game_msg( "Gained heal ability" );
  543.       add_objective_text( "H(e)al: [0% Charged]", "heal_charge", "null.wav" );
  544.       popup_dialog( "You have gained a new ability to heal troops under your command.  Press the 'E' key when this ability is charged to activate it and drop a healing beacon." );
  545.       set_leader_name( 1, "Duke of Wellington" );
  546.       popup_dialog( "Your services to Britain have earned you the title Duke of Wellington.  Congratulations." );
  547.     }
  548.     else if ( level == 10 )
  549.     {
  550.       gain_tech(1, "Strategy");
  551.       print_game_msg( "Leadership abilities improved!" );
  552.       remove_objective( "exp_bar" );
  553.       disable_trigger( exp_updated ); 
  554.     }
  555.     
  556.     enable_trigger( "level_up" );
  557.   }
  558.   
  559.   trigger you_captured( unit_type_killed( 1, "General" ) )
  560.   {
  561.     popup_dialog( "General, you have been captured in battle.  You will have to sit out the rest of the war in a French prison. " );
  562.     set_defeat_message( "You were captured" );
  563.     defeat( 1 );
  564.   }
  565.   
  566.   trigger abilities_charger ( timer_expired( "charge_abilities" ) )
  567.   {
  568.     if ( ( level >= 3 ) && ( time_sec() % DAYRATE == 0 ) )
  569.     {
  570.       reinforce_count++;
  571.     }
  572.     if ( ( level >= 5 ) && ( explore_percent < 100 ) )
  573.     {
  574.       explore_percent++;
  575.       change_objective_text( "explore_charge",  "E(x)plore: [" + explore_percent + "% Charged]" );
  576.     }
  577.     // Level 7 is passive and needs no charging
  578.     if ( ( level >= 9 ) && ( heal_count == 0 ) && ( heal_percent < 100 ) )
  579.     {
  580.       heal_percent++;
  581.       change_objective_text( "heal_charge", "H(e)al: [" + heal_percent + "% Charged]" ); 
  582.     }
  583.   
  584.     set_timer( "charge_abilities", 1 );
  585.     enable_trigger( "abilities_charger" );
  586.   }
  587.   
  588.   trigger hit_e ( key_down( "e" ) && ( heal_percent == 100 ) )
  589.   {
  590.     play_sound( "skill.wav" );
  591.     print_game_msg( "Activated heal" );
  592.     heal_percent = 0;
  593.     
  594.     mouseX = get_mouse_game_x();
  595.     mouseY = get_mouse_game_y();
  596.     
  597.     change_objective_text( "heal_charge", "H(e)al: [In Use]" );
  598.     
  599.     add_flag( mouseX, mouseY );
  600.     enable_trigger( "heal_you" );
  601.     set_timer( "the_healer", 1 );
  602.     heal_count = 7;  // Number of seconds healing has effect
  603.     
  604.     enable_trigger( "hit_e" );
  605.   }
  606.   
  607.   trigger heal_you ( timer_expired( "the_healer" ) )
  608.   {
  609.     whoToHeal = 0;
  610.   
  611.     if ( heal_count > 0 )
  612.     {
  613.       for ( i = 0; i < population( 1 ); i++ )
  614.       {
  615.         whoToHeal = find_military( 1 );
  616.         if ( object_near( 1, whoToHeal, mouseX, mouseY, HEALRADIUS + level ) )
  617.         {
  618.           heal_object( 1, whoToHeal, 5 + ( (int) ( level / 3 ) ) );
  619.         }
  620.         whoToHeal = find_unit( 1, "Supply Wagon" );
  621.         if ( object_near( 1, whoToHeal, mouseX, mouseY, HEALRADIUS + level ) )
  622.         {
  623.           heal_object( 1, whoToHeal, 5 + ( (int) ( level / 3 ) ) );
  624.         }
  625.       }
  626.       whoToHeal = find_unit( 1, "General" );
  627.       if ( object_near( 1, whoToHeal, mouseX, mouseY, HEALRADIUS + level ) )
  628.       {
  629.           heal_object( 1, whoToHeal, 5 + ( (int) ( level / 3 ) ) );
  630.       }
  631.       
  632.       heal_count--;
  633.       set_timer( "the_healer", 1 );
  634.       enable_trigger( "heal_you" );
  635.     }
  636.     else
  637.     {
  638.       clear_flags();
  639.       change_objective_text( "heal_charge", "H(e)al: [0% Charged]" );
  640.     }
  641.   }
  642.   
  643.   trigger hit_x ( key_down( "x" ) && ( explore_percent == 100 ) )
  644.   {
  645.     print_game_msg( "Activated explore" );
  646.     play_sound( "skill.wav" );
  647.     explore_percent = 0;
  648.     
  649.     change_objective_text( "explore_charge",  "E(x)plore: [0% Charged]" );
  650.     
  651.     set_explored( 1, 200, 200, 200 );
  652.     
  653.     enable_trigger( "hit_x" );
  654.   }
  655.  
  656.   trigger demoralize( timer_expired( "demoralizer" ) )
  657.   {
  658.     int myX = object_position_x( 1, find_unit( 1, "General" ) );
  659.     int myY = object_position_y( 1, find_unit( 1, "General" ) );
  660.     
  661.     for ( j = 2; j < 7; j++ )
  662.     {
  663.       if ( !is_defeated( j ) )
  664.       {
  665.         for ( i = 0; i < num_military_units( j ); i++ )
  666.         {
  667.           whoToDemoralize = find_military( j );
  668.           if ( object_near( j, whoToDemoralize, myX, myY, DEMORALIZERADIUS ) == 1 )
  669.           {
  670.             damage_object( j, whoToDemoralize, 1 ); 
  671.           }
  672.         }
  673.       }
  674.       else
  675.       {
  676.         // player 'j' is defeated.  Skip them.      
  677.       }
  678.     }  
  679.     
  680.     set_timer( "demoralizer", 1 );
  681.     enable_trigger( "demoralize" );
  682.   }
  683.   
  684.   trigger reinforcing ( reinforce_count >= 60 )
  685.   {
  686.     reinforce_count = 0;
  687.     play_sound( "reinforce.wav" );
  688.     print_game_msg( "Reinforcements from Britain are ariving" );
  689.     
  690.     ping( 1, 1, 210, 392 );
  691.     
  692.     if ( level <= 5 )
  693.     {
  694.       create_unit( 1, 210, 392, "Hussar", 1 );
  695.       group_attack_to_order( 1, 218, 355 );
  696.       create_unit( 1, 210, 392, "Musketeers", 3 );
  697.       group_attack_to_order( 1, 218, 355 );
  698.       create_unit( 1, 210, 392, "Sloop", 1 );
  699.       group_attack_to_order( 1, 229, 381 );
  700.     }
  701.     else
  702.     {
  703.       create_unit( 1, 210, 392, "Cuirassier", 1 );
  704.       group_attack_to_order( 1, 218, 355 );
  705.       create_unit( 1, 210, 392, "Musketeers", 4 );
  706.       group_attack_to_order( 1, 218, 355 );
  707.       create_unit( 1, 210, 392, "Frigate", 1 );
  708.       group_attack_to_order( 1, 229, 381 ); 
  709.     }
  710.     
  711.     enable_trigger( "reinforcing" );       
  712.   }
  713.   
  714.   trigger uprising ( timer_expired( "keep_on_rising" ) )
  715.   {
  716.     someGuy = 0;
  717.     rand_seed( score( 1 ) );
  718.     randType = rand_int( 0, 100 );
  719.     
  720.     for ( i = 2; i < 7; i++ )
  721.     {
  722.       someGuy = find_unit( i, "Citizen" );
  723.       
  724.       if ( someGuy > 0 )
  725.       {
  726.         X = object_position_x( i, someGuy );
  727.         Y = object_position_y( i, someGuy );
  728.       
  729.         kill_unit_anim( i, someGuy, 1 );
  730.         if ( randType%10 != 0 )
  731.         {
  732.           create_unit( 7, X, Y, "Iberian Militia", 1 );
  733.         }
  734.         else
  735.         {
  736.           create_unit( 7, X, Y, "Royal Tercios", 1 );
  737.           create_unit( 7, X, Y, "Iberian Militia", 1 );
  738.           create_unit( 7, X, Y, "Minuteman", 1 );
  739.         }
  740.       }
  741.     }
  742.     
  743.     set_timer( "keep_on_rising", 90 );
  744.     enable_trigger( "uprising" );
  745.   }
  746.   
  747.   trigger ceiling1813( )
  748.   {
  749.     for ( i = 2; i < 7; i++ )
  750.     {
  751.       set_population_cap( i, CAP_1813 );
  752.     }    
  753.     
  754.     enable_trigger( "ceiling1813" );
  755.   }
  756.   
  757.   trigger madrid_falls ( find_city_owner( "Madrid" ) != 4 ) 
  758.   {
  759.     if ( find_city_owner( "Valencia" ) == 6 )
  760.     {
  761.       print_msg( "Madrid falls.  King Joseph flees to Valencia." );
  762.       create_unit( 4, 182, 72, "General", 1 );
  763.       create_unit( 4, 182, 72, "Musketeers", 5 );
  764.       switch_teams( 4, 6, 2002 );
  765.     }
  766.     else
  767.     {
  768.       print_msg( "Madrid falls.  King Joseph is taken prisoner." );
  769.       defeat( 4 );
  770.       disable_trigger( "joseph_killed" );
  771.     }
  772.   }
  773.   
  774.   trigger joseph_killed ( unit_type_killed ( 4, "General" ) )
  775.   {
  776.     print_msg( "Joseph Bonaparte is killed in battle." );
  777.     defeat( 4 );
  778.   }
  779.   
  780. }
  781.  
  782. int scenario expTable( int curlev )
  783. {
  784.   // Hey look, it's a recursive function!
  785.   // It calculates how much experience needed for a level.
  786.   
  787.   if ( curLev < 2 )
  788.   {
  789.     return 10; // Base of 10
  790.   }
  791.   else
  792.   {
  793.     return expTable( curlev - 1 ) + expTable( curlev - 2 );
  794.   }
  795.   
  796. }