Skip to content
Open
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
1 change: 1 addition & 0 deletions sizzlinglib/include/SizzPluginContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,5 @@ class CSizzPluginContext
ConVarRef m_refRedTeamName;
};

static const int sCrusadersCrossbowType = 11;
#endif // SIZZ_PLUGIN_CONTEXT_H
44 changes: 44 additions & 0 deletions sizzlingstats/LogStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ bool CLogStats::Load( CSizzPluginContext &plugin_context )
m_context->AddListener( this, "item_pickup", true );
m_context->AddListener( this, "player_hurt", true );
m_context->AddListener( this, "player_healed", true );
m_context->AddListener( this, "arrow_impact", true );
m_context->AddListener( this, "player_spawn", true );
m_context->AddListener( this, "player_team", true );
m_context->AddListener( this, "player_changename", true );
Expand Down Expand Up @@ -275,6 +276,49 @@ void CLogStats::FireGameEvent( IGameEvent *event )
WriteLog( log );
//L 03/21/2011 - 02:35:56: "GooB<330><STEAM_0:1:23384772><Blue>" picked up item "tf_ammo_pack"
}
else if ( FStrEq( name, "arrow_impact" ) )
{
// Only count crusader's crossbow
if ( event->GetInt("projectileType") == sCrusadersCrossbowType )
{

int healer = event->GetInt( "shooter" );
playerInfo &pInfo1 = m_entIndexToPlayerInfo[healer];

int patient = event->GetInt( "attachedEntity" );
playerInfo &pInfo2 = m_entIndexToPlayerInfo[patient];

if (pInfo1.teamid == pInfo2.teamid)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticing that there's an IsDead check here. Will the event fire if you arrow a dead teammate's ragdoll? or the position where they died?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would have to test. I wanted to protect the case where the medic shot and then immediately died. I figured I might as well check the other case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it, it seems proper for players to have this stat counted regardless of whether they are alive or not. I believe the heal points from arrows are counted that way too. The IsPlayer check should be removed too. I forget the exact conditions for it to return true/false, but I don't think it's doing much for us here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if someone shoots an arrow and then quits the server before the arrow
connects?

On Mon, Aug 22, 2016 at 8:07 PM, Jordan Cristiano notifications@github.com
wrote:

In sizzlingstats/LogStats.cpp
#27 (comment)
:

  •   // Only count crusader's crossbow
    
  •   if ( event->GetInt("projectileType") == 11 )
    
  •   {
    
  •       int healer = event->GetInt( "shooter" );
    
  •       playerInfo &pInfo1 = m_entIndexToPlayerInfo[healer];
    
  •       int patient = event->GetInt( "attachedEntity" );
    
  •       playerInfo &pInfo2 = m_entIndexToPlayerInfo[patient];
    
  •       // Only count arrows for alive players and on the same team
    
  •       if (pInfo1.pPlayerInfo->IsPlayer() && !pInfo1.pPlayerInfo->IsDead()
    
  •        && pInfo2.pPlayerInfo->IsPlayer() && !pInfo2.pPlayerInfo->IsDead()
    
  •        && pInfo1.teamid == pInfo2.teamid)
    
  •       {
    

Thinking about it, it seems proper for players to have this stat counted
regardless of whether they are alive or not. I believe the heal points from
arrows are counted that way too. The IsPlayer check should be removed too.
I forget the exact conditions for it to return true/false, but I don't
think it's doing much for us here.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/SizzlingStats/sizzlingplugins/pull/27/files/9ede4cb9ef2e78f32b5d4223c9b87a53d77203ba#r75782581,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACZ9ib2hMfy44RzzS4QNcinSp3czHwqjks5qijmogaJpZM4Jk3IH
.

vec_t distance = pInfo1.pPlayerInfo->GetAbsOrigin().DistTo(pInfo2.pPlayerInfo->GetAbsOrigin());

if ( pInfo1.steamid[0] == '\0' )
{
m_context->GetSteamIDString(pInfo1.userid, pInfo1.steamid, sizeof(pInfo1.steamid));
}

if ( pInfo2.steamid[0] == '\0' )
{
m_context->GetSteamIDString(pInfo2.userid, pInfo2.steamid, sizeof(pInfo2.steamid));
}

char log[196];
Q_snprintf( log, 196, "\"%s<%d><%s><%s>\" triggered \"arrow_impact\" against \"%s<%d><%s><%s> (distance \"%.2f\")\"\n",
pInfo1.name,
healer,
pInfo1.steamid,
teamNames[pInfo1.teamid],
pInfo2.name,
patient,
pInfo2.steamid,
teamNames[pInfo2.teamid],
distance );
WriteLog( log );
// L 08/15/2016 - 15:47:39: "happs<1><[U:1:20443063]><Blue>" triggered "arrow_impact" against "Chell<2><BOT><Blue> (distance "822.21")"
}
}

}
else if ( FStrEq( name, "player_spawn" ) )
{
int userid = event->GetInt( "userid" );
Expand Down
2 changes: 2 additions & 0 deletions sizzlingstats/SSPlayerData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ void SS_PlayerData::UpdateRoundExtraData( const extradata_t &dat )
m_RoundScoreData.data[MedPicks] = dat.medpicks;
m_RoundScoreData.data[UbersDropped] = dat.ubersdropped;
m_RoundScoreData.data[OverkillDamage] = dat.overkillDamage;
m_RoundScoreData.data[ArrowsLanded] = dat.arrowslanded;
m_RoundScoreData.data[ArrowsReceived] = dat.arrowsrecv;
}

int SS_PlayerData::GetStat( int StatID )
Expand Down
10 changes: 7 additions & 3 deletions sizzlingstats/SSPlayerData.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ enum stats
MedPicks,
UbersDropped,
OverkillDamage,
ShotsFired,
ShotsHit,
ArrowsLanded,
ArrowsReceived,
NumOfStats
};

typedef struct extradata_s
{
extradata_s():
healsrecv(0), medpicks(0), ubersdropped(0), overkillDamage(0)
healsrecv(0), medpicks(0), ubersdropped(0), overkillDamage(0), arrowslanded(0), arrowsrecv(0)
{
}

Expand All @@ -62,13 +62,17 @@ typedef struct extradata_s
medpicks = a;
ubersdropped = a;
overkillDamage = a;
arrowslanded = a;
arrowsrecv = a;
return *this;
}

int healsrecv;
short medpicks;
short ubersdropped;
int overkillDamage;
short arrowslanded;
short arrowsrecv;
} extradata_t;

struct ScoreData
Expand Down
25 changes: 25 additions & 0 deletions sizzlingstats/SizzlingStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,15 @@ void SizzlingStats::PlayerHealed( int entindex, int amount )
data.m_pExtraData->healsrecv += amount;
}

void SizzlingStats::PlayerArrowed( int patientEntIndex, int medicEntIndex, float distance )
{
playerAndExtra_t medic_data = m_PlayerDataManager.GetPlayerData(medicEntIndex);
medic_data.m_pExtraData->arrowslanded += 1;

playerAndExtra_t data = m_PlayerDataManager.GetPlayerData(patientEntIndex);
data.m_pExtraData->arrowsrecv += 1;
}

void SizzlingStats::MedPick( int entindex )
{
playerAndExtra_t data = m_PlayerDataManager.GetPlayerData(entindex);
Expand Down Expand Up @@ -512,6 +521,8 @@ void SizzlingStats::SS_DisplayStats( CSizzPluginContext *pPluginContext, int ent
int ubers = playerData.GetStat(Invulns);
int drops = playerData.GetStat(UbersDropped);
int medpicks = playerData.GetStat(MedPicks);
int arrowsLanded = playerData.GetStat(ArrowsLanded);
int arrowsReceived = playerData.GetStat(ArrowsReceived);

IPlayerInfo *pPlayerInfo = pPluginContext->GetPlayerInfo(ent_index);
CTFPlayerWrapper player(pPluginContext->BaseEntityFromEntIndex(ent_index));
Expand Down Expand Up @@ -549,13 +560,27 @@ void SizzlingStats::SS_DisplayStats( CSizzPluginContext *pPluginContext, int ent
SS_SingleUserChatMessage(pPluginContext, ent_index, pText);
}

if ( arrowsReceived != 0 )
{
memset( pText, 0, sizeof(pText) );
V_snprintf( pText, 64, "Arrows Received: %i\n", arrowsReceived );
SS_SingleUserChatMessage(pPluginContext, ent_index, pText);
}

if ( medpicks != 0 )
{
memset( pText, 0, sizeof(pText) );
V_snprintf( pText, 64, "Medic Picks: %i\n", medpicks );
SS_SingleUserChatMessage(pPluginContext, ent_index, pText);
}

if ( arrowsLanded != 0 )
{
memset( pText, 0, sizeof(pText) );
V_snprintf( pText, 64, "Arrows Landed: %i\n", arrowsLanded );
SS_SingleUserChatMessage(pPluginContext, ent_index, pText);
}

if ( (backstabs != 0) && (headshots != 0) )
{
memset( pText, 0, sizeof(pText) );
Expand Down
1 change: 1 addition & 0 deletions sizzlingstats/SizzlingStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class SizzlingStats
void LoadConfig( CSizzPluginContext *pPluginContext );

void PlayerHealed( int entindex, int amount );
void PlayerArrowed( int patientEntIndex, int medicEntIndex, float distance );
void MedPick( int entindex );
void UberDropped( int entindex );
void OnPlayerDeath(int inflictorEntIndex, int victimEntIndex);
Expand Down
2 changes: 2 additions & 0 deletions sizzlingstats/WebStatsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ void CWebStatsHandler::producePostString(const hostInfo_t &host, const CUtlVecto
jsonWriter.InsertKV("medpicks", pScores->getStat(MedPicks));
jsonWriter.InsertKV("ubersdropped", pScores->getStat(UbersDropped));
jsonWriter.InsertKV("overkillDamage", pScores->getStat(OverkillDamage));
jsonWriter.InsertKV("arrowsLanded", pScores->getStat(ArrowsLanded));
jsonWriter.InsertKV("arrowsReceived", pScores->getStat(ArrowsReceived));
jsonWriter.EndObject();
}
}
Expand Down
25 changes: 24 additions & 1 deletion sizzlingstats/serverplugin_empty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,9 @@ bool CEmptyServerPlugin::Load( CreateInterfaceFn interfaceFactory, CreateInterfa

// player healed (not incl buffs)
m_plugin_context.AddListener( this, "player_healed", true );

// player arrowed (crusader, same team only)
m_plugin_context.AddListener( this, "arrow_impact", true );

// happens when mp_winlimit or mp_timelimit is met or something i don't know, i forget
m_plugin_context.AddListener( this, "teamplay_game_over", true );
Expand Down Expand Up @@ -514,7 +517,7 @@ void CEmptyServerPlugin::GameFrame( bool simulating )
{
using namespace Teamplay_GameRule_States;

//Msg( UTIL_VarArgs( "round state is now %s\n", GetStateName(state) ) );
//Msg( UTIL_VarArgs( "round state is now %s\n", GetStateName((gamerules_roundstate_t)roundstate) ) );
switch (roundstate)
{
case GR_STATE_PREROUND:
Expand Down Expand Up @@ -841,6 +844,26 @@ void CEmptyServerPlugin::FireGameEvent( IGameEvent *event )
}
}
}
else if ( m_bShouldRecord && FStrEq( name, "arrow_impact" ) )
{
if (event->GetInt("projectileType") == sCrusadersCrossbowType)
{
const int victim = event->GetInt("attachedEntity");
const int medic = event->GetInt("shooter");
if (victim > 0 && medic > 0)
{
IPlayerInfo *pVictim = m_plugin_context.GetPlayerInfo( victim );
IPlayerInfo *pMedic = m_plugin_context.GetPlayerInfo( medic );

if (pVictim && pMedic && pVictim->GetTeamIndex() == pMedic->GetTeamIndex())
{
vec_t distance = pVictim->GetAbsOrigin().DistTo(pMedic->GetAbsOrigin());
m_SizzlingStats.PlayerArrowed(victim, medic, distance);
}
}
}

}
else if ( m_bShouldRecord && FStrEq( name, "player_death" ) )
{
const int victim = event->GetInt("victim_entindex");
Expand Down