Areas and Command Points

From WiCWiki

Jump to: navigation, search

Contents

Areas and Command Points

In this section we will explain how to handle areas and command points in WICEd.

The map used in most of the examples in this chapter is europeTest.

But before we start we need to clarify some of the terms we are going to use.


Image:Areas_and_commandpoints_001.jpg The select object button. Located in the tool bar in WICEd.


Image:Areas_and_commandpoints_002.jpg The place object button. Located in the tool bar in WICEd.


Image:Areas_and_commandpoints_003.jpg


The object editor. If the object editor is not present, press either the select object button or the place object button.

After you have started WICEd and loaded a map, in our case europeTest, you have to enable singleplayer divisions. If you don’t enable it you will not be able to edit or see objects belonging to the singleplayer part of the map.

To enable it enter View up in the menu bar and then head down to Divisions.

Here you will see three options, Common, Singleplayer and Cinematic.

Make sure the Singleplayer alternative is checked and Voilà, everything singleplayer related are now visible and editable.


Image:Areas_and_commandpoints_004.jpg


All the areas, command points and perimeter points we have used in europeTest can be found in the image last in this chapter.


Handling the areas

Areas are used in many functions and to many things in a singleplayer map. Mostly they are used as position indicators for example to place units on the map, but they can also be used as target areas for Tactical aid bombardment to be dropped in.

The areas are completely invisible ingame, the only way you can se them is in WICEd.


To place an area in WICEd you have to find and press the area icon in the object editor. It is the one that looks like a green bubble.


Image:Areas_and_commandpoints_005.jpg


With the area section selected in the Object Editor, press the place object button in the toolbar.


There is two ways to place an area, either with a radius or just as a point.

To place the area without a radius it’s only to press the left mouse button on the ground where you want it.

To place it with a radius, press and hold the left mouse button and drag on the ground where you want the area. When the size is as large or small as you want it, release the mouse button.


For future lessons in the tutorial we will now create an area on the road coming up from the south. Create it without a radius.


Image:Areas_and_commandpoints_006.jpg


After you have created your area we recommend you check in which .juice file it will be saved. It’s important the area will be saved in the mapname_singleplayer.juice file Only as it otherwise will be available in multiplayer to.

Open the properties tab in the object editor, with the area section selected. From the dropdown menu Division select Singleplayer only if it’s not already selected. Now when you save the map the area will be added to the right .juice file.


Image:Areas_and_commandpoints_007.jpg


Edit Areas

If you accidentally released the mouse button so the area size turned out wrong or if you later realize it needs to be changed there is two ways you can use to change the radius.

The first method is to select the area you want to edit. Enter the properties tab in the object editor, with the area section selected. Here you will find a box for size. Enter a new size and the selected area will change automatically.


Image:Areas_and_commandpoints_008.jpg


The second method is to select the area. Press and hold control and press and drag with the left mouse button. Release the mouse button when you are satisfied with the new size.


If you want to move an area you have to select it. Then press and hold alt and left mouse button. Move the area to its new place and when you feel satisfied with the new location just release the mouse button.


To change the name of an area you have to first select it. Then press the rename button in the button of the object editor. Write the new name in the bar that appears and press ok.


Now select the area we placed earlier in this tutorial. Now rename it to areaPlayerStartPos with the method described above. This area will be used in a later chapter when we will create starting units.


Image:Areas_and_commandpoints_009.jpg


Practical use of an area

We will now make a practical example and modify the starting camera for our map.

To do this we’ll need two areas, of which one is the previously created areaPlayerStartPos. The second area we have to create. To do that use the method used to create areaPlayerStartPos. Place this area further away from the village close to the map edge ( see the image in the end of this chapter). Name it to areaCamStartPos and don’t forget to check the division settings under properties.

Now we have the areas, so let’s head to the server.py file.


In server.py head down to def Intro(): function we created in the chapter ’Before we start’.

It is in this function we will change the camera.

First we will get the position from the areaCamStartPos and put in a temporary variable. This is done by using the Getposition() function, which is used very often and in most cases in combination with areas.

cameraStartPos = GetPosition( 'areaCamStartPos' )

Now we have the position stored, but there is one problem with this position. The areas height position is aligned to the ground mesh. This means that our camera later will show us a view from the ground level. This can be remedied by adding a numerical value to the Y position of the saved variable.

cameraStartPos.myY = 170 

This will send the cameras position up 170 units.

The next thing we want to do is to point the camera in a direction.

Most likely we would like it to show us possible starting units (which will be created in a later chapter). Therefore we will get the position of the areaPlayerStartPos , the same way we used earlier.

cameraStartLookAt = GetPosition( 'areaPlayerStartPos' )

The last thing left to do is now to assign the new positions to the camera.

To do that we will have to use the SetCameraPosition() function. It is dependent of the player so we have to add which players camera to add it to.

thePlayers[ PLAYER_HUMAN ].SetCameraPosition( cameraStartPos, cameraStartLookAt )

That’s it folks, if you start the game now the camera should look onto the startposition of the units we will add in a later chapter.

cameraStartPos = GetPosition( 'areaCamStartPos' )
cameraStartPos.myY = 170
cameraStartLookAt = GetPosition( 'areaPlayerStartPos' )
thePlayers[ PLAYER_HUMAN ].SetCameraPosition( cameraStartPos, cameraStartLookAt )

Creating areas in python

There is a slightly different type of areas that are created through python scripts with the function Area( aPosition, aRadius ). These areas are used in most of the reactions regarding areas and some of the functions in the python framework.


There are a couple of different ways to create these Areas, or rather inputs to the parameters.

The first method is to quite simply, enter a numeric position and a radius value.

Area( Position( 423, 25.36, 589.714 ), 100.000 )

You can also choose to not give a radius value, this will give the area a radius of 0.0.

Area( Position( 333, 30, 300 ) )

The second method is to use an area created in wic as a position giver. This method is the one we used most when creating the singleplayer campaign.

Area( 'areaKillArtyFire1',  40 )

The third method is to use both the position and radius value of an in WICEd created area. To do that you skip giving a radius value.

Area( 'areaKillArtyFire1' )

You can also get the same results with the function GetArea().

GetArea('areaKillArtyFire1' )

A fourth method is to fetch a position value from a game object, for example a building. To be able to do this we use the useful function GetPosition().

Area( GetPosition('Barn__3'), 50 )

Now that we have the methods pointed out we will show you how you could use them. In the example we will use the

RE_OnPlayerInArea() reaction.
RE_OnPlayerInArea( aPlayer, someAreas, someActions )

aPlayer

This parameter can be either the Human Player or one of the AI’s.


someAreas

This is a single area or a list of areas.


someActions

This is a single action or a list of actions.

RE_OnPlayerInArea( PLAYER_HUMAN,  Area('areaVillageRuMove1', 100 ), Action( ShowMessageBox, 'Test_1’, 1) )

A reaction will trigger the actions given when a certain conditions is met, in our case it will show a messagebox when the human player enters within the area areaVillageRuMove1 radius.

There will be more information about reactions and actions in the reaction chapter later in this tutorial.

Handling Command Points

The first step to getting a command point in your map is to add them to the singleplayerdata.juice file, with WICEd.

If you want to add a new command point to the map, you will have to select the command point section in the object editor. The icon looks like a ring divided into four pieces.


Image:Areas_and_commandpoints_010.jpg


Then press the place object button in the toolbar and place the command point where you want it.

Now we will create the first command point on this map. With the above described method place the command point close to the village (see the image last in this chapter).


After you placed it select the command point and select the proporties tab in the object editor. Make sure the Division dropdown menu has Singleplayer only chosen or otherwise the command point will appear in multiplayer, but not in the singleplayer versions of the map.


Image:Areas_and_commandpoints_011.jpg


Adding Perimeterpoints

The next step will be to add one or more perimeter points.

Once more select the command point you want to add the perimeter point to and head to the properties tab.

Under the Division dropdown menu you will find the Add Perimeter Point button.

When you push the button a perimeter point with attached fortifications will appear. The perimeter point is randomly placed so you will have to select it and move it with alt and left mouse button.

Now repeat the procedure until you have the desired amount of perimeter points.


For the tutorial lessons we will add one perimeter point to the command point we placed close to the village. Use the above method and add a single perimeter point to the command point.

Editing command points and perimeter points

You can rename command points, perimeter points and fortifications by selecting the object and pressing the rename button on the bottom of the object editor. Write the new name in the bar that appears and press ok.


For the tutorial we will rename the command points, perimeter point and the fortifications. It’s generally a good idea to rename them to something you will remember or rather distinguish from every other command or perimeter point. In this case we will rename the command point to CP_Village and the perimeter point to PP_Village. The fortifications we will only rename partly. We will keep the suffixes

( _DefFort ) for all the fortifications and replace the rest with PP_Village. This will help us understand which perimeter point the fortification belongs to. The new names should look like this: PP_Village_DefFort1, PP_Village_DefFort2 and PP_Village_DefFort3.


You can also give the command point a name to be shown in game. With the command point selected, under the properties tab you will find a box called Name:. It has “Command Point” as a default value. Remember, this name is only used to be shown in game, in the megamap. The real name used for scripting and everything else, can only be changed through the rename button.


You can move both perimeter points and command points in the same way as the areas earlier in this chapter. This also applies to the fortifications belonging to the perimeter point as well. The fortifications can also be rotated, by selecting the fortification and pressing and holding ctrl and left mouse button. Then rotate the selected fortification to position and release the mouse button.


Move the perimeter point now named PP_Village, right on top of its command point CP_Village. You can arrange the fortifications as you want.


The perimeter points have another property you can change, the size.

To edit the size you have to enter the properties tab in the object editor, with the perimeter point selected. Here you will see a dropdown menu where you can chose either small or large. You will see the selected perimeter bubble change, but the visual ring representation will change first the next time you reload the map.


Image:Areas_and_commandpoints_012.jpg

A second method to add command points and perimeter points

There is a second method to place and move command points and perimeter points. This uses the Gameplay editor.


Image:Areas_and_commandpoints_013.jpgPress the Gameplay Editor button in the toolbar.


This opens up the Gameplay overhead map.

Right click with the mouse where you want to place the new command point.

A button saying Add Command Point will now appear (an explaining picture below). Press the button and the command point will be placed.


Image:Areas_and_commandpoints_014.jpg


After you have placed your command point you will have to change in which .juice file the command point will be saved. This, as explained earlier in this chapter, so the command point will appear in singleplayer and not in multiplayer.

In the Gameplay Editor, chose properties and head to the Division dropdown menu and here select Singleplayer Only.


Image:Areas_and_commandpoints_015.jpg


To place a perimeter point you will have to right click on an already placed command point. You will now be given two choices, either to delete the command point or to add a perimeter point.

When you press the Add Perimeter Point button a perimeter point will randomly be placed and linked to the command point.


To move either command or perimeter points you have to press and hold the right mouse button. Then move the object to the position you desire and release the mouse button.


Activating Command Points

Now that we have added a command point and a perimeter point to the mapname_singleplayer.juice file the next step is to activate them, making them visible in singleplayer.

To do this open the server.py file for europeTest located in wic\maps\europeTest\python\. At the end of this file create a function called def CreateCommandPoints().

Here we will put all the functions needed to activate the command and perimeter point and all the fortifications. We will also have to call this function for it to work. We will call it already in the OnGameStarted() function, so add the line CreateCommandPoints() in the end of that function. You can find the OnGameStarted function in the chapter ’Before we start’, where we explain how to setup the server.py file.

We begin with the activation of the command point, so here is a description of the function needed.

wicg.CreateCommandPointEx( aCPName, aTeam, aValue )

aCPName
This is the name of the command point from WICEd or the mapname_singleplayer.juice file, you want to activate.


aTeam
This sets which team the command point and its perimeter points belong to i.e. if someone should own it from the beginning. For example if we use TEAM_RUSSIA it will be red from the start.


aValue
This is a ghost from early production faze. This is not actually a used parameter but you still need to give an input here or bad things may happen. We usually set this value to 0 or 1, it doesn’t matter which you chose.


In our tutorial case we have the command point named CP_Village and we chose to set the team to neutral.

The CreateCommandPoints function should now look like this.

def CreateCommandPoints( ):
    wicg.CreateCommandPointEx("CP_Village", TEAM_NEUTRAL, 0 )  


The command point is now active but will not appear on the map. For it to appear you must add at least one perimeter point.


This following function will give you control on when you want the command point to be activated or deactivated in the mission.

SetCommandPointActive( aCPName, aFlag )

aCPName
This is the name of the command point from WICEd or the mapname_singleplayer.juice file, you want to activate.


aFlag
This is a True or False flag. False will deactivate the command point and hide it from the map. True will activate it and show it on the map. I.e. the same function is used both to activate and deactivate the command point.

All perimeter points connected to the command point will also be affected by this, but not the fortifications. The fortifications can only be placed by the SetFortificationLevel() explained later in this chapter.


So if you set the function to:

SetCommandPointActive( ‘CP_Village’, False )

You will later be able to activate it by setting the aFlag to True.

SetCommandPointActive( ‘CP_Village’, True )

The next step is to activate the perimeter point, here follows a description of the function needed.

wicg.CreatePerimeterPointEx( aPPName, aCPName )


aPPName
This is the name of the perimeter point you want to activate.


aCPName
This is the name of the command point which the perimeter point belongs to.


We named our perimeter point to PP_Village and the command point name linked to it is CP_Village.

The CreateCommandPoints function should now look like this.

def CreateCommandPoints( ):
    wicg.CreateCommandPointEx("CP_Village", TEAM_NEUTRAL, 0 )  
    wicg.CreatePerimeterPointEx("PP_Village", "CP_Village")

Now we will activate the fortifications. This step will set how many fortifications a perimeter point will have active in the game. If this step is skipped, the perimeter point won’t allow any fortifications at all even though all fortifications are visible in WICEd

The function to activate fortifications is descriped below.

wicg.CreateFortificationPointEx( aFortName,  aPPName,  aCPName )

aFortName
This is the name of the fortification you want to activate.


aPPName
This is the name of the perimeter point the fortification belongs to.

aCPName
This is the name of the command point the fortification belongs to.

To activate all three of the fortifications, we have to make three separate functions, one for each fortification. But if you want to allow fewer fortifications, only the machine gun fortification for example, it would be enough to activate only that. You can chose exactly which fortifications you want and for example you can have level one and level three without the level two.

We named the fortifications earlier in this chapter and both the perimeter and command point have been activated. So the CreateCommandPoints function should now look something like this.


def CreateCommandPoints( ):
    wicg.CreateCommandPointEx("CP_Village", TEAM_NEUTRAL, 0 )
    wicg.CreatePerimeterPointEx("PP_Village", "CP_Village")
    wicg.CreateFortificationPointEx("PP_Village_DefFort1", " PP_Village ", "CP_Village ")
    wicg.CreateFortificationPointEx("PP_Village_DefFort2", " PP_Village ", "CP_Village ")
    wicg.CreateFortificationPointEx("PP_Village_DefFort3", " PP_Village ", "CP_Village ")


You have now enabled the perimeter point to host three fortifications. These will start to appear when a team has captured the perimeter points and hold it for a while, but sometimes you want to have the fortifications already in place. Then you have to use the following function.

SetFortificationLevel( aPPName, aLevel, aTeam )


aPPName
This is the name of the perimeter point you want to have the fortification prebuilt in.


aLevel
This is the fortification level you want to activate.
1 equals the machinegun fortification
2 equals the Anti-Tank fortification.
3 equals the Anti-Air fortification.


aTeam
This is the team the fortification will belong to.


Ex.

This will place the Machine Gun and Anti-Air fortification in the perimeter point and assign them to the neutral team.

SetFortificationLevel( ‘PP_Village’, 1, TEAM_NEUTRAL )
SetFortificationLevel( ‘PP_Village’, 3, TEAM_NEUTRAL )


There are some functions useful when it comes to Fortifications.


RemoveAllFortifications( aPerimeterPoint, aExplodeFlag )

This function will remove every fortification in a perimeterpoint.


aPerimeterPoint
This is a string containing the name of the perimeter point.


aExplodeFlag
This is a flag deciding if the fortifications should explode when removed or not.

True will make them explode. False will just make them disappear. This is the default setting.

ex.

RemoveAllFortifications("PP_Village", True )

RemoveFortification( aPerimeterPoint, aLevel, aExplodeFlag )

This function will remove a single fortification stated by the level input.


aPerimeterPoint
This is a string containing the name of the perimeter point.


aLevel
This is a numerical value deciding which of the fortifications to remove.


aExplodeFlag
This is a flag deciding if the fortifications should explode when removed or not.

True will make them explode. False will just make them disappear. This is the default setting.


ex.

This will remove the AntiTank Fortification in the PP_Village perimeter point.

RemoveFortification("PP_Village", 3, False ) 

CheckIfFortified( aPerimeterPoint, aTeam )

This function will return True as value if there is a fortification in the perimeter point.


aPerimeterPoint
This is a string containing the name of the perimeter point.


aTeam
This is which team the fortification should belong to, for the True value to be returned.


ex.

This function shows a message box if the team USA have a fortification in the perimeter point “PP_Village”.


If CheckIfFortified( "PP_Village", TEAM_USA ):
    ShowMessageBox( ‘Test_1’, 1 )        


The chapter is now at its end. One last thing remains and that is to prepare the code examples for the rest of the tutorial.

First of all the perimeter point should not allow any fortifications to be built. So the three functions added earlier should be removed.

The last part is to add a SetCommandPointActive function so we can activate the command point later in the scripts.

The CreateCommandPoints function should look like this when you are finished.


def CreateCommandPoints( ):         
    wicg.CreateCommandPointEx("CP_Village", TEAM_NEUTRAL, 0 )
    wicg.CreatePerimeterPointEx("PP_Village", "CP_Village")
    SetCommandPointActive( ‘CP_Village’, False )


This image is an overview over all areas and all fortifications we use in the europeTest map. Feel free to place your areas and command points wherever you like but when we talk about different areas and command point we usually mean the ones in this image.


Image:Areas_and_commandpoints_016.jpg

Appendix

In this chapters server.py file we have created a command point with a perimeter point. We make the command point visible in the game and set the cameras start position. We have also listed all the areas that are necessary for some of the chapters in this tutorial. You can create them now or later.

Changed files in this chapter:

Server.py

europeTest_singleplayerdata.juice


Changes in the server.py file.

def OnGameStarted():

  [more code here]

  theGame.ShowGUIChunk( 'minimap' )
 
  # Create all command points and hide them.
  CreateCommandPoints( )


  # Start the mission.
  Intro( )

def Intro( ):
  DebugMessage( "Intro::" )

  # Set the players camera start position and the point it should look at. 
  cameraStartPos = GetPosition( 'areaCamStartPos' )
  cameraStartPos.myY = 170
  cameraStartLookAt = GetPosition( 'areaPlayerStartPos' )
  thePlayers[ PLAYER_HUMAN ].SetCameraPosition( cameraStartPos, cameraStartLookAt )

  # Setup all Events.
  [more code here]


def VillageCam( ):
  DebugMessage( "VillageCam::" )

  SetCommandPointActive( 'CP_Village', True )



def CreateCommandPoints( ):
  
  # Create a command point that are neutral.
  wicg.CreateCommandPointEx("CP_Village", 0, 0 )
   
  # add a perimeter point to the command point.
  wicg.CreatePerimeterPointEx("PP_Village", "CP_Village") 

  # Hide the command point and its perimeter point.
  SetCommandPointActive( "CP_Village", False )


Areas and Command points (changed in the europeTest_singleplayerdata.juice file).

Here you have a list of areas and a command point that have one perimeter point that we will assume that the test map have in the following chapters. Take a look at the overview image in the previous sub chapter if you want to know where we placed ours.

CP_Village

PP_Village

areaCamStartPos

areaPlayerStartPos

areaPlayerSpawnPos

areaPlayerStartPos2

areaVillageSpawn1

areaVillageSpawn2

areaVillageSpawn3

areaVillageRuMove1

areaArtySpawn

areaKillArtyRuSpawn

areaKillArtyRuMove1

areaKillArtyFire1

areaKillArtyFire2

areaKillArtyFire3

Chapter 2: Custom Mission <-> Chapter 4: Player Starting Units
Personal tools
User Created Content