* Get the priority for a target. Various of things have influence on this score, * most noticeable the movementType of the target, his distance to you, and * if he is moving/firing. * @note It only considers units on sand. * * @param unit The Unit that is requesting the score. * @param target The Unit that is being targeted. * @return The priority of the target. */
| 985 | * @return The priority of the target. |
| 986 | */ |
| 987 | static uint16 Unit_Sandworm_GetTargetPriority(Unit *unit, Unit *target) |
| 988 | { |
| 989 | uint16 res; |
| 990 | uint16 distance; |
| 991 | |
| 992 | if (unit == NULL || target == NULL) return 0; |
| 993 | if (!Map_IsPositionUnveiled(Tile_PackTile(target->o.position))) return 0; |
| 994 | if (!g_table_landscapeInfo[Map_GetLandscapeType(Tile_PackTile(target->o.position))].isSand) return 0; |
| 995 | |
| 996 | switch(g_table_unitInfo[target->o.type].movementType) { |
| 997 | case MOVEMENT_FOOT: res = 0x64; break; |
| 998 | case MOVEMENT_TRACKED: res = 0x3E8; break; |
| 999 | case MOVEMENT_HARVESTER: res = 0x3E8; break; |
| 1000 | case MOVEMENT_WHEELED: res = 0x1388; break; |
| 1001 | default: res = 0; break; |
| 1002 | } |
| 1003 | |
| 1004 | if (target->speed != 0 || target->fireDelay != 0) res *= 4; |
| 1005 | |
| 1006 | distance = Tile_GetDistanceRoundedUp(unit->o.position, target->o.position); |
| 1007 | |
| 1008 | if (distance != 0 && res != 0) res /= distance; |
| 1009 | if (distance < 2) res *= 2; |
| 1010 | |
| 1011 | return res; |
| 1012 | } |
| 1013 | |
| 1014 | /** |
| 1015 | * Find the best target, based on the score. Only considers units on sand. |
no test coverage detected