MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DoExternalCommands

Method DoExternalCommands

scripts/AIGame.cpp:5019–5600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5017}
5018
5019bool GuideBot::DoExternalCommands(int me, gb_com *command, int it) {
5020 int g_robot;
5021 int roomnum;
5022 vector pos;
5023 int flags;
5024
5025 mprintf(0, "Command %d for GB\n", command->action);
5026
5027 // In general, Turn on friend avoidance
5028 flags = AIF_AUTO_AVOID_FRIENDS;
5029 AI_Value(me, VF_SET_FLAGS, AIV_I_FLAGS, &flags);
5030
5031 if (command->action == COM_REINIT) {
5032 return DoInit(me, true);
5033 } else if (command->action == COM_DO_ACTION) {
5034 int param1 = command->index;
5035 // mprintf(0, "P is %d\n", param1);
5036
5037 memory->last_command = param1;
5038
5039 if ((param1 >= GBC_FIND_ACTIVE_GOAL_0 && param1 <= GBC_FIND_ACTIVE_GOAL_7) ||
5040 (param1 >= GBC_FIND_ACTIVE_SEC_GOAL_0 && param1 <= GBC_FIND_ACTIVE_SEC_GOAL_7)) {
5041 int g_id;
5042 int flags;
5043 char type;
5044 int rhandle[32];
5045 bool rdone[32];
5046 int handle[32];
5047 bool done[32];
5048 int i;
5049 int rnum_items;
5050 int num_items;
5051
5052 if (param1 >= GBC_FIND_ACTIVE_GOAL_0 && param1 <= GBC_FIND_ACTIVE_GOAL_7)
5053 LGoal_Value(VF_GET, LGSV_I_ACTIVE_PRIMARY_GOAL, &g_id, param1 - GBC_FIND_ACTIVE_GOAL_0);
5054 else
5055 LGoal_Value(VF_GET, LGSV_I_ACTIVE_SECONDARY_GOAL, &g_id, param1 - GBC_FIND_ACTIVE_SEC_GOAL_0);
5056
5057 LGoal_Value(VF_GET, LGSV_I_STATUS, &flags, g_id);
5058 LGoal_Value(VF_GET, LGSSV_C_ITEM_TYPE, &type, g_id, 0);
5059
5060 LGoal_Value(VF_GET, LGSV_I_NUM_ITEMS, &rnum_items, g_id);
5061
5062 for (i = 0; i < rnum_items; i++) {
5063 LGoal_Value(VF_GET, LGSSV_I_ITEM_HANDLE, &rhandle[i], g_id, i);
5064 LGoal_Value(VF_GET, LGSSV_B_ITEM_DONE, &rdone[i], g_id, i);
5065 }
5066
5067 num_items = 0;
5068 for (i = 0; i < rnum_items; i++) {
5069 if (!rdone[i]) {
5070 handle[num_items++] = rhandle[i];
5071 }
5072 }
5073
5074 if (num_items == 0) {
5075 num_items = 1;
5076 handle[0] = rhandle[0];

Callers

nothing calls this directly

Calls 9

LGoal_ValueFunction · 0.85
Obj_ValueFunction · 0.85
Room_ValueFunction · 0.85
AI_FindObjOfTypeFunction · 0.85
Obj_BurningFunction · 0.85
Sound_Play2dFunction · 0.85
AI_GetNearbyObjsFunction · 0.85
Player_ValueFunction · 0.85
Sound_Play3dFunction · 0.85

Tested by

no test coverage detected