pumpkinhelmet.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // Have a spooky Halloween everyone!
  2. class PumpkinHelmet : HelmetBase
  3. {
  4. void PumpkinHelmet()
  5. {
  6. SetEventMask(EntityEvent.INIT); // Enable EOnInit event
  7. }
  8. override void OnMovedInsideCargo(EntityAI container)
  9. {
  10. UpdateGlowState();
  11. }
  12. override void OnMovedWithinCargo(EntityAI container)
  13. {
  14. UpdateGlowState();
  15. }
  16. override void OnRemovedFromCargo(EntityAI container)
  17. {
  18. UpdateGlowState();
  19. }
  20. override void EOnInit( IEntity other, int extra)
  21. {
  22. UpdateGlowState();
  23. }
  24. override void OnItemLocationChanged( EntityAI old_owner, EntityAI new_owner)
  25. {
  26. super.OnItemLocationChanged( old_owner, new_owner);
  27. UpdateGlowState();
  28. }
  29. override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
  30. {
  31. super.EEHealthLevelChanged(oldLevel,newLevel,zone);
  32. UpdateGlowState();
  33. }
  34. void UpdateGlowState()
  35. {
  36. // Makes sure PumpkinHelmet doesn't glow when it's attached on head, or it's inside cargo.
  37. bool do_glow = true;
  38. if ( IsDamageDestroyed() )
  39. {
  40. do_glow = false;
  41. }
  42. else
  43. {
  44. int id = InventorySlots.HEADGEAR;
  45. InventoryLocation IL = new InventoryLocation();
  46. GetInventory().GetCurrentInventoryLocation( IL );
  47. int id_2 = IL.GetSlot();
  48. int id_cargo = IL.GetIdx();
  49. if ( id == id_2) // Pumpkin is attached on head
  50. do_glow = false;
  51. if ( id_cargo != -1 ) // Pumpkin is in cargo
  52. do_glow = false;
  53. }
  54. SetPilotLight(do_glow);
  55. }
  56. override void UpdateNVGStatus(PlayerBase player, bool attaching = false, bool force_disable = false)
  57. {
  58. if ( !GetGame().IsDedicatedServer() ) //SP only
  59. {
  60. if (force_disable)
  61. {
  62. player.RemoveActiveNV(NVTypes.NV_PUMPKIN);
  63. }
  64. else
  65. {
  66. if ( attaching && (!player.IsNVGWorking() || player.GetNVType() != NVTypes.NV_PUMPKIN) )
  67. {
  68. player.AddActiveNV(NVTypes.NV_PUMPKIN);
  69. }
  70. else if ( !attaching && player.IsNVGWorking() )
  71. {
  72. player.RemoveActiveNV(NVTypes.NV_PUMPKIN);
  73. }
  74. }
  75. }
  76. }
  77. override protected set<int> GetAttachmentExclusionInitSlotValue(int slotId)
  78. {
  79. set<int> ret = super.GetAttachmentExclusionInitSlotValue(slotId);
  80. if (slotId == InventorySlots.HEADGEAR)
  81. {
  82. ret.Insert(EAttExclusions.EXCLUSION_HEADGEAR_HELMET_0);
  83. ret.Insert(EAttExclusions.EXCLUSION_MASK_1);
  84. ret.Insert(EAttExclusions.EXCLUSION_MASK_2);
  85. ret.Insert(EAttExclusions.EXCLUSION_HEADSTRAP_0);
  86. ret.Insert(EAttExclusions.SHAVING_HEADGEAR_ATT_0);
  87. }
  88. return ret;
  89. }
  90. };
  91. // boo!