healthregen.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. class HealthRegenMdfr: ModifierBase
  2. {
  3. override void Init()
  4. {
  5. m_TrackActivatedTime = false;
  6. m_ID = eModifiers.MDF_HEALTH_REGEN;
  7. m_TickIntervalInactive = DEFAULT_TICK_TIME_INACTIVE;
  8. m_TickIntervalActive = DEFAULT_TICK_TIME_ACTIVE;
  9. DisableDeactivateCheck();
  10. }
  11. override bool ActivateCondition(PlayerBase player)
  12. {
  13. return true;
  14. }
  15. override void OnActivate(PlayerBase player)
  16. {
  17. }
  18. override void OnReconnect(PlayerBase player)
  19. {
  20. }
  21. override bool DeactivateCondition(PlayerBase player)
  22. {
  23. return false;
  24. }
  25. override void OnTick(PlayerBase player, float deltaT)
  26. {
  27. if (player.IsAlive())//this needs to be here, some of the other modifiers can kill the character during the same modifier tick, and not checking here can partially revive him(resulting in a broken char)
  28. {
  29. float regen_speed = player.GetHealthRegenSpeed() * deltaT;;
  30. player.AddHealth("GlobalHealth", "Health" , regen_speed );
  31. player.AddHealth("RightArm","Health",regen_speed * PlayerConstants.DAMAGE_ZONE_BLOOD_REGEN_MODIFIER );
  32. player.AddHealth("RightHand","Health",regen_speed * PlayerConstants.DAMAGE_ZONE_BLOOD_REGEN_MODIFIER);
  33. player.AddHealth("LeftArm","Health",regen_speed * PlayerConstants.DAMAGE_ZONE_BLOOD_REGEN_MODIFIER);
  34. player.AddHealth("LeftHand","Health",regen_speed * PlayerConstants.DAMAGE_ZONE_BLOOD_REGEN_MODIFIER);
  35. //Leg regen when legs are NOT BROKEN
  36. if ( player.GetBrokenLegs() == eBrokenLegs.NO_BROKEN_LEGS )
  37. {
  38. player.AddHealth("RightLeg","Health", PlayerConstants.LEG_HEALTH_REGEN);
  39. player.AddHealth("RightFoot","Health", PlayerConstants.LEG_HEALTH_REGEN);
  40. player.AddHealth("LeftLeg","Health", PlayerConstants.LEG_HEALTH_REGEN);
  41. player.AddHealth("LeftFoot","Health", PlayerConstants.LEG_HEALTH_REGEN);
  42. }
  43. else
  44. {
  45. //Leg regen when legs are BROKEN or SPLINTED
  46. player.AddHealth("RightLeg","Health", PlayerConstants.LEG_HEALTH_REGEN_BROKEN);
  47. player.AddHealth("RightFoot","Health",PlayerConstants.LEG_HEALTH_REGEN_BROKEN);
  48. player.AddHealth("LeftLeg","Health", PlayerConstants.LEG_HEALTH_REGEN_BROKEN);
  49. player.AddHealth("LeftFoot","Health", PlayerConstants.LEG_HEALTH_REGEN_BROKEN);
  50. }
  51. player.AddHealth("Torso","Health",regen_speed * PlayerConstants.DAMAGE_ZONE_BLOOD_REGEN_MODIFIER);
  52. // We increase head health regeneration as it is unclear to players what health level individual zones have
  53. player.AddHealth("Head","Health",( regen_speed * PlayerConstants.DAMAGE_ZONE_BLOOD_REGEN_MODIFIER ) * 2 );
  54. }
  55. }
  56. };