| 46 | } |
| 47 | |
| 48 | void BattleItem::hopTo(GameState &state, Vec3<float> targetPosition) |
| 49 | { |
| 50 | if (falling) |
| 51 | { |
| 52 | return; |
| 53 | } |
| 54 | // It was observed that boomeroids hop 1 to 4 tiles away (never overshooting) |
| 55 | int distance = |
| 56 | std::min(16.0f, BattleUnitTileHelper::getDistanceStatic(position, targetPosition)) / 4.0f; |
| 57 | distance = distance > 1 ? randBoundsInclusive(state.rng, 1, distance) : distance; |
| 58 | auto targetVector = targetPosition - position; |
| 59 | float velXY = 0.0f; |
| 60 | float velZ = 0.0f; |
| 61 | while (distance > 1) |
| 62 | { |
| 63 | // Try to hop this distance towards target |
| 64 | velXY = 0.0f; |
| 65 | velZ = 0.0f; |
| 66 | Vec3<float> target = position + glm::normalize(targetVector) * (float)distance; |
| 67 | if (item->getVelocityForThrow(tileObject->map, 100, position, target, velXY, velZ)) |
| 68 | { |
| 69 | break; |
| 70 | } |
| 71 | else |
| 72 | { |
| 73 | distance--; |
| 74 | } |
| 75 | } |
| 76 | if (distance > 1) |
| 77 | { |
| 78 | falling = true; |
| 79 | velocity = (glm::normalize(Vec3<float>{targetVector.x, targetVector.y, 0.0f}) * velXY + |
| 80 | Vec3<float>{0.0f, 0.0f, velZ}) * |
| 81 | VELOCITY_SCALE_BATTLE; |
| 82 | // Enough to leave our home cell |
| 83 | collisionIgnoredTicks = |
| 84 | (int)ceilf(36.0f / glm::length(velocity / VELOCITY_SCALE_BATTLE)) + 1; |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | // Returns true if sound and doodad were handled by it |
| 89 | bool BattleItem::applyDamage(GameState &state, int power, StateRef<DamageType> damageType) |
no test coverage detected