Checks to see if tractor beam pulling can commence/continue
| 4732 | |
| 4733 | // Checks to see if tractor beam pulling can commence/continue |
| 4734 | bool Lifter::OkToPull(int me, bool initial_check /*=true*/) { |
| 4735 | matrix orient; |
| 4736 | vector vec_to_target; |
| 4737 | int target_handle; |
| 4738 | float fov_angle; |
| 4739 | |
| 4740 | // If it's the initial check, make sure we're in alert mode |
| 4741 | if (initial_check) { |
| 4742 | char type; |
| 4743 | AI_Value(me, VF_GET, AIV_C_ANIMATION_TYPE, &type); |
| 4744 | |
| 4745 | // Wait until the current anim type is alert, then return to normal |
| 4746 | if (type != AS_ALERT) |
| 4747 | return false; |
| 4748 | } |
| 4749 | |
| 4750 | // Make sure we still have a target |
| 4751 | AI_Value(me, VF_GET, AIV_I_TARGET_HANDLE, &target_handle); |
| 4752 | if (target_handle == OBJECT_HANDLE_NONE) |
| 4753 | return false; |
| 4754 | |
| 4755 | // Make sure it's a pullable target |
| 4756 | int type; |
| 4757 | Obj_Value(target_handle, VF_GET, OBJV_I_TYPE, &type); |
| 4758 | if (type != OBJ_PLAYER) |
| 4759 | return false; |
| 4760 | |
| 4761 | // If it's not the initial pull, make sure the target hasn't changed |
| 4762 | if (!initial_check && target_handle != memory->pull_target) |
| 4763 | return false; |
| 4764 | |
| 4765 | // Make sure the target isn't cloaked |
| 4766 | if (qObjectCloakTime(target_handle) != 0.0f) |
| 4767 | return false; |
| 4768 | |
| 4769 | // check distance to target |
| 4770 | float dist; |
| 4771 | AI_Value(me, VF_GET, AIV_F_DIST_TO_TARGET, &dist); |
| 4772 | if (dist > LIFTER_MAX_PULLING_DIST) |
| 4773 | return false; |
| 4774 | |
| 4775 | // Only check min distance if it's the initial decision check (whether to start pulling) |
| 4776 | if (initial_check && dist < LIFTER_MIN_PULLING_DIST) |
| 4777 | return false; |
| 4778 | |
| 4779 | // check FOV position of target (greater than 45 degrees is too much) |
| 4780 | Obj_Value(me, VF_GET, OBJV_M_ORIENT, &orient); |
| 4781 | |
| 4782 | // NOTE: do my own vec to target here! (chris' doesn't update quick enough) |
| 4783 | AI_Value(me, VF_GET, AIV_V_VEC_TO_TARGET, &vec_to_target); |
| 4784 | vm_VectorNormalize(&vec_to_target); |
| 4785 | fov_angle = orient.fvec * vec_to_target; |
| 4786 | if (fov_angle < 0.7f) |
| 4787 | return false; |
| 4788 | |
| 4789 | // see if anything is in the way |
| 4790 | ray_info ray; |
| 4791 | int flags, fate; |
nothing calls this directly
no test coverage detected