void BulletData(uint16_t id)
{
stBulletData sync;
ZeroMemory(&sync, sizeof(stBulletData));
stRemotePlayer *pPlayer = SF->getSAMP()->getPlayers()->pRemotePlayer[id];
if (!pPlayer) return;
float aimHit[3] = { PEDSELF->GetPosition()->fX, PEDSELF->GetPosition()->fY, PEDSELF->GetPosition()->fZ };
float bodyPos[3] = { pPlayer->pPlayerData->fOnFootPos[0], pPlayer->pPlayerData->fOnFootPos[1], pPlayer->pPlayerData->fOnFootPos[2] };
float hitPos[3] = { 0.0, 0.0, 0.5 };
sync.fOrigin[0] = aimHit[0];
sync.fOrigin[1] = aimHit[1];
sync.fOrigin[2] = aimHit[2];
sync.fTarget[0] = bodyPos[0];
sync.fTarget[1] = bodyPos[1];
sync.fTarget[2] = bodyPos[2];
sync.fCenter[0] = hitPos[0];
sync.fCenter[1] = hitPos[1];
sync.fCenter[2] = hitPos[2];
sync.byteWeaponID = SF->getSAMP()->getPlayers()->pLocalPlayer->byteCurrentWeapon;
sync.byteType = 1;
sync.sTargetID = id;
BitStream BulletSync;
BulletSync.Write((BYTE)PacketEnumeration::ID_BULLET_SYNC);
BulletSync.Write((PCHAR)&sync, sizeof(stBulletData));
SF->getRakNet()->SendPacket(&BulletSync);
UpdateAmmo();
}
inline void SendTakeDamageRPC(uint32_t TargetID, unsigned int weapon_id, int damage)
{
BitStream bs;
bs.Write(true);
bs.Write(TargetID);
bs.Write((float)damage);
bs.Write(weapon_id);
bs.Write(3);
SF->getRakNet()->SendRPC(RPCEnumeration::RPC_GiveTakeDamage, &bs);
}
inline float vect3_length(const float in[3])
{
return sqrtf(in[0] * in[0] + in[1] * in[1] + in[2] * in[2]);
}
inline void vect3_copy(const float in[3], float out[3])
{
memcpy(out, in, sizeof(float) * 3);
}
void AimVectorToPlayer(WORD player) // SAMP ID цели
{
stAimData aim = SF->getSAMP()->getPlayers()->pLocalPlayer->aimData;
actor_info* actorInfo = SF->getSAMP()->getPlayers()->pRemotePlayer[player]->pPlayerData->pSAMP_Actor->pGTA_Ped;
float matched_pos[3], AimVector[3];
vect3_copy(actorInfo->base.matrix + 12, matched_pos);
float* fPos = actorInfo->base.matrix + 12;
for (int i = 0; i < 3; ++i)
{
AimVector[i] = matched_pos[i] - aim.vecAimPos[i];
aim.vecAimf1[i] = AimVector[i] / vect3_length(AimVector);
aim.vecAimPos[i] = fPos[i];
}
aim.vecAimPos[2] += 0.2f;
BitStream bs;
bs.Write((BYTE)ID_AIM_SYNC);
bs.Write((PCHAR)&aim, sizeof(stAimData));
SF->getRakNet()->SendPacket(&bs);
}
void SendFakeParameters(int id)
{
AimVectorToPlayer(id);
BulletData(id);
SendTakeDamageRPC(id, SF->getSAMP()->getPlayers()->pLocalPlayer->byteCurrentWeapon, 11);
}