//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- int C_TF_PlayerResource::GetCountForPlayerClass( int iTeam, int iClass, bool bExcludeLocalPlayer /*=false*/ ) { int count = 0; int iLocalPlayerIndex = GetLocalPlayerIndex(); for ( int i = 1 ; i <= MAX_PLAYERS ; i++ ) { if ( bExcludeLocalPlayer && ( i == iLocalPlayerIndex ) ) { continue; } if ( ( GetTeam( i ) == iTeam ) && ( GetPlayerClass( i ) == iClass ) ) { count++; } } return count; }
//----------------------------------------------------------------------------- // Purpose: Calculates the players "accuracy" level //----------------------------------------------------------------------------- void CBaseTFPlayer::CalculateAccuracy( void ) { static flLastTime = 0; // Get the time since the last calculation float flTimeSlice = (gpGlobals->curtime - flLastTime); m_flTargetAccuracy = 0; if ( !GetPlayerClass() ) return; // Get the base accuracy from the current weapon if ( m_hActiveWeapon ) { m_flTargetAccuracy = m_hActiveWeapon->GetAccuracy(); // Accuracy is increased if the player's crouching if ( GetFlags() & FL_DUCKING ) m_flTargetAccuracy *= m_hActiveWeapon->GetDuckingMultiplier(); // Accuracy is decreased if the player's moving if ( m_vecVelocity.Length2D() > ( GetPlayerClass()->GetMaxSpeed() * 0.5 ) ) m_flTargetAccuracy *= m_hActiveWeapon->GetRunningMultiplier(); } // Accuracy is decreased if the player's arms are injured // Accuracy is increased if there's an Officer nearby // Accuracy is decreased if this player's being supressed (bullets/explosions impacting nearby) float flFarTime = (m_flLastRicochetNearby + ACC_RICOCHET_TIME); if ( gpGlobals->curtime <= flFarTime ) m_flTargetAccuracy *= 1 + (m_flNumberOfRicochets * ACC_RICOCHET_MULTIPLE) * (ACCMULT_RICOCHET * ((flFarTime - gpGlobals->curtime) / ACC_RICOCHET_TIME)); // Accuracy is decreased if the player's just been hit by a bullet/explosion // Now float towards the target accuracy if ( m_bSnapAccuracy ) { m_bSnapAccuracy = false; m_flAccuracy = m_flTargetAccuracy; } else { if ( m_flAccuracy < m_flTargetAccuracy ) { m_flAccuracy += (flTimeSlice * ACCURACY_CHANGE_SPEED); if ( m_flAccuracy > m_flTargetAccuracy ) m_flAccuracy = m_flTargetAccuracy ; } else if ( m_flAccuracy > m_flTargetAccuracy ) { m_flAccuracy -= (flTimeSlice * ACCURACY_CHANGE_SPEED); if ( m_flAccuracy < m_flTargetAccuracy ) m_flAccuracy = m_flTargetAccuracy ; } } // Clip to prevent silly accuracies if ( m_flAccuracy > 1024 ) m_flAccuracy = 1024; flLastTime = gpGlobals->curtime; }
void cChat::ChatAddStats(DWORD aIndex, LPCSTR IpBuffer, BYTE CMD_STATS_TYPE) { int Points = atoi(IpBuffer); char* Name; Name = (char*)gObj_GetChar(aIndex,gObjNick); GOBJSTRUCT *gObj = (GOBJSTRUCT*)OBJECT_POINTER(aIndex); if(Config.IsAdd == 0) { GCServerMsgStringSend(MSG07,aIndex, 1); return; } else if((int)gObj_GetLevel(aIndex) < Config.AddLevel) { char levelmsg[120]; sprintf(levelmsg,MSG08,Config.AddLevel); GCServerMsgStringSend(levelmsg, aIndex, 1); Log.outError("[Add] [%s]: [%s] not enought Level \n",gObj->AccountID,Name); return; } else if(strlen(IpBuffer) <1 || Points<1) { GCServerMsgStringSend(MSG09, aIndex, 1); Log.outError("[Add] [%s]: [%s] syntax error \n",gObj->AccountID,Name); return; } else if((int) gObj_GetInt(aIndex,gObjLupp)<Points) { GCServerMsgStringSend(MSG10, aIndex, 1); Log.outError("[Add] [%s]: [%s] lacking points \n",gObj->AccountID,Name); return; } else if(gObj->Money < Config.AddCost) { char OutputZenLack[120]={0}; sprintf(OutputZenLack,MSG11,Config.AddCost); GCServerMsgStringSend(OutputZenLack,aIndex,1); Log.outError("[Add] [%s]: [%s] lacking Zend \n",gObj->AccountID,Name); return; } else if (Points>Config.AddMaxPoints) { char exceedpoint[120]; sprintf(exceedpoint,MSG12,Config.AddMaxPoints); GCServerMsgStringSend(exceedpoint,aIndex,1); Log.outError("[Add] [%s]: [%s] exceed points \n",gObj->AccountID,Name); return; } else if(CMD_STATS_TYPE == 4 && GetPlayerClass(aIndex) != 64 && GetPlayerClass(aIndex) != 66) { GCServerMsgStringSend(MSG13, aIndex, 1); Log.outError("[Add] [%s]: [%s] syntax error \n",gObj->AccountID,Name); return; } else if(Points > 100) { WORD wStr,wDex,wViatality,wEnergy,wLeader ; DWORD dwLvUpPoint; PBYTE pADataAddr ; pADataAddr = (PBYTE)(aIndex*gObjSize +gObjOffset) ; _asm { push eax push ebx mov eax,pADataAddr xor ebx,ebx mov bx,WORD PTR [eax+0xDC] mov wStr,bx mov bx,WORD PTR [eax+0xDE] mov wDex,bx mov bx,WORD PTR [eax+0xE0] mov wViatality,bx mov bx,WORD PTR [eax+0xE2] mov wEnergy,bx mov bx,WORD PTR [eax+0x100] mov wLeader,bx mov ebx,DWORD PTR [eax+0xAC] mov dwLvUpPoint,ebx pop ebx pop eax } Log.outNormal("[%s]: [%s] Before Add: %d Str %d Agi %d Vit %d Ene %d Lead %d \n",gObj->AccountID,Name,dwLvUpPoint,wStr,wDex,wViatality,wEnergy,wLeader); WORD wTmpAddPoint = 0 ; DWORD dwTmpAddPoint = 0 ; wTmpAddPoint = Points ; dwTmpAddPoint = wTmpAddPoint ; if ( wTmpAddPoint >0) { switch (CMD_STATS_TYPE) { case 0x00: _asm { push eax push ebx mov eax,pADataAddr xor ebx,ebx mov bx,WORD PTR [eax+0xDC] add bx,wTmpAddPoint mov WORD PTR [eax+0xDC],bx mov ebx,DWORD PTR [eax+0xAC] sub ebx,dwTmpAddPoint mov DWORD PTR [eax+0xAC],ebx pop ebx pop eax } break; case 0x01: _asm { push eax push ebx mov eax,pADataAddr xor ebx,ebx mov bx,WORD PTR [eax+0xDE] add bx,wTmpAddPoint mov WORD PTR [eax+0xDE],bx mov ebx,DWORD PTR [eax+0xAC] sub ebx,dwTmpAddPoint mov DWORD PTR [eax+0xAC],ebx pop ebx pop eax } break; case 0x02: _asm { push eax push ebx mov eax,pADataAddr xor ebx,ebx mov bx,WORD PTR [eax+0xE0] add bx,wTmpAddPoint mov WORD PTR [eax+0xE0],bx mov ebx,DWORD PTR [eax+0xAC] sub ebx,dwTmpAddPoint mov DWORD PTR [eax+0xAC],ebx pop ebx pop eax } break; case 0x03: _asm { push eax push ebx mov eax,pADataAddr xor ebx,ebx mov bx,WORD PTR [eax+0xE2] add bx,wTmpAddPoint mov WORD PTR [eax+0xE2],bx mov ebx,DWORD PTR [eax+0xAC] sub ebx,dwTmpAddPoint mov DWORD PTR [eax+0xAC],ebx pop ebx pop eax } break; case 0x04: _asm { push eax push ebx mov eax,pADataAddr xor ebx,ebx mov bx,WORD PTR [eax+0x100] add bx,wTmpAddPoint mov WORD PTR [eax+0x100],bx mov ebx,DWORD PTR [eax+0xAC] sub ebx,dwTmpAddPoint mov DWORD PTR [eax+0xAC],ebx pop ebx pop eax } break; } } _asm { push eax push ebx mov eax,pADataAddr xor ebx,ebx mov bx,WORD PTR [eax+0xDC] mov wStr,bx mov bx,WORD PTR [eax+0xDE] mov wDex,bx mov bx,WORD PTR [eax+0xE0] mov wViatality,bx mov bx,WORD PTR [eax+0xE2] mov wEnergy,bx mov bx,WORD PTR [eax+0x100] mov wLeader,bx mov ebx,DWORD PTR [eax+0xAC] mov dwLvUpPoint,ebx pop ebx pop eax } gObj->Money = gObj->Money - Config.AddCost; GCMoneySend(aIndex,gObj->Money); Log.outNormal("[%s]: [%s] After Add: %d Str %d Agi %d Vit %d Ene %d Lead %d \n",gObj->AccountID,Name,dwLvUpPoint,wStr,wDex,wViatality,wEnergy,wLeader); GCServerMsgStringSend(MSG14, aIndex, 1); return; }