* Untarget the given Unit. * * @param unit The Unit to untarget. */
| 1609 | * @param unit The Unit to untarget. |
| 1610 | */ |
| 1611 | void Unit_UntargetMe(Unit *unit) |
| 1612 | { |
| 1613 | PoolFindStruct find; |
| 1614 | uint16 encoded = Tools_Index_Encode(unit->o.index, IT_UNIT); |
| 1615 | |
| 1616 | Object_Script_Variable4_Clear(&unit->o); |
| 1617 | |
| 1618 | find.houseID = HOUSE_INVALID; |
| 1619 | find.type = 0xFFFF; |
| 1620 | find.index = 0xFFFF; |
| 1621 | |
| 1622 | while (true) { |
| 1623 | Unit *u; |
| 1624 | |
| 1625 | u = Unit_Find(&find); |
| 1626 | if (u == NULL) break; |
| 1627 | |
| 1628 | if (u->targetMove == encoded) u->targetMove = 0; |
| 1629 | if (u->targetAttack == encoded) u->targetAttack = 0; |
| 1630 | if (u->o.script.variables[4] == encoded) Object_Script_Variable4_Clear(&u->o); |
| 1631 | } |
| 1632 | |
| 1633 | find.houseID = HOUSE_INVALID; |
| 1634 | find.type = 0xFFFF; |
| 1635 | find.index = 0xFFFF; |
| 1636 | |
| 1637 | while (true) { |
| 1638 | Structure *s; |
| 1639 | |
| 1640 | s = Structure_Find(&find); |
| 1641 | if (s == NULL) break; |
| 1642 | |
| 1643 | if (s->o.type != STRUCTURE_TURRET && s->o.type != STRUCTURE_ROCKET_TURRET) continue; |
| 1644 | if (s->o.script.variables[2] == encoded) s->o.script.variables[2] = 0; |
| 1645 | } |
| 1646 | |
| 1647 | Unit_RemoveFromTeam(unit); |
| 1648 | |
| 1649 | find.houseID = HOUSE_INVALID; |
| 1650 | find.type = 0xFFFF; |
| 1651 | find.index = 0xFFFF; |
| 1652 | |
| 1653 | while (true) { |
| 1654 | Team *t; |
| 1655 | |
| 1656 | t = Team_Find(&find); |
| 1657 | if (t == NULL) break; |
| 1658 | |
| 1659 | if (t->target == encoded) t->target = 0; |
| 1660 | } |
| 1661 | } |
| 1662 | |
| 1663 | /** |
| 1664 | * Set the new orientation of the unit. |
no test coverage detected