Skip to content

Commit f97aa9b

Browse files
committed
Added 5 VScript functions to get High Quality Random Numbers using MT19937 algorithm.
1. void RandomHQSetSeed(int seed). This function is used to set a specific seed value for reproducibility. 2. void RandomHQSetRandomDevice(). This function is useful to reset the generator to a non-deterministic state. By default, you don't need to call these functions, as it will automatically seed the generator to a non-deterministic state upon game initialization. 3. int RandomHQUniformIntDistribution(int min, int max). Returns a uniformly distributed random integer in the range [min, max]. If min > max, the values are swapped. 4. float RandomHQUniformFloatDistribution(float min, float max). Returns a uniformly distributed random float in the range [min, max]. If min > max, the values are swapped. 5. float RandomHQNormalDistribution(float mean, float std_dev). Returns a normally(Gaussian) distributed random float with the specified mean and standard deviation. If std_dev <= 0.0f, it sets stddev to 1.0f. Updated Traitors challenge to use c++ versions of RNG.
1 parent d6c76c5 commit f97aa9b

9 files changed

Lines changed: 143 additions & 93 deletions

File tree

reactivedrop/content/traitors_challenge/scripts/vscripts/challenge_traitors.nut

Lines changed: 63 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ function DetectAndApplySkill(interval = 1) {
476476
foreach(idx, menuProps in g_lst_MenuProps) {
477477
if (menuProps.entIndex == entindex && Time() >= g_tbl_MenuSkillInfo.scannerLastSkillTime + g_tbl_MenuSkillInfo.scannerSkillCD) {
478478
if (g_tbl_MenuSkillInfo.scannerRandomScanCounter > 0) {
479-
local rand = RandIntUniformDistribution(0, g_marine_Total_Unshuffled.len() - 5 + g_tbl_MenuSkillInfo.scannerRandomScanCounter);
479+
local rand = RandomHQUniformIntDistribution(0, g_marine_Total_Unshuffled.len() - 5 + g_tbl_MenuSkillInfo.scannerRandomScanCounter);
480480
foreach(idx, prop in g_lst_MenuProps) {
481481
if (prop.scannerIsRevealed || prop.entIndex == g_marine_Scanner.entindex()) {
482482
continue;
@@ -849,6 +849,12 @@ function WriteMatchResultToFile(winner) {
849849
StringToFile("Challenge_Traitor_Result_" + GetLocalTime().tostring() + ".txt", g_str_GameResult);
850850
}
851851

852+
function GetLocalTime() {
853+
local localTime = {};
854+
LocalTime(localTime);
855+
return localTime.dayofyear * 86400 + localTime.hour * 3600 + localTime.minute * 60 + localTime.second;
856+
}
857+
852858
function ShowSpeciallRolesList() {
853859
local hPlayer = null;
854860
while (hPlayer = Entities.FindByClassname(hPlayer, "player")) {
@@ -907,8 +913,6 @@ function OnMissionStart() {
907913
}
908914

909915
function OnGameplayStart() {
910-
PrepareRNG(); //准备随机数
911-
912916
SetConVars(); //设置cvar
913917
SetTechMap(); //设置技术地图标识,暂时没有作用
914918
SetImmuneTimeAndFlags(); //设置出生保护,记录当前地图
@@ -1029,7 +1033,7 @@ function InitializeExtraHealthAndShield() {
10291033

10301034
function DeterminRoleCount() {
10311035
// 确定各种数量
1032-
local tempRandom = RandIntUniformDistribution(0, 1)
1036+
local tempRandom = RandomHQUniformIntDistribution(0, 1)
10331037
switch (g_int_MarineCount) {
10341038
case 0:
10351039
case 1:
@@ -1052,15 +1056,15 @@ function DeterminRoleCount() {
10521056

10531057
LocalizedClientPrint(null, 3, TextColor(160, 32, 240) + "%s1", "#challenge_traitors_not_enough_players");
10541058
if (DEBUG) {
1055-
g_int_TraitorCount = 0; //RandIntUniformDistribution(0, 1);
1059+
g_int_TraitorCount = 0; //RandomHQUniformIntDistribution(0, 1);
10561060
//tempRandom;
10571061
g_bool_ClhallengeEnable = true;
10581062
LocalizedClientPrint(null, 3, TextColor(255, 0, 0) + "You are now in DEBUG mode");
10591063
} // Debug only
10601064
break;
10611065
case 3:
10621066
g_int_TraitorCount = 1;
1063-
g_bool_HasTraitorLeader = (RandIntUniformDistribution(0, 2) == 0);
1067+
g_bool_HasTraitorLeader = (RandomHQUniformIntDistribution(0, 2) == 0);
10641068
g_int_TraitorLeaderExtraHealth = 60;
10651069
break; //1
10661070
case 4:
@@ -1080,13 +1084,13 @@ function DeterminRoleCount() {
10801084
break; //2
10811085
case 7:
10821086
g_int_TraitorCount = 2;
1083-
g_bool_HasIafLeader = (RandIntUniformDistribution(0, 2) == 0);
1084-
g_bool_HasScanner = (RandIntUniformDistribution(0, 20) == 0);
1085-
g_bool_HasBiochemist = (RandIntUniformDistribution(0, 14) == 0);
1087+
g_bool_HasIafLeader = (RandomHQUniformIntDistribution(0, 2) == 0);
1088+
g_bool_HasScanner = (RandomHQUniformIntDistribution(0, 20) == 0);
1089+
g_bool_HasBiochemist = (RandomHQUniformIntDistribution(0, 14) == 0);
10861090
g_bool_HasInfector = g_bool_HasBiochemist;
10871091
g_bool_HasSilencer = g_bool_HasScanner;
1088-
g_bool_HasTraitorLeader = g_bool_HasIafLeader || (RandIntUniformDistribution(0, 3) == 0);
1089-
switch (RandIntUniformDistribution(0, 6)) {
1092+
g_bool_HasTraitorLeader = g_bool_HasIafLeader || (RandomHQUniformIntDistribution(0, 3) == 0);
1093+
switch (RandomHQUniformIntDistribution(0, 6)) {
10901094
case 0:
10911095
//g_bool_HasInfector = true;
10921096
break;
@@ -1097,21 +1101,21 @@ function DeterminRoleCount() {
10971101
g_bool_HasSilencer = true;
10981102
break;
10991103
}
1100-
g_bool_HasShield = (RandIntUniformDistribution(0, 12) == 0);
1101-
g_bool_HasSniper = (RandIntUniformDistribution(0, 12) == 0);
1102-
g_bool_HasDemo = (RandIntUniformDistribution(0, 12) == 0);
1103-
g_bool_HasDeserter = (RandIntUniformDistribution(0, 8) == 0);
1104+
g_bool_HasShield = (RandomHQUniformIntDistribution(0, 12) == 0);
1105+
g_bool_HasSniper = (RandomHQUniformIntDistribution(0, 12) == 0);
1106+
g_bool_HasDemo = (RandomHQUniformIntDistribution(0, 12) == 0);
1107+
g_bool_HasDeserter = (RandomHQUniformIntDistribution(0, 8) == 0);
11041108
break; //2
11051109
case 8:
11061110
g_int_TraitorCount = 2;
1107-
g_bool_HasScanner = (RandIntUniformDistribution(0, 10) == 0);
1108-
g_bool_HasBiochemist = (RandIntUniformDistribution(0, 7) == 0);
1109-
g_bool_HasIafLeader = (RandIntUniformDistribution(0, 1) == 0);
1111+
g_bool_HasScanner = (RandomHQUniformIntDistribution(0, 10) == 0);
1112+
g_bool_HasBiochemist = (RandomHQUniformIntDistribution(0, 7) == 0);
1113+
g_bool_HasIafLeader = (RandomHQUniformIntDistribution(0, 1) == 0);
11101114
g_bool_HasInfector = g_bool_HasBiochemist;
11111115
g_bool_HasSilencer = g_bool_HasScanner;
11121116
g_bool_HasTraitorLeader = true;
11131117
g_int_TraitorLeaderExtraHealth = 250;
1114-
switch (RandIntUniformDistribution(0, 5)) {
1118+
switch (RandomHQUniformIntDistribution(0, 5)) {
11151119
case 0:
11161120
//g_bool_HasInfector = true;
11171121
break;
@@ -1122,10 +1126,10 @@ function DeterminRoleCount() {
11221126
g_bool_HasSilencer = true;
11231127
break;
11241128
}
1125-
g_bool_HasShield = (RandIntUniformDistribution(0, 8) == 0);
1126-
g_bool_HasSniper = (RandIntUniformDistribution(0, 12) == 0);
1127-
g_bool_HasDemo = (RandIntUniformDistribution(0, 8) == 0);
1128-
g_bool_HasDeserter = (RandIntUniformDistribution(0, 6) == 0);
1129+
g_bool_HasShield = (RandomHQUniformIntDistribution(0, 8) == 0);
1130+
g_bool_HasSniper = (RandomHQUniformIntDistribution(0, 12) == 0);
1131+
g_bool_HasDemo = (RandomHQUniformIntDistribution(0, 8) == 0);
1132+
g_bool_HasDeserter = (RandomHQUniformIntDistribution(0, 6) == 0);
11291133
break; //2
11301134
case 9:
11311135
g_int_TraitorCount = 3;
@@ -1155,37 +1159,37 @@ function DeterminRoleCount() {
11551159
if (g_int_MarineCount >= 9 && g_int_MarineCount < 12) {
11561160
g_bool_HasScanner = true;
11571161
g_bool_HasBiochemist = true;
1158-
g_bool_HasIafLeader = (RandIntUniformDistribution(0, 14 - g_int_MarineCount) == 0);
1159-
g_bool_HasShield = (RandIntUniformDistribution(0, 16 - g_int_MarineCount) == 0);
1160-
if ((RandIntUniformDistribution(0, 16 - g_int_MarineCount) == 0)) {
1161-
g_bool_HasSniper = (RandIntUniformDistribution(0, 1) == 0);
1162+
g_bool_HasIafLeader = (RandomHQUniformIntDistribution(0, 14 - g_int_MarineCount) == 0);
1163+
g_bool_HasShield = (RandomHQUniformIntDistribution(0, 16 - g_int_MarineCount) == 0);
1164+
if ((RandomHQUniformIntDistribution(0, 16 - g_int_MarineCount) == 0)) {
1165+
g_bool_HasSniper = (RandomHQUniformIntDistribution(0, 1) == 0);
11621166
g_bool_HasDemo = !g_bool_HasSniper;
11631167
}
1164-
g_bool_HasDeserter = (RandIntUniformDistribution(0, 16 - g_int_MarineCount) == 0);
1168+
g_bool_HasDeserter = (RandomHQUniformIntDistribution(0, 16 - g_int_MarineCount) == 0);
11651169

11661170
g_bool_HasInfector = true;
1167-
g_bool_HasSilencer = (RandIntUniformDistribution(0, 3) != 0);
1171+
g_bool_HasSilencer = (RandomHQUniformIntDistribution(0, 3) != 0);
11681172
g_bool_HasMimic = !g_bool_HasSilencer;
11691173
g_bool_HasTraitorLeader = g_bool_HasIafLeader;
1170-
if ((RandIntUniformDistribution(0, 12 - g_int_MarineCount) == 0)) {
1171-
g_bool_HasBoomer = (RandIntUniformDistribution(0, 1) == 0);
1174+
if ((RandomHQUniformIntDistribution(0, 12 - g_int_MarineCount) == 0)) {
1175+
g_bool_HasBoomer = (RandomHQUniformIntDistribution(0, 1) == 0);
11721176
g_bool_HasInfector = !g_bool_HasBoomer;
11731177
}
11741178
}
11751179
if (g_int_MarineCount >= 12 && g_int_MarineCount < 16) {
11761180
g_bool_HasScanner = true;
11771181
g_bool_HasBiochemist = true;
11781182
g_bool_HasIafLeader = true;
1179-
g_bool_HasShield = (RandIntUniformDistribution(0, 16 - g_int_MarineCount) == 0);
1180-
g_bool_HasSniper = (RandIntUniformDistribution(0, 16 - g_int_MarineCount) == 0);
1181-
g_bool_HasDemo = (RandIntUniformDistribution(0, 16 - g_int_MarineCount) == 0);
1183+
g_bool_HasShield = (RandomHQUniformIntDistribution(0, 16 - g_int_MarineCount) == 0);
1184+
g_bool_HasSniper = (RandomHQUniformIntDistribution(0, 16 - g_int_MarineCount) == 0);
1185+
g_bool_HasDemo = (RandomHQUniformIntDistribution(0, 16 - g_int_MarineCount) == 0);
11821186
g_bool_HasDeserter = true;
11831187

11841188
g_bool_HasInfector = true;
11851189
g_bool_HasSilencer = true;
11861190
g_bool_HasTraitorLeader = true;
1187-
g_bool_HasMimic = (RandIntUniformDistribution(0, 16 - g_int_MarineCount) == 0);
1188-
g_bool_HasBoomer = (RandIntUniformDistribution(0, 16 - g_int_MarineCount) == 0);
1191+
g_bool_HasMimic = (RandomHQUniformIntDistribution(0, 16 - g_int_MarineCount) == 0);
1192+
g_bool_HasBoomer = (RandomHQUniformIntDistribution(0, 16 - g_int_MarineCount) == 0);
11891193
g_bool_HasInfector = !g_bool_HasBoomer;
11901194
}
11911195
if (g_int_MarineCount >= 16) {
@@ -1207,21 +1211,6 @@ function DeterminRoleCount() {
12071211
g_int_IafAliveCount = g_int_MarineCount - g_int_TraitorCount;
12081212
}
12091213

1210-
function PrepareRNG() {
1211-
RngSetSeed(GetLocalTime()); //设置随机数种子
1212-
local i = 0;
1213-
for (; i < 200; i++) {
1214-
RandIntUniformDistribution(0, 1); //丢弃前50个随机数
1215-
}
1216-
RngSetSeed(GetLocalTime() * 1000 + (Time() * 1000).tointeger() % 1000); //重新设置随机数种子
1217-
}
1218-
1219-
function GetLocalTime() {
1220-
local localTime = {};
1221-
LocalTime(localTime);
1222-
return localTime.dayofyear * 86400 + localTime.hour * 3600 + localTime.minute * 60 + localTime.second;
1223-
}
1224-
12251214
function DelayFunctionCall(function_name, function_params, delay) {
12261215
if (!this["self"])
12271216
return;
@@ -2253,17 +2242,17 @@ function SetConVars(interval = 1) {
22532242
Convars.SetValue("asw_marine_ff_absorption", 0);
22542243
Convars.SetValue("rd_aim_marines", 1);
22552244
Convars.SetValue("rd_hp_regen", 1);
2256-
Convars.SetValue("rm_health_regen_amount", RandFloatNormalDistribution(3, 0.5));
2257-
Convars.SetValue("rm_health_regen_interval", RandFloatNormalDistribution(10, 0.4));
2245+
Convars.SetValue("rm_health_regen_amount", RandomHQNormalDistribution(3, 0.5));
2246+
Convars.SetValue("rm_health_regen_interval", RandomHQNormalDistribution(10, 0.4));
22582247
Convars.SetValue("rd_weapons_show_hidden", 1);
2259-
Convars.SetValue("rd_jumpjet_knockdown_marines", RandIntUniformDistribution(0, 10) >= 8 ? 0 : 1);
2248+
Convars.SetValue("rd_jumpjet_knockdown_marines", RandomHQUniformIntDistribution(0, 10) >= 8 ? 0 : 1);
22602249
Convars.SetValue("rd_marine_ignite_immediately", 1);
22612250
Convars.SetValue("asw_marine_time_until_ignite", 0);
2262-
Convars.SetValue("asw_marine_burn_time_easy", RandFloatNormalDistribution(45, 5));
2263-
Convars.SetValue("asw_marine_burn_time_normal", RandFloatNormalDistribution(45, 5));
2264-
Convars.SetValue("asw_marine_burn_time_hard", RandFloatNormalDistribution(45, 5));
2265-
Convars.SetValue("asw_marine_burn_time_insane", RandFloatNormalDistribution(45, 5));
2266-
Convars.SetValue("asw_blink_charge_time", RandFloatNormalDistribution(100, 25));
2251+
Convars.SetValue("asw_marine_burn_time_easy", RandomHQNormalDistribution(45, 5));
2252+
Convars.SetValue("asw_marine_burn_time_normal", RandomHQNormalDistribution(45, 5));
2253+
Convars.SetValue("asw_marine_burn_time_hard", RandomHQNormalDistribution(45, 5));
2254+
Convars.SetValue("asw_marine_burn_time_insane", RandomHQNormalDistribution(45, 5));
2255+
Convars.SetValue("asw_blink_charge_time", RandomHQNormalDistribution(100, 25));
22672256
Convars.SetValue("asw_minigun_spin_down_rate", 100);
22682257
Convars.SetValue("asw_minigun_spin_rate_threshold", 1);
22692258
Convars.SetValue("asw_minigun_spin_up_rate", 50);
@@ -2272,20 +2261,20 @@ function SetConVars(interval = 1) {
22722261
Convars.SetValue("rd_techreq", 0);
22732262
Convars.SetValue("rd_hackall", 1);
22742263
Convars.SetValue("rd_biomass_ignite_from_explosions", 1);
2275-
Convars.SetValue("rd_spawn_medkits", RandFloatNormalDistribution(61, 2).tointeger());
2276-
Convars.SetValue("asw_fist_passive_damage_scale", RandFloatNormalDistribution(4500, 500));
2264+
Convars.SetValue("rd_spawn_medkits", RandomHQNormalDistribution(61, 2).tointeger());
2265+
Convars.SetValue("asw_fist_passive_damage_scale", RandomHQNormalDistribution(4500, 500));
22772266
Convars.SetValue("rd_stuck_bot_teleport", 1);
2278-
Convars.SetValue("rd_damage_buff_scale", RandFloatNormalDistribution(1.2, 0.02));
2267+
Convars.SetValue("rd_damage_buff_scale", RandomHQNormalDistribution(1.2, 0.02));
22792268

2280-
Convars.SetValue("asw_cluster_grenade_fuse", RandFloatNormalDistribution(4, 0.7));
2281-
local child_fuse_max = RandFloatNormalDistribution(2.4, 0.3);
2282-
local child_fuse_min = child_fuse_max / RandFloatUniformDistribution(1.5, 3.0);
2269+
Convars.SetValue("asw_cluster_grenade_fuse", RandomHQNormalDistribution(4, 0.7));
2270+
local child_fuse_max = RandomHQNormalDistribution(2.4, 0.3);
2271+
local child_fuse_min = child_fuse_max / RandomHQUniformFloatDistribution(1.5, 3.0);
22832272
Convars.SetValue("asw_cluster_grenade_child_fuse_max", child_fuse_max);
22842273
Convars.SetValue("asw_cluster_grenade_child_fuse_min", child_fuse_min);
2285-
Convars.SetValue("asw_cluster_grenade_radius_check_scale", RandFloatNormalDistribution(0.55, 0.017));
2274+
Convars.SetValue("asw_cluster_grenade_radius_check_scale", RandomHQNormalDistribution(0.55, 0.017));
22862275

2287-
Convars.SetValue("rd_marine_passive_armor_layers_amount", RandFloatNormalDistribution(14, 1.5).tointeger());
2288-
Convars.SetValue("rd_marine_passive_armor_layer_protection_value", RandFloatNormalDistribution(0.04, 0.0005));
2276+
Convars.SetValue("rd_marine_passive_armor_layers_amount", RandomHQNormalDistribution(14, 1.5).tointeger());
2277+
Convars.SetValue("rd_marine_passive_armor_layer_protection_value", RandomHQNormalDistribution(0.04, 0.0005));
22892278

22902279
Convars.SetValue("asw_sentry_friendly_fire_scale", 0.2);
22912280
Convars.SetValue("asw_sentry_friendly_target", g_enum_CurrentMap == MAP.RED_6 ? 0 : 1);
@@ -2295,15 +2284,15 @@ function SetConVars(interval = 1) {
22952284
//Convars.SetValue("autoaim_max_dist", 0);
22962285

22972286
Convars.SetValue("asw_ammo_count_sniper_rifle", 1);
2298-
Convars.SetValue("asw_skill_accuracy_sniper_rifle_dmg_step", RandFloatNormalDistribution(5, 1).tointeger());
2299-
Convars.SetValue("rd_sniper_dmg_base", RandFloatUniformDistribution(100, 150));
2300-
Convars.SetValue("rd_sniper_rifle_dmg_zoomed_bonus", RandFloatUniformDistribution(500, 700));
2287+
Convars.SetValue("asw_skill_accuracy_sniper_rifle_dmg_step", RandomHQNormalDistribution(5, 1).tointeger());
2288+
Convars.SetValue("rd_sniper_dmg_base", RandomHQUniformFloatDistribution(100, 150));
2289+
Convars.SetValue("rd_sniper_rifle_dmg_zoomed_bonus", RandomHQUniformFloatDistribution(500, 700));
23012290

2302-
Convars.SetValue("asw_ammo_count_devastator", RandIntUniformDistribution(10, 25));
2291+
Convars.SetValue("asw_ammo_count_devastator", RandomHQUniformIntDistribution(10, 25));
23032292

2304-
Convars.SetValue("rd_railgun_dmg_base", RandIntUniformDistribution(100, 250));
2293+
Convars.SetValue("rd_railgun_dmg_base", RandomHQUniformIntDistribution(100, 250));
23052294

2306-
Convars.SetValue("rd_pistols_min_delay", RandFloatUniformDistribution(0.116, 0.126));
2295+
Convars.SetValue("rd_pistols_min_delay", RandomHQUniformFloatDistribution(0.116, 0.126));
23072296

23082297
local hPlayer = null;
23092298
local playerCount = 0;

reactivedrop/content/traitors_challenge/scripts/vscripts/challenge_traitors_events/ongameevent_entity_killed.nut

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function OnGameEvent_entity_killed(params) {
3333
EntFireByHandle(explosion, "Kill", "", 3, null, null); // 销毁爆炸实体
3434
victim.PrecacheSoundScript("Traitors.Boomer_Explode");
3535
victim.EmitSound("Traitors.Boomer_Explode");
36-
ApplyExplosionDamageToMarines(victim, deathPos, 150, RandFloatNormalDistribution(0.95, 0.05));
36+
ApplyExplosionDamageToMarines(victim, deathPos, 150, RandomHQNormalDistribution(0.95, 0.05));
3737
}
3838

3939
local tempList = [];

reactivedrop/content/traitors_challenge/scripts/vscripts/challenge_traitors_events/ongameevent_heal_beacon_placed.nut

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ function OnGameEvent_heal_beacon_placed(params) {
5050
hNewHealBeacon = PlaceHealBeacon(230, 6, 3.65, 23, 180, HealBeaconOrigin + offset);
5151
hNewHealBeacon.SetVelocity(LaunchVector(hNewHealBeacon.GetOrigin(), targetPos, 150, 0.5));
5252

53-
if (RandIntUniformDistribution(0, 999) >= 945) {
53+
if (RandomHQUniformIntDistribution(0, 999) >= 945) {
5454
hNewDamageAmplifier = PlaceDamageAmplifier(30, 180, HealBeaconOrigin + offset);
5555
hNewDamageAmplifier.SetVelocity(LaunchVector(hNewDamageAmplifier.GetOrigin(), targetPos, 150, 0.5));
5656
}
5757

58-
if (RandIntUniformDistribution(0, 999) >= 669) {
58+
if (RandomHQUniformIntDistribution(0, 999) >= 669) {
5959
hNewFreezeGrenade = DropFreezeGrenade(30, 2, 180, HealBeaconOrigin + offset);
6060
hNewFreezeGrenade.SetVelocity(LaunchVector(hNewFreezeGrenade.GetOrigin(), targetPos, 150, 0.5));
6161
}

reactivedrop/content/traitors_challenge/scripts/vscripts/challenge_traitors_events/ongameevent_weapon_reload.nut

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ function OnGameEvent_weapon_reload(params) {
55
switch (hWeapon.GetClassname()) {
66
case "asw_weapon_sniper_rifle": //神射手
77
//EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_flNextPrimaryAttack\", " + (Time() + fFireRate).tostring() + " );", 0.0, null, null);
8-
local time = Time() + RandFloatUniformDistribution(1.0, 2.0);
8+
local time = Time() + RandomHQUniformFloatDistribution(1.0, 2.0);
99
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadStart\", " + time.tostring() + " );", 0.0, null, null);
1010
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadEnd\", " + (time + 0.1).tostring() + " );", 0.0, null, null);
1111
break;
1212
case "asw_weapon_pistol": //双手枪
13-
local time = Time() + RandFloatUniformDistribution(0.05, 0.9);
13+
local time = Time() + RandomHQUniformFloatDistribution(0.05, 0.9);
1414
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadStart\", " + time.tostring() + " );", 0.0, null, null);
1515
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadEnd\", " + (time + 0.05).tostring() + " );", 0.0, null, null);
1616
break;
1717
case "asw_weapon_pdw": //单兵防御武器
18-
local time = Time() + RandFloatUniformDistribution(0.05, 0.9);
18+
local time = Time() + RandomHQUniformFloatDistribution(0.05, 0.9);
1919
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadStart\", " + time.tostring() + " );", 0.0, null, null);
2020
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadEnd\", " + (time + 0.05).tostring() + " );", 0.0, null, null);
2121
break;

reactivedrop/content/traitors_challenge/scripts/vscripts/challenge_traitors_events/onreceivedtextmessage.nut

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ function SetBomb() {
102102
}
103103
g_bool_BombActivited = true;
104104
if (g_marine_Boomer != g_marine_SilencedMarine) {
105-
local delay = RandIntUniformDistribution(0, 5);
105+
local delay = RandomHQUniformIntDistribution(0, 5);
106106
DelayFunctionCall("BomberAlert", "", delay + 0.01);
107107

108108
g_marine_Boomer.PrecacheSoundScript(BOOMER_SOUND.COUNT_DOWN[delay]);
@@ -130,7 +130,7 @@ function BomberSelfExplode() {
130130
local radius = 150;
131131
local hAttacker = g_marine_Boomer;
132132
local explosionPos = hAttacker.GetOrigin() + Vector(0, 0, 60);
133-
local damageScale = RandFloatNormalDistribution(1.05, 0.05);
133+
local damageScale = RandomHQNormalDistribution(1.05, 0.05);
134134
while (hMarine = Entities.FindByClassnameWithin(hMarine, "asw_marine", explosionPos, 4 * radius)) {
135135
// 检查实体是否有效且存活
136136
if (g_int_Counter > g_int_ImmuneCounter && hMarine.IsValid() && hMarine != hAttacker && hMarine.GetHealth() > 0) {

reactivedrop/content/traitors_challenge/scripts/vscripts/challenge_traitors_events/ontakedamage_alive_any.nut

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ function OnTakeDamage_Alive_Any(victim, inflictor, attacker, weapon, damage, dam
8080
case "asw_weapon_prifle": //原型突击步枪
8181
local distance = (attacker.GetOrigin() - victim.GetOrigin()).Length();
8282
local temp = distance < 250 ? 1.0 : 300.0 / distance;
83-
factor1 = temp * RandFloatUniformDistribution(0.25, 0.54);
84-
factor2 = temp * RandFloatUniformDistribution(0.23, 0.44);
85-
factor3 = temp * RandFloatUniformDistribution(0.27, 0.64);
83+
factor1 = temp * RandomHQUniformFloatDistribution(0.25, 0.54);
84+
factor2 = temp * RandomHQUniformFloatDistribution(0.23, 0.44);
85+
factor3 = temp * RandomHQUniformFloatDistribution(0.27, 0.64);
8686
break;
8787
case "asw_weapon_autogun": //自动机枪
8888
factor1 = 0.47;
@@ -148,7 +148,7 @@ function OnTakeDamage_Alive_Any(victim, inflictor, attacker, weapon, damage, dam
148148
factor3 = 1.00;
149149
break;
150150
case "asw_weapon_grenades": //手雷
151-
damage = RandFloatNormalDistribution(2000, 200);
151+
damage = RandomHQNormalDistribution(2000, 200);
152152
factor1 = 0.001;
153153
factor2 = 0.005;
154154
factor3 = 0.015;
@@ -333,8 +333,8 @@ function PunchKnockdown(attacker, victim) {
333333
} else {
334334
thresh = hasPowerFist ? 0.9 : 0.75;
335335
}
336-
if (thresh >= RandFloatUniformDistribution(0.0, 1.0)) {
337-
local temp = RandFloatUniformDistribution(1.0, 1.5) * -200;
336+
if (thresh >= RandomHQUniformFloatDistribution(0.0, 1.0)) {
337+
local temp = RandomHQUniformFloatDistribution(1.0, 1.5) * -200;
338338
vecAttackerToVictim.x *= temp;
339339
vecAttackerToVictim.y *= temp;
340340
vecAttackerToVictim.z = 70 * temp;

0 commit comments

Comments
 (0)