| 2904 | } |
| 2905 | |
| 2906 | void BattleUnit::updateMovementNormal(GameState &state, unsigned int &moveTicksRemaining, |
| 2907 | bool &wasUsingLift) |
| 2908 | { |
| 2909 | // We are not moving and not falling |
| 2910 | if (current_movement_state == MovementState::None) |
| 2911 | { |
| 2912 | // Check if we should adjust our current position |
| 2913 | if (goalPosition == getPosition()) |
| 2914 | { |
| 2915 | goalPosition = tileObject->getOwningTile()->getRestingPosition(isLarge()); |
| 2916 | } |
| 2917 | atGoal = goalPosition == getPosition(); |
| 2918 | if (atGoal) |
| 2919 | { |
| 2920 | getNewGoal(state); |
| 2921 | if (retreated) |
| 2922 | { |
| 2923 | return; |
| 2924 | } |
| 2925 | } |
| 2926 | } |
| 2927 | // We are moving and not falling |
| 2928 | else |
| 2929 | { |
| 2930 | unsigned int speedModifier = 100; |
| 2931 | if (current_body_state == BodyState::Flying) |
| 2932 | { |
| 2933 | speedModifier = std::max((unsigned)1, flyingSpeedModifier); |
| 2934 | } |
| 2935 | Vec3<float> vectorToGoal = goalPosition - getPosition(); |
| 2936 | unsigned int distanceToGoal = (unsigned)ceilf(glm::length( |
| 2937 | vectorToGoal * VELOCITY_SCALE_BATTLE * (float)TICKS_PER_UNIT_TRAVELLED_BATTLEUNIT)); |
| 2938 | unsigned int moveTicksConsumeRate = BASE_MOVETICKS_CONSUMPTION_RATE; |
| 2939 | // Bring all jumpers to constant speed so that we can align leg animation with the edge |
| 2940 | if (target_body_state == BodyState::Jumping) |
| 2941 | { |
| 2942 | moveTicksConsumeRate = |
| 2943 | agent->modified_stats.getMovementSpeed() * BASE_MOVETICKS_CONSUMPTION_RATE / 15; |
| 2944 | } |
| 2945 | // Running is twice as fast |
| 2946 | else if (current_movement_state == MovementState::Running) |
| 2947 | { |
| 2948 | moveTicksConsumeRate = BASE_MOVETICKS_CONSUMPTION_RATE / 2; |
| 2949 | } |
| 2950 | // Crawling is at 66% speed |
| 2951 | else if (current_body_state == BodyState::Prone) |
| 2952 | { |
| 2953 | moveTicksConsumeRate = BASE_MOVETICKS_CONSUMPTION_RATE * 3 / 2; |
| 2954 | } |
| 2955 | |
| 2956 | // Quick check, if moving strictly vertical without falling or flying |
| 2957 | // then we must be using a lift. |
| 2958 | if (distanceToGoal > 0 && current_body_state != BodyState::Flying && |
| 2959 | current_movement_state != MovementState::Brainsuck && vectorToGoal.x == 0 && |
| 2960 | vectorToGoal.y == 0 && tileObject->getOwningTile()->hasLift) |
| 2961 | { |
| 2962 | // FIXME: Actually read set option |
| 2963 | if (config().getBool("OpenApoc.NewFeature.GravliftSounds") && !wasUsingLift) |
nothing calls this directly
no test coverage detected