Enhanced trigger_changelevel

This commit is contained in:
s1lent 2017-10-13 17:12:26 +07:00 committed by Dmitry Novikov
parent e88dae7bb9
commit 96030a48ca
5 changed files with 76 additions and 57 deletions

View File

@ -446,60 +446,6 @@ void CGamePlayerZone::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP
{
FireTargets(STRING(m_iszOutCount), pActivator, this, USE_SET, playersOutCount);
}
/*
int playersInCount = 0;
int playersOutCount = 0;
if (!CanFireForActivator(pActivator))
return;
for (int i = 1; i <= gpGlobals->maxClients; i++)
{
CBaseEntity *pPlayer = UTIL_PlayerByIndex(i);
if (!pPlayer)
continue;
TraceResult trace;
int hullNumber;
hullNumber = human_hull;
if (pPlayer->pev->flags & FL_DUCKING)
{
hullNumber = head_hull;
}
UTIL_TraceModel(pPlayer->pev->origin, pPlayer->pev->origin, hullNumber, edict(), &trace);
if (trace.fStartSolid)
{
playersInCount++;
if (!FStringNull(m_iszInTarget))
{
FireTargets(STRING(m_iszInTarget), pPlayer, pActivator, useType, value);
}
}
else
{
playersOutCount++;
if (!FStringNull(m_iszOutTarget))
{
FireTargets(STRING(m_iszOutTarget), pPlayer, pActivator, useType, value);
}
}
}
if (!FStringNull(m_iszInCount))
{
FireTargets(STRING(m_iszInCount), pActivator, this, USE_SET, playersInCount);
}
if (!FStringNull(m_iszOutCount))
{
FireTargets(STRING(m_iszOutCount), pActivator, this, USE_SET, playersOutCount);
}
*/
}
LINK_ENTITY_TO_CLASS(game_player_hurt, CGamePlayerHurt, CCSGamePlayerHurt)

View File

@ -1246,6 +1246,14 @@ void CChangeLevel::KeyValue(KeyValueData *pkvd)
m_changeTargetDelay = Q_atof(pkvd->szValue);
pkvd->fHandled = TRUE;
}
#ifdef REGAMEDLL_FIXES
else if (FStrEq(pkvd->szKeyName, "percent_of_players"))
{
m_flPercentOfPlayers = Q_atof(pkvd->szValue);
m_flPercentOfPlayers = clamp(m_flPercentOfPlayers, 0.0f, 1.0f);
pkvd->fHandled = TRUE;
}
#endif
else
{
CBaseTrigger::KeyValue(pkvd);
@ -1380,10 +1388,20 @@ void CChangeLevel::ChangeLevelNow(CBaseEntity *pActivator)
void CChangeLevel::TouchChangeLevel(CBaseEntity *pOther)
{
if (!FClassnameIs(pOther->pev, "player"))
{
if (!pOther->IsPlayer())
return;
#ifdef REGAMEDLL_FIXES
if (m_flPercentOfPlayers > 0.0f)
{
int playersInCount = 0;
int playersOutCount = 0;
int playersCount = UTIL_CountPlayersInBrushVolume(true, this, playersInCount, playersOutCount);
if (m_flPercentOfPlayers > float(playersInCount / playersCount))
return;
}
#endif
ChangeLevelNow(pOther);
}

View File

@ -361,6 +361,10 @@ public:
char m_szLandmarkName[MAX_MAPNAME_LENGHT]; // landmark on next map
int m_changeTarget;
float m_changeTargetDelay;
#ifdef REGAMEDLL_FIXES
float m_flPercentOfPlayers;
#endif
};
class CLadder: public CBaseTrigger

View File

@ -331,7 +331,7 @@ public:
virtual void PlayerDetected(const bool fInVolume, CBasePlayer *pPlayer) = 0;
};
int UTIL_CountPlayersInBrushVolume(bool bOnlyAlive, CBaseEntity *pBrushEntity, int &playersInCount, int &playersOutCount, CPlayerInVolumeAdapter *pAdapter);
int UTIL_CountPlayersInBrushVolume(bool bOnlyAlive, CBaseEntity *pBrushEntity, int &playersInCount, int &playersOutCount, CPlayerInVolumeAdapter *pAdapter = nullptr);
inline float_precision UTIL_FixupAngle(float_precision v)
{

View File

@ -2179,6 +2179,57 @@
target(target_destination) : "Target (when bomb blows)"
]
@SolidClass base(Targetname) = trigger_cdaudio : "Trigger CD Audio"
[
health(choices) : "Track #" : -1 =
[
-1 : "Stop"
1 : "Track 1"
2 : "Track 2"
3 : "Track 3"
4 : "Track 4"
5 : "Track 5"
6 : "Track 6"
7 : "Track 7"
8 : "Track 8"
9 : "Track 9"
10 : "Track 10"
11 : "Track 11"
12 : "Track 12"
13 : "Track 13"
14 : "Track 14"
15 : "Track 15"
16 : "Track 16"
17 : "Track 17"
18 : "Track 18"
19 : "Track 19"
20 : "Track 20"
21 : "Track 21"
22 : "Track 22"
23 : "Track 23"
24 : "Track 24"
25 : "Track 25"
26 : "Track 26"
27 : "Track 27"
28 : "Track 28"
29 : "Track 29"
30 : "Track 30"
]
]
@SolidClass base(Targetname) = trigger_changelevel : "Trigger Change level"
[
map(string) : "New map name"
landmark(string) : "Landmark name"
changetarget(target_destination) : "Change Target"
changedelay(string) : "Delay before change target" : "0"
percent_of_players(string) : "Percentage of players needed" : 0
spawnflags(flags) =
[
2: "USE Only" : 0
]
]
@SolidClass base(Breakable, RenderFields, ZHLT, TexLightType) = func_breakable : "Breakable Object"
[
spawnflags(flags) =