Advertisement
nomy

Untitled

Sep 2nd, 2014
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.31 KB | None | 0 0
  1. //---------------------------------------------------------------------------------
  2. // Purpose: Slap a player
  3. //---------------------------------------------------------------------------------
  4. void    ProcessSlapPlayer
  5. (
  6.  player_t *player,
  7.  int damage,
  8.  bool slap_angle
  9. )
  10. {
  11.  
  12.         // let's just slap for if mani_tk_team_wound_reflect is set to 1
  13.         int sound_index = rand() % 3;
  14.         if (!gpManiGameType->IsTeleportAllowed()) return;
  15.  
  16.         CBaseEntity *m_pCBaseEntity = player->entity->GetUnknown()->GetBaseEntity();
  17.  
  18.         Vector vVel;
  19.         CBaseEntity_GetVelocity(m_pCBaseEntity, &vVel, NULL);
  20.  
  21.         if (slap_angle)
  22.         {
  23.                 vVel.x += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1:1);
  24.                 vVel.y += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1:1);
  25.                 QAngle angle = CBaseEntity_EyeAngles(m_pCBaseEntity);
  26.                 angle.x -= 20;
  27.                 CBaseEntity_Teleport(m_pCBaseEntity, NULL, &angle, &vVel);
  28.         }
  29.         else
  30.         {
  31.                 vVel.x += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1:1);
  32.                 vVel.y += ((rand() % 180) + 50) * (((rand() % 2) == 1) ? -1:1);
  33.                 vVel.z += rand() % 200 + 100;
  34.                 CBaseEntity_Teleport(m_pCBaseEntity, NULL, NULL, &vVel);
  35.         }
  36.  
  37.         int health = 0;
  38.  
  39.         health = Prop_GetVal(player->entity, MANI_PROP_HEALTH, 0);
  40.         // health = m_pCBaseEntity->GetHealth();
  41.         if (health <= 0)
  42.         {
  43.                 return;
  44.         }
  45.                
  46.         health -= ((damage >= 0) ? damage : damage * -1);
  47.         if (health <= 0)
  48.         {
  49.                 health = 0;
  50.         }
  51.  
  52.         //m_pCBaseEntity->SetHealth(health);
  53.         Prop_SetVal(player->entity, MANI_PROP_HEALTH, health);
  54.  
  55. //      Vector vVel = m_pCBaseEntity->GetLocalVelocity();
  56.  
  57.         if (health <= 0)
  58.         {
  59.                 // Player dead
  60.                 SlayPlayer(player, false, false, false);
  61.         }
  62.  
  63.         if (esounds)
  64.         {
  65.                 Vector pos = player->entity->GetCollideable()->GetCollisionOrigin();
  66.  
  67.                 // Play the "death"  sound
  68.                 MRecipientFilter mrf; // this is my class, I'll post it later.
  69.                 mrf.MakeReliable();
  70.                 mrf.AddAllPlayers(max_players);
  71.                 if ((gpManiGameType->IsGameType(MANI_GAME_CSS)) || (gpManiGameType->IsGameType(MANI_GAME_CSGO)))
  72.                 {
  73. #if defined ( GAME_CSGO )
  74.                         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);
  75. #else
  76.                         esounds->EmitSound((IRecipientFilter &)mrf, player->index, CHAN_AUTO, slap_sound_name[sound_index].sound_name, 0.7,  ATTN_NORM, 0, 100, 0, &pos);
  77. #endif
  78.                 }
  79.                 else
  80.                 {
  81. #if defined ( GAME_CSGO )
  82.                         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);
  83. #else
  84.                         esounds->EmitSound((IRecipientFilter &)mrf, player->index, CHAN_AUTO, hl2mp_slap_sound_name[sound_index].sound_name, 0.7,  ATTN_NORM, 0, 100, 0, &pos);
  85. #endif
  86.                 }
  87.  
  88.         }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement