1. package GuardDevilUnbreakable
  2. import DamageType
  3. import StructuredDD
  4. import ClosureTimers
  5. import Players
  6. import Invulnerable
  7. constant int ID_GUARD_DEVIL = 'h03B'
  8. constant int ID_GUARD_DEVIL_GREATER = 'h03C'
  9. constant int ID_ABILITY_UNBREAKABLE = 'A01W'
  10. constant int ID_ABILITY_UNBREAKA_CD = 'A01X'
  11. constant int ID_INVULNERABLE = 'Avul'
  12. constant real RADIUS = 600.
  13. constant real DURATION = 1.
  14. constant real COOLDOWN = 60.
  15. constant string SHIELD_FX = "Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl"
  16. group grp = CreateGroup()
  17. function isGuardDevil( unit u ) returns bool
  18. return u.getTypeId() == ID_GUARD_DEVIL or u.getTypeId() == ID_GUARD_DEVIL_GREATER
  19. end
  20. function findUnbreakable( unit u ) returns unit
  21. unit guard = null
  22. unit iter
  23. grp.enumUnitsInRange( vec2( u.getX(), u.getY()), RADIUS )
  24. loop
  25. iter = FirstOfGroup( grp )
  26. exitwhen iter == null
  27. if iter.isAlive() and isGuardDevil( iter ) and iter.hasAbility( ID_ABILITY_UNBREAKABLE )
  28. guard = iter
  29. end
  30. grp.removeUnit( iter )
  31. end
  32. return guard
  33. end
  34. function h()
  35. unit tU = GetTriggerUnit()
  36. real damage = GetEventDamage()
  37. if tU.getOwner() .getId() < Players.COUNT and DamageType.get() == DamageType.ATTACK and ( tU.getHP() - damage < 1. ) and not tU.hasAbility( ID_INVULNERABLE )
  38. unit unbreakableSource = findUnbreakable( tU )
  39. if unbreakableSource != null
  40. Invulnerable.apply( tU, DURATION )
  41. unbreakableSource.removeAbility( ID_ABILITY_UNBREAKABLE )
  42. unbreakableSource.addAbility( ID_ABILITY_UNBREAKA_CD )
  43. effect shield = tU.addEffect( SHIELD_FX, "origin" )
  44. doAfter( DURATION, () - > begin
  45. shield.destr()
  46. end )
  47. doAfter( COOLDOWN, () - > begin
  48. unbreakableSource.addAbility( ID_ABILITY_UNBREAKABLE )
  49. unbreakableSource.removeAbility( ID_ABILITY_UNBREAKA_CD )
  50. end )
  51. end
  52. end
  53. end
  54. init
  55. StructuredDD.addHandler( function h )
  56. end

Diesen Code in Original-Formatierung anzeigen
goto line:
Compare with:
text copy window edit this code post new code