Skip to content
Home
Post Code
Jass (Warcraft III)
Wurst
GUI (Warcraft III)
Galaxy (StarCraft II)
GUI (StarCraft II)
C++
Java
Delphi
Text
Search Code
Compare Code
Uploads
Draw
Create New Drawing
View Drawings
Graph
Log in
[code]package GuardDevilUnbreakable import DamageType import StructuredDD import ClosureTimers import Players import Invulnerable constant [color=AA77FF]int[/color] ID_GUARD_DEVIL = 'h03B' constant [color=AA77FF]int[/color] ID_GUARD_DEVIL_GREATER = 'h03C' constant [color=AA77FF]int[/color] ID_ABILITY_UNBREAKABLE = 'A01W' constant [color=AA77FF]int[/color] ID_ABILITY_UNBREAKA_CD = 'A01X' constant [color=AA77FF]int[/color] ID_INVULNERABLE = 'Avul' constant real RADIUS = [color=FF7777]600.[/color] constant real DURATION = [color=FF7777]1.[/color] constant real COOLDOWN = [color=FF7777]60.[/color] constant [color=AA77FF]string[/color] SHIELD_FX = [color=77FF77]"Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl"[/color] group grp = CreateGroup[b]([/b][b])[/b] function isGuardDevil[b]([/b]unit u[b])[/b] returns [color=AA77FF]bool[/color] [color=7777FF][b]return[/b][/color] u.getTypeId[b]([/b][b])[/b] == ID_GUARD_DEVIL or u.getTypeId[b]([/b][b])[/b] == ID_GUARD_DEVIL_GREATER end function findUnbreakable[b]([/b]unit u[b])[/b] returns unit unit guard = [color=7777FF][b]null[/b][/color] unit iter grp.enumUnitsInRange[b]([/b]vec2[b]([/b]u.getX[b]([/b][b])[/b], u.getY[b]([/b][b])[/b][b])[/b], RADIUS[b])[/b] loop iter = FirstOfGroup[b]([/b]grp[b])[/b] exitwhen iter == [color=7777FF][b]null[/b][/color] [color=7777FF][b]if[/b][/color] iter.isAlive[b]([/b][b])[/b] and isGuardDevil[b]([/b]iter[b])[/b] and iter.hasAbility[b]([/b]ID_ABILITY_UNBREAKABLE[b])[/b] guard = iter end grp.removeUnit[b]([/b]iter[b])[/b] end [color=7777FF][b]return[/b][/color] guard end function h[b]([/b][b])[/b] unit tU = GetTriggerUnit[b]([/b][b])[/b] real damage = GetEventDamage[b]([/b][b])[/b] [color=7777FF][b]if[/b][/color] tU.getOwner[b]([/b][b])[/b].getId[b]([/b][b])[/b] < Players.COUNT and DamageType.get[b]([/b][b])[/b] == DamageType.ATTACK and [b]([/b]tU.getHP[b]([/b][b])[/b] - damage < [color=FF7777]1.[/color][b])[/b] and not tU.hasAbility[b]([/b]ID_INVULNERABLE[b])[/b] unit unbreakableSource = findUnbreakable[b]([/b]tU[b])[/b] [color=7777FF][b]if[/b][/color] unbreakableSource [b]![/b]= [color=7777FF][b]null[/b][/color] Invulnerable.apply[b]([/b]tU, DURATION[b])[/b] unbreakableSource.removeAbility[b]([/b]ID_ABILITY_UNBREAKABLE[b])[/b] unbreakableSource.addAbility[b]([/b] ID_ABILITY_UNBREAKA_CD[b])[/b] effect shield = tU.addEffect[b]([/b]SHIELD_FX, [color=77FF77]"origin"[/color][b])[/b] doAfter[b]([/b]DURATION, [b]([/b][b])[/b] -> begin shield.destr[b]([/b][b])[/b] end[b])[/b] doAfter[b]([/b]COOLDOWN, [b]([/b][b])[/b] -> begin unbreakableSource.addAbility[b]([/b] ID_ABILITY_UNBREAKABLE[b])[/b] unbreakableSource.removeAbility[b]([/b]ID_ABILITY_UNBREAKA_CD[b])[/b] end[b])[/b] end end end init StructuredDD.addHandler[b]([/b]function h[b])[/b] end [/code]
select language
jass
java
delphi
C++
php
> GSL
galaxy
visualBasic
wurst
Text
Markdown
select style
default
> bbcode - default
Jasscraft
jasscraft html
visual
lightweight
lightweightNr
goto line:
Compare with:
text copy window
edit this code
post new code
package GuardDevilUnbreakable import DamageType import StructuredDD import ClosureTimers import Players import Invulnerable constant int ID_GUARD_DEVIL = 'h03B' constant int ID_GUARD_DEVIL_GREATER = 'h03C' constant int ID_ABILITY_UNBREAKABLE = 'A01W' constant int ID_ABILITY_UNBREAKA_CD = 'A01X' constant int ID_INVULNERABLE = 'Avul' constant real RADIUS = 600. constant real DURATION = 1. constant real COOLDOWN = 60. constant string SHIELD_FX = "Abilities\\Spells\\Human\\DivineShield\\DivineShieldTarget.mdl" group grp = CreateGroup() function isGuardDevil(unit u) returns bool return u.getTypeId() == ID_GUARD_DEVIL or u.getTypeId() == ID_GUARD_DEVIL_GREATER end function findUnbreakable(unit u) returns unit unit guard = null unit iter grp.enumUnitsInRange(vec2(u.getX(), u.getY()), RADIUS) loop iter = FirstOfGroup(grp) exitwhen iter == null if iter.isAlive() and isGuardDevil(iter) and iter.hasAbility(ID_ABILITY_UNBREAKABLE) guard = iter end grp.removeUnit(iter) end return guard end function h() unit tU = GetTriggerUnit() real damage = GetEventDamage() if tU.getOwner().getId() < Players.COUNT and DamageType.get() == DamageType.ATTACK and (tU.getHP() - damage < 1.) and not tU.hasAbility(ID_INVULNERABLE) unit unbreakableSource = findUnbreakable(tU) if unbreakableSource != null Invulnerable.apply(tU, DURATION) unbreakableSource.removeAbility(ID_ABILITY_UNBREAKABLE) unbreakableSource.addAbility( ID_ABILITY_UNBREAKA_CD) effect shield = tU.addEffect(SHIELD_FX, "origin") doAfter(DURATION, () -> begin shield.destr() end) doAfter(COOLDOWN, () -> begin unbreakableSource.addAbility( ID_ABILITY_UNBREAKABLE) unbreakableSource.removeAbility(ID_ABILITY_UNBREAKA_CD) end) end end end init StructuredDD.addHandler(function h) end