Secret Weapons of the Empire
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Secret Weapons of the Empire

The forum for the Star Wars Empire at War: Forces of Corruption mod
 
HomePortalSearchLatest imagesRegisterLog in

 

 Tutorial: Basic Story Scripting Part II

Go down 
AuthorMessage
SmallPox
Admin
SmallPox


Male Number of posts : 62
Age : 33
Location : Germany
Registration date : 2008-01-28

Tutorial: Basic Story Scripting Part II Empty
PostSubject: Tutorial: Basic Story Scripting Part II   Tutorial: Basic Story Scripting Part II EmptySat Jul 16, 2011 12:12 pm

Hi guys, this is my second part of the story scripting tutorial. I recommend you read part 1 first, since I might refer to things mentioned there.

We'll be dealing with the following things in this tutorial:
1. A holo video message with screen text
2. Working with flags


============================================================================================================
1. A holo video message with screen text

Now I'll show you to play a holo video and display a screen text.
For this event we'll need the reward type MULTIMEDIA, a reward that allows you to show videos, screen text and play sounds. It's also capable of doing a few other things, but usually you don't need them too often.

Let's start:

Code:

<Event Name="A_Multimedia_Event">
   <Event_Type>STORY_TRIGGER</Event_Type>
   <Reward_Type>MULTIMEDIA</Reward_Type>
   <Reward_Param1>TEXT_ENTRY</Reward_Param1>
   <Reward_Param2>-1</Reward_Param2>
   <Reward_Param9>Thrawn_Loop</Reward_Param9>
   <Reward_Param10>1</Reward_Param10>
   <Prereq>Universal_Story_Start</Prereq>
</Event>

Ok, so what does this do?
Parameter 1 of MULTIMEDIA specifies a text entry from the master text file that shall be displayed on the screen.
Parameter 2 tells EaW/FoC how long the text shall be displayed. -1 stands for infinite display duration.
Parameter 9 calls a movie from Movies.xml
Parameter 10 determines whether the movie shall be looped or not. 1= Loop, 0= do not loop

Perhaps you're wondering now why we set the display duration -1 and the loop to 1.
The reason is simple:
If the display duration of the text is longer or shorter than the length of the video then the text wouldn't disappear at the same time as the video. That wouldn't look too good of course, so we need to stop the screen text and the video with additional events.
Therefor we need two other events, one that triggers after a determined time after the MULTIMEDIA event and that uses the reward SCREEN_TEXT and another one with the reward STOP_COMMANDBAR_MOVIE with the SCREEN_TEXT event as prerequisite.
SCREEN_TEXT serves mainly for two purposes: 1. displaying screen text and 2. removing it.


Code:

<Event Name="A_Multimedia_Event">
   <Event_Type>STORY_TRIGGER</Event_Type>
   <Reward_Type>MULTIMEDIA</Reward_Type>
   <Reward_Param1>TEXT_ENTRY</Reward_Param1>
   <Reward_Param2>-1</Reward_Param2>
   <Reward_Param9>Thrawn_Loop</Reward_Param9>
   <Reward_Param10>1</Reward_Param10>
   <Prereq>Universal_Story_Start</Prereq>
</Event>



<Event Name="Kill_the_screen_text">
   <Event_Type>STORY_ELAPSED</Event_Type>
   <Event_Param1>10</Event_Param1>
   <Reward_Type>SCREEN_TEXT</Reward_Type>
   <Reward_Param1>TEXT_ENTRY</Reward_Param1>
   <Reward_Param4>remove</Reward_Param4>
   <Prereq>A_Multimedia_Event</Prereq>
</Event>


<Event Name="Stop_the_commandbar_movie">
   <Event_Type>STORY_TRIGGER</Event_Type>
   <Reward_Type>STOP_COMMANDBAR_MOVIE</Reward_Type>
   <Prereq>Kill_the_screen_text</Prereq>
</Event>


1. "Kill the screen text"
As soon as "A_Multimedia_Event" has been triggered this event will count to 10 (in EaW game seconds).
After reaching 10 the reward type will be activated.
Parameter 1 of SCREEN_TEXT contains the text entry from the master text file. In this case it's the name of the text entry we want to remove from the screen.
Parameter 4 is just there to tell the game that it has to remove that entry. The only valid command for this parameter is "remove".


2. "Stop_the_commandbar_movie"
Due to the event type STORY_TRIGGER and the prerequisite "Kill_the_screen_text" this event will be triggered as soon as the event "Kill_the_screen_text" has been triggered.
The reward type should be quite self-explaining: STOP_COMMANDBAR_MOVIE stops a commandbar movie. It doesn't have any reward parameters so it's really easy to use.

Now we've achieved what we wanted to do and the screen text will disappear at the same time as the video.

============================================================================================================================
2. Working with Flags


Flags are useful to count stuff in game. They're also useable for a few other things, but we'll stick to the basics in this tutorial.
A flag has two attributes: 1. A name of your choice and 2. a value.

We will start with setting a flag at the beginning of the game:

Code:

<Event Name="Set_a_flag">
   <Event_Type>STORY_TRIGGER</Event_Type>
   <Reward_Type>SET_FLAG</Reward_Type>
   <Reward_Param1>Flag_Name</Reward_Param1>
   <Reward_Param2>0</Reward_Param2>
   <Prereq>Universal_story_Start</Prereq>
</Event>


As you can probably (and hopefully) guess the reward type SET_FLAG creates a flag.
Parameter 1 defines the name of the flag. You can call it whatever you want.
Parameter 2 sets the start value of the flag, in this case 0.

Now there are basicly two things we can do with our new flag.
We can play around with its value or check its value.

First we'll play around with the value a bit:

Code:

<Event Name="Increment_the_flag">
   <Event_Type>STORY_CONQUER<Event_Type>
   <Event_Param1>Coruscant</Event_Param1>
   <Event_Param3>FILTER_FRIENDLY_ONLY</Event_Param3>
   <Reward_Type>INCREMENT_FLAG</Reward_Type>
   <Reward_Param1>Flag_Name</Reward_Param1>
   <Reward_Param2>5</Reward_Param2>
</Event>


What the reward type INCREMENT_FLAG does should be self-explaining.
Parameter 1 of INCREMENT_FLAG contains the name of the flag you want to increment. It has to be created with SET_FLAG just as we did above.
Parameter 2 determines the amount by which the flag is incremented. This amount can be positive or negative and can contain any number.


Now we'll check the value of the flag with the event type STORY_FLAG:


Code:

<Event Name="Check_if_flag_is_greater_than_1">
   <Event_Type>STORY_FLAG</Event_Type>
   <Event_Param1>Flag_Name</Event_Param1>
   <Event_Param2>1</Event_Param2>
   <Event_Param3>GREATER_THAN</Event_Param3>
   <Reward_Type>UNIQUE_UNIT</Reward_Type>
   <Reward_Param1>Star_Destroyer</Reward_Param1>
   <Reward_Param2>Coruscant</Reward_Param2>
   <Reward_Param3>1</Reward_Param3>
</Event>


As said before STORY_FLAG checks the value of a flag.
Event parameter 1 contains again the name of the flag you want to check.
Parameter 2 determines a value.
Parameter 3 specifies a comparison method. This method is then used to compare the value specified in parameter 2 to the actual value of the flag. In our case the game will spawn a star destroyer if the flag value is greater than one.
Possible comparison methods for parameter 3 are:
GREATER_THAN
LESS_THAN
EQUAL_TO
GREATER_THAN_EQUAL_TO
LESS_THAN_EQUAL_TO
Back to top Go down
http://secretweapons.heavenforum.com
 
Tutorial: Basic Story Scripting Part II
Back to top 
Page 1 of 1
 Similar topics
-
» Tutorial: Basic Story Scripting Part I
» Mapping Tutorial [English/Deutsch]

Permissions in this forum:You cannot reply to topics in this forum
Secret Weapons of the Empire :: General Modding :: XML/LUA Modding-
Jump to: