MCPcopy Create free account
hub / github.com/OpenDUNE/OpenDUNE / Unit_GetTargetStructurePriority

Function Unit_GetTargetStructurePriority

src/unit.c:2562–2579  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

2560 * @return The priority of the target.
2561 */
2562uint16 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
2581void Unit_LaunchHouseMissile(uint16 packed)
2582{

Callers 3

Calls 3

House_AreAlliedFunction · 0.85
Unit_GetHouseIDFunction · 0.85

Tested by

no test coverage detected