Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_CharacterEntityWaypointGroupCommand.c
Go to the documentation of this file.
1//command that takes an EntityWaypoint, and executes the waypoint with entity under cursor, or player controller entity if Character entity not found
4{
5 //------------------------------------------------------------------------------------------------
6 override bool Execute(IEntity cursorTarget, IEntity target, vector targetPosition, int playerID, bool isClient)
7 {
8 if (isClient && playerID == SCR_PlayerController.GetLocalPlayerId())
9 {
10 //SpawnWPVisualization(targetPosition, playerID);
11 return true;
12 }
13
14 //SpawnWPVisualization(targetPosition, playerID);
15 if (m_sWaypointPrefab.Empty || !target || !targetPosition)
16 return false;
17
18 IEntity targetEntity;
19 if (cursorTarget)
20 targetEntity = cursorTarget.GetRootParent();
21
22 return CreateCharacterEntityWP(targetEntity, target, targetPosition, playerID);
23 }
24
25 //------------------------------------------------------------------------------------------------
26 bool CreateCharacterEntityWP(IEntity cursorTarget, IEntity targetGroup, vector targetPosition, int playerID)
27 {
28 ChimeraCharacter character = ChimeraCharacter.Cast(cursorTarget);
29 if (!character)
30 character = ChimeraCharacter.Cast(GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID));
31
32 if (!character)
33 return false;
34
35 Resource waypointPrefab = Resource.Load(GetWaypointPrefab());
36 if (!waypointPrefab.IsValid())
37 {
38 Print("SCR_CharacterEntityWaypointGroupCommand:: Invalid prefab path", LogLevel.ERROR);
39 return false;
40 }
41
42 SCR_AIGroup slaveGroup = SCR_AIGroup.Cast(targetGroup);
43 if (!slaveGroup)
44 return false;
45
47 params.TransformMode = ETransformMode.WORLD;
48 params.Transform[3] = character.GetOrigin();
49
50 CheckPreviousWaypoints(slaveGroup);
51
52 SCR_EntityWaypoint wp = SCR_EntityWaypoint.Cast(GetGame().SpawnEntityPrefabLocal(waypointPrefab, null, params));
53 if (!wp)
54 return false;
55
57 wp.SetPriorityLevel(SCR_AIActionBase.PRIORITY_LEVEL_PLAYER);
58
59 wp.SetCompletionRadius(m_fCompletionRadius);
60 wp.SetEntity(character);
61 slaveGroup.AddWaypoint(wp);
62
63 return true;
64 }
65}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
proto external IEntity GetRootParent()
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
void CheckPreviousWaypoints(SCR_AIGroup slaveGroup)
void EntitySpawnParams()
Definition gameLib.c:130
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
Definition LogLevel.c:14