Announcement

Collapse
No announcement yet.

Info: scripting language

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Info: scripting language

    Tell me about the scenario editor and triggers please. I've been wanting to know this for ages!

  • #2
    the scenario editor is not included in the preview betas.
    there is a whole scripting language with functions, variables, and everything that will give lots of powers to scenario makers
    triggers are like writing an if statement...
    Co-Founder, Apolyton Civilization Site
    Co-Owner/Webmaster, Top40-Charts.com | CTO, Apogee Information Systems
    giannopoulos.info: my non-mobile non-photo news & articles blog

    Comment


    • #3
      i found an example of a trigger from the world conquest campaign
      Code:
        trigger (num_type(PLAYER1, "general") == 0) {
          player1_timer = time_sec() + general_defeat;        
          if (player2_timer < 0) {    
            print_game_msg("Your general has been killed!  Your 
      army will disintegrate in " + general_defeat + "seconds.");    
          }
        }
      Co-Founder, Apolyton Civilization Site
      Co-Owner/Webmaster, Top40-Charts.com | CTO, Apogee Information Systems
      giannopoulos.info: my non-mobile non-photo news & articles blog

      Comment


      • #4
        Originally posted by MarkG
        i found an example of a trigger from the world conquest campaign
        Code:
          trigger (num_type(PLAYER1, "general") == 0) {
            player1_timer = time_sec() + general_defeat;        
            if (player2_timer < 0) {    
              print_game_msg("Your general has been killed!  Your 
        army will disintegrate in " + general_defeat + "seconds.");    
            }
          }
        Cool.

        The whole RT thing will make timings a whole new game in scripting me thinks, but it looks very good. And in-script message text is a big plus on SLIC
        Concrete, Abstract, or Squoingy?
        "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

        Comment


        • #5
          i hope bhg doesnt mind

          here is the 1st tutorial script
          Code:
          /******************************************/
          /*************RISE OF NATIONS**************/
          /***************TUTORIAL ONE***************/
          /**************Big Huge Games**************/
          /********Scripted by: Joshua Mitnick*******/
          /*******Storyboarded by: Doug Kaufman******/
          /***************July 25, 2002**************/
          /******************************************/
          
          /*******************************************************
          Scenario 1 - Boudicea vs. the Romans
          
          Map: A Briton village, bounded by mountains and forests.
          A Roman camp (obs tower and maybe a barracks) nearby.
          
          Setup: Several combat units on both sides. The Britons
          outnumber the Romans. The Britons have a scout, multiple
          slingers, and a few each of bowmen and hoplites. A
          Boudicea unit is in the lower left.
          ********************************************************/
          
          include "scripts.bhh"
          
          scenario {
          
            // nations
            labels {
              HUMAN = 1,
              COMPUTER = 2,
            }
          
            labels {
              FLAG_X           = 27,
              FLAG_Y           = 50,
              FLAG2_X          = 25,
              FLAG2_Y          = 33,
              BONUS_LEGIONS_X  = 35,
              BONUS_LEGIONS_Y  = 28,
              ARMY_CREATE_X    = 35,
              ARMY_CREATE_Y    = 28,
              ATTACK_TO_X      = 37,
              ATTACK_TO_Y      = 30,
            }
          
            static boudicea_id        = 19;  // HACK!!  find_unit(HUMAN, "BOUDICEAN");
            static briton_id          = find_city_id("Briton");
            static Briton_X           = object_position_x (HUMAN, briton_id);
            static Briton_Y           = object_position_y (HUMAN, briton_id);
            static Legions_create_X   = Briton_X;
            static Legions_create_Y   = Briton_Y;
            static barracks_id        = find_build(COMPUTER, "barracks");
            static R_Barracks_X       = object_position_x (COMPUTER, barracks_id);
            static R_Barracks_Y       = object_position_y (COMPUTER, barracks_id);
            static lookout_id         = find_build( COMPUTER, "lookout" );
            static lookout_x          = object_position_x( COMPUTER, lookout_id );
            static lookout_y          = object_position_y( COMPUTER, lookout_id );
            static tower_destroyed    = false;
            static barracks_destroyed = false;
          	static army_destroyed     = false;
            static objective_delay    = 60;
          
            run_once {
              bubble_text_hide();
              set_explored(HUMAN, ( (R_Barracks_X + lookout_x ) / 2) , ( ( R_Barracks_Y + lookout_y ) / 2 ), 10);
              disable_all_triggers();
              set_unique_unit( "BOUDICEAN", "Boudicea" );
              set_object_type_max_health( "barracks", 250 );
              set_object_type_max_health( "lookout", 125 );
              disable_type("Citizen");
          		set_music_volume(50);
              enable_trigger("Global");
              enable_trigger("Start");
              set_timer("progress_check",objective_delay );
            }
          
          	trigger Objective_Reminder( timer_expired("progress_check") && sound_finished() ) {
          		clear_all_arrows();
          		draw_screen_arrow_line(200, 0, 200, 90, 10 );
          		play_sound("objective.wav");
              if(objective_delay < 300) {
               objective_delay = objective_delay * 2;
              } else {
               objective_delay = 300;
              }
          		set_timer("progress_check", objective_delay);
          		enable_trigger("Objective_Reminder");
          	}
          
            trigger Start () {
              //WAV: We must remove the Romans from the lands of Briton.  Lead Boudecia back to the city 
          	//     where we will muster our troops to drive the Romans out.
              play_sound ("boudicea.wav");
              enable_trigger("Select_a_unit");
              enable_trigger("Select_Boudicea");
              enable_trigger("Objective_Reminder");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Select_a_unit( sound_finished() ) {
          
              //WAV: "You must select a unit before you can give it orders. Move the mouse over Boudicea and left click to 'select' her."
              add_objective("Left click on Boudicea.", "Select_boudicea", "select_boudicea.wav");    
          		play_objective_sound("Select_boudicea");
          
              enable_trigger ("Select_Boudicea");
              enable_trigger ("Ping_Boudicea");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Select_Boudicea( object_selected(HUMAN, boudicea_id ) ) {
              disable_trigger ("Ping_Boudicea");
              disable_trigger("Select_a_unit");
          		objective_complete("Select_boudicea");
          
              // WAV: "Well done. You can be sure you have the right unit by looking at the name of 
          	// the unit you've selected in the lower right panel. Now you can give Boudicea orders."
              play_sound("boudicea_selected.wav");
          
              // draw arrow to unit display info
              unit_display_left = get_button_left("right_window");
              unit_display_top  = get_button_top("right_window");
              draw_screen_arrow_line( unit_display_left - 100, unit_display_top - 100, unit_display_left, unit_display_top, 0 );
          
              enable_trigger ("Move_a_unit");
              enable_trigger ("Deselect_Boudicea");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Deselect_Boudicea( !object_selected(HUMAN, boudicea_id )) {
              play_sound ("lostboud.wav");
              //WAV: Left-clicking on the map will clear all selections. To regain control of Boudicea, left click on her, then
          	//     right click where you want her to go.***/
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Ping_Boudicea( sound_finished () && !object_selected(HUMAN, boudicea_id ) ) {
              ping_object (1, 1, 1, boudicea_id);
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Move_a_unit( sound_finished () &&  object_selected(HUMAN, boudicea_id ) ) {
              clear_all_arrows();
          		add_objective("Select Boudicea and right click on the flag.", "Move_boudicea", "move_boudicea.wav");
              play_objective_sound("Move_boudicea");
              //WAV: "To move a unit, select it and then right-click on the map where you want it to go. 
              //      With Boudicea selected, move her toward the flag in the upper right.
              add_flag (FLAG_X, FLAG_Y);
              enable_trigger("Flag");
              enable_trigger("reveal_flag");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger reveal_flag(sound_finished() ) {
              set_explored( HUMAN, FLAG_X, FLAG_Y, 5 );   
            }
          
            trigger Flag(object_near (HUMAN, boudicea_id, FLAG_X, FLAG_Y, 2)) {
              disable_trigger("reveal_flag");
              objective_complete("Move_boudicea");
              clear_flags ();
              play_sound ("at_flag.wav");
              // WAV: "Very good. Now we'll guide your boudicea back to the village and rally the troops."
          		disable_trigger("Deselect_boudicea");
              enable_trigger ("Learn_scroll");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Learn_scroll (sound_finished ()) {
              // WAV: Briton is off the screen to the upper right.  To see off the screen, move the mouse cursor to the edge of the screen and a little beyond.
              //      This is called scrolling.  Scroll to find Briton in the upper right now.
          		add_objective("Locate Briton by scrolling to the upper right.", "Find_briton", "learnscroll.wav");
          		draw_screen_arrow_line (get_screen_width() - 100, 100, get_screen_width(), 0, 10 );
          		play_objective_sound("Find_briton");	
          		set_timer("progress_check",objective_delay);
          		enable_trigger("camera_over_village");
            }
          
          	trigger camera_over_village( is_on_screen (object_position_x(HUMAN, BRITON_ID)-1, object_position_y(HUMAN, BRITON_ID)-1)){
              clear_all_arrows();
          		objective_complete("Find_briton");
              // wav:  Very good.  You found the city of Briton.  Now, right click to move boudicea to the flag outside the village.
          		add_objective("Right click to move your unit to the flag.", "Move_to_briton", "move_b_village.wav");
              add_flag (FLAG2_X, FLAG2_Y);
          		enable_trigger("Deselect_boudicea");
          		play_objective_sound("Move_to_briton");
          		enable_trigger("Knows_moving");
          	}
          
            trigger Knows_moving (object_near_build (HUMAN, boudicea_id, HUMAN, BRITON_ID, 8)) {
              objective_complete("Move_to_briton");
              clear_flags();
              play_sound ("boudicearejoins.wav");
              //WAV: "Good work! You've successfully guided Boudica back to Briton so we can start rallying our troops. But before we attack, we must first we must find our hated foe."
              disable_all_triggers ();
          		disable_trigger("Deselect_boudicea");
              enable_trigger ("Global");
              enable_trigger ("Learn_zoom");
          		enable_trigger ("Objective_Reminder");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Learn_zoom (sound_finished ()) {
              scrolling_lock ();
            /***WAV: "To see more of the map and have a better chance of locating the Romans,"
              "zoom out by rolling the mousewheel backward (or pressing the Page Up key twice)."***/
              add_objective("Roll the mousewheel back or press PageUp twice to zoom out.", "zoom_out", "learnzoom.wav");
          		play_objective_sound("zoom_out");
              enable_trigger ("Zoom_out");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Zoom_out (is_zoomed_out ()) {
              scrolling_unlock ();
          		objective_complete("zoom_out");
          
              add_objective("Locate the Roman camp by scrolling the map to the bottom right.", "find_camp", "zoomlearned.wav");
              play_objective_sound("find_camp");
            //WAV: Well done. Now that you know how to zoom out, it will be easier
            //to locate the Roman camp. Scroll to the bottom right until you find it.
              draw_screen_arrow_line (get_screen_width() - 100, get_screen_height() - 100, get_screen_width(), get_screen_height(), 10 );
              enable_trigger ("Find_camp");
            }
          
            trigger Find_camp (is_on_screen (R_Barracks_X+10, R_Barracks_Y+10)) {
              clear_all_arrows();
              //ping_object (1, 1, 2, barracks_id);
            
              mid_x = ( R_Barracks_X + lookout_x ) / 2;
              mid_y = ( R_Barracks_Y + lookout_y ) / 2;
          
              ping(1, 1, mid_x, mid_y );
              add_flag( mid_x, mid_y );
          		objective_complete("find_camp");
              play_sound ("foundcamp.wav");
            //WAV: "Excellent, you've found the Roman camp. Now let's take a"
            //"closer look at their defenses."
              enable_trigger ("Mouseover");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Mouseover (sound_finished ()) {
              clear_flags();
              ping_object (1, 1, 2, barracks_id);
              //WAV: Moving the mouse over anything in the game will show you the help text in the lower
              //     left corner.  Move your mouse over the Roman Barracks.
          		add_objective("Move your mouse over the Roman barracks", "over_barracks", "mouseover.wav" );
          		play_objective_sound("over_barracks");
              enable_trigger("Over_tower");
              enable_trigger("Over_barracks");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Over_tower( sound_finished() && get_object_type_at_mouse (COMPUTER, "Lookout") ) {
              play_sound("over_tower.wav");
              //WAV: You have highlighted the roman tower.  The barracks are just below it and to the right.
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Over_barracks( sound_finished() && get_object_type_at_mouse (COMPUTER, "Barracks") ) {
              objective_complete("over_barracks");
              disable_trigger("Over_tower");
              play_sound ("overbarracks.wav");
            /***WAV: "Notice the help text in the lower left--it says this building is used to produce troops.
            We'd better destroy it quickly! Let's get our units organized and attack!"***/
          		enable_trigger("scouting_complete");
            }
          
          	trigger scouting_complete( sound_finished() ) {
          		play_sound("knowrposition.wav");
                    //WAV: Excellent! Now you know a lot about the Roman position. Let's get our units organized, and attack.
          
          		enable_trigger("Attack_the_Romans");
          		set_timer("progress_check", objective_delay);
            }
          
            trigger Attack_the_Romans (sound_finished ()) {
              center_camera_on (HUMAN, find_military (HUMAN));
          		add_objective("Select all troops with a drag box.", "all_troops", "multiselect2.wav");
          		play_objective_sound("all_troops");
            /***WAV: "You can select your whole army at once with a drag box."
                "Hold the mouse near your units, left-click, then drag the mouse
                "to create a box around all your troops."***/
              enable_trigger ("All_troops");
              enable_trigger ("Not_all_troops");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Not_all_troops ( (num_unit_selected (HUMAN) > 1) && (num_unit_selected (HUMAN) < num_military_units (HUMAN) )) {
              play_sound ("notall.wav");
            /***WAV: You selected some, but not all, of your troops. Try again, and make a bigger box.***/
          		set_timer("progress_check",objective_delay);
            }
          
            trigger All_troops (all_military_selected (HUMAN)) {
              disable_trigger ("Not_all_troops");
              objective_complete("all_troops");
          		add_objective("Right-click to move your troops into the Roman camp.","destroy_camp", "alltroops.wav");
          		play_objective_sound("destroy_camp");
              
              mid_x = ( R_Barracks_X + lookout_x ) / 2;
              mid_y = ( R_Barracks_Y + lookout_y ) / 2;
          
              ping(1, 1, mid_x, mid_y );
              add_flag( mid_x, mid_y );
            /***WAV: "Good work. You successfully selected all of your troops.  Now send"
                "your troops toward the Roman position. If they stop close to an enemy building"
                "or unit, they'll attack automatically. Destroy the Roman camp.  We'll teach them"
                "to march into our town!"***/
          	  enable_trigger ("Deselect_army");
              set_timer("deselect_timer", 1 );
          		enable_trigger("Destroy_camp");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Global (have_fought (HUMAN, COMPUTER)) {
          		
              clear_flags ();
              clear_all_arrows ();
              scrolling_unlock ();
              create_unit(COMPUTER, R_Barracks_X - 4, R_Barracks_Y, "Legions", 2);
          
              if (is_trigger_enabled ("Destroy_camp")) {
                play_sound ("attackbegun.wav");
                //WAV: "The attack is begun! To attack specific targets, select the attacking
                //unit and right click on an enemy.  If you want a better view of the action, 
                // you can zoom in by rolling the mouse wheel forward or pressing the page down key multiple times.
                enable_trigger ("See_health");
                enable_trigger ("Deselect_army");
              } else {
                play_sound ("earlyattack.wav");
            /***WAV: Good work General. Apparently you don't need any help in order to conquer the Romans. Good luck!***/
                clear_objectives();
                disable_all_triggers ();
                enable_trigger ("Destroy_camp");
              }
          
          		objective_complete("destroy_camp");
          		add_objective("Destroy Roman army",     "destroy_army",     "alltroops.wav" );
          		add_objective("Destroy Roman barracks", "destroy_barracks", "alltroops.wav");
          		add_objective("Destroy Roman lookout",  "destroy_lookout",  "alltroops.wav");
              enable_trigger ("Destroy_tower");
              enable_trigger ("Destroy_barracks");
          		enable_trigger ("Destroy_army");
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Deselect_army (sound_finished () && (num_unit_selected (HUMAN) == 0 ) && timer_expired("deselect_timer") ) {
              play_sound ("lostarmy.wav");
            /***WAV: You have troops that are not selected who are not attacking. Select them with a left click or
                drag box and get them in the fight!***/
          		enable_trigger("Deselect_army");
              set_timer("deselect_timer", 10);
            }
          
            trigger See_health (sound_finished ()) {
              play_sound ("damage.wav");
            /***WAV: As the fight progresses, you can see units and buildings taking damage. Each selected unit and building has a green
                bar above it when it's at full strength. As they are hit by the enemy, this bar shrinks and becomes yellow and then
                red. When the health bar is all gone, the unit or building is destroyed.***/
          		set_timer("progress_check",objective_delay);
            }
          
            trigger Destroy_tower (building_type_destroyed (COMPUTER, "Lookout")) {
              tower_destroyed = true;
          		objective_complete("destroy_lookout");
            }
          
            trigger Destroy_barracks (building_type_destroyed (COMPUTER, "Barracks")) {
              barracks_destroyed = true;
          		objective_complete("destroy_barracks");
            }
          
          	trigger Destroy_army( num_military_units(COMPUTER) < 1 ) {
          		army_destroyed = true;
          		objective_complete("destroy_army");
          	}
          
            trigger Destroy_camp (tower_destroyed && barracks_destroyed && army_destroyed) {
              disable_all_triggers ();
              play_sound ("congrats.wav");
            /***WAV: Congratulations!  You've leveled the Roman camp.  But it won't be long before"
                "they'll be back in strength.  We'd best be ready.***/
              enable_trigger ("Bonus");
          		disable_trigger("Objective_Reminder");
            }
            //==========================================================
          
          
            //Putting it all together===================================
            trigger Bonus (sound_finished ()) {
              set_timer ("Help", 4);
              Legions = create_unit (COMPUTER, BONUS_LEGIONS_X, BONUS_LEGIONS_Y, "Legions", 1);
              unit_attack_order(COMPUTER, Legions, HUMAN, BRITON_ID);
          		zoom_in_on(HUMAN, BRITON_ID);
              enable_trigger ("Help_out");
              enable_trigger ("The_end");
            }
          
            trigger Help_out (timer_expired ("Help")) {
            /***WAV: The vile Romans have launched a sneak attack against Briton! We must come to her aid.***/
          		center_camera_on(HUMAN, find_military(HUMAN) );
          	  add_objective("Briton is under attack! Right-click to move your troops to defend the city!", "sneak_attack", "sneakattack.wav");
          		play_objective_sound("sneak_attack");
              enable_trigger ("Reinforce");
          		enable_trigger("Deselect_army");
            }
          
            trigger Reinforce (num_military_units (HUMAN) < 1) {
              create_unit (HUMAN, ARMY_CREATE_X, ARMY_CREATE_Y, "Hoplites", 7);
              for (i = 0; i < num_military_units (HUMAN); i++) {
                ID = find_military (HUMAN);
                unit_attack_to_order (HUMAN, ID, ATTACK_TO_X, ATTACK_TO_Y);
              }
            }
          
            trigger The_end (num_military_units (COMPUTER) < 1) {
              objective_complete("sneak_attack");
          		play_sound ("victory.wav");
          		/***WAV: Congratulations! You have fended off the evil Romans***/
              enable_trigger("The_real_end");
            }
          
            trigger The_real_end( sound_finished() ) {
              victory( HUMAN );
            }
            //==========================================================
          }
          Co-Founder, Apolyton Civilization Site
          Co-Owner/Webmaster, Top40-Charts.com | CTO, Apogee Information Systems
          giannopoulos.info: my non-mobile non-photo news & articles blog

          Comment


          • #6
            Thanks Markos
            Concrete, Abstract, or Squoingy?
            "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

            Comment


            • #7
              You bet. Lots of new stuff to learn about! Thanks again Markos.

              Comment


              • #8
                Good stuff, thanks Markos

                Very C-like language, from the looks of it - more so than CtP's SLIC anyway. That's good news for programmers () but might make things a bit harder to get into for non-programmers (). Let's hope there will be good newbie-friendly documentation...

                Assuming there are sufficent functions and triggers (and this certainly looks promising), this could turn out to be a very powerful and versatile scripting language. Hats off to BHG
                Administrator of WePlayCiv -- Civ5 Info Centre | Forum | Gallery

                Comment


                • #9
                  Will the language be simplified so the people who can't read it can?

                  Comment


                  • #10
                    Pray for documentation

                    If not, I'm sure somebody who does figure it out pretty quick will write a helpful "How To" guide.
                    Concrete, Abstract, or Squoingy?
                    "I don't believe in giving scripting languages because the only additional power they give users is the power to create bugs." - Mike Breitkreutz, Firaxis

                    Comment


                    • #11
                      WoW! That looks AWSOME!

                      I've never actually worked on game modding/scn making much, but I might have to with such a wonderful looking language. Locutus is right, though -- being a C programmer, I'm thrilled, but non-programmers might not have it quite so easy.

                      -- adaMada
                      Civ 3 Democracy Game:
                      PTW Game: Proud member of the Roleplay Team, and Ambassador to Glory of War
                      Intersite PTW Game: Member of Apolyton

                      Comment


                      • #12
                        Wow! Allowing full scripting language for scenarios is incredibly powerful and fantastic for the game and the community.

                        Does anyone know the following questions:

                        Is there going to be a scenario editor that is easier than a scripting language?

                        Can we edit AI strategies with the scripting language?
                        About 24,000 people die every day from hunger or hunger-related causes. With a simple click daily at the Hunger Site you can provide food for those who need it.

                        Comment


                        • #13
                          cant scenarios be made the old editor way???
                          i dont even understand that kind of scripts.
                          "The meaning of war is not to die for your country, but making your enemies die for their..."

                          Staff member at RoN Empire

                          Comment


                          • #14
                            scripting is for doing things like triggering events, etc
                            civ editing, city placement, etc will have nothing to with the scripting
                            Co-Founder, Apolyton Civilization Site
                            Co-Owner/Webmaster, Top40-Charts.com | CTO, Apogee Information Systems
                            giannopoulos.info: my non-mobile non-photo news & articles blog

                            Comment


                            • #15
                              Yes, Tim Train confirmed that there will be the standard sort of scenario editor.

                              I think, but am not sure about this, that there may be some sort of intermediate scripting editor which will simplify writing triggers.

                              Comment

                              Working...
                              X