| 1271 | } |
| 1272 | |
| 1273 | void 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 | { |
no test coverage detected