MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / GetActions

Method GetActions

engine/Poseidon/AI/VehicleAIPilot.cpp:1273–1446  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1271}
1272
1273void EntityAI::GetActions(UIActions& actions, AIUnit* unit, bool now)
1274{
1275 if (!unit)
1276 {
1277 return;
1278 }
1279 // user actions
1280 // FIX
1281 if (_userActions.Size() > 0)
1282 {
1283 bool ok = true;
1284 if (now && unit->GetVehicle() != this)
1285 {
1286 // check if in front
1287 Vector3Val relPos = unit->GetPerson()->PositionWorldToModel(Position());
1288 ok = relPos.Z() > 0 && relPos.SquareSize() < Square(10);
1289 }
1290 if (ok)
1291 {
1292 for (int i = 0; i < _userActions.Size(); i++)
1293 {
1294 int id = _userActions[i].id;
1295 actions.Add(ATUser, this, 1.5 - 0.001 * id, id, true);
1296 }
1297 }
1298 }
1299
1300 // user type actions
1301 const EntityAIType* type = GetType();
1302 if (type->_userTypeActions.Size() > 0)
1303 {
1304 Vector3Val relPos = PositionWorldToModel(unit->GetPerson()->WorldPosition());
1305 GameState* gstate = GWorld->GetGameState();
1306 gstate->VarSet("this", GameValueExt(this), true);
1307
1308 for (int i = 0; i < type->_userTypeActions.Size(); i++)
1309 {
1310 const UserTypeAction& act = type->_userTypeActions[i];
1311 if (relPos.Distance2(act.modelPosition) > Square(act.radius))
1312 {
1313 continue;
1314 }
1315 if (!gstate->EvaluateBool(act.condition))
1316 {
1317 continue;
1318 }
1319
1320 actions.Add(ATUserType, this, 1.4 - 0.001 * i, i, true);
1321 }
1322 }
1323
1324 if (unit->GetVehicle() == this && CommanderUnit() == unit && !unit->IsInCargo())
1325 {
1326 // lights on / off
1327 if (unit->IsPlayer() && _reflectors.Size() > 0)
1328 {
1329 if (IsPilotLight())
1330 {

Callers 2

CollectActionsMethod · 0.45
ProcessActionsMethod · 0.45

Calls 15

GameValueExtClass · 0.85
IsHandGunSelectedFunction · 0.85
GetReloadActionsFunction · 0.85
GetPersonMethod · 0.80
EvaluateBoolMethod · 0.80
IsInCargoMethod · 0.80
IsPlayerMethod · 0.80
NightEffectMethod · 0.80
MainLightMethod · 0.80
SquareFunction · 0.50
GetTypeFunction · 0.50
SizeMethod · 0.45

Tested by

no test coverage detected