Following zookeepers' example I'll reuse this topic and post a list of features for review. I'm planning to add a few more things.
Ship orders access for scripting including modification of some values of an order ( shiporder = ship.Orders, order = shiporders[1], order:getType(), order.Priority, order.Target, order.TargetSubsystem, order:remove() ). Is partially based in zookeepers' patch.
Index: code/parse/lua.cpp
===================================================================
--- code/parse/lua.cpp (revision 10284)
+++ code/parse/lua.cpp (working copy)
@@ -522,7 +522,7 @@
//that any new enumerations have indexes of NEXT INDEX (see below)
//or after. Don't forget to increment NEXT INDEX after you're done.
//=====================================
-static const int ENUM_NEXT_INDEX = 69; // <<<<<<<<<<<<<<<<<<<<<<
+static const int ENUM_NEXT_INDEX = 71; // <<<<<<<<<<<<<<<<<<<<<<
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
static flag_def_list Enumerations[] = {
#define LE_ALPHABLEND_FILTER 14
@@ -603,6 +603,12 @@
#define LE_ORDER_WAYPOINTS_ONCE 46
{ "ORDER_WAYPOINTS_ONCE", LE_ORDER_WAYPOINTS_ONCE, 0},
+ #define LE_ORDER_ATTACK_WING 69
+ { "ORDER_ATTACK_WING", LE_ORDER_ATTACK_WING, 0},
+
+ #define LE_ORDER_GUARD_WING 70
+ { "ORDER_GUARD_WING", LE_ORDER_GUARD_WING, 0},
+
#define LE_PARTICLE_DEBUG 4
{ "PARTICLE_DEBUG", LE_PARTICLE_DEBUG, 0},
@@ -2434,133 +2440,6 @@
return ade_set_args(L, "b", dbh->IsValid());
}
-//**********HANDLE: order
-struct order_h
-{
- object_h objh;
- int odx;
- int sig;
-
- order_h() {
- objh = object_h();
- odx = -1;
- sig = -1;
- }
-
- order_h(object *objp, int n_odx)
- {
- objh = object_h(objp);
- if(objh.IsValid() && objh.objp->type == OBJ_SHIP && n_odx > -1 && n_odx < MAX_AI_GOALS)
- {
- odx = n_odx;
- sig = Ai_info[Ships[objh.objp->instance].ai_index].goals[odx].signature;
- }
- else
- {
- odx = -1;
- sig = -1;
- }
- }
-
- bool IsValid()
- {
- return (this != NULL && objh.IsValid() && objh.objp->type == OBJ_SHIP && odx > -1 && odx < MAX_AI_GOALS && sig == Ai_info[Ships[objh.objp->instance].ai_index].goals[odx].signature);
- }
-};
-
-ade_obj<order_h> l_Order("order", "order handle");
-
-ADE_FUNC(remove, l_Order, NULL, "Removes the given order from the ship's priority queue.", "boolean", "True if order was successfully removed, otherwise false or nil.")
-{
- order_h *ohp = NULL;
- if(!ade_get_args(L, "o", l_Order.GetPtr(&ohp)))
- return ADE_RETURN_NIL;
-
- if(!ohp->IsValid())
- return ADE_RETURN_FALSE;
-
- ai_info *aip = &Ai_info[Ships[ohp->objh.objp->instance].ai_index];
-
- ai_remove_ship_goal(aip, ohp->odx);
-
- return ADE_RETURN_TRUE;
-}
-
-//**********HANDLE: shiporders
-ade_obj<object_h> l_ShipOrders("shiporders", "Ship orders");
-
-ADE_FUNC(__len, l_ShipOrders, NULL, "Number of textures on ship", "number", "Number of textures on ship, or 0 if handle is invalid")
-{
- object_h *objh = NULL;
- if(!ade_get_args(L, "o", l_ShipOrders.GetPtr(&objh)))
- return ade_set_error(L, "i", 0);
-
- if(!objh->IsValid() || objh->objp->type != OBJ_SHIP || Ships[objh->objp->instance].ai_index < 0)
- return ade_set_error(L, "i", 0);
-
- return ade_set_args(L, "i", ai_goal_num(&Ai_info[Ships[objh->objp->instance].ai_index].goals[0]));
-}
-
-ADE_INDEXER(l_ShipOrders, "number Index/string TextureFilename", "Array of ship orders", "order", "Order, or invalid texture handle on failure")
-{
- object_h *objh = NULL;
- char *s = NULL;
- order_h *oh = NULL;
- int i;
-
- if (!ade_get_args(L, "os|o", l_ShipOrders.GetPtr(&objh), &s, l_Order.GetPtr(&oh)))
- return ade_set_error(L, "o", l_Order.Set(order_h()));
-
- if (!objh->IsValid() || s==NULL)
- return ade_set_error(L, "o", l_Order.Set(order_h()));
-
- ai_info *aip = &Ai_info[Ships[objh->objp->instance].ai_index];
-
- //Determine index
- int idx = atoi(s) - 1; //Lua->FS2
-
- if (idx < 0 || idx >= MAX_AI_GOALS)
- return ade_set_error(L, "o", l_Order.Set(order_h()));
-
- int num = 0;
- for(i = 0; i < MAX_AI_GOALS; i++)
- {
- if(aip->goals[i].ai_mode != AI_GOAL_NONE)
- {
- if(idx == num)
- break;
-
- num++;
- }
- }
-
- if(i >= MAX_AI_GOALS)
- return ade_set_error(L, "o", l_Order.Set(order_h()));
-
- if (ADE_SETTING_VAR)
- {
- if(!oh->IsValid())
- {
- ai_remove_ship_goal(aip, i);
- }
- else
- {
- aip->goals[i] = Ai_info[Ships[oh->objh.objp->instance].ai_index].goals[oh->odx];
- }
- }
-
- return ade_set_args(L, "o", l_Order.Set(order_h(objh->objp, i)));
-}
-
-ADE_FUNC(isValid, l_ShipOrders, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs")
-{
- object_h *oh;
- if(!ade_get_args(L, "o", l_ShipOrders.GetPtr(&oh)))
- return ADE_RETURN_NIL;
-
- return ade_set_args(L, "b", oh->IsValid());
-}
-
//**********HANDLE: physics
struct physics_info_h
{
@@ -7596,7 +7475,411 @@
return ade_set_args(L, "b", sso->IsValid());
}
+//**********HANDLE: order
+struct order_h
+{
+ object_h objh;
+ int odx;
+ int sig;
+ ai_goal *aigp;
+ order_h() {
+ objh = object_h();
+ odx = -1;
+ sig = -1;
+ aigp = NULL;
+ }
+
+ order_h(object *objp, int n_odx)
+ {
+ objh = object_h(objp);
+ if(objh.IsValid() && objh.objp->type == OBJ_SHIP && n_odx > -1 && n_odx < MAX_AI_GOALS)
+ {
+ odx = n_odx;
+ sig = Ai_info[Ships[objh.objp->instance].ai_index].goals[odx].signature;
+ aigp = &Ai_info[Ships[objh.objp->instance].ai_index].goals[odx];
+ }
+ else
+ {
+ odx = -1;
+ sig = -1;
+ aigp = NULL;
+ }
+ }
+
+ bool IsValid()
+ {
+ if (objh.objp == NULL || aigp == NULL)
+ return false;
+
+ return (this != NULL && objh.IsValid() && objh.objp->type == OBJ_SHIP && odx > -1 && odx < MAX_AI_GOALS && sig == Ai_info[Ships[objh.objp->instance].ai_index].goals[odx].signature);
+ }
+};
+
+ade_obj<order_h> l_Order("order", "order handle");
+
+ADE_VIRTVAR(Priority, l_Order, "number", "Priority of the given order", "number", "Order priority or 0 if invalid")
+{
+ order_h *ohp = NULL;
+ int priority = 1;
+
+ if(!ade_get_args(L, "o|i", l_Order.GetPtr(&ohp), &priority))
+ return ade_set_error(L, "i", 0);
+
+ if(!ohp->IsValid())
+ return ade_set_error(L, "i", 0);
+
+ if(ADE_SETTING_VAR) {
+ ohp->aigp->priority = priority;
+ }
+
+ return ade_set_args(L, "i", ohp->aigp->priority);
+}
+
+ADE_FUNC(remove, l_Order, NULL, "Removes the given order from the ship's priority queue.", "boolean", "True if order was successfully removed, otherwise false or nil.")
+{
+ order_h *ohp = NULL;
+ if(!ade_get_args(L, "o", l_Order.GetPtr(&ohp)))
+ return ADE_RETURN_NIL;
+
+ if(!ohp->IsValid())
+ return ADE_RETURN_FALSE;
+
+ ai_info *aip = &Ai_info[Ships[ohp->objh.objp->instance].ai_index];
+
+ ai_remove_ship_goal(aip, ohp->odx);
+
+ return ADE_RETURN_TRUE;
+}
+
+ADE_FUNC(getType, l_Order, NULL, "Gets the type of the order.", "enumeration", "The type of the order as one of the ORDER_* enumerations.")
+{
+ order_h *ohp = NULL;
+ int eh_idx = -1;
+ if(!ade_get_args(L, "o", l_Order.GetPtr(&ohp)))
+ return ade_set_error(L, "o", l_Enum.Set(enum_h()));
+
+ if(!ohp->IsValid())
+ return ade_set_error(L, "o", l_Enum.Set(enum_h()));
+
+ switch(ohp->aigp->ai_mode){
+ case AI_GOAL_DESTROY_SUBSYSTEM:
+ case AI_GOAL_CHASE_WEAPON:
+ case AI_GOAL_CHASE:
+ eh_idx = LE_ORDER_ATTACK;
+ break;
+ case AI_GOAL_DOCK:
+ eh_idx = LE_ORDER_DOCK;
+ break;
+ case AI_GOAL_WAYPOINTS:
+ eh_idx = LE_ORDER_WAYPOINTS;
+ break;
+ case AI_GOAL_WAYPOINTS_ONCE:
+ eh_idx = LE_ORDER_WAYPOINTS_ONCE;
+ break;
+ case AI_GOAL_WARP:
+ eh_idx = LE_ORDER_DEPART;
+ break;
+ case AI_GOAL_FORM_ON_WING:
+ eh_idx = LE_ORDER_FORM_ON_WING;
+ break;
+ case AI_GOAL_UNDOCK:
+ eh_idx = LE_ORDER_UNDOCK;
+ break;
+ case AI_GOAL_GUARD:
+ eh_idx = LE_ORDER_GUARD;
+ break;
+ case AI_GOAL_DISABLE_SHIP:
+ eh_idx = LE_ORDER_DISABLE;
+ break;
+ case AI_GOAL_DISARM_SHIP:
+ eh_idx = LE_ORDER_DISARM;
+ break;
+ case AI_GOAL_CHASE_ANY:
+ eh_idx = LE_ORDER_ATTACK_ANY;
+ break;
+ case AI_GOAL_IGNORE_NEW:
+ case AI_GOAL_IGNORE:
+ eh_idx = LE_ORDER_IGNORE;
+ break;
+ case AI_GOAL_EVADE_SHIP:
+ eh_idx = LE_ORDER_EVADE;
+ break;
+ case AI_GOAL_STAY_NEAR_SHIP:
+ eh_idx = LE_ORDER_STAY_NEAR;
+ break;
+ case AI_GOAL_KEEP_SAFE_DISTANCE:
+ eh_idx = LE_ORDER_KEEP_SAFE_DISTANCE;
+ break;
+ case AI_GOAL_REARM_REPAIR:
+ eh_idx = LE_ORDER_REARM;
+ break;
+ case AI_GOAL_STAY_STILL:
+ eh_idx = LE_ORDER_STAY_STILL;
+ break;
+ case AI_GOAL_PLAY_DEAD:
+ eh_idx = LE_ORDER_PLAY_DEAD;
+ break;
+ case AI_GOAL_FLY_TO_SHIP:
+ eh_idx = LE_ORDER_FLY_TO;
+ break;
+ case AI_GOAL_CHASE_WING:
+ eh_idx = LE_ORDER_ATTACK_WING;
+ break;
+ case AI_GOAL_GUARD_WING:
+ eh_idx = LE_ORDER_GUARD_WING;
+ break;
+ }
+
+ return ade_set_args(L, "o", l_Enum.Set(eh_idx));
+}
+
+ADE_VIRTVAR(Target, l_Order, "object", "Target of the order. Value may also be a deriviative of the 'object' class, such as 'ship'.", "object", "Target object or invalid object handle if order handle is invalid or order requires no target.")
+{
+ order_h *ohp = NULL;
+ object_h *newh = NULL;
+ ai_info *aip = NULL;
+ waypoint_list *wpl = NULL;
+ int shipnum = -1, objnum = -1;
+ if(!ade_get_args(L, "o|o", l_Order.GetPtr(&ohp), l_Object.GetPtr(&newh)))
+ return ade_set_error(L, "o", l_Object.Set(object_h()));
+
+ if(!ohp->IsValid())
+ return ade_set_error(L, "o", l_Object.Set(object_h()));
+
+ aip = &Ai_info[Ships[ohp->objh.objp->instance].ai_index];
+
+ if(ADE_SETTING_VAR){
+ if(newh->IsValid()){
+ switch(ohp->aigp->ai_mode){
+ case AI_GOAL_DESTROY_SUBSYSTEM:
+ case AI_GOAL_CHASE:
+ case AI_GOAL_FORM_ON_WING:
+ case AI_GOAL_GUARD:
+ case AI_GOAL_DISABLE_SHIP:
+ case AI_GOAL_DISARM_SHIP:
+ case AI_GOAL_IGNORE_NEW:
+ case AI_GOAL_IGNORE:
+ case AI_GOAL_EVADE_SHIP:
+ case AI_GOAL_STAY_NEAR_SHIP:
+ case AI_GOAL_KEEP_SAFE_DISTANCE:
+ case AI_GOAL_FLY_TO_SHIP:
+ case AI_GOAL_STAY_STILL:
+ if ((newh->objp->type == OBJ_SHIP) && !stricmp(Ships[newh->objp->instance].ship_name, ohp->aigp->target_name)){
+ ohp->aigp->target_name = Ships[newh->objp->instance].ship_name;
+ ohp->aigp->time = Missiontime;
+ if(ohp->odx == 0) {
+ aip->ok_to_target_timestamp = timestamp(0);
+ set_target_objnum(aip, OBJ_INDEX(newh->objp));
+ }
+ }
+ break;
+ case AI_GOAL_CHASE_WEAPON:
+ if ((newh->objp->type == OBJ_WEAPON) && (ohp->aigp->target_signature != newh->sig)){
+ ohp->aigp->target_instance = newh->objp->instance;
+ ohp->aigp->target_signature = Weapons[newh->objp->instance].objnum;
+ ohp->aigp->time = Missiontime;
+ if(ohp->odx == 0) {
+ aip->ok_to_target_timestamp = timestamp(0);
+ set_target_objnum(aip, OBJ_INDEX(newh->objp));
+ }
+ }
+ break;
+ case AI_GOAL_WAYPOINTS:
+ case AI_GOAL_WAYPOINTS_ONCE:
+ if (newh->objp->type == OBJ_WAYPOINT){
+ waypoint_list *wpl = find_waypoint_list_with_instance(newh->objp->instance);
+ if (!stricmp(wpl->get_name(),ohp->aigp->target_name)){
+ ohp->aigp->target_name = wpl->get_name();
+ ohp->aigp->time = Missiontime;
+ if(ohp->odx == 0) {
+ int flags = 0;
+ if ( ohp->aigp->ai_mode == AI_GOAL_WAYPOINTS)
+ flags |= WPF_REPEAT;
+ ai_start_waypoints(ohp->objh.objp, wpl, flags);
+ }
+ }
+ }
+ break;
+ case AI_GOAL_CHASE_WING:
+ if((newh->objp->type == OBJ_SHIP) && !stricmp(Ships[newh->objp->instance].ship_name, ohp->aigp->target_name)){
+ ship *shipp = &Ships[newh->objp->instance];
+ if (shipp->wingnum != -1){
+ ohp->aigp->target_name = Wings[shipp->wingnum].name;
+ if(ohp->odx == 0) {
+ aip->ok_to_target_timestamp = timestamp(0);
+ ai_attack_wing(ohp->objh.objp,shipp->wingnum);
+ }
+ }
+ }
+ break;
+ case AI_GOAL_GUARD_WING:
+ if((newh->objp->type == OBJ_SHIP) && !stricmp(Ships[newh->objp->instance].ship_name, ohp->aigp->target_name)){
+ ship *shipp = &Ships[newh->objp->instance];
+ if (shipp->wingnum != -1){
+ ohp->aigp->target_name = Wings[shipp->wingnum].name;
+ if(ohp->odx == 0) {
+ aip->ok_to_target_timestamp = timestamp(0);
+ ai_set_guard_wing(ohp->objh.objp,shipp->wingnum);
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ switch(ohp->aigp->ai_mode){
+ case AI_GOAL_DESTROY_SUBSYSTEM:
+ case AI_GOAL_CHASE:
+ case AI_GOAL_DOCK:
+ case AI_GOAL_FORM_ON_WING:
+ case AI_GOAL_GUARD:
+ case AI_GOAL_DISABLE_SHIP:
+ case AI_GOAL_DISARM_SHIP:
+ case AI_GOAL_IGNORE_NEW:
+ case AI_GOAL_IGNORE:
+ case AI_GOAL_EVADE_SHIP:
+ case AI_GOAL_STAY_NEAR_SHIP:
+ case AI_GOAL_KEEP_SAFE_DISTANCE:
+ case AI_GOAL_REARM_REPAIR:
+ case AI_GOAL_FLY_TO_SHIP:
+ case AI_GOAL_UNDOCK:
+ shipnum = ship_name_lookup(ohp->aigp->target_name);
+ objnum = Ships[shipnum].objnum;
+ break;
+ case AI_GOAL_CHASE_WEAPON:
+ objnum = Weapons[ohp->aigp->target_instance].objnum;
+ break;
+ case AI_GOAL_WAYPOINTS:
+ case AI_GOAL_WAYPOINTS_ONCE:
+ wpl = find_matching_waypoint_list(ohp->aigp->target_name);
+ if(ohp->odx == 0) {
+ objnum = aip->wp_list->get_waypoints()[aip->wp_index].get_objnum();
+ } else {
+ objnum = wpl->get_waypoints().front().get_objnum();
+ }
+ break;
+ case AI_GOAL_STAY_STILL:
+ shipnum = ship_name_lookup(ohp->aigp->target_name);
+ if (shipnum != -1){
+ objnum = Ships[shipnum].objnum;
+ break;
+ }
+ case AI_GOAL_CHASE_WING:
+ case AI_GOAL_GUARD_WING:
+ int wingnum = wing_name_lookup(ohp->aigp->target_name);
+ if (Wings[wingnum].current_count > 0){
+ shipnum = Wings[wingnum].ship_index[0];
+ objnum = Ships[shipnum].objnum;
+ }
+ break;
+ }
+
+ return ade_set_object_with_breed(L, objnum);
+}
+
+
+ADE_VIRTVAR(TargetSubsystem, l_Order, "subsystem", "Target subsystem of the order.", "subsystem", "Target subsystem, or invalid subsystem handle if order handle is invalid or order requires no subsystem target.")
+{
+ order_h *ohp = NULL;
+ ship_subsys_h *newh = NULL;
+ ai_info *aip = NULL;
+ object *objp = NULL;
+ if(!ade_get_args(L, "o|o", l_Order.GetPtr(&ohp), l_Subsystem.GetPtr(&newh)))
+ return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h()));
+
+ if(!ohp->IsValid())
+ return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h()));
+
+ aip = &Ai_info[Ships[ohp->objh.objp->instance].ai_index];
+
+ if(ADE_SETTING_VAR)
+ {
+ if(newh->IsValid() && (ohp->aigp->ai_mode == AI_GOAL_DESTROY_SUBSYSTEM))
+ {
+ objp = &Objects[newh->ss->parent_objnum];
+ if(!stricmp(Ships[objp->instance].ship_name, ohp->aigp->target_name)) {
+ ohp->aigp->target_name = Ships[objp->instance].ship_name;
+ ohp->aigp->time = Missiontime;
+ if(ohp->odx == 0) {
+ aip->ok_to_target_timestamp = timestamp(0);
+ set_target_objnum(aip, OBJ_INDEX(objp));
+ }
+ }
+ ohp->aigp->ai_submode = ship_get_subsys_index( &Ships[objp->instance], newh->ss->system_info->subobj_name );
+ if(ohp->odx == 0) {
+ set_targeted_subsys(aip, newh->ss, OBJ_INDEX(objp));
+ }
+ if (aip == Player_ai) {
+ Ships[newh->ss->parent_objnum].last_targeted_subobject[Player_num] = newh->ss;
+ }
+ }
+ }
+
+ if(ohp->aigp->ai_mode == AI_GOAL_DESTROY_SUBSYSTEM){
+ return ade_set_args(L, "o", l_Subsystem.Set(ship_subsys_h(&Objects[Ships[ship_name_lookup(ohp->aigp->target_name)].objnum], ship_get_indexed_subsys(&Ships[ship_name_lookup(ohp->aigp->target_name)],ohp->aigp->ai_submode))));
+ } else {
+ return ade_set_error(L, "o", l_Subsystem.Set(ship_subsys_h()));
+ }
+}
+
+ADE_FUNC(isValid, l_Order, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs")
+{
+ order_h *ohp = NULL;
+ if(!ade_get_args(L, "o", l_Order.GetPtr(&ohp)))
+ return ADE_RETURN_NIL;
+
+ return ade_set_args(L, "b", ohp->IsValid());
+}
+
+//**********HANDLE: shiporders
+ade_obj<object_h> l_ShipOrders("shiporders", "Ship orders");
+
+ADE_FUNC(__len, l_ShipOrders, NULL, "Number of ship orders", "number", "Number of ship orders, or 0 if handle is invalid")
+{
+ object_h *objh = NULL;
+ if(!ade_get_args(L, "o", l_ShipOrders.GetPtr(&objh)))
+ return ade_set_error(L, "i", 0);
+
+ if(!objh->IsValid() || objh->objp->type != OBJ_SHIP || Ships[objh->objp->instance].ai_index < 0)
+ return ade_set_error(L, "i", 0);
+
+ return ade_set_args(L, "i", ai_goal_num(&Ai_info[Ships[objh->objp->instance].ai_index].goals[0]));
+}
+
+ADE_INDEXER(l_ShipOrders, "number Index", "Array of ship orders", "order", "Order, or invalid order handle on failure")
+{
+ object_h *objh = NULL;
+ int i;
+
+ if (!ade_get_args(L, "oi", l_ShipOrders.GetPtr(&objh), &i))
+ return ade_set_error(L, "o", l_Order.Set(order_h()));
+
+ i--; //Lua->FS2
+
+ if (!objh->IsValid() || i < 0 || i >= MAX_AI_GOALS)
+ return ade_set_error(L, "o", l_Order.Set(order_h()));
+
+ ai_info *aip = &Ai_info[Ships[objh->objp->instance].ai_index];
+
+ if (aip->goals[i].ai_mode != AI_GOAL_NONE)
+ return ade_set_args(L, "o", l_Order.Set(order_h(objh->objp, i)));
+ else
+ return ade_set_args(L, "o", l_Order.Set(order_h()));
+}
+
+ADE_FUNC(isValid, l_ShipOrders, NULL, "Detects whether handle is valid", "boolean", "true if valid, false if handle is invalid, nil if a syntax/type error occurs")
+{
+ object_h *oh;
+ if(!ade_get_args(L, "o", l_ShipOrders.GetPtr(&oh)))
+ return ADE_RETURN_NIL;
+
+ return ade_set_args(L, "b", oh->IsValid());
+}
+
+
+
//**********HANDLE: shiptextures
ade_obj<object_h> l_ShipTextures("shiptextures", "Ship textures handle");
@@ -8587,6 +8870,24 @@
return ade_set_args(L, "i", Ships[objh->objp->instance].weapon_recharge_index);
}
+ADE_VIRTVAR(Orders, l_Ship, "shiporders", "Array of ship orders", "shiporders", "Ship orders, or invalid handle if ship handle is invalid")
+{
+ object_h *objh = NULL;
+ object_h *newh = NULL;
+ if(!ade_get_args(L, "o|o", l_Ship.GetPtr(&objh), l_ShipOrders.GetPtr(&newh)))
+ return ade_set_error(L, "o", l_ShipOrders.Set(object_h()));
+
+ if(!objh->IsValid())
+ return ade_set_error(L, "o", l_ShipOrders.Set(object_h()));;
+
+ if(ADE_SETTING_VAR)
+ {
+ LuaError(L, "Attempted to use incomplete feature: Ai orders copy. Use giveOrder instead");
+ }
+
+ return ade_set_args(L, "o", l_ShipOrders.Set(object_h(objh->objp)));
+}
+
ADE_FUNC(kill, l_Ship, "[object Killer]", "Kills the ship. Set \"Killer\" to the ship you are killing to self-destruct", "boolean", "True if successful, false or nil otherwise")
{
object_h *victim,*killer=NULL;
@@ -8947,6 +9248,35 @@
}
break;
}
+ case LE_ORDER_ATTACK_WING:
+ {
+ if(tgh_valid && tgh->objp->type == OBJ_SHIP)
+ {
+ ship *shipp = &Ships[tgh->objp->instance];
+ if (shipp->wingnum != -1)
+ {
+ ai_mode = AI_GOAL_CHASE_WING;
+ ai_shipname = Wings[shipp->wingnum].name;
+ ai_submode = SM_ATTACK;
+ }
+ }
+ break;
+ }
+ case LE_ORDER_GUARD_WING:
+ {
+ if(tgh_valid && tgh->objp->type == OBJ_SHIP)
+ {
+ ship *shipp = &Ships[tgh->objp->instance];
+ if (shipp->wingnum != -1)
+ {
+ ai_mode = AI_GOAL_GUARD_WING;
+ ai_shipname = Wings[shipp->wingnum].name;
+ ai_submode = AIS_GUARD_STATIC;
+ }
+ }
+
+ break;
+ }
}
//Nothing got set!