Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------------
- // Purpose: Slap a player
- //---------------------------------------------------------------------------------
- void ProcessSlapPlayer
- (
- player_t *player,
- int damage,
- bool slap_angle
- )
- {
- // let's just slap for if mani_tk_team_wound_reflect is set to 1
- int sound_index = rand() % 3;
- if (!gpManiGameType->IsTeleportAllowed()) return;
- CBaseEntity *m_pCBaseEntity = player->entity->GetUnknown()->GetBaseEntity();
- Vector vVel;
- CBaseEntity_GetVelocity(m_pCBaseEntity, &vVel, NULL);
- if (slap_angle)
- {
- vVel.x += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1:1);
- vVel.y += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1:1);
- QAngle angle = CBaseEntity_EyeAngles(m_pCBaseEntity);
- angle.x -= 20;
- CBaseEntity_Teleport(m_pCBaseEntity, NULL, &angle, &vVel);
- }
- else
- {
- vVel.x += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1:1);
- vVel.y += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1:1);
- vVel.z += rand() % 200 + 100;
- CBaseEntity_Teleport(m_pCBaseEntity, NULL, NULL, &vVel);
- }
- int health = 0;
- health = Prop_GetVal(player->entity, MANI_PROP_HEALTH, 0);
- // health = m_pCBaseEntity->GetHealth();
- if (health <= 0)
- {
- return;
- }
- health -= ((damage >= 0) ? damage : damage * -1);
- if (health <= 0)
- {
- health = 0;
- }
- //m_pCBaseEntity->SetHealth(health);
- Prop_SetVal(player->entity, MANI_PROP_HEALTH, health);
- // Vector vVel = m_pCBaseEntity->GetLocalVelocity();
- if (health <= 0)
- {
- // Player dead
- SlayPlayer(player, false, false, false);
- }
- if (esounds)
- {
- Vector pos = player->entity->GetCollideable()->GetCollisionOrigin();
- // Play the "death" sound
- MRecipientFilter mrf; // this is my class, I'll post it later.
- mrf.MakeReliable();
- mrf.AddAllPlayers(max_players);
- if ((gpManiGameType->IsGameType(MANI_GAME_CSS)) || (gpManiGameType->IsGameType(MANI_GAME_CSGO)))
- {
- #if defined ( GAME_CSGO )
- esounds->EmitSound((IRecipientFilter &)mrf, player->index, CHAN_AUTO, NULL, 0, slap_sound_name[sound_index].sound_name, 0.7, ATTN_NORM, 0, 0, 100, &pos);
- #else
- esounds->EmitSound((IRecipientFilter &)mrf, player->index, CHAN_AUTO, slap_sound_name[sound_index].sound_name, 0.7, ATTN_NORM, 0, 100, 0, &pos);
- #endif
- }
- else
- {
- #if defined ( GAME_CSGO )
- esounds->EmitSound((IRecipientFilter &)mrf, player->index, CHAN_AUTO, NULL, 0, hl2mp_slap_sound_name[sound_index].sound_name, 0.7, ATTN_NORM, 0, 0, 100, &pos);
- #else
- esounds->EmitSound((IRecipientFilter &)mrf, player->index, CHAN_AUTO, hl2mp_slap_sound_name[sound_index].sound_name, 0.7, ATTN_NORM, 0, 100, 0, &pos);
- #endif
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement