Skip to content

Commit 2ea3519

Browse files
committed
Show secret icons on traitor marines
1. As described. Currently vgui/swarm/Emotes/EmoteExclaim is used. 2. Replace TakeDamage() with Die() to fix marines sometimes ignoring TakeDamage() issue 3. Fix minor issues when debuging with bots
1 parent f8e9ff3 commit 2ea3519

6 files changed

Lines changed: 142 additions & 19 deletions

File tree

reactivedrop/content/traitors_challenge/resource/challenges/traitors.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"description" "#challenge_traitors_description"
44
"allowed_mode" "coop"
55
"convars" {
6+
"_rd_traitors_challenge_enabled" "1"
67
"rd_player_bots_allowed" "0"
78
"rd_add_index_to_name" "1"
89
"rd_draw_restricted_rectangles_coop" "1"

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

Lines changed: 68 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ function Update() {
152152

153153
//DebugKillAliens(20);
154154

155+
SetTraitorIcon();
156+
155157
DropWeapon();
156158
RefreshSkillMenu();
157159
DetectAndApplySkill(5);
@@ -184,6 +186,52 @@ function DebugKillAliens(interval = 1) {
184186
}
185187
}
186188

189+
function SetTraitorIcon(interval = 10) {
190+
if (g_int_Counter % interval != 0) {
191+
return;
192+
}
193+
foreach(hMarine in g_marine_Total) {
194+
if (hMarine == null || !hMarine.IsValid()) {
195+
continue;
196+
}
197+
hMarine.ValidateScriptScope();
198+
switch (hMarine.GetScriptScope().Role) {
199+
case ROLE.TRAITOR:
200+
case ROLE.INFECTED_IAF:
201+
case ROLE.INFECTED_SCANNER:
202+
case ROLE.INFECTED_BIOCHEMIST:
203+
case ROLE.INFECTED_IAF_LEADER:
204+
case ROLE.INFECTED_SHIELD:
205+
case ROLE.INFECTED_SNIPER:
206+
case ROLE.INFECTED_DEMO:
207+
case ROLE.INFECTED_DESERTER:
208+
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 8));
209+
break;
210+
case ROLE.TRAITOR_LEADER:
211+
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 9));
212+
break;
213+
case ROLE.INFECTOR:
214+
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 10));
215+
break;
216+
case ROLE.BOOMER:
217+
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 11));
218+
break;
219+
case ROLE.SILENCER:
220+
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 12));
221+
break;
222+
case ROLE.MIMIC:
223+
NetProps.SetPropInt(hMarine, "m_iEmote", NetProps.GetPropInt(hMarine, "m_iEmote") | (1 << 13));
224+
break;
225+
}
226+
}
227+
foreach(hPlayer in g_player_TraitorHistory) {
228+
if (hPlayer == null || !hPlayer.IsValid()) {
229+
continue;
230+
}
231+
NetProps.SetPropInt(hPlayer, "m_iFrags", 99);
232+
}
233+
}
234+
187235
function DropWeapon() {
188236
local idx_end = g_int_Counter % 31;
189237
for (local i = 0; i * 31 + idx_end < g_int_MarineCount; i++) {
@@ -562,8 +610,7 @@ function DetectAndApplySkill(interval = 1) {
562610
}
563611

564612
if (hMarine != g_marine_Deserter) {
565-
hMarine.SetHealth(1);
566-
hMarine.TakeDamage(999, DAMAGE_TYPE.DMG_FALL, null);
613+
hMarine.Die();
567614
} else {
568615
if (Time() > g_marine_Deserter.GetScriptScope().RevealTime + 30.0) {
569616
hMarine.SetHealth(1);
@@ -748,7 +795,7 @@ function RemoveBot(interval) {
748795
if (hMarine.GetHealth() > 15) {
749796
hMarine.SetHealth(15);
750797
}
751-
// hMarine.TakeDamage( 256, 64, hMarine );// 修复了机器人不死的bug,但是微了保留之前的体验,这里不杀死机器人,这样意外掉出地图,还有希望丝血传送回来。This will kill bot, but it would be beter to set bot health to 1 so that one can have a chance to teleport back if they fall outside of the map, also preventing players from abuse bot tp.
798+
// hMarine.Die();// 这里不杀死机器人,这样意外掉出地图,还有希望丝血传送回来。This will kill bot, but it would be beter to set bot health to 1 so that one can have a chance to teleport back if they fall outside of the map, also preventing players from abuse bot tp.
752799
}
753800
}
754801
}
@@ -847,12 +894,6 @@ function WriteMatchResultToFile(winner) {
847894
StringToFile("Challenge_Traitor_Result_" + GetLocalTime().tostring() + ".txt", g_str_GameResult);
848895
}
849896

850-
function GetLocalTime() {
851-
local localTime = {};
852-
LocalTime(localTime);
853-
return localTime.dayofyear * 86400 + localTime.hour * 3600 + localTime.minute * 60 + localTime.second;
854-
}
855-
856897
function ShowSpeciallRolesList() {
857898
local hPlayer = null;
858899
while (hPlayer = Entities.FindByClassname(hPlayer, "player")) {
@@ -963,8 +1004,7 @@ function InitializeMarineList() {
9631004
hMarine.RemoveWeapon(1);
9641005
hMarine.RemoveWeapon(2);
9651006
hMarine.SetOrigin(hMarine.GetOrigin() + Vector(0, -5000, 0));
966-
hMarine.SetHealth(1);
967-
hMarine.TakeDamage(999, DAMAGE_TYPE.DMG_FALL, null);
1007+
hMarine.Die();
9681008
} else {
9691009
g_marine_Total.append(hMarine); // 将所有士兵句柄存入列表,句柄作为士兵的唯一标识
9701010
g_lst_MenuProps.append(InitializeMenuProps(hMarine));
@@ -1221,6 +1261,9 @@ function DelayFunctionCall(function_name, function_params, delay) {
12211261

12221262
function ClientPrintRoles() {
12231263
foreach(hMarine in g_marine_Total) {
1264+
if (!hMarine || !hMarine.IsValid() || !hMarine.IsInhabited()) {
1265+
continue;
1266+
}
12241267
local hPlayer = hMarine.GetCommander();
12251268
local strLanguage = GetClientLanguage(hPlayer.entindex());
12261269

@@ -1237,6 +1280,9 @@ function ClientPrintRoles() {
12371280
}
12381281

12391282
foreach(hMarine in g_marine_TraitorAlive) {
1283+
if (!hMarine || !hMarine.IsValid() || !hMarine.IsInhabited()) {
1284+
continue;
1285+
}
12401286
local hPlayer = hMarine.GetCommander();
12411287
local role = hMarine.GetScriptScope().Role;
12421288
local strRole = GetRoleString(role);
@@ -1246,6 +1292,9 @@ function ClientPrintRoles() {
12461292
LocalizedClientPrint(hPlayer, 3, g_str_TraitorNameList, "#challenge_traitors_traitor_list", "#challenge_traitors_traitor_player_unavailable");
12471293
}
12481294
foreach(hMarine in g_marine_IafAlive) {
1295+
if (!hMarine || !hMarine.IsValid() || !hMarine.IsInhabited()) {
1296+
continue;
1297+
}
12491298
local hPlayer = hMarine.GetCommander();
12501299
local role = hMarine.GetScriptScope().Role;
12511300
local strRole = GetRoleString(role);
@@ -1272,7 +1321,6 @@ function FixMapIssueOnStart() {
12721321
if (hMarine == null || !hMarine.IsValid()) {
12731322
continue;
12741323
}
1275-
//printl(hMarine.GetOrigin());
12761324
// 防止acc32-4中玩家出生在隧道里
12771325
if (g_enum_CurrentMap == MAP.ACC_4 && hMarine.GetOrigin().y > -5000) {
12781326
hMarine.SetOrigin(Vector(-1012 + RandomInt(0, 30), -6204 + RandomInt(0, 30), 569 + RandomInt(0, 30)));
@@ -1354,7 +1402,7 @@ function CreatePlayerHudAndVGuiEntities() {
13541402
}
13551403

13561404
function SetHudForIafPlayer(hMarine, role) {
1357-
if (hMarine == null) {
1405+
if (!hMarine || !hMarine.IsValid() || !hMarine.IsInhabited()) {
13581406
return;
13591407
}
13601408
local strRole = GetRoleString(role);
@@ -1371,7 +1419,7 @@ function SetHudForIafPlayer(hMarine, role) {
13711419
}
13721420

13731421
function SetHudForTraitorPlayer(hMarine, role, timeOffset = 2.0) {
1374-
if (hMarine == null) {
1422+
if (hMarine == null || !hMarine.IsValid() || !hMarine.IsInhabited()) {
13751423
return;
13761424
}
13771425
local strRole = GetRoleString(role);
@@ -2315,8 +2363,12 @@ function SelectRoles() {
23152363

23162364
//生成内鬼历史列表和当前内鬼玩家列表
23172365
foreach(idx, hMarine in g_marine_Traitor) {
2318-
g_player_TraitorHistory.append(hMarine.GetCommander());
2319-
g_player_Traitor[idx] = hMarine.GetCommander();
2366+
if (hMarine && hMarine.IsValid() && hMarine.IsInhabited()) {
2367+
g_player_TraitorHistory.append(hMarine.GetCommander());
2368+
g_player_Traitor[idx] = hMarine.GetCommander();
2369+
} else {
2370+
g_player_Traitor[idx] = null;
2371+
}
23202372
}
23212373

23222374
//选择特殊角色

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ g_ModeScript.OnGameEvent_marine_selected <- function(params) {
8484
if (tempPlayer == hPlayer) // 如果曾经做过内鬼,直接处死反骨仔
8585
{
8686
hMarine.SetHealth(1);
87-
hMarine.TakeDamage(999, DAMAGE_TYPE.DMG_FALL, null);
87+
hMarine.Die();
8888
LocalizedClientPrint(tempPlayer, 3, "%s1", "#challenge_traitors_iaf_bot_killed_notify");
8989

9090
local strLanguage = GetClientLanguage(hMarine.GetCommander().entindex());

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ function SetMapHandler() {
204204
hMarine.GetScriptScope().DamageMapModifier = 1.0;
205205
local temp = hMarine.GetOrigin();
206206
if ((temp.x > 400 && temp.x < 800 && temp.y > 1500 && temp.y < 1900) || (temp.x < 100 && temp.y < 1600)) {
207-
hMarine.TakeDamage(999, DAMAGE_TYPE.DMG_FALL, null);
207+
hMarine.Die();
208208
} else if (temp.x < 0 && temp.z > 720) {
209209
hMarine.TakeDamage(10, DAMAGE_TYPE.DMG_FALL, null);
210210
}

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

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "c_asw_door.h"
2424
#include "c_asw_use_area.h"
2525
#include "asw_input.h"
26+
#include "c_playerresource.h"
2627

2728
#include "ConVar.h"
2829
#include "tier0/vprof.h"
@@ -37,6 +38,7 @@
3738
using namespace vgui;
3839

3940
extern ConVar asw_draw_hud;
41+
ConVar _rd_traitors_challenge_enabled("_rd_traitors_challenge_enabled", "0", FCVAR_REPLICATED | FCVAR_HIDDEN, "An internal convar to indicate whether the traitors challenge is enabled or not. This is used to determine whether the traitor emotes should be shown or not.");
4042

4143
//-----------------------------------------------------------------------------
4244
// Purpose: Shows the marines emote graphics
@@ -54,6 +56,7 @@ class CASWHudEmotes : public CASW_HudElement, public vgui::Panel
5456
virtual void PaintEmotes();
5557
virtual void PaintEmotesFor( C_ASW_Marine *pMarine );
5658
virtual void PaintEmote( C_BaseEntity *pEnt, float fTime, int iTexture, float fScale = 1.0f );
59+
virtual void PaintTraitorEmote(C_BaseEntity* pEnt, int iTexture, float fScale = 1.0f);
5760
virtual bool ShouldDraw( void ) { return asw_draw_hud.GetBool() && CASW_HudElement::ShouldDraw(); }
5861

5962
CPanelAnimationVarAliasType( int, m_nMedicTexture, "MedicEmoteTexture", "vgui/swarm/Emotes/EmoteMedic", "textureid" );
@@ -70,6 +73,14 @@ class CASWHudEmotes : public CASW_HudElement, public vgui::Panel
7073
CPanelAnimationVarAliasType( int, m_nHackTexture, "HackTexture", "vgui/swarm/ClassIcons/HackIcon", "textureid" );
7174
CPanelAnimationVarAliasType( int, m_nWeldTexture, "WeldTexture", "vgui/swarm/ClassIcons/WeldIcon", "textureid" );
7275
CPanelAnimationVarAliasType( int, m_nReviveMarineTexture, "ReviveMarineTexture", "vgui/swarm/ClassIcons/revivemarine", "textureid" );
76+
77+
// Traitors emotes
78+
CPanelAnimationVarAliasType(int, m_nTraitorEmoteTexture, "TraitorEmoteTexture", "vgui/swarm/Emotes/EmoteExclaim", "textureid");
79+
CPanelAnimationVarAliasType(int, m_nTraitorLeaderEmoteTexture, "TraitorLeaderEmoteTexture", "vgui/swarm/Emotes/EmoteExclaim", "textureid");
80+
CPanelAnimationVarAliasType(int, m_nInfectorEmoteTexture, "InfectorEmoteTexture", "vgui/swarm/Emotes/EmoteExclaim", "textureid");
81+
CPanelAnimationVarAliasType(int, m_nBoomerEmoteTexture, "BoomerEmoteTexture", "vgui/swarm/Emotes/EmoteExclaim", "textureid");
82+
CPanelAnimationVarAliasType(int, m_nSilencerEmoteTexture, "SilencerEmoteTexture", "vgui/swarm/Emotes/EmoteExclaim", "textureid");
83+
CPanelAnimationVarAliasType(int, m_nMimicEmoteTexture, "MimicEmoteTexture", "vgui/swarm/Emotes/EmoteExclaim", "textureid");
7384
};
7485

7586
DECLARE_HUDELEMENT( CASWHudEmotes );
@@ -141,6 +152,26 @@ void CASWHudEmotes::PaintEmotesFor( C_ASW_Marine *pMarine )
141152
if ( pMarine->m_iClientEmote & ( 1 << 7 ) )
142153
PaintEmote( pMarine, pMarine->m_fEmoteQuestionTime, m_nQuestionTexture );
143154

155+
if (_rd_traitors_challenge_enabled.GetBool())
156+
{
157+
C_ASW_Player* pPlayer = C_ASW_Player::GetLocalASWPlayer();
158+
if (pPlayer && g_PR && g_PR->GetPlayerScore(pPlayer->entindex()) == 99)
159+
{
160+
if (pMarine->m_iEmote & (1 << 8))
161+
PaintTraitorEmote(pMarine, m_nTraitorEmoteTexture, 0.35f);
162+
if (pMarine->m_iEmote & (1 << 9))
163+
PaintTraitorEmote(pMarine, m_nTraitorLeaderEmoteTexture, 0.35f);
164+
if (pMarine->m_iEmote & (1 << 10))
165+
PaintTraitorEmote(pMarine, m_nInfectorEmoteTexture, 0.35f);
166+
if (pMarine->m_iEmote & (1 << 11))
167+
PaintTraitorEmote(pMarine, m_nBoomerEmoteTexture, 0.35f);
168+
if (pMarine->m_iEmote & (1 << 12))
169+
PaintTraitorEmote(pMarine, m_nSilencerEmoteTexture, 0.35f);
170+
if (pMarine->m_iEmote & (1 << 13))
171+
PaintTraitorEmote(pMarine, m_nMimicEmoteTexture, 0.35f);
172+
}
173+
}
174+
144175
bool bBuildingSentry = false;
145176
bool bWelding = false;
146177

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

src/game/server/swarm/asw_marine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ IMPLEMENT_SERVERCLASS_ST(CASW_Marine, DT_ASW_Marine)
227227
SendPropBool (SENDINFO(m_bOnFire)),
228228

229229
// emotes
230-
SendPropInt ( SENDINFO( m_iEmote ), 8, SPROP_UNSIGNED ),
230+
SendPropInt ( SENDINFO( m_iEmote ), 16, SPROP_UNSIGNED ),
231231
SendPropFloat ( SENDINFO( m_flLastMedicCall ) ),
232232
SendPropFloat ( SENDINFO( m_flLastAmmoCall ) ),
233233

0 commit comments

Comments
 (0)