• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Cruel Evasion (incl. Stun Unit System)

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
This is my Cruel Evasion spell requested by Axarion.


Cruel Evasion
The warrior has a chance to evade an attack, blink behind the attacker, hit him critically and stun him.
it is MUI, leak free and easy to customize

including my stun system which is very simple...

JASS:
library StunSystem
// how to:
//
//   call StunUnit(yourunit, time)
//
//Setup
globals
    // this is the special effect created on a stunned unit
    private string sfx = "Abilities\\Spells\\Human\\Thunderclap\\ThunderclapTarget.mdl"
    // this is the attachement point for sfx
    private string AttachPoint = "overhead"
endglobals
//End of setup

private struct data
unit u
real t
effect sfx
endstruct

globals
    private data array StunnedUnits
    private integer total=0
    private timer tim = CreateTimer()
endglobals

private function Stun takes nothing returns nothing
    local integer i = 0
    local data dat
    loop
        exitwhen i >= total
        set dat = StunnedUnits[i]
        if dat.t <= 0 or IsUnitType(dat.u,UNIT_TYPE_DEAD) then
            call DestroyEffect(dat.sfx)
            set total = total-1
            set StunnedUnits[i] = StunnedUnits[total]
            call dat.destroy()
            set i = i - 1
        else
            set dat.t = dat.t - 0.01
            call SetUnitPosition(dat.u,GetUnitX(dat.u),GetUnitY(dat.u))
        endif
        set i = i + 1
    endloop
    if total == 0 then
        call PauseTimer(tim)
    endif
endfunction

function StunUnit takes unit u,real time returns nothing
    local data dat = data.create()
    set dat.t = time
    set dat.u = u
    set dat.sfx = AddSpecialEffectTarget(sfx,u,AttachPoint)
    if total == 0 then
        call TimerStart(tim,0.01,true,function Stun)
    endif
    set StunnedUnits[total]=dat
    set total = total + 1
endfunction
endlibrary


JASS:
scope CruelEvasion initializer Init
//Cruel Evasion by The_Witcher
//
// requires my Stun System
//
// the unit has a chance to evade an attack, blink behind the attacker, hit him critical and stun him.
//
// The SETUP part
globals 
    // The rawcode of your ability
    private constant integer AbiID = 'A000'                  
    // The effect created at the target loc
    private constant string BlinkTargetSFX = "Abilities\\Spells\\NightElf\\Blink\\BlinkTarget.mdl"
    // The effect created at the caster loc
    private constant string BlinkCasterSFX = "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"
    // If ranged is false only attacks from nearer then 200 will fire the effect
    private boolean ranged = true
endglobals

private function GetEvasionPercentage takes integer level returns real
    return 0.2 * level                 //20% on level 1, 40% on level 2, 60% on level 3,...
endfunction

private function GetDamage takes integer level returns real
    return 100 + 50 * I2R(level)       //150 on level 1, 200 level 2, 250 level 3,...
endfunction

private function GetStunTime takes integer level returns real
    return 1 + 1 * I2R(level)          //2sec on level 1, 3sec level 2, 4sec level 3,...
endfunction

// END OF SETUP PART

private function DistanceBetweenUnits takes unit a, unit b returns real
    local real dx = GetUnitX(b) - GetUnitX(a)
    local real dy = GetUnitY(b) - GetUnitY(a)
    return SquareRoot(dx * dx + dy * dy)
endfunction

private function check takes nothing returns boolean
    local unit a = GetTriggerUnit()
    local unit b = GetAttacker()
    local integer lvl = GetUnitAbilityLevel(a,AbiID)
    local real time = GetStunTime(lvl)
    local real p = GetEvasionPercentage(lvl)
    local real dmg = GetDamage(lvl)
    local real x = GetUnitX(b) + 100 * Cos((GetUnitFacing(b)-180) *bj_DEGTORAD)
    local real y = GetUnitY(b) + 100 * Sin((GetUnitFacing(b)-180) *bj_DEGTORAD)
    local real rp = GetRandomReal(0,1)
    local boolean bool = DistanceBetweenUnits(a,b) < 200
    if ranged then
        set bool = true
    endif
    if lvl > 0 and rp > (1-p) and bool then
        call DestroyEffect(AddSpecialEffect(BlinkCasterSFX,GetUnitX(a),GetUnitY(a)))
        call DestroyEffect(AddSpecialEffect(BlinkTargetSFX,x,y))
        call SetUnitPosition(a,x,y)
        call SetUnitFacing(a,GetUnitFacing(b))
        call StunUnit(b,time)
        call UnitDamageTarget(a,b,dmg,true,false,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
        call SetUnitAnimation(a,"attack")
    endif
    set a = null
    set b = null
    return false
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition(t,Condition(function check))
endfunction

endscope

Keywords:
stun, blink, damage, cruel, critical, evade, mui, mpi, vjass, effect
Contents

Cruel Evasion (Map)

Reviews
22:34, 2nd Jan 2010 TriggerHappy: Your stun system appears to just...create an effect. The spell itself is far too simple to be approved.

Moderator

M

Moderator

22:34, 2nd Jan 2010
TriggerHappy:

  • Your stun system appears to just...create an effect.
  • The spell itself is far too simple to be approved.
 
Level 10
Joined
Feb 20, 2008
Messages
448
lol I made an almost similar spell like this in GUI...well yours is jass and MUI so yeah...

Do u mind to show me a Gui 1 ,becuz poeple ask me request doesnt alway have jngp editor

& it is normal that even with jngp editor its doesnt work ? i cant test it wc3 doesnt lauch the map!! it is truly compatible 1.24b ?becuz nothing seems to work!!
 
Last edited:
Level 10
Joined
Sep 3, 2009
Messages
458
Do u mind to show me a Gui 1 ,becuz poeple ask me request doesnt alway have jngp editor

& it is normal that even with jngp editor its doesnt work ? i cant test it wc3 doesnt lauch the map!! it is truly compatible 1.24b ?becuz nothing seems to work!!

well sure I guess, uhm where do I upload it?

EDIT:

ok here it is. I do warn you it's not mui

  • Counter Cooldown
    • Events
      • Time - Counter_Timer expires
    • Conditions
    • Actions
      • Trigger - Turn on Counter Start <gen>
  • Counter Start
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • (Level of Counter for (Attacked unit)) Not equal to 0
          • ((Attacking unit) is A Hero) Equal to True
          • (Percentage life of (Attacked unit)) Greater than or equal to ((Real((Level of Counter for Counter_Caster))) x 10.00)
          • (Distance between (Position of (Attacking unit)) and (Position of (Attacked unit))) Less than or equal to 500.00
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to 45
        • Then - Actions
          • Set Counter_Caster = (Attacked unit)
          • Set Counter_Epoint = (Position of Counter_Caster)
          • Set Counter_Unit = (Attacking unit)
          • Set Counter_Point = ((Position of Counter_Unit) offset by -100.00 towards (Facing of Counter_Unit) degrees)
          • Special Effect - Create a special effect at Counter_Epoint using Abilities\Spells\NightElf\Blink\BlinkTarget.mdl
          • Set Counter_Effect[0] = (Last created special effect)
          • Unit - Move Counter_Caster instantly to Counter_Point, facing (Facing of Counter_Unit) degrees
          • Special Effect - Destroy Counter_Effect[0]
          • Unit - Create 1 Dummy Unit for (Owner of Counter_Caster) at Counter_Point facing Default building facing degrees
          • Set Counter_Dummy = (Last created unit)
          • Unit - Add Storm Bolt (Counter) to Counter_Dummy
          • Unit - Order Counter_Dummy to Human Mountain King - Storm Bolt Counter_Unit
          • Countdown Timer - Start Counter_Timer as a One-shot timer that will expire in 3.00 seconds
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Last edited:
Top