Skip to content

Commit 939d6a5

Browse files
committed
additional fix for STAY_NEAR_TARGET_ITEM
When issuing the stay-near-target order via hud squad message, default to a distance of 300, the same as the sexp.
1 parent 3783cb0 commit 939d6a5

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

code/ai/aigoals.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -732,12 +732,14 @@ void ai_goal_fixup_dockpoints(ai_info *aip, ai_goal *aigp)
732732
// from the mission goals (i.e. those goals which come from events) in that we don't
733733
// use sexpressions for goals from the player...so we enumerate all the parameters
734734

735-
void ai_add_goal_sub_player(ai_goal_type type, ai_goal_mode mode, int submode, const char *target_name, ai_goal *aigp, const ai_lua_parameters& lua_target )
735+
void ai_add_goal_sub_player(ai_goal_type type, ai_goal_mode mode, int submode, const char *target_name, ai_goal *aigp, int int_data, float float_data, const ai_lua_parameters& lua_target )
736736
{
737737
Assert ( (type == ai_goal_type::PLAYER_WING) || (type == ai_goal_type::PLAYER_SHIP) );
738738

739739
ai_goal_reset(aigp, true, mode, submode, type);
740740

741+
aigp->int_data = int_data;
742+
aigp->float_data = float_data;
741743
aigp->lua_ai_target = lua_target;
742744

743745
if ( mode == AI_GOAL_WARP ) {
@@ -865,14 +867,14 @@ void ai_add_ship_goal_scripting(ai_goal_mode mode, int submode, int priority, co
865867
// is issued to ship or wing (from player), mode is AI_GOAL_*. submode is the submode the
866868
// ship should go into. shipname is the object of the action. aip is the ai_info pointer
867869
// of the ship receiving the order
868-
void ai_add_ship_goal_player(ai_goal_type type, ai_goal_mode mode, int submode, const char *shipname, ai_info *aip, const ai_lua_parameters& lua_target)
870+
void ai_add_ship_goal_player(ai_goal_type type, ai_goal_mode mode, int submode, const char *shipname, ai_info *aip, int int_data, float float_data, const ai_lua_parameters& lua_target)
869871
{
870872
int empty_index;
871873
ai_goal *aigp;
872874

873875
empty_index = ai_goal_find_empty_slot( aip->goals, aip->active_goal );
874876
aigp = &aip->goals[empty_index];
875-
ai_add_goal_sub_player( type, mode, submode, shipname, aigp, lua_target );
877+
ai_add_goal_sub_player( type, mode, submode, shipname, aigp, int_data, float_data, lua_target );
876878

877879
// if the goal is to dock, then we must determine which dock points on the two ships to use.
878880
// If the target of the dock is a cargo type container, then we should use DOCK_TYPE_CARGO
@@ -886,7 +888,7 @@ void ai_add_ship_goal_player(ai_goal_type type, ai_goal_mode mode, int submode,
886888

887889
// adds a goal from the player to the given wing (which in turn will add it to the proper
888890
// ships in the wing
889-
void ai_add_wing_goal_player(ai_goal_type type, ai_goal_mode mode, int submode, const char *shipname, int wingnum, const ai_lua_parameters& lua_target)
891+
void ai_add_wing_goal_player(ai_goal_type type, ai_goal_mode mode, int submode, const char *shipname, int wingnum, int int_data, float float_data, const ai_lua_parameters& lua_target)
890892
{
891893
int i, empty_index;
892894
wing *wingp = &Wings[wingnum];
@@ -897,15 +899,15 @@ void ai_add_wing_goal_player(ai_goal_type type, ai_goal_mode mode, int submode,
897899
int num = wingp->ship_index[i];
898900
if ( num == -1 ) // ship must have been destroyed or departed
899901
continue;
900-
ai_add_ship_goal_player( type, mode, submode, shipname, &Ai_info[Ships[num].ai_index], lua_target );
902+
ai_add_ship_goal_player( type, mode, submode, shipname, &Ai_info[Ships[num].ai_index], int_data, float_data, lua_target );
901903
}
902904
}
903905

904906
// add the sexpression index into the wing's list of goal sexpressions if
905907
// there are more waves to come. We use the same method here as when adding a goal to
906908
// a ship -- find the first empty entry. If none exists, take the oldest entry and replace it.
907909
empty_index = ai_goal_find_empty_slot( wingp->ai_goals, -1 );
908-
ai_add_goal_sub_player( type, mode, submode, shipname, &wingp->ai_goals[empty_index], lua_target );
910+
ai_add_goal_sub_player( type, mode, submode, shipname, &wingp->ai_goals[empty_index], int_data, float_data, lua_target );
909911
}
910912

911913

code/ai/aigoals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ extern int ai_remove_goal_sexp_sub( int sexp, ai_goal* aigp, bool &remove_more )
185185
extern void ai_remove_wing_goal_sexp( int sexp, wing *wingp );
186186

187187
// adds goals to ships/sings through player orders
188-
extern void ai_add_ship_goal_player(ai_goal_type type, ai_goal_mode mode, int submode, const char* shipname, ai_info* aip, const ai_lua_parameters& lua_target = { object_ship_wing_point_team(), luacpp::LuaValueList{} });
189-
extern void ai_add_wing_goal_player(ai_goal_type type, ai_goal_mode mode, int submode, const char* shipname, int wingnum, const ai_lua_parameters& lua_target = { object_ship_wing_point_team(), luacpp::LuaValueList{} });
188+
extern void ai_add_ship_goal_player(ai_goal_type type, ai_goal_mode mode, int submode, const char* shipname, ai_info* aip, int int_data = 0, float float_data = 0.0f, const ai_lua_parameters& lua_target = { object_ship_wing_point_team(), luacpp::LuaValueList{} });
189+
extern void ai_add_wing_goal_player(ai_goal_type type, ai_goal_mode mode, int submode, const char* shipname, int wingnum, int int_data = 0, float float_data = 0.0f, const ai_lua_parameters& lua_target = { object_ship_wing_point_team(), luacpp::LuaValueList{} });
190190

191191
extern void ai_remove_ship_goal( ai_info *aip, int index );
192192
extern void ai_clear_ship_goals( ai_info *aip );

code/hud/hudsquadmsg.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,8 @@ int hud_squadmsg_send_ship_command( int shipnum, int command, int send_message,
10991099
int ai_submode; // ...and submode needed for ship commands
11001100
ship *target = nullptr;
11011101
char *target_shipname;
1102+
int int_data = 0;
1103+
float float_data = 0.0f;
11021104
ai_lua_parameters lua_target;
11031105
int message;
11041106
int target_team, ship_team; // team id's for the ship getting message and any target the player has
@@ -1322,6 +1324,7 @@ int hud_squadmsg_send_ship_command( int shipnum, int command, int send_message,
13221324
case STAY_NEAR_TARGET_ITEM:
13231325
ai_mode = AI_GOAL_STAY_NEAR_SHIP;
13241326
ai_submode = -1;
1327+
float_data = 300.0f; // distance from target ship
13251328
message = MESSAGE_YESSIR;
13261329
if (command == STAY_NEAR_ME_ITEM) {
13271330
target_shipname = ordering_shipp->ship_name;
@@ -1351,7 +1354,7 @@ int hud_squadmsg_send_ship_command( int shipnum, int command, int send_message,
13511354
// handle case of messaging one ship. Deal with messaging all fighters next.
13521355
if (ai_mode != AI_GOAL_NONE) {
13531356
Assert(ai_submode != -1234567);
1354-
ai_add_ship_goal_player(ai_goal_type::PLAYER_SHIP, ai_mode, ai_submode, target_shipname, &Ai_info[Ships[shipnum].ai_index], lua_target);
1357+
ai_add_ship_goal_player(ai_goal_type::PLAYER_SHIP, ai_mode, ai_submode, target_shipname, &Ai_info[Ships[shipnum].ai_index], int_data, float_data, lua_target);
13551358
if (update_history == SQUADMSG_HISTORY_ADD_ENTRY) {
13561359
hud_add_issued_order(Ships[shipnum].ship_name, command);
13571360
hud_update_last_order(target_shipname, player_num, special_index);
@@ -1391,6 +1394,8 @@ int hud_squadmsg_send_wing_command( int wingnum, int command, int send_message,
13911394
int ai_submode; // ...and submode needed for ship commands
13921395
ship *target = nullptr;
13931396
char *target_shipname;
1397+
int int_data = 0;
1398+
float float_data = 0.0f;
13941399
ai_lua_parameters lua_target;
13951400
int message_sent, message;
13961401
int target_team, wing_team; // team for the wing and the player's target
@@ -1575,7 +1580,7 @@ int hud_squadmsg_send_wing_command( int wingnum, int command, int send_message,
15751580

15761581
if (ai_mode != AI_GOAL_NONE) {
15771582
Assert(ai_submode != -1234567);
1578-
ai_add_wing_goal_player(ai_goal_type::PLAYER_WING, ai_mode, ai_submode, target_shipname, wingnum, lua_target);
1583+
ai_add_wing_goal_player(ai_goal_type::PLAYER_WING, ai_mode, ai_submode, target_shipname, wingnum, int_data, float_data, lua_target);
15791584

15801585
if (update_history == SQUADMSG_HISTORY_ADD_ENTRY) {
15811586
hud_add_issued_order(Wings[wingnum].name, command);

0 commit comments

Comments
 (0)