Vehicle

A reference to a Vehicle instance.




Back to Scripting API

Scripting API

AiParams

Class that handles AI parameters management.

ReturnFunction NameDescriptionVote
voidallowBeingTargetedIf enabled, enemies will target this soldier whenever they see him. If disabled, the soldier will be completly ignored by enemies. Toghether with allowCheckForEnemies, this function is helpful to script systems like Civilian or Non combatant medics. 362
voidallowChangePoseWhen enabled, AI will change pose depending on cover, suppression and other situations. Disable this function if you want to control soldier's pose by custom scripting 293
voidallowCheckForEnemiesWhen enabled, AI will check for enemies around and target them. When this function is disabled AI will not search and target enemies. Useful for custom AI implementations 308
voidallowDoMedicWhen this function is enabled, if a soldier has medic equipments in his inventory he will proceed to heal nearby units 266
voidallowFindCoverWhenSuppressedWhen enabled, AI will automatically find cover when suppressed. If you want to move the AI trough custom scripting, you most likely want to disable this feature 300
voidallowFollowOrdersWhen enabled, AI will automatically follow squad leader orders. If you want to move this specific unit with your custom scripts, for example by using Soldier.moveTo function, most likely you want this to be disabled 275
voidallowGiveOrdersWhen enabled, AI will automatically give orders to the squad if squad leader. If you want to give orders to a squad with your custom scripts, for example by using Squad.moveTo function, most likely you want this to be disabled 280
voidallowLeaveVehicleWhen enabled, AI will leave vehicle when necessary. If you want to control which vehicle the AI should use or force an AI never to leave a vehicle, you might want to disable this feature 289
voidallowMovementsWhen enabled, AI will perform move commands. if you don't want the AI never to move, not even with moveTo commands, disable this feature 278
voidallowOpenWindowsWhen enabled, AI will open windows that blocks it's vision, for example when in cover behind a window 286
voidallowRadioOrdersWhen enabled and if radioman, AI will communicate radio orders requested by squad leader 251
voidenableAiBehaviourThis function enables or disbales all AI functionalities toghether, including: allowChangePose, allowCheckForEnemies, allowFindCoverWhenSuppressed, allowLeaveVehicle, allowMovements, allowOpenWindows, allowOrders and allowRadioOrders 319
ObjectivefindObjectiveFind an objective from it's unique Id (network safe). Useful in case you have to reference a specific objective across different phases or players, based on it's unique Id, for example, passed trough a global variable 179
voidfollowCustomDirectCommandsDisable various AI behaviors in order to prepare the soldier to follow direct commands, such as soldier.moveTo() 311
voidfollowCustomSquadOrdersNormally squad soldiers will automatically give the orders that they cosndier the best according to the situation. This function disables various AI behaviors in order to prepare the soldier to only follow and give custom squad orders via code, such as squad.moveTo() 287
stringgetNameReturn the name of the vehicle 250
voidsetTargetPlanesOftenEnable this feature to force the AI to target planes, if closer than any other spotted enemy 308
Base Functions

These functions are not part of a specific class and can be called from anywhere.

ReturnFunction NameDescriptionVote
void#includeInclude an external file into the code of a lua script. Useful to create files with collections of functions to share across different script. Included files must be placed within the folder '[mission folder]/scripts/general/' or any subfolder. The script will be pre-processed and aded to the final code before executing it 294
floatdistanceThe distance between 2 Vector3 points in meters 249
voidlogLog some text in the F3 console. This helps a lot with testing custom Lua code. press F3 to open the console and visualize the log 261
voidprintDisplay a message on the screen 436
floatroundRound a number to a specific quantity to decimal points 365
voidsayMissionClipLoads a voice clip from the mission "sounds" folder, plays it from the soldier's mouth. Currently only .waw files are supported. 36
voidsleepPause the execution of the LUA script for some time. Notice: this is very helpful to give some pause to the CPU, expecially during 'while' and 'for' loops 299
SoldierspawnHumanSpawn a new human without specific loadout or rank. Faction Ids can be acquired in the Script Settings menu -> Id tables section 256
ObjectivespawnMissionObjectiveSpawn a Scriptable Mission Objective on current active phase and it's relative 3D Marker on the current phase. Only the master client can spawn and handle a Mission Objective. A Scriptable Objective doesn't do anything in particular on it's own. The user must make sure to update it's progress value, text, and other parameters on it's own, otherwise it will just act as a 3D Marker. For icon Ids see setIcon. 324
SoldierspawnSoldierSpawn an AI soldier. Faction Ids and loadout Ids can be acquired in the Script Settings menu -> Id tables section 310
SoldierspawnSoldierOnVehicleSpawn an AI soldier on a vehicle. Faction Ids and loadout Ids can be acquired in the Script Settings menu -> Id tables section 266
SquadspawnSquadSpawn an AI squad. Faction Ids and Squad Ids can be acquired in the Script Settings menu -> Id tables section. Can spawn custom squads made with Squad Editor 269
SquadspawnSquadOnVehicleSpawn an AI squad inside a given vehicle. Faction Ids and Squad Ids can be acquired in the Script Settings menu -> Id tables section. Vehicle crew squads will automatically fit the seats inside the vehicle. Can spawn custom squads made with Squad Editor 274
SquadspawnSquadOnVehicle_scriptSpawn an AI squad inside a given vehicle, and assign a script to each AI. Faction Ids and Squad Ids can be acquired in the Script Settings menu -> Id tables section. Vehicle crew squads will automatically fit the seats inside the vehicle. Can spawn custom squads made with Squad Editor 492
SquadspawnSquad_scriptSpawn an AI squad and assign a script to each AI. Faction Ids and Squad Ids can be acquired in the Script Settings menu -> Id tables section. Can spawn custom squads made with Squad Editor 381
VehiclespawnVehicleSpawn a vehicle. Vehicle Ids can be acquired in the Script Settings menu -> Id tables section 302
VehiclespawnVehicle_camoSpawn a vehicle with a specified camo. Vehicle Ids can be acquired in the Script Settings menu -> Id tables section 378
VehiclespawnVehicle_camo_destSpawn a vehicle with a specified camo and give it a destination. For Auto-Transport vehicles, this is where units will be deployed. Vehicle Ids can be acquired in the Script Settings menu -> Id tables section 298
VehiclespawnVehicle_destSpawn a vehicle and give it a destination. For Auto-Transport vehicles, this is where units will be deployed. Vehicle Ids can be acquired in the Script Settings menu -> Id tables section 262
voidwaitForAnyPause the execution of the script until any of the given conditions are met. 282
voidwaitUntilPause the execution of the script until one or multiple conditions are met. 348
er2

General utility and helper functions.

ReturnFunction NameDescriptionVote
voidaddInvadersTicketsAdds tickets to the current invaders faction. 324
vec3cameraPositionGet the world position of the camera 267
voidclearAllRunOnJoinClear all buffered requests to run a script locally for joining users 215
integercountAliveDefendersGet the count of all the currently alive defenders 273
integercountAliveInFactionGet the count of all the currently alive units on a specific faction 286
integercountAliveInvadersGet the count of all the currently alive invaders 332
integercountDeceasedDefendersCount how many defenders are deceased during the mission 281
integercountDeceasedInvadersCount how many invaders are deceased during the mission 285
integercountLostVehiclesDefendersCount how many defenders have been captured during the mission 266
integercountLostVehiclesInvadersCount how many invaders have been captured during the mission 191
integercountPrisonersDefendersCount how many vehicles have been lost by the defenders during the mission 242
integercountPrisonersInvadersCount how many vehicles have been lost by the invaders during the mission 254
voiddestroyAllDestroys all DestructableBuilding props within radius, including buildings not currently in view. Optionally kills units and explode vehicles. 29
voidendPrecipitationStops the rain or the snow from falling in the map To synchronize the weather changes to other clients you can use synchWeather. 258
voidexplosionGenerates an explosion 405
SoldierfindSoldierFind a soldier from it's unique Id (network safe). Useful in case you have to reference a specific soldier across different phases or players, based on it's unique Id, for example, passed trough a global variable 271
SoldierfindVehicleFind a vehicle from it's unique Id (network safe). Useful in case you have to reference a specific vehicle across different phases or players, based on it's unique Id, for example, passed trough a global variable 308
voidgetAllObjectivesGet all Mission Objectives in the current phase. 294
voidgetAllSoldiersGet all alive soldiers. Notice: After a new soldier spawns or dies, this function might get a few instant before returning a correctly updated value. 254
voidgetAllVehiclesGet all vehicles around the map 248
stringgetBattleNameReturns the current battle's name 288
NumbergetCurrentPhaseIdGet the Id of the current phases. 248
stringgetDefendersFactionGet the Id for the defenders faction 264
floatgetDistanceFromTerrainReturns the distance between the given position and the terrain. 274
stringgetInvadersFactionGet the Id for the invaders faction 260
integergetInvadersTicketReturns the number of tickets left by the invaders 235
stringgetMapNameReturns the name of the map of the current battle 272
stringgetMyNicknameGet nickname of the local user 352
ObjectivegetNearestObjectiveGet the nearest Mission Objective to a specific location 211
SquadgetNearestSoldierGet nearest soldier to a specific location 280
VehiclegetNearestVehicleGet nearest vehicle from a specific location 247
stringgetNicknameGet nickname of an online player 225
SoldiergetPlayerFind a reference to the Soldier controlled by the player 265
floatgetSettingMaxAlliesGet the max allies threshold set during match creation. It is suggested to use this value to measure the amount of AI to spawn according to player preference. This can be used to impact gameplay balancing and performance. 328
floatgetSettingMaxAxisGet the max axis threshold set during match creation. It is suggested to use this value to measure the amount of AI to spawn according to player preference. This can be used to impact gameplay balancing and performance. 270
integergetSettingMaxPlayersDefendersGet the max allowed amount of Human Players on the defenders faction. Works only during multiplayer matches 286
integergetSettingMaxPlayersInvadersGet the max allowed amount of Human Players on the invaders faction. Works only during multiplayer matches 281
floatgetSettingTicketsMultiplierGet the tickets multipler set during match creation 349
TablegetSoldiersInAreaGet all alive soldiers within a specific radius from a specific position, ordered by the distance from the given position. Notice: After a new soldier spawns or dies, this function might get a few instant before returning a correctly updated value. 268
floatgetTerrainHeightReturns the terrain height from sea level of the given x and z coordinates. 288
integergetTimeOfDayHourGets the current time (hour) 37
integergetTimeOfDayMinuteGets the current time (minutes) 27
voidgetVehiclesInAreaGet all vehicles within a specific area 248
boolisAlliedCheck if a given faction Id is part of Allies faction 237
boolisAxisCheck if a given faction Id is part of Axis faction 263
AiParamsisCivilianCheck if a given faction Id is part of Civilians faction 279
boolisInsideMainTerrainBoundsChecks if the given position is inside the terrain bounds 327
boolisMasterClientCheck if current user is master client for online match. In an offline mission, the user is always the master client 367
boolisOnlineCheck if current mission is being played on an online match 369
boolisSameFactionCheck if two faction Ids are part of the same faction (Allies or Axis) 374
SquadmakeSquadCreate a new empty squad. You can add soldiers to this squad in order to make them react to squad orders 253
boolnextPhaseForce mission to skip to next phase 304
voidnukeGenerate a nuke explosion at a certain position. The nuke will devastate a certain area and will spawn a huge explosion visual effect with a never-ending smoke effect. Having multiple nuke smokes leftovers in a map can cause severe performance issues, so use this carefully. 216
voidplayClipPlay a global Audio Clip (.wav) 290
voidplayClip3DPlay a 3D Audio Clip, coming from a specific location and with a maximum hear distance (.wav). Notice: In various occasions, such as host change, a phase script might restart, so make use of set and get to check whenever set to be played in loop forever was already initialized to avoid spawning it multiple times. 290
voidplayClipOnRadioPlay a global Audio Clip with a radio distortion effect (.wav) 277
voidplayClipOnRadio3DPlay a 3D Audio Clip, coming from a specific location and with a maximum hear distance with a radio distortion effect (.wav) 270
voidplayMusicPlays a music track globally. 286
boolpreviousPhaseForce mission to skip to previous phase 304
floatraycastCasts a ray from an origin toward a direction. Used to test collisions and objects presence. The test is done trough a Unity Raycast. 269
voidrequireEquivalent to default Lua require function, but handles the script paths as local misison paths, to ensure easier file referencing and compatibility with Xbox, Nintendo Switch and PlayStation systems. External file must be placed within the folder '[mission folder]/scripts/general/' or any subfolder 378
boolresetCallbackUnassign a callback by it's Id. 313
voidresetCallbacksUnassign all global callbacks 311
boolrunExecute an external file without stopping execution of current scrip. External file must be placed within the folder '[mission folder]/scripts/general/' or any subfolder 277
voidrunEveryoneRun a script locally for every player in the match (or just for the user if it's a SinglePlayer match). External file must be placed within the folder '[mission folder]/scripts/general/' or any subfolder 354
voidrunEveryoneOnceRun a script locally for every player in the match making sure it was not executed before (or just for the user if it's a SinglePlayer match). External file must be placed within the folder '[mission folder]/scripts/general/' or any subfolder 265
boolrunOnceExecute an external file without stopping execution of current scrip, if the external file was never executed before during the mission. External file must be placed within the folder '[mission folder]/scripts/general/' or any subfolder 361
boolsetCallbackregister a global callback on a specific event Id. Only a callback can be tied to an event Id, so when this is called again on the same Id, the new callback reference will override previous one. Callback Ids are specified at this page. 381
boolsetPhaseChanges the current phase to the one of index order 324
voidsetRainingActivates the rain on the map. To synchronize the weather changes to other clients you can use synchWeather. 364
voidsetSnowingActivates the snow on the map. To synchronize the weather changes to other clients you can use synchWeather. 295
voidsetTaskTextDefendersSet task text for defenders 185
voidsetTaskTextInvadersSet task text for invaders 194
voidsetTimeAndWeatherSets the current time of day of the mission and some weather conditions, like clouds, snow and fog. To synchronize the weather changes to other clients you can use synchWeather. NOTE: This function it's CPU heavy 313
voidsetTimeOfDaySets the current time of day of the mission. NOTE: This function is CPU heavy 350
voidsetVictoryDefendersConcludes the mission declaring defenders as winners 516
voidsetVictoryInvadersConcludes the mission declaring invaders as winners 250
voidshowObjectiveDisplay a new objective text 279
voidsynchWeatherApply the weather changes to all clients. Must be called on Master Client. After calling this, set weather is automatically applied for newly connected clients. Calling it too often can result in high network traffic and mission crash. 228
floattimeTime in seconds since the start of the execution of the game. The value is linear and doesn't take into account pausing, slowing down or speeding up game time 273
floattimeScaledScaled time in seconds since the start of the execution of the game. If the game is paused the count of the time doesn't increase. If the game is speeding up or slowing down this variable also increases with a proportional rate 294
booltriggerCallbackForce the triggering of a callback set trough setCallback 333
global

Functions to manipulate global variables that can be accessed from any script and over the network.

ReturnFunction NameDescriptionVote
anygetGet the value of a stored global variable 312
anymyplayergetGet the value of a stored global variable by my player. 296
voidmyplayersetSet a global variable for my network player that can be referenced from any script and by any player in the room. If another player sets a variable with the same id, it won't compromise my variable. 262
anyplayergetGet the value of a stored global variable by a specific player. 304
voidsetSet a global variable that can be referenced from any script and by any player in the room 367
Objective

Functions related to mission objective areas and markers.

ReturnFunction NameDescriptionVote
boolcanControlCheck if user can change the objective data, such as objective name, completition value, radius, icon and position. Usually this correspond to the Master Client 271
voidcompleteSet the conquer progress of the Scripted Mission Objective to 1 (max). Equivalent of Objective.setProgress(1). Just like any other Mission Objective property, it doesn't work with Conquer Area Objective, or any other Vanilla objective type, but only with Scripted Mission Objective spawned with spawnMissionObjective call. Notice: When all the objectives in a Mission Phase are completed (progress = 1) the Next Phase is automatically triggered 384
vec3getPositionGet the world position of the Mission Objective 377
floatgetProgressGet the progress of a Mission Objective. A value equals to 1 means that the Objective have been completed. When all Objectives in a Mission Phase are completed, the match pass automatically to the Next Phase 275
floatgetRadiusGet the area radius of the Mission Objective 345
integergetUniqueIdGet unique identifier for the objective. This is useful to check if an objective already exist, or to find specific objective with findObjective, especially across the network or between different phases. 255
boolisAttractorCheck if a Mission Objective will attract default AI to fight on the area for at least a faction, or optionally, for a specific one. 265
boolisCompletedCheck whenever a Mission Objective progress is complete (check if Objective.getProgress >= 1). Notice: When all the Mission Objectives in the current Mission Phase are marked as completed, the Next Phase will automatically be triggered 272
boolisInsideCheck whenever a vec3() position is inside a specific Mission Objective, specifically within it's radius from it's center position 265
boolisScriptedCheck if a Mission Objective is a scriptable one 8Scripted Mission Objective spawned with spawnMissionObjective call), where it is possible to control all the data 291
voidremoveRemove this objective from the current Mission Phase. Just like setting properties, only the master client can call do this operation 276
voidresetIconDefendersUnset the icon of a Scripted Mission Objective specifically for the defenders faction, making it using the same icon as the attackers. This function impacts network performance during online gameplay, so don't call it too often. When this icon gets unset, the defenders will share the same icon as the attackers, which is assigned with setIcon 272
voidsetAttractorEnable or disable the attractor feature of the Scripted Mission Objective for both factions. When enabled, default AI will try to reach and fight inside the area. Optionally can change the effect for one faction only 264
voidsetIconUpdate the icon of a Scripted Mission Objective from the icon Id. This function impacts network performance during online gameplay, so don't call it too often. Possible Ids are: "0": Conquer area icon. "1": Defend area icon. "2": Clear area icon. "3": Destroy AT gun icon. "4": Destroy vehicle icon. "5": Important area icon. 304
voidsetIconDefendersUpdate the icon of a Scripted Mission Objective from the icon Id, specifically for the defenders faction. This function impacts network performance during online gameplay, so don't call it too often. When this icon gets unset, the defenders will share the same icon as the attackers, which is assigned with setIcon 262
voidsetPositionUpdate the world position of a Scripted Mission Objective 271
voidsetProgressSet the conquer progress of the Scripted Mission Objective. Just like any other Mission Objective property, it doesn't work with Conquer Area Objective, or any other Vanilla objective type, but only with Scripted Mission Objective spawned with spawnMissionObjective call. Notice: When all the objectives in a Mission Phase are completed (progress = 1) the Next Phase is automatically triggered 289
voidsetRadiusUpdate the area radius of a Scripted Mission Task 214
voidsetTextUpdate the text of a Scripted Mission Objective. The text is displayed when inside the Mission Objective radius. This function impacts network performance during online gameplay, so don't call it too often 273
voidsetTextDefendersUpdate the text of a Scripted Mission Objective for the Defenders. The text is displayed when inside the Mission Objective radius. If this function is never called, the defenders will see the same text as the invaders. This function impacts network performance during online gameplay, so don't call it too often. 253
Soldier

Functions related to player actions and properties.

ReturnFunction NameDescriptionVote
booladdAmmoAdds an ammo box to the soldier's invetory 293
booladdMagazineAdds a magazine to the soldier's invetory. 292
booladdNewItemAdds an item to the soldier's inventory 301
voidalertForPuts the soldier in an alert state for a defined time 268
voidapplyBleedingApplies bleed status to the soldier 252
voidboardVehicleOrder the soldier to approach and borar onto the specified vehicle if available. 294
boolcanSwitchSeatCheck if the soldier is ready to switch seat. Usually this happens when a soldier is not busy with enteirng or leaving the vehicle with an animation. 238
voidcarryBodyForce the soldier to carry a another incapacitated soldier 314
voiddamageSoldierApply damage to a soldier 227
voiddecreaseStaminaDecreases soldier's stamina 332
voiddisableHitByVehicleForDisable receiving damage from impacts with vehicles for some time 341
booldoingMeleeCheck if the soldier is doing a melee attack 248
voidexecuteOrdersRoutineExecutes the routine to process squad orders for the soldier. 281
voidfindCoverFinds a cover position near a specified position within a given radius. 275
boolforceTargetForce a Soldier to target a specific Soldier or Vehicle. 305
AiParamsgetAiParamsAccess AI parameters management 291
SoldiergetCarriedBodyGet a reference to the incapacitated soldier carried by this unit 342
stringgetClassNameReturns the soldier's class name 298
VehiclegetCurrentVehicleReturns the current vehicle the soldier is in 277
floatgetDistanceFromGroundGet the distance between the soldier and the ground below 250
vec3getFacePositionGet the world position of soldier's face 262
stringgetFactionGets the soldier's faction ID 319
vec3getFireDirectionReturn a vector representing the direction where the gun held by the soldier is pointed to 271
stringgetHeadgearIdReturns the current wearing headgear Id 258
floatgetHealthGet the soldier's health 251
vec3getMoveDirectionReturns the moving direction of the soldier 256
stringgetNameReturns the soldier's full name 355
SoldiergetNearestInjuredGet the nearest wounded soldier around the current one 253
VehiclegetNearestVehicleToRepairReturns the nearest vehicle that requires repair from the current soldier 254
voidgetOffVehicleKicks the soldier from the current vehicle 262
stringgetOwnerIdGet Id of the online player controlling this soldier (Including AIs being controlled by his machine). 270
vec3getPositionGet world position of the soldier 364
SquadgetSquadGet the Squad that the soldier is currently in. Notice: The squad might not be available immediatly after a soldier is spawned, so make sure to wait for it to be ready 270
floatgetSuppressionValueChecks the suppression value of the soldier from the enemy fire. 269
stringgetUniformIdGet the Id of the uniform worn by the soldier 237
integergetUniqueIdGet unique identifier for the unit. This is useful to check if a unit already exist, or to find specific units with findSoldier, especially across the network or between different phases. 326
VehiclegetVehicleSoldierIsExitingFromGet the vehicle the current soldier is exiting from 254
vec3getVelocityReturns the current soldier's velocity 260
stringgetVestIdGet the Id of the vest worn by the soldier 364
boolhasHeadgearCheck if the the soldier is wearing an headgear 329
boolhasRadioCheck if a soldier is wearing a radio 357
boolhasVestCheck if a soldier is wearing a vest 234
voidhealSoldierHeals soldier of a certain amount 246
voidincapacitateForce incapacitate a soldier 290
boolisAIChecks if the current soldier is controlled by the AI 357
boolisAimingChecks if the current soldier is aiming the gun 310
boolisAlertedCheck if the soldier has spotted an enemy recently and is moving carefully 333
boolisAliveChecks if the current soldier is alive 298
boolisAlliedCheck if current soldier is part of Allies faction 390
boolisAmmoBoxCarrierCheck if soldier is carrying an ammo box 311
boolisATSoldierReturns true if the current soldier is an Anti-Tank unit 304
boolisAxisCheck if current soldier is part of Axis faction 377
boolisBleedingCheck if the soldier is bleeding 299
boolisCarriedReturns true if the current soldier is getting carried 335
boolisCarryingBodyCheck if the current soldier is carrying an incapacitated soldier 294
boolisChargingReturns true if the current soldier is charging 317
AiParamsisCivilianCheck if current soldier is part of Civilians faction 341
boolisCrawlingReturns true if the current soldier is crawling 354
boolisDeadCheck if a soldier is dead 299
boolisEnteringVehicleReturns true if the current soldier has started the entering vehicle animation 280
boolisExitingVehicleReturns true if the current soldier has started the exiting vehicle animation 329
boolisFallingFromParachuteChecks if the current soldier is falling with a parachute 270
boolisFlameThrowerCarrierCheck if a soldier is a flamethrower carrier 326
boolisFromChargingFactionCheck if the soldier can execute a charge order 243
boolisGroundedReturns true if the soldier is on the ground 461
boolisIncapacitatedCheck if a soldier is incapacitated 252
boolisInsideVehicleCheck if the soldier is inside a vehicle 257
boolisJumpingReturns true if the current soldier is jumping 248
boolisMarksmanReturns true if the current soldier is a Marksman 200
boolisMechanicReturns true if the current soldier is a mechanic 313
boolisMedicReturns true if the current soldier is a medic 279
boolisMineCheck whenever I have network authority over a soldier 342
boolisMovingReturns true if the current soldier is moving 258
boolisOnCoverCheck if a soldier is taking cover 301
boolisOnFireReturns true if the current soldier is on fire 261
boolisOnWaterCheck if a soldier is walking inside water 283
boolisOutOfStaminaReturns true if the current soldier is out of stamina 239
boolisPlayerCheck if the soldier is a player 260
boolisPlayerFPSReturns true if the current soldier is a player and in first person 249
boolisRadiomanCheck if the current soldier is a Radioman 307
boolisReachingVehicleToMountCheck if a soldier is on his way to mount inside a vehicle 289
boolisReloadingReturns true if the current soldier is reloading a weapon 308
boolisRunningReturns true if the current soldier is running 350
boolisSameFactionCheck if another soldier is in the same faction of this soldier 280
boolisSquadLeaderReturns true if the current soldier is the Squad Leader 261
boolisSquadReadyCheck if soldier is in a squad, and the squad is marked as ready to receive orders. Notice: A squad might not be ready immediately after a soldier has spawned, so this can be used to check whenever the soldier is in a squad before getting the squad reference 256
boolisStealthReturns true if the soldier is moving stealthly 246
boolisSuppressedChecks if the soldier is being suppressed 200
boolisSurrenderingCheck if the soldier is surrendering 296
boolisTalkingReturns true if the current soldier is talking 280
boolisThrowingReturns true if the current soldier is throwing something 297
boolisTowardWallReturns true if the current soldier is facing a wall 265
boolisUsingVehicleTurretCheck if soldier is operating a turret 248
voidjumpMakes the soldier jump. Notice: the jump movement is based on the current soldier velocity and direction. 265
voidkillSoldierKills the soldier 296
voidleaveVehicleCommands the soldier to eject from the current vehicle. 266
voidmoveToMoves the soldier to a specified position using CoverPosition with a new DestinationWithoutCover based on the given position and current pose. 280
SoldiermyselfCan be called within a SoldierBrain script to acquire the soldier controlled by the script 404
voidpauseAlertPauses the soldier's alert state. Notice: the difference between this and setnotalerted is that this one just pauses the alert state, while the other one stops 327
voidremoveBleedingRemoves bleeding effect from soldier 275
boolremoveItemRemove one or multiple items from a soldier invenotory 259
boolresetCallbackUnassign a callback by it's Id on a specific Soldier 376
voidresetCallbacksUnassign all callbacks on a specific Soldier 373
voidresetPoseAllow the soldier to automatically choose it's pose, canceling setPose command 345
voidsayMakes the soldier say a line based on the VoiceClip Enum 360
voidsayClipPlay a 3D Audio Clip, coming from soldier mouth and with soldier speaking animation (.wav) 421
voidsetAnimatorBoolSets a bool parameter on the soldier's animator 27
voidsetAnimatorControllerLoads a RuntimeAnimatorController by name from the "er2animations" bundle and applies it. 29
boolsetBrainSet script that controls AI. Usually AI will work with "Default" behaviour, which will controls the way AI gives and follows squad orders, however it's possible to define a completly new behaviour by coding a dedicated "brain" LUA file and assign it to the AI with this function 282
boolsetCallbackRegister a callback for a specific event Id on a specific Soldier. Only a callback can be tied to an event Id, so when this is called again on the same Id, the new callback reference will override previous one. Callback Ids are specified at this page. 390
voidsetInVehicleTeleport the soldier inside the specified vehicle. 295
voidsetNotAlertedForce concludes the alert state of the soldier 265
voidsetOnFireSets the current soldier on fire. Notice: The fire does not damage the soldier. 384
voidsetPlayerForce a soldier to be controlled by the player. Notice: This only works for soldiers and AIs that have been spawned (or are controlled) by current player's machine 362
voidsetPoseSets the soldier's pose based on the given integer. The soldier will strictly follow the assigned pose until resetPose is called 299
voidstopStops the soldier by resetting the cover position to the current position. 261
voidstopIncapacitateStops a soldier from being incapacitated 493
voidstopSurrenderingCancel soldier surrendering action 281
voidsurrenderForce surrender the current soldier 401
booltriggerCallbackForce the triggering of a callback set trough setCallback on a specific Soldier 378
Squad

Class to handle a Squad controlling multiple Soldiers.

ReturnFunction NameDescriptionVote
booladdSoldierAdd a Soldier to a squad 359
voidalertEnemiesAlert all enemies of the presence of the squad for some time 321
voidattackFromPointOrders the squad to attack from the specified waypoint within the given radius. 284
voidboardVehicleOrders the squad to board the specified vehicle. 263
voidcancelRadioRequestCancels any active radio request by the squad. 249
voidchargeOrders the squad to charge towards the specified position within the given radius. 360
voidcoverAreaOrders the squad to cover an area defined by a center position and radius. 222
voidfireAtWillOrders the squad to fire at will, canceling the stealth "hold fire" order, optionally playing an order animation. 296
voidfollowLeaderOrders the squad to follow their leader, optionally playing an order animation. 337
voidgetAllMembersGet all soldiers inside the squad 268
SoldiergetLeaderGet reference to the Squad Leader 302
SoldiergetMechanicGet reference to the Squad Mechanic 407
SoldiergetMedicGet reference to the Squad Medic 362
vec3getObjectivePositionReturns the position of the squad's current objective, or the leader's position if none is set. 236
floatgetObjectiveRadiusReturns the radius of the squad's current objective area, or a default value if none exists. 246
SoldiergetRadiomanGet reference to the Squad Radioman 414
boolhasAliveMembersReturns whether the squad has any alive members. 256
boolhasFullySpawnedWhen using in-game Spawn Manager, spawning a squad can take a few instants. This function can be used to check whenever a squad has fully spawned 277
boolhasObjectiveReturns whether the squad has an assigned objective. 324
voidholdFireOrders the squad to hold fire and move stealthy, optionally playing an order animation. 269
boolisPlayerInSquadCheck if Player is inside a squad 336
voidleaveVehicleOrders the squad to leave the specified vehicle. The force flag determines whether the leave order is forced. 253
voidmoveToOrders the squad to hold an area at the specified position with the given radius. Make sure that the squad can follow order, and eventually that the squad leader AI has give order feature disabled to avoid squad leader to override your orders 296
boolremoveSoldierRemove a Soldier from a Squad (Soldier will be put on a new Squad) 420
voidrepairVehicleOrders the squad to repair the specified vehicle. 322
voidsetClosestObjectiveOrders the squad to set their objective to the closest available one. 309
voidsetRandomObjectiveOrders the squad to set a random objective. 346
Vehicle

Functions to handle vehicle spawning and behavior.

ReturnFunction NameDescriptionVote
voidaddNewItemToCargoAdd a new item to the cargo of the vehicle 358
boolcanBeRepairedChecks if the vehicle can be repaired 244
anycanRecieveDamageChecks if the vehicle can recieve any form of damage. 318
boolcanRefillAmmoChecks if is possible to refill ammo for the vehicle 339
boolcanShootInDirectionChecks if someone on the vehicle can shoot in that direction 248
boolcargoContainsItemCheck if vehicle inventory contains a specific item 261
integercountEmptySeatsCounts the empty seats in the vehicle 241
integercountItemsCount how many items with a specific Id are found inside the inventory of the vehicle 225
anycountPeopleInsideCounts all the people inside the vehicle 255
voiddamageApply damage to the hull of a vehicle 336
voiddamageEngineDamage vehicle engine (if any) 272
voiddamageFuelTankDamage vehicle fuel tank (if any) 312
voiddamageTracksDamage vehicle tracks and/or wheels (if any) 225
voiddestroyDisable the vehicle forever 368
voiddropInfantryKicks all the soldier seated in the passenger seats 269
voidemptyAllTurretsEmpties the magazines of all the turrets in the vehicle 293
floatgetDamageCheck life amount of a vehicle (hull integrity) 314
SoldiergetDriverGet reference to the Soldier driving the vehicle 273
floatgetEngineDamageCheck life amount of a vehicle engine (engine integrity) 280
stringgetFactionGet faction Id of the vehicle 353
floatgetFueltankDamageCheck life amount of vehicle fuel tank 192
SoldiergetGunnerGet reference to a soldier controlling a turret of the vehicle 285
SoldiergetLeaderGet reference of the soldier in the commanding seat of the vehicle 271
SoldiergetPassengersGet all passengers of the vehicle 268
vec3getPosition_vehicleGet the world position of the vehicle 437
floatgetTracksDamageCheck life amount of vehicle tracks/wheels 257
integergetUniqueIdGet unique identifier for the vehicle. This is useful to check if a vehicle already exist, or to find specific vehicle with findVehicle, especially across the network or between different phases. 352
boolhasDriverChecks if the vehicle has a driver 285
boolisArtilleryVehicleChecks if the vehicle has any seat to be considered artillery 249
boolisBrakingChecks if the vehicle is braking 227
boolisDestroyedCheck if vehicle is fully destroyed 266
boolisDriverAliveChecks if there's a driver and is alive 276
boolisEmptyCheck if vehicle is empty (No units are left inside) 309
boolisFullCheck if vehicle seats are all occupied 266
boolisLockedCheck whenever a vehicle can be entered or leaved 244
boolisMineCheck whenever I have network authority over a vehicle 408
voidkickEveryoneOutForce everyone to leave the vehicle 291
voidkickUnitsForce specific units to leave the vehicle 281
boolplayerIsInsideCheck if the LOCAL player is currently inside this vehicle 34
voidremoveItemFromCargoRemove an item from the cargo of the vehicle 266
voidrepairSet vehicle to fully repaired. Notice: This works only on vehicles that are not fully destroyed 351
boolresetCallbackUnassign a callback by it's Id on a specific Vehicle 386
voidresetCallbacksUnassign all callbacks on a specific Vehicle 358
boolsetCallbackRegister a callback for a specific event Id on a specific Vehicle. Only a callback can be tied to an event Id, so when this is called again on the same Id, the new callback reference will override previous one. Callback Ids are specified at this page. 312
booltriggerCallbackForce the triggering of a callback set trough setCallback on a specific Vehicle 376