Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"allowed_mode" "coop"
"convars" {
"rd_player_bots_allowed" "0"
"cl_add_index_to_name" "1"
"rd_draw_restricted_rectangles_coop" "1"

"rd_auto_fast_restart" "1"
"rd_ready_mark_override" "1"
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

FONT_DEFAULTLARGE <- self.LookupFont("DefaultLarge");
rowHeight <- self.GetFontTall(FONT_DEFAULTLARGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ efaultUnderline
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

FONT_DEFAULTLARGE <- self.LookupFont("DefaultLarge");
rowHeight <- self.GetFontTall(FONT_DEFAULTLARGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

FONT_DEFAULTLARGE <- self.LookupFont("DefaultLarge");
rowHeight <- self.GetFontTall(FONT_DEFAULTLARGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ efaultUnderline
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

FONT_DEFAULTLARGE <- self.LookupFont("DefaultLarge");
rowHeight <- self.GetFontTall(FONT_DEFAULTLARGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

function Paint() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

FONT_DEFAULTLARGE <- self.LookupFont("DefaultLarge");
rowHeight <- self.GetFontTall(FONT_DEFAULTLARGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

FONT_DEFAULTLARGE <- self.LookupFont("DefaultLarge");
rowHeight <- self.GetFontTall(FONT_DEFAULTLARGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

FONT_DEFAULTLARGE <- self.LookupFont("DefaultLarge");
rowHeight <- self.GetFontTall(FONT_DEFAULTLARGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ efaultUnderline
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

FONT_DEFAULTLARGE <- self.LookupFont("DefaultLarge");
rowHeight <- self.GetFontTall(FONT_DEFAULTLARGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

FONT_DEFAULTLARGE <- self.LookupFont("DefaultLarge");
rowHeight <- self.GetFontTall(FONT_DEFAULTLARGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ efaultUnderline
*/
isServer <- false;
IncludeScript("challenge_traitors_enums");
IncludeScript("traitors_client_shared");
IncludeScript("challenge_traitors_client_shared");

FONT_DEFAULTLARGE <- self.LookupFont("DefaultLarge");
rowHeight <- self.GetFontTall(FONT_DEFAULTLARGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function OnGameEvent_entity_killed(params) {
EntFireByHandle(explosion, "Kill", "", 3, null, null); // 销毁爆炸实体
victim.PrecacheSoundScript("Traitors.Boomer_Explode");
victim.EmitSound("Traitors.Boomer_Explode");
ApplyExplosionDamageToMarines(victim, deathPos, 150, RandFloatNormalDistribution(0.95, 0.05));
ApplyExplosionDamageToMarines(victim, deathPos, 150, RandomHQNormalDistribution(0.95, 0.05));
}

local tempList = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ function OnGameEvent_heal_beacon_placed(params) {
hNewHealBeacon = PlaceHealBeacon(230, 6, 3.65, 23, 180, HealBeaconOrigin + offset);
hNewHealBeacon.SetVelocity(LaunchVector(hNewHealBeacon.GetOrigin(), targetPos, 150, 0.5));

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

if (RandIntUniformDistribution(0, 999) >= 669) {
if (RandomHQUniformIntDistribution(0, 999) >= 669) {
hNewFreezeGrenade = DropFreezeGrenade(30, 2, 180, HealBeaconOrigin + offset);
hNewFreezeGrenade.SetVelocity(LaunchVector(hNewFreezeGrenade.GetOrigin(), targetPos, 150, 0.5));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ function ResetHudAndChatForIafPlayer(hMarine) {
if (hMarine == null) {
return;
}
hMarine.ValidateScriptScope();
local role = hMarine.GetScriptScope().Role;
local strRole = GetRoleString(role);
local hPlayer = hMarine.GetCommander();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ function OnGameEvent_weapon_reload(params) {
switch (hWeapon.GetClassname()) {
case "asw_weapon_sniper_rifle": //神射手
//EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_flNextPrimaryAttack\", " + (Time() + fFireRate).tostring() + " );", 0.0, null, null);
local time = Time() + RandFloatUniformDistribution(1.0, 2.0);
local time = Time() + RandomHQUniformFloatDistribution(1.0, 2.0);
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadStart\", " + time.tostring() + " );", 0.0, null, null);
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadEnd\", " + (time + 0.1).tostring() + " );", 0.0, null, null);
break;
case "asw_weapon_pistol": //双手枪
local time = Time() + RandFloatUniformDistribution(0.05, 0.9);
local time = Time() + RandomHQUniformFloatDistribution(0.05, 0.9);
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadStart\", " + time.tostring() + " );", 0.0, null, null);
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadEnd\", " + (time + 0.05).tostring() + " );", 0.0, null, null);
break;
case "asw_weapon_pdw": //单兵防御武器
local time = Time() + RandFloatUniformDistribution(0.05, 0.9);
local time = Time() + RandomHQUniformFloatDistribution(0.05, 0.9);
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadStart\", " + time.tostring() + " );", 0.0, null, null);
EntFireByHandle(hWeapon, "RunScriptCode", "NetProps.SetPropFloat( self, \"m_fFastReloadEnd\", " + (time + 0.05).tostring() + " );", 0.0, null, null);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function OnReceivedTextMessage(recipient, sender, message) {
}

function ToggleVGuiMenu(hSender, hMarine) {
hMarine.ValidateScriptScope();
if (hSender.GetMarine() != g_marine_SilencedMarine) {
if (hMarine.GetScriptScope().IsOpen == true) {
local hVGuiBackground = Entities.FindByName(null, hMarine.GetScriptScope().strVGuiNameBackground)
Expand Down Expand Up @@ -101,7 +102,7 @@ function SetBomb() {
}
g_bool_BombActivited = true;
if (g_marine_Boomer != g_marine_SilencedMarine) {
local delay = RandIntUniformDistribution(0, 5);
local delay = RandomHQUniformIntDistribution(0, 5);
DelayFunctionCall("BomberAlert", "", delay + 0.01);

g_marine_Boomer.PrecacheSoundScript(BOOMER_SOUND.COUNT_DOWN[delay]);
Expand Down Expand Up @@ -129,7 +130,7 @@ function BomberSelfExplode() {
local radius = 150;
local hAttacker = g_marine_Boomer;
local explosionPos = hAttacker.GetOrigin() + Vector(0, 0, 60);
local damageScale = RandFloatNormalDistribution(1.05, 0.05);
local damageScale = RandomHQNormalDistribution(1.05, 0.05);
while (hMarine = Entities.FindByClassnameWithin(hMarine, "asw_marine", explosionPos, 4 * radius)) {
// 检查实体是否有效且存活
if (g_int_Counter > g_int_ImmuneCounter && hMarine.IsValid() && hMarine != hAttacker && hMarine.GetHealth() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ function OnTakeDamage_Alive_Any(victim, inflictor, attacker, weapon, damage, dam
case "asw_weapon_prifle": //原型突击步枪
local distance = (attacker.GetOrigin() - victim.GetOrigin()).Length();
local temp = distance < 250 ? 1.0 : 300.0 / distance;
factor1 = temp * RandFloatUniformDistribution(0.25, 0.54);
factor2 = temp * RandFloatUniformDistribution(0.23, 0.44);
factor3 = temp * RandFloatUniformDistribution(0.27, 0.64);
factor1 = temp * RandomHQUniformFloatDistribution(0.25, 0.54);
factor2 = temp * RandomHQUniformFloatDistribution(0.23, 0.44);
factor3 = temp * RandomHQUniformFloatDistribution(0.27, 0.64);
break;
case "asw_weapon_autogun": //自动机枪
factor1 = 0.47;
Expand Down Expand Up @@ -148,7 +148,7 @@ function OnTakeDamage_Alive_Any(victim, inflictor, attacker, weapon, damage, dam
factor3 = 1.00;
break;
case "asw_weapon_grenades": //手雷
damage = RandFloatNormalDistribution(2000, 200);
damage = RandomHQNormalDistribution(2000, 200);
factor1 = 0.001;
factor2 = 0.005;
factor3 = 0.015;
Expand Down Expand Up @@ -203,6 +203,7 @@ function OnTakeDamage_Alive_Any(victim, inflictor, attacker, weapon, damage, dam
}
damage *= distanceRatio;

attacker.ValidateScriptScope();
local hHud = Entities.FindByName(null, attacker.GetScriptScope().strFlashbangHudName);
local ratio = 1.0;
local currentIntensity;
Expand Down Expand Up @@ -250,6 +251,7 @@ function OnTakeDamage_Alive_Any(victim, inflictor, attacker, weapon, damage, dam
ResetHudAndChatForDeserterPlayer(g_marine_Deserter);
}
}
victim.ValidateScriptScope();
return victim.GetScriptScope().DamageMapModifier * damage;
}

Expand All @@ -258,6 +260,7 @@ function ResetHudAndChatForDeserterPlayer(hMarine) {
return;
}
local hPlayer = hMarine.GetCommander();
hPlayer.ValidateScriptScope();
local role = hMarine.GetScriptScope().Role;
local strRole = GetRoleString(role);

Expand Down Expand Up @@ -330,8 +333,8 @@ function PunchKnockdown(attacker, victim) {
} else {
thresh = hasPowerFist ? 0.9 : 0.75;
}
if (thresh >= RandFloatUniformDistribution(0.0, 1.0)) {
local temp = RandFloatUniformDistribution(1.0, 1.5) * -200;
if (thresh >= RandomHQUniformFloatDistribution(0.0, 1.0)) {
local temp = RandomHQUniformFloatDistribution(1.0, 1.5) * -200;
vecAttackerToVictim.x *= temp;
vecAttackerToVictim.y *= temp;
vecAttackerToVictim.z = 70 * temp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function SetMapHandler() {
temp.z = 0;
local radius = temp.Norm();
if (radius < 100) {
hMarine.SetOrigin(Vector(RandFloatUniformDistribution(-650, 870), RandFloatUniformDistribution(-1590, -1320), -30));
hMarine.SetOrigin(Vector(RandomHQUniformFloatDistribution(-650, 870), RandomHQUniformFloatDistribution(-1590, -1320), -30));
}
}
};
Expand Down Expand Up @@ -326,13 +326,13 @@ function SetMapHandler() {
hMarine.TakeDamage(4, DAMAGE_TYPE.DMG_FALL, null);
}
if (temp.y >= 5129 && temp.y <= 5350) {
hMarine.SetOrigin(Vector(RandIntUniformDistribution(-5606, -5257), RandIntUniformDistribution(4388, 4996), 810));
hMarine.SetOrigin(Vector(RandomHQUniformIntDistribution(-5606, -5257), RandomHQUniformIntDistribution(4388, 4996), 810));
}
}
if (g_int_Counter == g_int_MapKillCounter[0]) {
foreach(hMarine in g_marine_Total) {
if (hMarine != null && hMarine.IsValid() && hMarine.GetOrigin().x > -3200) {
hMarine.SetOrigin(Vector(RandIntUniformDistribution(-3426, -3228), RandIntUniformDistribution(6834, 7258), 810));
hMarine.SetOrigin(Vector(RandomHQUniformIntDistribution(-3426, -3228), RandomHQUniformIntDistribution(6834, 7258), 810));
}
}
}
Expand All @@ -354,13 +354,13 @@ function SetMapHandler() {
g_int_MapKillCounter[0] = g_int_Counter + 600;
}
if (temp.y >= 4947 && temp.y <= 5019) {
hMarine.SetOrigin(Vector(RandIntUniformDistribution(-5642, -5316), RandIntUniformDistribution(5375, 5989), 810) + g_vec_Jac2Offset);
hMarine.SetOrigin(Vector(RandomHQUniformIntDistribution(-5642, -5316), RandomHQUniformIntDistribution(5375, 5989), 810) + g_vec_Jac2Offset);
}
}
if (g_int_Counter == g_int_MapKillCounter[0]) {
foreach(hMarine in g_marine_Total) {
if (hMarine != null && hMarine.IsValid() && (hMarine.GetOrigin().x - g_vec_Jac2Offset.x) <= -3900) {
hMarine.SetOrigin(Vector(RandIntUniformDistribution(-3426, -3228), RandIntUniformDistribution(6834, 7258), 810) + g_vec_Jac2Offset);
hMarine.SetOrigin(Vector(RandomHQUniformIntDistribution(-3426, -3228), RandomHQUniformIntDistribution(6834, 7258), 810) + g_vec_Jac2Offset);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// Better to use built-in MT19937 RNG provided by c++ STL for highest performance.
// void RandomHQSetSeed(int seed) // Do not call this unless necessary. RNG is automatically seeded upon game start.
// void RandomHQSetRandomDevice() // Do not call this unless necessary. RNG is automatically seeded upon game start.
// int RandomHQUniformIntDistribution(int min, int max)
// float RandomHQUniformFloatDistribution(float min, float max)
// float RandomHQNormalDistribution(float mean, float std_dev)


// 基于 Mersenne Twister ( MT19937 )的高质量随机数生成器,具有无偏的均匀分布和正态分布。
_mtArray <- array(624); // 状态数组
_mtIndex <- 0;
Expand Down
1 change: 1 addition & 0 deletions reactivedrop/resource/challenges/rd_first_person.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

"convars" {
"asw_controls" "0"
"rd_draw_restricted_rectangles_coop" "0"
}
}
1 change: 1 addition & 0 deletions reactivedrop/resource/challenges/rd_third_person.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

"convars" {
"asw_controls" "2"
"rd_draw_restricted_rectangles_coop" "0"
}
}
18 changes: 14 additions & 4 deletions src/game/client/c_playerresource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const float PLAYER_RESOURCE_THINK_INTERVAL = 0.2f;
#define PLAYER_DEBUG_NAME "WWWWWWWWWWWWWWW"

ConVar cl_names_debug( "cl_names_debug", "0", FCVAR_DEVELOPMENTONLY );

ConVar cl_add_index_to_name("cl_add_index_to_name", "0", FCVAR_REPLICATED);

void RecvProxy_ChangedTeam( const CRecvProxyData *pData, void *pStruct, void *pOut )
{
Expand Down Expand Up @@ -143,6 +143,7 @@ void C_PlayerResource::OnDataChanged(DataUpdateType_t updateType)

void C_PlayerResource::UpdatePlayerName( int slot )
{
static char szNameTemp[MAX_PLAYERS + 1][MAX_PLAYER_NAME_LENGTH];
if ( slot < 1 || slot > MAX_PLAYERS )
{
Error( "UpdatePlayerName with bogus slot %d\n", slot );
Expand All @@ -155,11 +156,20 @@ void C_PlayerResource::UpdatePlayerName( int slot )
{
g_RDTextFiltering.FilterTextName( sPlayerInfo.name, g_RDTextFiltering.GetClientSteamID( slot ) );
pchPlayerName = sPlayerInfo.name;
V_snprintf(szNameTemp[slot], MAX_PLAYER_NAME_LENGTH - 1, "%d-%s", slot, pchPlayerName);
}

if ( !m_szName[slot] || Q_stricmp( m_szName[slot], pchPlayerName ) )
if (cl_add_index_to_name.GetBool()) {
if (!m_szName[slot] || Q_stricmp(m_szName[slot], szNameTemp[slot]))
{
m_szName[slot] = AllocPooledString(szNameTemp[slot]);
}
}
else
{
m_szName[slot] = AllocPooledString( pchPlayerName );
if (!m_szName[slot] || Q_stricmp(m_szName[slot], pchPlayerName))
{
m_szName[slot] = AllocPooledString(pchPlayerName);
}
}
}

Expand Down
Loading