diff --git a/src/ai/ai_scanner.cpp b/src/ai/ai_scanner.cpp index ac77a0b8fd..77a2c814a5 100644 --- a/src/ai/ai_scanner.cpp +++ b/src/ai/ai_scanner.cpp @@ -14,6 +14,7 @@ #include "../core/random_func.hpp" #include "../script/squirrel_class.hpp" +#include "../script/api/script_object.hpp" #include "ai_info.hpp" #include "ai_scanner.hpp" @@ -77,12 +78,7 @@ AIInfo *AIScannerInfo::SelectRandomAI() const } /* Find a random AI */ - uint pos; - if (_networking) { - pos = InteractiveRandomRange(num_random_ais); - } else { - pos = RandomRange(num_random_ais); - } + uint pos = ScriptObject::GetRandomizer(OWNER_NONE).Next(num_random_ais); /* Find the Nth item from the array */ ScriptInfoList::const_iterator it = this->info_single_list.begin(); diff --git a/src/script/script_config.cpp b/src/script/script_config.cpp index 07be966052..738a898a79 100644 --- a/src/script/script_config.cpp +++ b/src/script/script_config.cpp @@ -11,6 +11,7 @@ #include "../settings_type.h" #include "../core/random_func.hpp" #include "script_info.hpp" +#include "api/script_object.hpp" #include "../textfile_gui.h" #include "../string_func.h" @@ -35,7 +36,7 @@ void ScriptConfig::Change(const char *name, int version, bool force_exact_match, * for the Script that have the random flag to a random value. */ for (const auto &item : *this->info->GetConfigList()) { if (item.flags & SCRIPTCONFIG_RANDOM) { - this->SetSetting(item.name, InteractiveRandomRange(item.max_value + 1 - item.min_value) + item.min_value); + this->SetSetting(item.name, ScriptObject::GetRandomizer(OWNER_NONE).Next(item.max_value + 1 - item.min_value) + item.min_value); } } @@ -157,7 +158,7 @@ void ScriptConfig::AddRandomDeviation() { for (const auto &item : *this->GetConfigList()) { if (item.random_deviation != 0) { - this->SetSetting(item.name, InteractiveRandomRange(item.random_deviation * 2 + 1) - item.random_deviation + this->GetSetting(item.name)); + this->SetSetting(item.name, ScriptObject::GetRandomizer(OWNER_NONE).Next(item.random_deviation * 2 + 1) - item.random_deviation + this->GetSetting(item.name)); } } }