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

Function cDroidManagerHandleGoals

scripts/Merc7.cpp:1590–1638  ·  view source on GitHub ↗

$$ACTION Custom Droid Manager Handle GoalID [e:GoalID=-1] for Droid [o:Object]. cDroidManagerHandleGoals Handles all droid goal events. function is the complement for Droid Manager Frame Interval, handles goals like exit, terminal and end goals. Parameters: GoalID: Goal ID Object: Object that triggered the goal. $$END */

Source from the content-addressed store, hash-verified

1588$$END
1589*/
1590void cDroidManagerHandleGoals(int goalid, int objhandle) {
1591 int i, goalid2;
1592
1593 if (DC_EQR == -100) {
1594 return;
1595 }
1596
1597 for (i = 0; i < DC_N_DROIDS; i++) {
1598 // alright, check if object is in list. then check if the goal is there too.
1599 if (dc_nodes[i].handle == objhandle && dc_nodes[i].goalid == goalid && dc_nodes[i].type != -1) {
1600 switch (dc_nodes[i].type) {
1601 case DC_EXIT_GOAL:
1602 // deactivate forcefield (should be portal 1 of room)
1603 // send object to the end goal, if there is one. otherwise just kill it now (BAD design)
1604 // end and exit and exit room handle indices should match up always
1605 aPortalRenderSet(0, 1, DC_Valid_Exit_RoomHandles[dc_nodes[i].type_index], true);
1606
1607 DC_Exit_Mask &= ~(1 << dc_nodes[i].type_index);
1608
1609 goalid2 = LEVEL_GOAL_UID(0, DC_Goal_Index++);
1610
1611 aAIGoalGotoObject(objhandle, DC_Valid_End_Handles[dc_nodes[i].type_index], GOAL_PRIORITY_LOW,
1612 GF_FORCE_AWARENESS | GF_ORIENT_VELOCITY, goalid2);
1613
1614 dc_nodes[i].type = DC_END_GOAL; // specify end to be allocated.
1615 dc_nodes[i].goalid = goalid2;
1616 dc_nodes[i].timer = 0.0f;
1617 mprintf(0, "DC: DROID [%d] REACHES EXIT %d\n", i, dc_nodes[i].type_index);
1618 break;
1619
1620 case DC_END_GOAL:
1621 // reactivate forcefield
1622 // kill droid, it has met its end.
1623 aPortalRenderSet(1, 1, DC_Valid_Exit_RoomHandles[dc_nodes[i].type_index], true);
1624 aObjDelete(dc_nodes[i].handle);
1625 cRemoveObjFromDroidManager(dc_nodes[i].handle);
1626 mprintf(0, "DC: DROID [%d] REACHES ITS END\n", i);
1627 break;
1628
1629 case DC_TERM_GOAL:
1630 // if i can think of anything nice, i'll put it here, but this should be unnecessary.
1631 mprintf(0, "DC: DROID [%d] REACHES TERMINAL %d\n", i, dc_nodes[i].type_index);
1632 dc_nodes[i].goalid = -1;
1633 dc_nodes[i].timer = 0.0f;
1634 break;
1635 }
1636 }
1637 }
1638}
1639
1640/*
1641$$ACTION

Callers

nothing calls this directly

Calls 5

aPortalRenderSetFunction · 0.85
LEVEL_GOAL_UIDFunction · 0.85
aAIGoalGotoObjectFunction · 0.85
aObjDeleteFunction · 0.85

Tested by

no test coverage detected