trap_smallfish.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. class Trap_SmallFish extends TrapSpawnBase
  2. {
  3. override void InitTrapValues()
  4. {
  5. super.InitTrapValues();
  6. m_DefectRate = 2.5; //Added damage after trap activation
  7. m_InitWaitTimeMin = 120;
  8. m_InitWaitTimeMax = 180;
  9. m_UpdateWaitTime = 30;
  10. m_SpawnUpdateWaitTime = 30;
  11. m_MaxActiveTime = 1200;
  12. m_MinimalDistanceFromPlayersToCatch = 15;
  13. m_AnimationPhaseSet = "inventory";
  14. m_AnimationPhaseTriggered = "placing";
  15. m_AnimationPhaseUsed = "triggered";
  16. }
  17. override void OnVariablesSynchronized()
  18. {
  19. super.OnVariablesSynchronized();
  20. if ( IsPlaceSound() )
  21. {
  22. PlayPlaceSound();
  23. }
  24. }
  25. override void InitCatchingComponent()
  26. {
  27. if (!m_CatchingContext)
  28. {
  29. int updateCount = m_MaxActiveTime/m_UpdateWaitTime;
  30. Param2<EntityAI,int> par = new Param2<EntityAI,int>(this,updateCount);
  31. m_CatchingContext = new CatchingContextTrapFishSmall(par);
  32. }
  33. }
  34. //========================================================
  35. //============= PLACING AND INVENTORY EVENTS =============
  36. //========================================================
  37. override bool IsPlaceableAtPosition( vector position )
  38. {
  39. return IsSurfaceWater( position );
  40. }
  41. override bool CanReceiveAttachment( EntityAI attachment, int slotId )
  42. {
  43. if ( !attachment.IsInherited( Worm ) )
  44. return false;
  45. return super.CanReceiveAttachment( attachment, slotId );
  46. }
  47. #ifdef PLATFORM_WINDOWS
  48. // How one sees the tripwire when in vicinity
  49. override int GetViewIndex()
  50. {
  51. if ( MemoryPointExists( "invView2" ) )
  52. {
  53. InventoryLocation il = new InventoryLocation;
  54. GetInventory().GetCurrentInventoryLocation( il );
  55. InventoryLocationType type = il.GetType();
  56. switch ( type )
  57. {
  58. case InventoryLocationType.CARGO:
  59. {
  60. return 0;
  61. }
  62. case InventoryLocationType.ATTACHMENT:
  63. {
  64. return 1;
  65. }
  66. case InventoryLocationType.HANDS:
  67. {
  68. return 0;
  69. }
  70. case InventoryLocationType.GROUND:
  71. {
  72. // Different view index depending on deployment state
  73. if ( IsDeployed() )
  74. return 1;
  75. // When folded
  76. return 0;
  77. }
  78. case InventoryLocationType.PROXYCARGO:
  79. {
  80. return 0;
  81. }
  82. default:
  83. {
  84. if ( IsDeployed() )
  85. return 1;
  86. // When folded
  87. return 0;
  88. }
  89. }
  90. }
  91. return 0;
  92. }
  93. #endif
  94. }
  95. class SmallFishTrap extends Trap_SmallFish
  96. {
  97. // DEPRECATED
  98. ref RainProcurementManager m_RainProcurement;
  99. //================================================================
  100. // ADVANCED PLACEMENT
  101. //================================================================
  102. override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
  103. {
  104. super.OnPlacementComplete( player, position, orientation );
  105. SetIsPlaceSound( true );
  106. }
  107. override bool IsDeployable()
  108. {
  109. return true;
  110. }
  111. override string GetDeploySoundset()
  112. {
  113. return "placeSmallFishTrap_SoundSet";
  114. }
  115. override string GetLoopDeploySoundset()
  116. {
  117. return "fishtrap_deploy_SoundSet";
  118. }
  119. override bool DoPlacingHeightCheck()
  120. {
  121. return true; //has to be able to catch rain, default distance raycast
  122. }
  123. }