| 1360 | } |
| 1361 | |
| 1362 | GameValue ObjFireEx(const GameState* state, GameValuePar oper1, GameValuePar oper2) |
| 1363 | { |
| 1364 | Object* obj = GetObject(oper1); |
| 1365 | if (!obj) |
| 1366 | { |
| 1367 | return NOTHING; |
| 1368 | } |
| 1369 | EntityAI* veh = dyn_cast<EntityAI>(obj); |
| 1370 | if (!veh) |
| 1371 | { |
| 1372 | return NOTHING; |
| 1373 | } |
| 1374 | |
| 1375 | const GameArrayType& array = oper2; |
| 1376 | GameStringType muzzle; |
| 1377 | GameStringType mode; |
| 1378 | GameStringType magazine; |
| 1379 | |
| 1380 | switch (array.Size()) |
| 1381 | { |
| 1382 | case 3: |
| 1383 | if (array[2].GetType() != GameString) |
| 1384 | { |
| 1385 | return NOTHING; |
| 1386 | } |
| 1387 | magazine = array[2]; |
| 1388 | case 2: |
| 1389 | if (array[0].GetType() != GameString) |
| 1390 | { |
| 1391 | return NOTHING; |
| 1392 | } |
| 1393 | muzzle = array[0]; |
| 1394 | if (array[1].GetType() != GameString) |
| 1395 | { |
| 1396 | return NOTHING; |
| 1397 | } |
| 1398 | mode = array[1]; |
| 1399 | break; |
| 1400 | default: |
| 1401 | return NOTHING; |
| 1402 | } |
| 1403 | |
| 1404 | for (int i = 0; i < veh->NMagazineSlots(); i++) |
| 1405 | { |
| 1406 | const MagazineSlot& slot = veh->GetMagazineSlot(i); |
| 1407 | if (stricmp(slot._muzzle->GetName(), muzzle) != 0) |
| 1408 | { |
| 1409 | continue; |
| 1410 | } |
| 1411 | |
| 1412 | if (magazine.GetLength() > 0) |
| 1413 | { |
| 1414 | Ref<MagazineType> type = MagazineTypes.New(magazine); |
| 1415 | int best = veh->FindBestMagazine(type, 0); |
| 1416 | if (best >= 0) |
| 1417 | { |
| 1418 | veh->AttachMagazine(slot._muzzle, veh->GetMagazine(best)); |
| 1419 | } |
nothing calls this directly
no test coverage detected