|
23 | 23 | #include "wing.h" |
24 | 24 |
|
25 | 25 | #include "ai/aigoals.h" |
| 26 | +#include "ai/ai.h" |
26 | 27 | #include "globalincs/utility.h" |
27 | 28 | #include "hud/hudets.h" |
28 | 29 | #include "hud/hudshield.h" |
@@ -1610,6 +1611,48 @@ ADE_FUNC(fireSecondary, l_Ship, NULL, "Fires ship secondary bank(s)", "number", |
1610 | 1611 | return ade_set_args(L, "i", ship_fire_secondary(objh->objp(), 0)); |
1611 | 1612 | } |
1612 | 1613 |
|
| 1614 | +ADE_FUNC(callSupport, |
| 1615 | + l_Ship, |
| 1616 | + nullptr, |
| 1617 | + "Forces this ship to request support rearm/repair if it's a valid ship type, not docked, and support is allowed.", |
| 1618 | + "boolean", |
| 1619 | + "True if a support request was issued, false otherwise") |
| 1620 | +{ |
| 1621 | + object_h* objh; |
| 1622 | + if (!ade_get_args(L, "o", l_Ship.GetPtr(&objh))) { |
| 1623 | + return ade_set_error(L, "b", false); |
| 1624 | + } |
| 1625 | + |
| 1626 | + if (!objh->isValid()) { |
| 1627 | + return ade_set_error(L, "b", false); |
| 1628 | + } |
| 1629 | + |
| 1630 | + auto objp = objh->objp(); |
| 1631 | + auto shipp = &Ships[objp->instance]; |
| 1632 | + auto aip = &Ai_info[shipp->ai_index]; |
| 1633 | + auto sip = &Ship_info[shipp->ship_info_index]; |
| 1634 | + |
| 1635 | + if (!sip->is_fighter_bomber()) { |
| 1636 | + return ADE_RETURN_FALSE; |
| 1637 | + } |
| 1638 | + |
| 1639 | + if (aip->ai_flags[AI::AI_Flags::Being_repaired, AI::AI_Flags::Awaiting_repair]) { |
| 1640 | + return ADE_RETURN_FALSE; |
| 1641 | + } |
| 1642 | + |
| 1643 | + if (object_is_docked(objp)) { |
| 1644 | + return ADE_RETURN_FALSE; |
| 1645 | + } |
| 1646 | + |
| 1647 | + if (!is_support_allowed(objp)) { |
| 1648 | + return ADE_RETURN_FALSE; |
| 1649 | + } |
| 1650 | + |
| 1651 | + ai_issue_rearm_request(objp); |
| 1652 | + |
| 1653 | + return ADE_RETURN_TRUE; |
| 1654 | +} |
| 1655 | + |
1613 | 1656 | ADE_FUNC_DEPRECATED(getAnimationDoneTime, l_Ship, "number Type, number Subtype", "Gets time that animation will be done", "number", "Time (seconds), or 0 if ship handle is invalid", |
1614 | 1657 | gameversion::version(22, 0, 0, 0), |
1615 | 1658 | "To account for the new animation tables, please use getSubmodelAnimationTime()") |
|
0 commit comments