Skip to content

Commit 37a0729

Browse files
authored
Merge pull request #956 from ywgATustcbbs/TraitorIconFix
Fix Traitors emotes not displaying on dedicated server.
2 parents 3d3abe0 + ba550fb commit 37a0729

6 files changed

Lines changed: 153 additions & 92 deletions

File tree

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

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
DEBUG <- true; // Debug flags 调试标识
1+
DEBUG <- false; // Debug flags 调试标识
22
INT_MAX <- 2147483647; // Constant 常量
33
isServer <- true; // If the code is running server side or client side 指示代码是在服务端运行的还是在客户端运行的
44
IsPaused <- false; // Not actually being used 没有实际用处
@@ -190,7 +190,14 @@ function SetTraitorIcon(interval = 10) {
190190
if (g_int_Counter % interval != 0) {
191191
return;
192192
}
193-
foreach(hMarine in g_marine_Total) {
193+
194+
195+
local list = {};
196+
for (local i = 6; i < 21; i++) {
197+
list[i] <- 0;
198+
}
199+
local i = 11;
200+
foreach(hMarine in g_marine_Traitor) {
194201
if (hMarine == null || !hMarine.IsValid()) {
195202
continue;
196203
}
@@ -205,30 +212,34 @@ function SetTraitorIcon(interval = 10) {
205212
case ROLE.INFECTED_SNIPER:
206213
case ROLE.INFECTED_DEMO:
207214
case ROLE.INFECTED_DESERTER:
208-
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 8));
215+
list[i] = hMarine.entindex();
216+
i++;
209217
break;
210218
case ROLE.TRAITOR_LEADER:
211-
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 9));
219+
list[6] = hMarine.entindex();
212220
break;
213221
case ROLE.INFECTOR:
214-
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 10));
222+
list[7] = hMarine.entindex();
215223
break;
216224
case ROLE.BOOMER:
217-
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 11));
225+
list[8] = hMarine.entindex();
218226
break;
219227
case ROLE.SILENCER:
220-
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 12));
228+
list[9] = hMarine.entindex();
221229
break;
222230
case ROLE.MIMIC:
223-
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 13));
224-
break;
231+
list[10] = hMarine.entindex();
225232
}
226233
}
227234
foreach(hPlayer in g_player_TraitorHistory) {
228235
if (hPlayer == null || !hPlayer.IsValid()) {
229236
continue;
230237
}
231-
NetProps.SetPropInt(hPlayer, "m_iChallengeScratch", 1);
238+
239+
local hHud2 = Entities.FindByName(null, hPlayer.GetScriptScope().strHudName2);
240+
for(local i = 6;i<21;i++) {
241+
hHud2.SetInt(i, list[i]);
242+
}
232243
}
233244
}
234245

@@ -1158,10 +1169,10 @@ function DeterminRoleCount() {
11581169
//g_bool_HasInfector = true;
11591170
break;
11601171
case 1:
1161-
g_bool_HasBoomer = true;
1172+
g_bool_HasBoomer = true;
11621173
break;
11631174
case 2:
1164-
g_bool_HasSilencer = true;
1175+
g_bool_HasSilencer = true;
11651176
break;
11661177
}
11671178
g_bool_HasShield = (RandomHQUniformIntDistribution(0, 8) == 0);
@@ -1461,6 +1472,9 @@ function CreatePlayerHud(hPlayer) {
14611472
hHud1.SetEntity(0, hPlayer);
14621473
local strHud1 = "HUD_" + UniqueString();
14631474
hHud1.SetName(strHud1);
1475+
for (local i = 6; i < 21; i++) {
1476+
hHud1.SetInt(i, 0);
1477+
}
14641478

14651479
hPlayer.GetScriptScope().strHudName1 <- strHud1;
14661480
hHud1.SetInt(0, ROLE.SPECTATOR);
@@ -1488,6 +1502,9 @@ function CreatePlayerHud(hPlayer) {
14881502
hHud2.SetEntity(0, hPlayer);
14891503
local strHud2 = "HUD_" + UniqueString();
14901504
hHud2.SetName(strHud2);
1505+
for (local i = 6; i < 21; i++) {
1506+
hHud2.SetInt(i, 0);
1507+
}
14911508

14921509
hPlayer.ValidateScriptScope();
14931510
hPlayer.GetScriptScope().strHudName2 <- strHud2;
@@ -1516,6 +1533,9 @@ function CreatePlayerHud(hPlayer) {
15161533
hHud4.SetEntity(0, hPlayer);
15171534
local strHud4 = "HUD_" + UniqueString();
15181535
hHud4.SetName(strHud4);
1536+
for (local i = 6; i < 21; i++) {
1537+
hHud4.SetInt(i, 0);
1538+
}
15191539

15201540
hPlayer.GetScriptScope().strHudName4 <- strHud4;
15211541
hHud4.SetInt(0, ROLE.SPECTATOR);
@@ -1543,6 +1563,9 @@ function CreatePlayerHud(hPlayer) {
15431563
hHud3.SetEntity(0, hPlayer);
15441564
local strhHud3 = "HUD_" + UniqueString();
15451565
hHud3.SetName(strhHud3);
1566+
for (local i = 6; i < 21; i++) {
1567+
hHud3.SetInt(i, 0);
1568+
}
15461569

15471570
hPlayer.ValidateScriptScope();
15481571
hPlayer.GetScriptScope().strHudName3 <- strhHud3;

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

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ function OnTakeDamage_Alive_Any(victim, inflictor, attacker, weapon, damage, dam
4646
factor3 = 0.10;
4747
break;
4848
case "asw_weapon_devastator": //毁灭者霰弹
49-
factor1 = 0.33;
50-
factor2 = 0.23;
51-
factor3 = 0.46;
49+
factor1 = 0.31;
50+
factor2 = 0.21;
51+
factor3 = 0.41;
5252
break;
5353
case "asw_weapon_vindicator": //复仇者霰弹
54-
factor1 = 0.16;
55-
factor2 = 0.12;
56-
factor3 = 0.20;
54+
factor1 = 0.20;
55+
factor2 = 0.15;
56+
factor3 = 0.25;
5757
break;
5858
default:
5959
factor1 = 0.08;
@@ -105,9 +105,9 @@ function OnTakeDamage_Alive_Any(victim, inflictor, attacker, weapon, damage, dam
105105
factor3 = 0.40;
106106
break;
107107
case "asw_weapon_minigun": //迷你机枪
108-
factor1 = 0.26;
109-
factor2 = 0.20;
110-
factor3 = 0.32;
108+
factor1 = 0.24;
109+
factor2 = 0.18;
110+
factor3 = 0.30;
111111
break;
112112
case "asw_weapon_deagle": //斗牛犬
113113
factor1 = 0.26;
@@ -137,9 +137,9 @@ function OnTakeDamage_Alive_Any(victim, inflictor, attacker, weapon, damage, dam
137137
factor3 = 0.145;
138138
break;
139139
case "asw_weapon_medrifle": //医疗冲锋枪
140-
factor1 = 0.55;
141-
factor2 = 0.45;
142-
factor3 = 0.65;
140+
factor1 = 0.50;
141+
factor2 = 0.40;
142+
factor3 = 0.60;
143143
break;
144144
case "asw_weapon_laser_mines": //激光地雷
145145
damage = 6;

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
int 2 - 行号
55
int 3 - 投降,当前人数
66
int 4 - 投降,总人数
7+
8+
int 6 - TRAITOR_LEADER 对应的marine index
9+
int 7 - INFECTOR 对应的marine index
10+
int 8 - BOOMER 对应的marine index
11+
int 9 - SILENCER 对应的marine index
12+
int 10 - MIMIC 对应的marine index
13+
int 11 - TRAITOR 对应的marine index
14+
...
15+
int 20 - TRAITOR 对应的marine index
16+
717
int 63 - 标识,1和2代表显示的是内鬼提示1和提示2。3代表显示的是内鬼开始投票,4代表投票中,5代表投票停止
818
919
float 0 - HUD信息显示的起始时间
@@ -45,9 +55,32 @@ IncludeScript("challenge_traitors_enums.nut");
4555

4656
FONT_DEFAULTLARGE <- self.LookupFont("DefaultMedium");
4757

58+
TEXTURE_TRAITOR <- self.LookupTexture("vgui/swarm/Emotes/EmoteTraitor");
59+
TEXTURE_TRAITORS <- {
60+
[6] = self.LookupTexture("vgui/swarm/Emotes/EmoteTraitorLeader"),
61+
[7] = self.LookupTexture("vgui/swarm/Emotes/EmoteInfector"),
62+
[8] = self.LookupTexture("vgui/swarm/Emotes/EmoteBoomer"),
63+
[9] = self.LookupTexture("vgui/swarm/Emotes/EmoteSilencer"),
64+
[10] = self.LookupTexture("vgui/swarm/Emotes/EmoteMimic"),
65+
[11] = TEXTURE_TRAITOR,
66+
[12] = TEXTURE_TRAITOR,
67+
[13] = TEXTURE_TRAITOR,
68+
[14] = TEXTURE_TRAITOR,
69+
[15] = TEXTURE_TRAITOR,
70+
[16] = TEXTURE_TRAITOR,
71+
[17] = TEXTURE_TRAITOR,
72+
[18] = TEXTURE_TRAITOR,
73+
[19] = TEXTURE_TRAITOR,
74+
[20] = TEXTURE_TRAITOR,
75+
};
76+
4877
xMargin <- 0;
4978

5079
function Paint() {
80+
for (local i = 6; i < 21; i++) {
81+
PaintTraitorIcon(i);
82+
}
83+
5184
//如果正在控制士兵,显示信息。
5285
if (self.GetEntity(0) == GetLocalPlayer()) {
5386
local message = self.GetString(0);
@@ -96,6 +129,33 @@ function PaintMsg(point, role, font, message) {
96129

97130
}
98131

132+
function PaintTraitorIcon(idx) {
133+
134+
if (self.GetInt(idx) <= 0 || TEXTURE_TRAITORS[idx] == -1) {
135+
return;
136+
}
137+
local screenPos = self.ClientGetEntityScreenPos(self.GetInt(idx));
138+
if (screenPos.z < 0.5) { //无效屏幕坐标
139+
return;
140+
}
141+
142+
local xPos = screenPos.x;
143+
local yPos = screenPos.y;
144+
145+
local fScale = (ScreenHeight() / 768.0) * 0.4;
146+
local HalfW = 128.0 * fScale * 0.5;
147+
local HalfH = 128.0 * fScale * 0.5;
148+
yPos += 100 * (ScreenHeight() / 768.0);
149+
150+
local points = [
151+
{x = xPos - HalfW, y = yPos - HalfH, s = 0, t = 0},
152+
{x = xPos + HalfW, y = yPos - HalfH, s = 1, t = 0},
153+
{x = xPos + HalfW, y = yPos + HalfH, s = 1, t = 1},
154+
{x = xPos - HalfW, y = yPos + HalfH, s = 0, t = 1}
155+
];
156+
self.PaintPolygon(points, 255, 255, 255, 255, TEXTURE_TRAITORS[idx]);
157+
}
158+
99159
function interp(i, t) {
100160
local t0 = self.GetFloat(0 + 3 * i);
101161
local t1 = self.GetFloat(3 + 3 * i);

src/game/client/swarm/vgui/asw_hud_emotes.cpp

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class CASWHudEmotes : public CASW_HudElement, public vgui::Panel
5757
virtual void PaintEmotes();
5858
virtual void PaintEmotesFor( C_ASW_Marine *pMarine );
5959
virtual void PaintEmote( C_BaseEntity *pEnt, float fTime, int iTexture, float fScale = 1.0f );
60-
virtual void PaintTraitorEmote(C_BaseEntity* pEnt, int iTexture, float fScale = 1.0f);
6160
virtual bool ShouldDraw( void ) { return asw_draw_hud.GetBool() && CASW_HudElement::ShouldDraw(); }
6261

6362
CPanelAnimationVarAliasType( int, m_nMedicTexture, "MedicEmoteTexture", "vgui/swarm/Emotes/EmoteMedic", "textureid" );
@@ -77,14 +76,6 @@ class CASWHudEmotes : public CASW_HudElement, public vgui::Panel
7776
CPanelAnimationVarAliasType( int, m_nHackTexture, "HackTexture", "vgui/swarm/ClassIcons/HackIcon", "textureid" );
7877
CPanelAnimationVarAliasType( int, m_nWeldTexture, "WeldTexture", "vgui/swarm/ClassIcons/WeldIcon", "textureid" );
7978
CPanelAnimationVarAliasType( int, m_nReviveMarineTexture, "ReviveMarineTexture", "vgui/swarm/ClassIcons/revivemarine", "textureid" );
80-
81-
// Traitors emotes
82-
CPanelAnimationVarAliasType( int, m_nTraitorEmoteTexture, "TraitorEmoteTexture", "vgui/swarm/Emotes/EmoteTraitor", "textureid" );
83-
CPanelAnimationVarAliasType( int, m_nTraitorLeaderEmoteTexture, "TraitorLeaderEmoteTexture", "vgui/swarm/Emotes/EmoteTraitorLeader", "textureid" );
84-
CPanelAnimationVarAliasType( int, m_nInfectorEmoteTexture, "InfectorEmoteTexture", "vgui/swarm/Emotes/EmoteInfector", "textureid" );
85-
CPanelAnimationVarAliasType( int, m_nBoomerEmoteTexture, "BoomerEmoteTexture", "vgui/swarm/Emotes/EmoteBoomer", "textureid" );
86-
CPanelAnimationVarAliasType( int, m_nSilencerEmoteTexture, "SilencerEmoteTexture", "vgui/swarm/Emotes/EmoteSilencer", "textureid" );
87-
CPanelAnimationVarAliasType( int, m_nMimicEmoteTexture, "MimicEmoteTexture", "vgui/swarm/Emotes/EmoteMimic", "textureid" );
8879
};
8980

9081
DECLARE_HUDELEMENT( CASWHudEmotes );
@@ -158,26 +149,6 @@ void CASWHudEmotes::PaintEmotesFor( C_ASW_Marine *pMarine )
158149
if ( pMarine->m_iClientEmote & ( 1 << 14 ) )
159150
PaintEmote( pMarine, pMarine->m_fEmoteThanksTime, m_nThanksTexture );
160151

161-
if ( _rd_traitors_challenge_enabled.GetBool() )
162-
{
163-
C_ASW_Player *pLocalPlayer = C_ASW_Player::GetLocalASWPlayer();
164-
if ( pLocalPlayer && ( pLocalPlayer->m_iChallengeScratch & 1 ) )
165-
{
166-
if ( pMarine->m_iEmote & ( 1 << 8 ) )
167-
PaintTraitorEmote( pMarine, m_nTraitorEmoteTexture, 0.35f );
168-
if ( pMarine->m_iEmote & ( 1 << 9 ) )
169-
PaintTraitorEmote( pMarine, m_nTraitorLeaderEmoteTexture, 0.35f );
170-
if ( pMarine->m_iEmote & ( 1 << 10 ) )
171-
PaintTraitorEmote( pMarine, m_nInfectorEmoteTexture, 0.35f );
172-
if ( pMarine->m_iEmote & ( 1 << 11 ) )
173-
PaintTraitorEmote( pMarine, m_nBoomerEmoteTexture, 0.35f );
174-
if ( pMarine->m_iEmote & ( 1 << 12 ) )
175-
PaintTraitorEmote( pMarine, m_nSilencerEmoteTexture, 0.35f );
176-
if ( pMarine->m_iEmote & ( 1 << 13 ) )
177-
PaintTraitorEmote( pMarine, m_nMimicEmoteTexture, 0.35f );
178-
}
179-
}
180-
181152
bool bBuildingSentry = false;
182153
bool bWelding = false;
183154

@@ -312,43 +283,4 @@ void CASWHudEmotes::PaintEmote( C_BaseEntity *pEnt, float fTime, int iTexture, f
312283
//xPos + HalfW, yPos + HalfH);
313284
}
314285
}
315-
}
316-
317-
void CASWHudEmotes::PaintTraitorEmote(C_BaseEntity* pEnt, int iTexture, float fEmoteScale)
318-
{
319-
//Msg("PaintEmote scale = %f\n", fEmoteScale);
320-
if (fEmoteScale < 0)
321-
fEmoteScale = 0;
322-
Vector screenPos;
323-
Vector vecFacing;
324-
AngleVectors(pEnt->GetRenderAngles(), &vecFacing);
325-
vecFacing *= 5;
326-
// BenLubar: Fix emotes being offset when the camera is rotated
327-
float flYaw = (ASWInput() ? ASWInput()->ASW_GetCameraYaw() : 90) / 180 * M_PI;
328-
Vector vecOffset(cosf(flYaw) * 40, sinf(flYaw) * 40, 70);
329-
if (!debugoverlay->ScreenPosition(pEnt->GetRenderOrigin() + vecOffset + vecFacing, screenPos))
330-
{
331-
float xPos = screenPos[0];
332-
float yPos = screenPos[1];
333-
334-
if (iTexture != -1)
335-
{
336-
float fScale = (ScreenHeight() / 768.0f) * fEmoteScale;
337-
float HalfW = 128.0f * fScale * 0.5f;
338-
float HalfH = 128.0f * fScale * 0.5f;
339-
yPos += 100 * (ScreenHeight() / 768.0f);
340-
341-
surface()->DrawSetColor(Color(255, 255, 255, 255.0f));
342-
surface()->DrawSetTexture(iTexture);
343-
344-
Vertex_t points[4] =
345-
{
346-
Vertex_t(Vector2D(xPos - HalfW, yPos - HalfH), Vector2D(0,0)),
347-
Vertex_t(Vector2D(xPos + HalfW, yPos - HalfH), Vector2D(1,0)),
348-
Vertex_t(Vector2D(xPos + HalfW, yPos + HalfH), Vector2D(1,1)),
349-
Vertex_t(Vector2D(xPos - HalfW, yPos + HalfH), Vector2D(0,1))
350-
};
351-
surface()->DrawTexturedPolygon(4, points);
352-
}
353-
}
354286
}

0 commit comments

Comments
 (0)