Event string

From WiCWiki

Jump to: navigation, search

Contents

Some information about Event strings

There are two different kinds of event strings. The one covered in this chapter is not the one who pops up when you get an objective. The one covered here is commonly used when things happen or changes during a map that we want to inform the player about for example that the reinforcements menu appeared.

Image:Event_String_001.jpg


Predefined event strings

There’s a bunch of predefined event strings. They are located here. Wic\juice\globalscriptevents.juice. The first part of that file contains multiplayer event strings and the last part is for us. Most of them call a function when you click the event string icon that will for example open the TA menu.


These three will open up the TA menu:

myTAMenu - "You can now use tactical aid."

myNewTA - "New tactical aid added."

myTACapRaised - "Your maximum amount of tactical aid points has been raised."


These three will open up the reinforcements menu:

myReinforcementMenu - "You can now use the reinforcement menu."

myReinforcementCapRaised - "You have received more reinforcement points."

myNewUnits - "New units have been added to your reinforcement menu."


These two will open up the mega map with the choose drop zone functionality.

myDropZoneExpanded - "Your drop zone has expanded."

myDropzoneChanged - "Your drop zone has changed."


These three call no functions:

myTADisabled - "Your tactical aid menu has been disabled."

myReinforcementDisabled - "Your reinforcement menu has been disabled."

myUnitReward - "You have been given control over new units."


Event strings in Python

It is really easy to call an event string from python. If you, as you should by now, use the Action queue the method looks like this and we use this code in the server.py file. You can place it wherever you want, just make sure the function you place the code in is called.


queMyQueue.AddEventString( 'myReinforcementMenu' )
queMyQueue.Execute( )

The one and only parameter you need is the name on the Event string.


Make sure you don’t forget to execute the action queue.


If you start the game now you should have an event string that looks something like this.


Image:Event_String_002.jpg


If you want to call it without an action queue you can use:

AddScriptEventAll('myReinforcementMenu')

You can, as with message boxes, trigger things on when the event string is finished, for an example, the old familiar message box. The code for that would look like this:

RE_OnEventStringDone('myReinforcementMenu', Action( ShowMessageBox, 'Test_1', 1 ) )

The first parameter is which event string it will be triggered on, in this case the one we made before.

The second parameter is an action or a list of actions; in this case we use the ‘ShowMessageBox’ function.

Create your own event string

You don’t have to use the predefined event string you can make your own as well. They will be placed in the wic\maps\mapname\mapname_singleplayerdata.juice. If you use the same name on your own event string as one of the predefined ones, the predefined ones will be overridden. In this example we will do just that, we’ll use the same name as one of the predefined ones but chance the string and the function that gets called.

As with message boxes and objectives, there are 2 ways of creating an event string. I will focus mainly on the text editor way.

If you open the mapname_singleplayerdata.juice file in a text editor it will look like this.

myScriptEvents
{
    ScriptEvent 
    {
    }
    “More Script events will be added here.”
}

The ‘ScriptEvent’ part is what will become an Event string. All event strings will be listed between the ‘myScriptEvents’ curly brackets.

The first thing we will do is to give the event string a name. This name is what you will use to call it from the python code later on. You write the name next to ‘ScriptEvent’, in this example we’ll use the name ‘myReinforcementMenu’

myScriptEvent 
{
    ScriptEvent myReinforcementMenu  
    {
    }
}


There are 7 variables which values you can change when creating an event string. All of them are listed between the “Script events” curly brackets. And as in previous chapters, use <empty> if you don’t have a value.

ScriptEvent myReinforcementsMenu
{
    myString
    myIcon <empty>
    mySound 
    myGuiElementToFlash                    
    myOnClickPythonClientFunction 
    myOnClickPythonServerFunction 
    myShowAsSysMessageFlag
}

If you open the juice file in the Juice maker you will find the event strings under mySinglePlayerData -> mySinglePlayerMissionStats -> myScriptEvents

Event string variables

myString. myIcon. mySound. myGuiElementToFlash. myOnClickPythonClientFunction. myOnClickPythonServerFunction. myShowAsSysMessageFlag.


1- myString.

The variable myString contains the text that will be shown in the event string. This works as text variables from message boxes and objectives.


myString "You can now make your own event strings."


If you use more than 200 characters the game will crash.


2 – myIcon.

By default the variable myIcon is set to <empty> and has a default image, the red circle. You can change this and add your own image if you like. The file must be an *.dds and it works the same way as with images in the objectives browser and message boxes.

myIcon myPictures /myIcon.dds


This icon will work as a button and will, if there is a value in the “myOnClickPythonClientFunction”, call that function if it’s clicked.


In our example we will use the default value so the code should look like this.

myIcon <empty>


3 – mySound.

By default the variable mySound is set to <empty>. You can change this and add your own sound if you like. The file could be an *.mp3 and it works the same way as with sound files in message boxes.


mySound mySounds/myEventStringSound.mp3


In our example we will use the default value so the code should look like this.

mySound <empty>

4 – myGuiElementToFlash.

This variable is deprecated and should be set to empty.

myGuiElementToFlash <empty>

5 – myOnClickPythonClientFunction.

The variable myOnClickPythonClientFunction can call any client function. It listens to if the player clicks the event strings icon. In this case we open up the reinforcements menu.


myOnClickPythonClientFunction ActivateObjectiveBrowser


There are 3 more things you can do and that’s:

ChooseDropZone, which opens up the mega map.

ActivateSupport, which opens up the TA-menu.

ActivateObjectiveBrowser, which opens up the objectives browser.


These 4 values are already defined and ready to use. We almost always use these but if you really want to do your own it will look something like this and should be written in the client.py file.


def ActivateReinforcements():

 wicp.ActivateGuiHandler( 'ActivateObjectiveBrowser' )

6 – myOnClickPythonServerFunction.

This variable works as the myOnClickPythonClientFunction variable but on the server side. We never use this variable.

myOnClickPythonServerFunction <empty>

7 – myShowAsSysMessageFlag.

This variable decides if the event string will be visible and is 0 by default. If you change it to a 1 you won’t se it.

myShowAsSysMessageFlag 0

The first, nice and good looking, cute little event string

If you followed this example you should have an event string that looks like this in a text editor.

ScriptEvent myReinforcementMenu
{
    myString "You can now make your own event strings."
    myIcon <empty>
    mySound <empty>
    myGuiElementToFlash <empty>
    myOnClickPythonClientFunction ActivateObjectiveBrowser
    myOnClickPythonServerFunction <empty>
    myShowAsSysMessageFlag 0
}


Appendix

Changed files in this chapter:

Server.py

Changes in the server.py file.


def RescueArtyStart( ):
    [More code here.]
    
    queRescueArtyComplete.AddObjectiveCompleted( mapvars.objRescueArty )
    queRescueArtyComplete.AddEventString( 'myUnitReward' )
    RE_OnCustomEvent( 'RescueArtyRuDead', [Action( RemoveReaction, mapvars.reactRescueArtyFail ),Action(queRescueArtyComplete.Execute ) ] )
    
    [More code here.]
Chapter 9: Drop Zones and the Reinforcements Menu < > Chapter 11a: Creating units
Personal tools
User Created Content