Difference between revisions of "Modding:PVEMissions:mission.php:MissionContextCommands"

From Galactineers
Jump to navigationJump to search
Line 183: Line 183:
 
$MissionContext->EnableButtonForPlayer('myButtonId', $PlayerOne);
 
$MissionContext->EnableButtonForPlayer('myButtonId', $PlayerOne);
 
$MissionContext->DisableButtonForPlayer($someButtonId, $MissionContext->PlayersList[0]);
 
$MissionContext->DisableButtonForPlayer($someButtonId, $MissionContext->PlayersList[0]);
 +
</source>
 +
 +
 +
==EnableDetectors() / DisableDetectors()==
 +
These commands enable/disable the detector capabilities of a ship in the mission, e.g. for a quest ship to avoid unfair advantages.
 +
<source lang="php">
 +
$MissionContext->EnableDetectors($shipId)
 +
$MissionContext->DisableDetectors($shipId)
 +
</source>
 +
 +
{| class="wikitable"
 +
|+ Parameters
 +
|-
 +
! Parameter
 +
! Type
 +
! Description
 +
|-
 +
| $ship || integer|| The Id of the ship, either received as return value from '''$MissionContext->AddShip''', or from the PlayersShipList.
 +
|}
 +
 +
'''Examples:'''
 +
<source lang="php">
 +
$MissionContext->EnableDetectors('myShipId');
 +
$MissionContext->DisableDetectors($someShipId);
 
</source>
 
</source>
  

Revision as of 11:23, 27 August 2016

AddBlock()

This command adds a single block to the mission map.

$MissionContext->AddBlock($coordinates, $materialId)
Parameters
Parameter Type Description
$coordinates array An array with the x, y, z coordinates of the location where to spawn the block.
$materialId integer The Id of the material the block should have. Taken from Blocks Id List


Example:

$MissionContext->AddBlock(array(10, 3, 12), 2); //Iron
$MissionContext->AddBlock($someLocation, 6); //Red Granite


AddButton()

This command adds a custom button at a given location (e.g. a building), which can be used for quests, story, or objectives.

$MissionContext->AddButton($buttonId, $coordinates, $buttonType)
Parameters
Parameter Type Description
$buttonId string The id of the button, which can be used to enable/disable the button with the $MissionContext->EnableButtonForPlayer command, and which is handed to the OnButtonClicked event.
$coordinates array An array with the x, y, z coordinates of the location where to spawn the button.
$buttonType string Defines the icon of the button. Possible values are: ship, arrowleft, arrowright, refresh, build, delete, jump, money, edit, sticky, arena, statistics, follow, hold, energy, chat, level


Example:

$MissionContext->AddButton('myButtonId', array(10, 3, 12), 'hold');
$MissionContext->AddButton($someButtonId, array(10, 3, 12), 'money');

AddInRegionTrigger()

This command adds a trigger for when a ship is inside a certain region. The function call like this:

$MissionContext->AddInRegionTrigger($triggerId, $regionId, $shipId)
Parameters
Parameter Type Description
$triggerId string The Id which is passed in the OnTrigger event handler and can be used in the RemoveTrigger command.
$regionId string The Id of a region that has been defined with the SetRegion command before.
$shipId integer The Id of a ship

Example:

$MissionContext->SetRegion('myCircle', array(10, 12), 7);
$MissionContext->AddInRegionTrigger('myTrigger', 'myCircle', 17);


AddObstacles()

This command fills up a region with blocks, so it becomes unpassable:

$MissionContext->AddObstacles($regionId, $materialId, $height, $density)
Parameters
Parameter Type Description
$regionId string The Id of a region that has been defined with the SetRegion command before, or placed in the editor.
$materialId integer The Id of the material the block should have. Taken from Blocks Id List
$height integer number of blocks above and beyond the ship height that should be filled too (e.g. to create a wall)
$density integer =0: solid obstacle. 1-100 The higher, the more dense. 10 is approx. like the Ice biome.

Example:

$MissionContext->AddObstacles('myRegion', 2, 16, 10); //Ice blocks with density like normal ice biome
$MissionContext->AddObstacles($someRegion, 1, 2, 0); //Solid carbon wall of height 5.

AddOutsideRegionTrigger()

This command adds a trigger for when a ship is not inside a certain region. The function signature and parameters are identical to the AddInRegionTrigger command:

$MissionContext->AddOutsideRegionTrigger($triggerId, $regionId, $shipId)


AddShip() / SpawnShip()

These commands add a new ship to the map, either by coordinates, or at a given spawn location. The function calls look like this:

$shipId = $MissionContext->AddShip($definitionId, $coordinates, $rotation, $owner)
$shipId = $MissionContext->SpawnShip($definitionId, $spawnLocationId, $rotation, $owner)
Parameters
Parameter Type Description
$definitionId string The Id of the <ShipDefinition> from the shipdefinitions.xml.
$coordinates array The x and z coordinates where to spawn the ship.
$spawnLocationId string The Id of the spawn location present in the map created with the editor.
$rotation integer The rotation (in degrees) of the ship.
$owner string The PlayerId of the ship owner. 'X' for enemies, 'Y' for allies, the playerId from the $MissionContext->PlayerList property for a player.
Return Value
Type Description
int The Id of the ship on the map for use in MoveShip command or OnShipKilled trigger for example.

Examples:

$shipId = $MissionContext->AddShip('PirateProbe', array(10, 12), 0, 'X');
$playerId = $MissionContext->PlayersList[0];
$shipId2 = $MissionContext->AddShip('Rosinante', array(6, -7), 45, $playerId);


EnableButtonForPlayer() / DisableButtonForPlayer()

These commands enable/disable a button, which has been defined with $MissionContext->AddButton, for a specific player

$MissionContext->EnableButtonForPlayer($buttonId, $playerId)
$MissionContext->DisableButtonForPlayer($buttonId, $playerId)
Parameters
Parameter Type Description
$buttonId string The Id of the button, which has been used when the button was created with $MissionContext->AddButton
$owner string The PlayerId for who the button should be enabled/disabled.

Examples:

$MissionContext->EnableButtonForPlayer('myButtonId', $PlayerOne);
$MissionContext->DisableButtonForPlayer($someButtonId, $MissionContext->PlayersList[0]);


EnableDetectors() / DisableDetectors()

These commands enable/disable the detector capabilities of a ship in the mission, e.g. for a quest ship to avoid unfair advantages.

$MissionContext->EnableDetectors($shipId)
$MissionContext->DisableDetectors($shipId)
Parameters
Parameter Type Description
$ship integer The Id of the ship, either received as return value from $MissionContext->AddShip, or from the PlayersShipList.

Examples:

$MissionContext->EnableDetectors('myShipId');
$MissionContext->DisableDetectors($someShipId);

MoveShip()

This command moves an existing ship to the target coordinates.

$MissionContext->MoveShip($shipId, $coordinates)

| class="wikitable" |+ Parameters |- ! Parameter ! Type ! Description |- | $shipId || integer || The Id of the ship received from the AddShip command or from the $MissionContext->PlayerShipList or $MissionContext->EnemyShipList properties. |- | $coordinates || array || The x and z coordinates where to move the ship. |}

Example:

$rosinante = $MissionContext->AddShip('Rosinante', array(6, -7), 45, '4711');  
$MissionContext->MoveShip($rosinante);


RemoveBlock()

This command removes a single block from the mission map.

$MissionContext->RemoveBlock($coordinates, $explode)
Parameters
Parameter Type Description
$coordinates array An array with the x, y, z coordinates of the location where to remove the block.
$explode boolean Determines if the block should explode (true) or just disappear (false)


Example:

$MissionContext->RemoveBlock(array(10, 3, 12));


RemoveBuilding()

This command removes a building from the mission map.

$MissionContext->RemoveBuilding($coordinates, $explode)
Parameters
Parameter Type Description
$coordinates array An array with the x, y, z coordinates of the building location.
$explode boolean Determines if the building should explode (true) or just disappear (false)


Example:

$MissionContext->RemoveBuilding(array(10, 3, 12));


RemoveButton()

This command removes a previously defined button from the mission.

$MissionContext->RemoveButton($buttonId)
Parameters
Parameter Type Description
$buttonId string The Id of the button which has been used during creation with $MissionContext->AddButton


Example:

$MissionContext->RemoveButton('myButtonId');

RemoveCounter()

Removes an existing counter from the UI of the players.

$MissionContext->RemoveCounter($counterId)
Parameters
Parameter Type Description
$counterId string The Id of the counter used when creating the counter with the SetCounter command.

Example:

$MissionContext->SetCounter('myCounter', 12, array('EN' => 'This counter has the value 12.));
$MissionContext->RemoveCounter('myCounter');


RemoveMissionObjective()

Removes an existing mission objective from the UI of the players.

$MissionContext->RemoveMissionObjective($objectiveId)
Parameters
Parameter Type Description
$objectiveId string The Id of the objective used when creating the objective with the SetMissionObjective command.

Example:

$MissionContext->SetMissionObjective('myObjective', array('EN' => 'This is an objective'));
$MissionContext->RemoveMissionObjective('myObjective');


RemoveObstacles()

This command removes a all blocks from a region

$MissionContext->RemoveObstacles($regionId, $explode)
Parameters
Parameter Type Description
$regionId array The Id of a region defined with the AddRegion command or in the editor.
$explode boolean Determines if the blocks should explode (true) or just disappear(false)


Example:

$MissionContext->RemoveObstacles('myRegion', true);

RemoveShip()

Removes a ship from the mission.

$MissionContext->RemoveShip($shipId, $explode)
Parameters
Parameter Type Description
$shipId integer The Id of the ship to remove from the mission. Taken from the PlayersShipList or from the return value of AddShip.
$explode boolean Set if the ship should be destroyed/explode (true), or just disappear (false)

RemoveTimer()

Removes an existing timer, and prevents its expiration.

$MissionContext->RemoveTimer($timerId)
Parameters
Parameter Type Description
$timerId string The Id of the timer used when creating the timer with the SetTimer command.

Example:

$MissionContext->SetTimer('myTimer', 12, true, array('EN' => 'This is a visible timer.'));
$MissionContext->RemoveTimer('myTimer');


RemoveTrigger()

Removes an existing trigger and prevents it from being triggered.

$MissionContext->RemoveTrigger($triggerId)
Parameters
Parameter Type Description
$trigger string The Id of the trigger used when creating the trigger with the AddInRegionTrigger or AddOutsideRegionTrigger command.

Example:

$MissionContext->AddInRegionTrigger('myTrigger', 'myCircle', 18);
$MissionContext->RemoveTrigger('myTrigger');


SendSystemMessage()

Sends an orange system chat message to all players.

$MissionContext->SendSystemMessage($messages)
Parameters
Parameter Type Description
$messages array The array of translated messages.

Example:

$MissionContext->SendSystemMessage(array('EN' => 'This is a message', 'DE' => 'Dies ist eine Nachricht'));


SetBuildingHitpoints()

This command modifies the hitpoints of a building.

$MissionContext->SetBuildingHitpoints($coordinates, $explode)
Parameters
Parameter Type Description
$coordinates array An array with the x, y, z coordinates of the building location.
$hitpoints integer Sets the remaining hitpoints of the building. If <= 0, RemoveBuilding with explode=true will be called.


Example:

$MissionContext->SetBuildingHitpoints(array(10, 3, 12), 1500);


SetBuildingOwner()

This command changes the owner of a building.

$MissionContext->SetBuildingOwner($coordinates, $ownerId)
Parameters
Parameter Type Description
$coordinates array An array with the x, y, z coordinates of the building location.
$ownerId string X for enemies, Y for allies.


Example:

$MissionContext->SetBuildingOwner(array(10, 3, 12), 'X');

SetCounter()

Adds or updates a counter visible to all players.

$MissionContext->SetCounter($counterId, $value, $counterTexts)
Parameters
Parameter Type Description
$counterId string The Id which can be used to call RemoveCounter or SetCounter (in order to update it again) later.
$value integer The (new) value of the counter.
$counterTexts array The array of translated counter descriptions

Example:

$MissionContext->SetCounter('enemyCounter', 20, array('EN' => 'Remaining enemies', 'DE' => 'Verbleibende Feinde.')); //Create
$MissionContext->SetCounter('enemyCounter', $MissionContext->EnemiesShipList->Count, array('EN' => 'Remaining enemies', 'DE' => 'Verbleibende Feinde.')); //Update


SetMissionObjective()

Adds or updates a mission objective visible to all players.

$MissionContext->SetCounter($objectiveId, $objectiveTexts)
Parameters
Parameter Type Description
$objectiveId string The Id which can be used to call RemoveMissionObjective or SetMissionObjective (in order to update it again) later.
$objectiveTexts array The array of translated objective texts.

Example:

$MissionContext->SetMissionObjective('killEnemies', array('EN' => 'Kill the first three enemies', 'DE' => 'Zerstöre die ersten drei Feinde.')); //Create
$MissionContext->SetMissionObjective('killEnemies', array('EN' => 'Kill all remaining enemies', 'DE' => 'Zerstöre alle verbleibenden Feinde.')); //Update


SetMissionFailed()

Ends the mission with a fail.

$MissionContext->SetMissionFailed($loseTexts)
Parameters
Parameter Type Description
$loseTexts array The array of translated texts why the mission was lost.

Example:

$MissionContext->SetMissionFailed(array('EN' => 'The timer has expired.', 'DE' => 'Die Zeit ist abgelaufen.'));


SetMissionSuccessful()

Ends the mission with a win. Will trigger the loot distribution.

$MissionContext->SetMissionSuccessful($winTexts)
Parameters
Parameter Type Description
$winTexts array The array of translated texts why the mission was won.

Example:

$MissionContext->SetMissionSuccessful(array('EN' => 'All enemies have been defeated.', 'DE' => 'Alle Feinde wurden zerstört.'));


SetRegion()

Defines a region on the map. A region can be used for a in-region trigger or outside-region trigger, or to add/remove obstacles. This function has an overload for two region types:

$MissionContext->SetRegion($regionId, $topLeftCoordinates, $size); //Rectangle
$MissionContext->SetRegion($regionId, $centerCoordinates, $radius); //Circle
Parameters
Parameter Type Description
$regionId string The Id of the region which can be used for the AddRegionTrigger or AddOutsideRegionTrigger commands.
$topLeftCoordinates array The x and z coordinates of the top left corner of the rectangle.
$size array The width and height of the rectangle.
$centerCoordinates array The x and z coordinates of the center of the circle.
$radius integer The radius of the circle.


Examples:

$MissionContext->SetRegion('myRectangle, array(10, 12), array(5, 5));
$MissionContext->SetRegion('myCircle', array(10, 12), 4);

SetShipOwner()

Changes the owner of a ship.

$MissionContext->SetShipOwner($shipId, $ownerId);
Parameters
Parameter Type Description
$shipId integer The Id of the ship which has been retreived from the PlayersShipList or via the AddShip command.
$ownerId string The player Id of the new owner of the ship. X for enemy, Y for neutral, or from the PlayersList

Examples:

$MissionContext->SetShipOwner(1,'X');
$MissionContext->SetShipOwner($myShipId, 'Y');

SetTimer()

Adds or updates a timer. It can count down secretly or be displayed (with a title) to the players.

$MissionContext->SetTimer($timer, $seconds, $display, $timerTexts);
Parameters
Parameter Type Description
$timer string The Id of the timer which can be used for the RemoveTimer or SetTimer (to update it later) commands, and which is passed to the OnTimerExpired event handler.
$seconds integer The remaining seconds on the timer until expiration.
$display boolean Defines if the timer is visible to the players.
$timerTexts array The translated titles of the timer. Mandatory, if $display = true.

Example:

$MissionContext->SetTimer('myTimer', 60, false);
$MissionContext->SetTimer('myTimer', 30, true, array('EN' => 'Remaining time until attack wave', 'DE' => 'Verbleibende Zeit bis Angriffswelle'));