bleeding.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //checks for critical blood level and kills the character if bellow
  2. class BleedingCheckMdfr: ModifierBase
  3. {
  4. protected const float BLOOD_DECREMENT_PER_SEC = -10;
  5. PluginAdminLog m_AdminLog;
  6. override void Init()
  7. {
  8. m_TrackActivatedTime = false;
  9. m_AnalyticsStatsEnabled = true;
  10. m_ID = eModifiers.MDF_BLEEDING;
  11. m_TickIntervalInactive = DEFAULT_TICK_TIME_INACTIVE;
  12. m_TickIntervalActive = DEFAULT_TICK_TIME_ACTIVE;
  13. if( GetGame().IsServer() )
  14. {
  15. m_AdminLog = PluginAdminLog.Cast( GetPlugin(PluginAdminLog) );
  16. }
  17. DisableDeactivateCheck();
  18. }
  19. override bool ActivateCondition(PlayerBase player)
  20. {
  21. float blood = player.GetHealth("","Blood");
  22. if( blood < PlayerConstants.BLOOD_THRESHOLD_FATAL )
  23. {
  24. return true;
  25. }
  26. return false;
  27. }
  28. override void OnActivate(PlayerBase player)
  29. {
  30. player.SetHealth("","",-1000);
  31. if ( m_AdminLog )
  32. {
  33. m_AdminLog.BleedingOut( player );
  34. }
  35. }
  36. override void OnDeactivate(PlayerBase player)
  37. {
  38. }
  39. override bool DeactivateCondition(PlayerBase player)
  40. {
  41. return false;
  42. }
  43. override void OnTick(PlayerBase player, float deltaT)
  44. {
  45. }
  46. };