Advertisement
Guest User

Giants guard script

a guest
Feb 10th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. Begin dg_AttackNPCCreatureScript
  2.  
  3. short sFlag
  4. float fCrime
  5. short sArrest
  6.  
  7. if ( MenuMode == 1 )
  8. return
  9. endif
  10.  
  11.  
  12. ;are there evil NPCs around?
  13. if ( NPCCreatureAttack > 0 )
  14.  
  15. ;return if dead
  16. if ( GetHealth <= 0 )
  17. return
  18. endif
  19.  
  20. ;are we attacking them already
  21. if( sFlag == 0 )
  22.  
  23. ;return if we're trying to kill the player
  24. if ( GetTarget, Player == 1 )
  25. return
  26. endif
  27.  
  28. ;if we're close, set to follow player so we attack NPC
  29. if ( GetDistance, Player < 3600 )
  30. set fCrime to GetPCCrimeLevel
  31. AiEscort, Player, 0 0 0 0 0 0
  32. set sFlag to 1
  33. set NPCGuardAttack to ( NPCGuardAttack + 1 )
  34. return
  35. endif
  36.  
  37. endif
  38.  
  39. ;we're already attacking the NPCs
  40. if ( sFlag == 1 )
  41.  
  42. ;if the PC crime Level has increased try to arrest him
  43. if ( fCrime < GetPCCrimeLevel )
  44. set sArrest to 1
  45. endif
  46.  
  47. endif
  48.  
  49. else ;there's no creatures around
  50.  
  51. ;switch back to regular AI if necessary
  52. if( sFlag == 1 )
  53.  
  54. if( NPCGuardAttack > 0 )
  55. set NPCGuardAttack to ( NPCGuardAttack - 1 )
  56. endif
  57.  
  58. set sFlag to 0
  59. if( GetCurrentAIPackage == 2 )
  60. StopCombat
  61. AiWander, 2000, 5, 0, 60, 20, 20, 20, 0, 0, 0, 20
  62. return
  63. endif
  64. endif
  65.  
  66. set fCrime to GetPCCrimeLevel
  67. set sArrest to 0
  68.  
  69. endif
  70.  
  71. ;are we trying to arrest PC?
  72. if ( sArrest == 1 )
  73.  
  74. ;return if dead
  75. if ( GetHealth <= 0 )
  76. return
  77. endif
  78.  
  79. ;don't arrest if we're trying to kill the PC
  80. if ( GetTarget, Player == 1 )
  81. return
  82. endif
  83.  
  84.  
  85. if ( GetDistance, Player < 300 )
  86. set NPCCreatureAttack to 0
  87. set fCrime to GetPCCrimeLevel
  88. set sArrest to 0
  89. if( GetCurrentAIPackage == 2 )
  90. StopCombat
  91. AiWander, 2000, 5, 0, 60, 20, 20, 20, 0, 0, 0, 20
  92. endif
  93. ForceGreeting
  94. endif
  95.  
  96. endif
  97.  
  98. End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement