Skip to content

Commit 73e82d9

Browse files
authored
Merge pull request #6786 from Goober5000/schroedinger_goals
schroedinger AI goals
2 parents 6a1ae81 + 0353348 commit 73e82d9

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

code/ai/aigoals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ enum class ai_goal_type
4747
enum ai_goal_mode : uint8_t
4848
{
4949
AI_GOAL_NONE = 0,
50-
AI_GOAL_PLACEHOLDER_1,
50+
AI_GOAL_SCHROEDINGER, // used for FRED when multiple ships are selected with different orders
5151

5252
AI_GOAL_CHASE, // per the original #define list, AI_GOAL_CHASE started at 2 (1<<1)
5353
AI_GOAL_DOCK, // used for undocking as well

code/scripting/api/objs/order.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ ADE_FUNC(getType, l_Order, NULL, "Gets the type of the order.", "enumeration", "
9191

9292
switch(ohp->aigp->ai_mode){
9393
case AI_GOAL_NONE:
94-
case AI_GOAL_PLACEHOLDER_1:
94+
case AI_GOAL_SCHROEDINGER:
9595
case AI_GOAL_NUM_VALUES:
9696
break;
9797
case AI_GOAL_DESTROY_SUBSYSTEM:

fred2/shipgoalsdlg.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,10 @@ ai_goal_mode ShipGoalsDlg::get_first_mode_from_combo_box(int which_item)
378378
// which_item indicates initial goal 1 through MAX_AI_GOALS, so find that behavior...
379379
int behavior_index = m_behavior[which_item];
380380

381+
// if we have a superposition of behaviors, bail here
382+
if (behavior_index < 0)
383+
return ai_goal_mode::AI_GOAL_SCHROEDINGER;
384+
381385
// the behavior is the index into the combo box that contains a subset of goals from Ai_goal_list
382386
const auto &set = m_ai_goal_combo_data[behavior_index].second;
383387

@@ -996,6 +1000,10 @@ void ShipGoalsDlg::update_item(int item, int multi)
9961000
MODIFY(goalp[item].ai_mode, mode);
9971001
return;
9981002

1003+
case AI_GOAL_SCHROEDINGER:
1004+
// return, but don't set the goal
1005+
return;
1006+
9991007
case AI_GOAL_WAYPOINTS:
10001008
case AI_GOAL_WAYPOINTS_ONCE:
10011009
case AI_GOAL_DISABLE_SHIP:
@@ -1163,7 +1171,7 @@ void ShipGoalsDlg::OnOK()
11631171

11641172
for (i=0; i<ED_MAX_GOALS; i++) {
11651173
auto mode = get_first_mode_from_combo_box(i);
1166-
if ((mode != AI_GOAL_NONE) && (mode != AI_GOAL_CHASE_ANY) && (mode != AI_GOAL_UNDOCK) && (mode != AI_GOAL_KEEP_SAFE_DISTANCE) && (mode != AI_GOAL_PLAY_DEAD) && (mode != AI_GOAL_PLAY_DEAD_PERSISTENT) && (mode != AI_GOAL_WARP) ) {
1174+
if ((mode != AI_GOAL_NONE) && (mode != AI_GOAL_SCHROEDINGER) && (mode != AI_GOAL_CHASE_ANY) && (mode != AI_GOAL_UNDOCK) && (mode != AI_GOAL_KEEP_SAFE_DISTANCE) && (mode != AI_GOAL_PLAY_DEAD) && (mode != AI_GOAL_PLAY_DEAD_PERSISTENT) && (mode != AI_GOAL_WARP) ) {
11671175
if (!m_object_box[i] -> GetCount()) // no valid objects?
11681176
m_behavior[i] = 0;
11691177
else

qtfred/src/mission/dialogs/ShipEditor/ShipGoalsDialogModel.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ namespace fso {
5555
// which_item indicates initial goal 1 through MAX_AI_GOALS, so find that behavior...
5656
int behavior_index = m_behavior[which_item];
5757

58+
// if we have a superposition of behaviors, bail here
59+
if (behavior_index < 0)
60+
return ai_goal_mode::AI_GOAL_SCHROEDINGER;
61+
5862
// the behavior is the index into the combo box that contains a subset of goals from Ai_goal_list
5963
const auto &set = m_ai_goal_combo_data[behavior_index].second;
6064

@@ -156,6 +160,10 @@ namespace fso {
156160
modify(goalp[item].ai_mode, mode);
157161
return;
158162

163+
case AI_GOAL_SCHROEDINGER:
164+
// return, but don't set the goal
165+
return;
166+
159167
case AI_GOAL_WAYPOINTS:
160168
case AI_GOAL_WAYPOINTS_ONCE:
161169
case AI_GOAL_DISABLE_SHIP:

0 commit comments

Comments
 (0)