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

Method DoSubModeFrame

scripts/AIGame.cpp:6522–6597  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6520}
6521
6522void Thief::DoSubModeFrame(int me) {
6523 float anim_frame;
6524 Obj_Value(me, VF_GET, OBJV_F_ANIM_FRAME, &anim_frame);
6525
6526 msafe_struct m;
6527 m.objhandle = me;
6528
6529 switch (memory->sub_mode) {
6530 case THIEF_SUB_NONE: {
6531 if (Game_GetTime() > memory->next_test_time) {
6532 int r_val = (rand() % 5) + 1;
6533 SetSubMode(me, r_val);
6534
6535 // In case above failed, make sure there is a time gap between submode checks
6536 memory->next_test_time = Game_GetTime() + 10.0f + (float)rand() * (1.0f / (float)RAND_MAX) * 10.0f;
6537 }
6538 } break;
6539 case THIEF_SUB_SUMMON: {
6540
6541 if (anim_frame >= 12.0f && anim_frame < 19.0f) {
6542 Obj_SetCustomAnim(me, 19.0f, 23.0f, 0.8f, AIAF_LOOPING);
6543 }
6544
6545 if (anim_frame > 19.0f && anim_frame < 23.0f) {
6546 if (memory->last_summon_time + 0.25f <= Game_GetTime()) {
6547 memory->last_summon_time = Game_GetTime();
6548
6549 // Chrishack - do summon stuff here
6550 }
6551 }
6552
6553 if (memory->sub_mode_time > 6.0f && anim_frame >= 19.0f && anim_frame <= 23.0f) {
6554 Obj_SetCustomAnim(me, 23.0f, 29.0f, 0.8f, AIAF_NOTIFY, -1, AS_ALERT);
6555 SetSubMode(me, THIEF_SUB_NONE);
6556 }
6557
6558 } break;
6559 case THIEF_SUB_CLOAK: {
6560 if (anim_frame > 61.0f && memory->last_frame <= 61.0f) {
6561 m.lifetime = 15.0f;
6562 m.state = 1;
6563
6564 MSafe_CallFunction(MSAFE_OBJECT_CLOAK, &m);
6565
6566 AI_SetGoalFlags(me, 2, GF_ORIENT_TARGET, false);
6567 }
6568 } break;
6569 case THIEF_SUB_THROW_ITEM: {
6570 if (anim_frame > 41.0f && memory->last_frame <= 41.0f) {
6571 memory->bomb_handle = CreateAndAttach(me, "PTMCSeeker", OBJ_ROBOT, 1, 0, true, true);
6572 }
6573
6574 if (anim_frame > 45.0f && memory->last_frame <= 45.0f) {
6575 matrix orient;
6576 Obj_Value(me, VF_GET, OBJV_M_ORIENT, &orient);
6577 vector velocity = orient.fvec * 50.0f;
6578
6579 Obj_UnattachFromParent(memory->bomb_handle);

Callers

nothing calls this directly

Calls 3

Obj_ValueFunction · 0.85
Obj_SetCustomAnimFunction · 0.85
CreateAndAttachFunction · 0.70

Tested by

no test coverage detected