Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ContextGetInGroupCommand.c
Go to the documentation of this file.
3{
4 [Attribute(desc: "Prefab of the AI waypoint used in this command to get into specific vehicle", params: "et class=AIWaypoint")]
6
7 //------------------------------------------------------------------------------------------------
8 override bool Execute(IEntity cursorTarget, IEntity target, vector targetPosition, int playerID, bool isClient)
9 {
10 if (isClient && playerID == SCR_PlayerController.GetLocalPlayerId())
11 {
12 //SpawnWPVisualization(targetPosition, playerID);
13 return true;
14 }
15
16 //SpawnWPVisualization(targetPosition, playerID);
17 if (!m_sWaypointPrefab || !m_sSpecificEntityWP || !target || !targetPosition)
18 return false;
19
20 return DecideAndSetWP(cursorTarget, target, targetPosition, playerID);
21 }
22
23 //------------------------------------------------------------------------------------------------
24 bool DecideAndSetWP(IEntity cursorTarget, IEntity target, vector targetPosition, int playerID)
25 {
26 IEntity playerEntity = GetGame().GetPlayerManager().GetPlayerControlledEntity(playerID);
27 if (!playerEntity)
28 return false;
29
30 ChimeraCharacter playerCharacter = ChimeraCharacter.Cast(playerEntity);
31 if (!playerCharacter)
32 return false;
33
34 if (playerCharacter.IsInVehicle())
35 {
36 CompartmentAccessComponent compartmentComp = playerCharacter.GetCompartmentAccessComponent();
37 if (!compartmentComp)
38 return false;
39
40 IEntity vehicleIn = compartmentComp.GetVehicleIn(playerCharacter);
41 if (!vehicleIn)
42 return false;
43
44 return CreateBoardingEntityWP(target, vehicleIn, vehicleIn.GetOrigin());
45 }
46
47 if (cursorTarget)
48 {
49 Vehicle cursorVehicle = Vehicle.Cast(cursorTarget.GetRootParent());
50 if (cursorVehicle)
51 return CreateBoardingEntityWP(target, cursorVehicle, cursorVehicle.GetOrigin());
52 }
53
54 //handle default logic
55 return SetWaypointForAIGroup(target, targetPosition, playerID);
56 }
57
58 //------------------------------------------------------------------------------------------------
60 {
61 Resource waypointPrefab = Resource.Load(m_sSpecificEntityWP);
62 if (!waypointPrefab.IsValid())
63 {
64 Print("SCR_ContextGetInGroupCommand:: Invalid prefab path", LogLevel.ERROR);
65 return false;
66 }
67
68 SCR_AIGroup slaveGroup = SCR_AIGroup.Cast(targetGroup);
69 if (!slaveGroup)
70 return false;
71
73 params.TransformMode = ETransformMode.WORLD;
74 params.Transform[3] = position;
75
76 CheckPreviousWaypoints(slaveGroup);
77
78 SCR_BoardingEntityWaypoint wp = SCR_BoardingEntityWaypoint.Cast(GetGame().SpawnEntityPrefabLocal(waypointPrefab, null, params));
79 if (!wp)
80 return false;
81
83 wp.SetPriorityLevel(SCR_AIActionBase.PRIORITY_LEVEL_PLAYER);
84
85 wp.SetCompletionRadius(m_fCompletionRadius);
86 wp.SetEntity(entity);
87 slaveGroup.AddWaypoint(wp);
88
89 return true;
90 }
91}
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
vector position
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external vector GetOrigin()
proto external IEntity GetRootParent()
Object holding reference to resource. In destructor release the resource.
Definition Resource.c:25
bool CreateBoardingEntityWP(IEntity targetGroup, IEntity entity, vector position)
override bool Execute(IEntity cursorTarget, IEntity target, vector targetPosition, int playerID, bool isClient)
bool DecideAndSetWP(IEntity cursorTarget, IEntity target, vector targetPosition, int playerID)
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
void CheckPreviousWaypoints(SCR_AIGroup slaveGroup)
bool SetWaypointForAIGroup(IEntity target, vector targetPosition, int playerID)
enum EPhysicsLayerPresets Vehicle
Definition gameLib.c:24
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
SCR_FieldOfViewSettings Attribute