trap_fishnet.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. class Trap_FishNet 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_IsFoldable = true;
  13. m_MinimalDistanceFromPlayersToCatch = 15;
  14. m_AnimationPhaseSet = "inventory";
  15. m_AnimationPhaseTriggered = "placing";
  16. m_AnimationPhaseUsed = "triggered";
  17. }
  18. override void OnVariablesSynchronized()
  19. {
  20. super.OnVariablesSynchronized();
  21. if ( IsPlaceSound() )
  22. {
  23. PlayPlaceSound();
  24. }
  25. }
  26. override void InitCatchingComponent()
  27. {
  28. if (!m_CatchingContext)
  29. {
  30. int updateCount = m_MaxActiveTime/m_UpdateWaitTime;
  31. Param2<EntityAI,int> par = new Param2<EntityAI,int>(this,updateCount);
  32. m_CatchingContext = new CatchingContextTrapFishLarge(par);
  33. }
  34. }
  35. //========================================================
  36. //============= PLACING AND INVENTORY EVENTS =============
  37. //========================================================
  38. override bool IsPlaceableAtPosition( vector position )
  39. {
  40. return IsSurfaceWater( position );
  41. }
  42. override bool CanReceiveAttachment( EntityAI attachment, int slotId )
  43. {
  44. if ( !attachment.IsInherited( Worm ) )
  45. return false;
  46. return super.CanReceiveAttachment( attachment, slotId );
  47. }
  48. #ifdef PLATFORM_WINDOWS
  49. // How one sees the tripwire when in vicinity
  50. override int GetViewIndex()
  51. {
  52. if ( MemoryPointExists( "invView2" ) )
  53. {
  54. InventoryLocation il = new InventoryLocation;
  55. GetInventory().GetCurrentInventoryLocation( il );
  56. InventoryLocationType type = il.GetType();
  57. switch ( type )
  58. {
  59. case InventoryLocationType.CARGO:
  60. {
  61. return 0;
  62. }
  63. case InventoryLocationType.ATTACHMENT:
  64. {
  65. return 1;
  66. }
  67. case InventoryLocationType.HANDS:
  68. {
  69. return 0;
  70. }
  71. case InventoryLocationType.GROUND:
  72. {
  73. // Different view index depending on deployment state
  74. if ( IsActive() )
  75. return 1;
  76. // When folded
  77. return 0;
  78. }
  79. case InventoryLocationType.PROXYCARGO:
  80. {
  81. return 0;
  82. }
  83. default:
  84. {
  85. if ( IsActive() )
  86. return 1;
  87. // When folded
  88. return 0;
  89. }
  90. }
  91. }
  92. return 0;
  93. }
  94. #endif
  95. //================================================================
  96. // ADVANCED PLACEMENT
  97. //================================================================
  98. override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" )
  99. {
  100. super.OnPlacementComplete( player, position, orientation );
  101. SetIsPlaceSound( true );
  102. }
  103. override bool IsDeployable()
  104. {
  105. return true;
  106. }
  107. override string GetDeploySoundset()
  108. {
  109. return "placeFishNetTrap_SoundSet";
  110. }
  111. override string GetLoopDeploySoundset()
  112. {
  113. return "fishnet_deploy_SoundSet";
  114. }
  115. }
  116. class FishNetTrap extends Trap_FishNet
  117. {
  118. }