thirst.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. class ThirstMdfr: ModifierBase
  2. {
  3. float m_LastWaterLevel;
  4. ref HumanMovementState m_MovementState = new HumanMovementState();
  5. override void Init()
  6. {
  7. m_TrackActivatedTime = false;
  8. m_ID = eModifiers.MDF_THIRST;
  9. m_TickIntervalInactive = DEFAULT_TICK_TIME_INACTIVE;
  10. m_TickIntervalActive = 1;
  11. DisableDeactivateCheck();
  12. }
  13. override bool ActivateCondition(PlayerBase player)
  14. {
  15. return true;
  16. }
  17. override void OnReconnect(PlayerBase player)
  18. {
  19. }
  20. override bool DeactivateCondition(PlayerBase player)
  21. {
  22. return false;
  23. }
  24. override void OnTick(PlayerBase player, float deltaT)
  25. {
  26. player.GetMovementState(m_MovementState);
  27. float water = player.GetStatWater().Get();
  28. float metabolic_speed = MiscGameplayFunctions.GetWaterMetabolicSpeed(m_MovementState.m_iMovement);
  29. float modifier = water/PlayerConstants.SL_WATER_MAX + PlayerConstants.CONSUMPTION_MULTIPLIER_BASE;
  30. metabolic_speed *= modifier; //non linear shaping for consumption curve (comment out to have it linear)
  31. player.GetStatWater().Add( (-metabolic_speed * deltaT) );
  32. if ( water <= PlayerConstants.LOW_WATER_THRESHOLD )
  33. {
  34. player.SetMixedSoundState( eMixedSoundStates.THIRSTY );
  35. if ((player.GetStomach().GetDigestingType() & PlayerStomach.DIGESTING_WATER) == 0)
  36. player.AddHealth("GlobalHealth", "Health", -PlayerConstants.LOW_WATER_DAMAGE_PER_SEC * deltaT );
  37. }
  38. else
  39. {
  40. player.UnsetMixedSoundState( eMixedSoundStates.THIRSTY );
  41. }
  42. }
  43. };