diff --git a/engine/CMakeLists.txt b/engine/CMakeLists.txt
index 03484b74b1..33bf911507 100644
--- a/engine/CMakeLists.txt
+++ b/engine/CMakeLists.txt
@@ -1752,6 +1752,7 @@ IF (USE_GTEST)
src/exit_unit_tests.cpp
src/components/tests/energy_container_tests.cpp
src/components/tests/balancing_tests.cpp
+ src/components/tests/jump_drive_tests.cpp
)
ADD_LIBRARY(vegastrike-testing
diff --git a/engine/src/cmd/unit_functions_generic.cpp b/engine/src/cmd/unit_functions_generic.cpp
index 7fd60ec62e..b31f12a56c 100644
--- a/engine/src/cmd/unit_functions_generic.cpp
+++ b/engine/src/cmd/unit_functions_generic.cpp
@@ -36,7 +36,7 @@
#include "universe.h"
#include "mount_size.h"
#include "damageable.h"
-
+#include "resource/random_utils.h"
//Various functions that were used in .cpp files that are now included because of
//the temple GameUnit class
@@ -255,10 +255,10 @@ void DealPossibleJumpDamage(Unit *un) {
static double max_damage = XMLSupport::parse_float(vs_config->getVariable("physics", "max_jump_damage", "100"));
// Also damage multiplier
- double chance_to_damage = ((double) rand() / (RAND_MAX)) + 1;
+ double chance_to_damage = randomDouble() - 0.01;
// If jump drive is fully operational, there's no chance for damage
- if(un->jump_drive.Operational() >= chance_to_damage) {
+ if(un->jump_drive.Percent() >= chance_to_damage) {
return;
}
diff --git a/engine/src/components/tests/jump_drive_tests.cpp b/engine/src/components/tests/jump_drive_tests.cpp
new file mode 100644
index 0000000000..a5659c9cfa
--- /dev/null
+++ b/engine/src/components/tests/jump_drive_tests.cpp
@@ -0,0 +1,66 @@
+/*
+ * jump_drive_tests.cpp
+ *
+ * Copyright (C) 2001-2023 Daniel Horn, Benjamen Meyer, Roy Falk, Stephen G. Tuggy,
+ * and other Vega Strike contributors.
+ *
+ * https://github.com/vegastrike/Vega-Strike-Engine-Source
+ *
+ * This file is part of Vega Strike.
+ *
+ * Vega Strike is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Vega Strike is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Vega Strike. If not, see .
+ */
+
+#include
+#include