* Get the priority a target structure has for a given unit. The higher the value, * the more serious it should look at the target. * * @param unit The unit looking at a target. * @param target The structure to look at. * @return The priority of the target. */
| 2560 | * @return The priority of the target. |
| 2561 | */ |
| 2562 | uint16 Unit_GetTargetStructurePriority(Unit *unit, Structure *target) |
| 2563 | { |
| 2564 | const StructureInfo *si; |
| 2565 | uint16 priority; |
| 2566 | uint16 distance; |
| 2567 | |
| 2568 | if (unit == NULL || target == NULL) return 0; |
| 2569 | |
| 2570 | if (House_AreAllied(Unit_GetHouseID(unit), target->o.houseID)) return 0; |
| 2571 | if ((target->o.seenByHouses & (1 << Unit_GetHouseID(unit))) == 0) return 0; |
| 2572 | |
| 2573 | si = &g_table_structureInfo[target->o.type]; |
| 2574 | priority = si->o.priorityBuild + si->o.priorityTarget; |
| 2575 | distance = Tile_GetDistanceRoundedUp(unit->o.position, target->o.position); |
| 2576 | if (distance != 0) priority /= distance; |
| 2577 | |
| 2578 | return min(priority, 32000); |
| 2579 | } |
| 2580 | |
| 2581 | void Unit_LaunchHouseMissile(uint16 packed) |
| 2582 | { |
no test coverage detected