[Spell]Jass omni slash

Status
Not open for further replies.

Prometheus

Everything is mutable; nothing is sacred
Reaction score
590
Omni Slash in JASS
Feel free to copy this spell into your map but please give me credit.
Just goto your spell (has to be a target unit spell) and hit ctrl
+ d. Look at its name and get the 1st 4 letters. replace A001 with those letters. If you press ctrl + d it'll go back to normal. I know it isin't exactly optimized a lot but it works and looks really good.

JASS:
function Trig_Omni_Slash_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

//======================================================================

function Trig_Omni_Slash_UnitIsDead takes nothing returns boolean
    return (IsUnitAliveBJ(GetFilterUnit()) == true) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false) and (IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true)
endfunction

//======================================================================

 function ABU takes unit a, unit b returns real 
     return bj_RADTODEG * Atan2(GetUnitY( b )  - GetUnitY( a ) , GetUnitX( b )  - GetUnitX( a ) ) 
endfunction
// Function ABU is a courtesy of emjir3. Thanks!

//======================================================================

function Trig_Omni_Slash_Actions takes nothing returns nothing
    local unit Caster = GetSpellAbilityUnit()
    local integer LevelofAbility = GetUnitAbilityLevelSwapped('A001', Caster)
    local unit Target = GetSpellTargetUnit()
    local real X = GetUnitX(Target)
    local real Y = GetUnitY(Target)
    local group NearbyUnits = CreateGroup()
    local real X_C = GetUnitX(Caster)
    local real Y_C = GetUnitY(Caster)
    local boolexpr blah = Condition( function Trig_Omni_Slash_UnitIsDead )
    local integer Increment = 1
    local player Owner = GetOwningPlayer(Caster)
    local real eff1
    local real eff2
    local real eff3
    local real eff4
    local effect SP
    local effect SP2
    call UnitAddAbility(Caster, 'A005')
    call SetCameraTargetControllerNoZForPlayer( Owner, Caster, 0, 0, false )
    call PauseUnit(Caster, true)
    call SetUnitInvulnerable( Caster, true )
    call SetUnitVertexColor(Caster, 255, 255, 255, 50)
    loop
        exitwhen Increment > LevelofAbility * 3
        set eff1 = GetUnitX(Caster)
        set eff2 = GetUnitY(Caster)
        call SetUnitPosition(Caster, X, Y)
        set eff3 = GetUnitX(Caster)
        set eff4 = GetUnitY(Caster)
        set SP = AddSpecialEffect("Abilities\\Spells\\Items\\AIil\\AIilTarget.mdx" , eff1, eff2)
        set SP2 = AddSpecialEffect("Abilities\\Spells\\Items\\AIil\\AIilTarget.mdx" , eff3, eff4)
        call ABU(Caster, Target)
        call SetUnitFacingToFaceUnitTimed( Caster, Target, 0 )
        call SetUnitAnimation(Caster, "slam" )
        call UnitDamageTargetBJ( Caster, Target, ( 50.00 * LevelofAbility ), ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL )
        call TriggerSleepAction(0.65)
        set Target = null
        set X_C = GetUnitX(Caster)
        set Y_C = GetUnitY(Caster)
        call GroupEnumUnitsInRange( NearbyUnits, X_C, Y_C, 600, blah)
        set Target = GroupPickRandomUnit(NearbyUnits)
        set X = GetUnitX(Target)
        set Y = GetUnitY(Target)
        call DestroyEffect(SP)
        call DestroyEffect(SP2)
        if (IsUnitGroupEmptyBJ(NearbyUnits) == true) then
            set Increment = 99
        endif
        call GroupClear(NearbyUnits)
        set Increment = Increment + 1
    endloop
    call DestroyGroup(NearbyUnits)
    set NearbyUnits = null
    call SetUnitVertexColor(Caster, 255, 255, 255, 500)
    call DestroyBoolExpr(blah)
    set blah = null
    call ResetToGameCameraForPlayer( Owner, 0.01 )
    call PauseUnit(Caster, false)
    call SetUnitInvulnerable( Caster, false )
    set Caster = null
    set Target = null
endfunction

//======================================================================

function InitTrig_Omni_Slash takes nothing returns nothing
    set gg_trg_Omni_Slash = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Omni_Slash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Omni_Slash, Condition( function Trig_Omni_Slash_Conditions ) )
    call TriggerAddAction( gg_trg_Omni_Slash, function Trig_Omni_Slash_Actions )
endfunction
 

Hero

─║╣ero─
Reaction score
250

Sim

Forum Administrator
Staff member
Reaction score
534
I will tell kc102 to attach a map with that trigger in it.
 
I

IKilledKEnny

Guest
> function Trig_Omni_Slash_Conditions
> function Trig_Omni_Slash_UnitIsDead

The Trig_ is just confusing. Also "UnitIsDead" has a misleading name.

> (IsUnitAliveBJ(GetFilterUnit()) == true)

You can simply check if it's life is more then .435 (I think it's .435, or somthing close to that) just to increase the trigger's speed.

> function ABU

What are you trying to do, calculate the distance between the units? If yes, say, so, add comments around your trigger so people could understand it clearly.

> local unit Caster = GetSpellAbilityUnit()

GetTriggerUnit(), was proved to be faster.

> local integer LevelofAbility = GetUnitAbilityLevelSwapped('A001', Caster)

Put it inside a constant function (like I was asked to do) so none JASSer could modify the spell easily.

> local boolexpr blah

A little confusing name. :rolleyes:

> call UnitAddAbility(Caster, 'A005')

What is 'A005' spell? Why don't you put it inside a constant as well?

> SetCameraTargetControllerNoZForPlayer

Do instead:

JASS:
function SetCameraTargetControllerNoZForPlayer takes player whichPlayer, unit whichUnit, real xoffset, real yoffset, boolean inheritOrientation returns nothing
    if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call SetCameraTargetController(whichUnit, xoffset, yoffset, inheritOrientation)
    endif
endfunction


All in all nice, you just need to add constants, comments and remove BJs.

Edit: I remove few things that were already told.
 

Tinki3

Special Member
Reaction score
418
Well, since the topic popped up, I've decided to post my JASS version of Omnislash.

It will run alot better than KC's, but that doesn't mean that you shouldn't use his one, because his is easier to implement :).

Notes if you want to implement:

  • KaTTaNa's local handle variable system is required (see the bottom of this thread)
  • You will need to create a new Game Cache variable called "GameCache", and initialize it as follows: Custom script: set udg_GameCache = InitGameCache("jasslocalvars.w3v")
  • The same rule for the ability ID goes for my Omnislash, as it does for KC's Omnislash; "Just goto your spell (has to be a target unit spell) and hit ctrl
    + d. Look at its name and get the 1st 4 letters. Replace A000 with these letters" (A000 is the spell's raw code, located in the function Omnislash_Conditions, and also needs to be changed in lines in the function Omnislash_Actions).

The code itself:
JASS:
constant function Attack_Delay takes nothing returns real
    return 0.35  //The delay between each slash
endfunction

constant function OS_FX_1 takes nothing returns string
    return "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl"  // Constant (created on the heroes weapon)
endfunction

constant function OS_FX_2 takes nothing returns string
    return "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl"  // Repetitive (created during each slash)
endfunction

function OS_Filter takes nothing returns boolean    
    return IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetHandleUnit(GetExpiredTimer(), "cast"))) == true and GetWidgetLife(GetFilterUnit()) > 0.405
endfunction

function Omnislash_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A000'       
endfunction

function Blink_to_Targets takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit cast = GetHandleUnit(t, "cast")
    local real attcks = GetHandleReal(t, "attcks")
    local real dmg = GetHandleReal(t, "dmg")
    local real X = GetUnitX(cast)
    local real Y = GetUnitY(cast)
    local effect fx = GetHandleEffect(t, "fx")
    local boolexpr b = Condition(function OS_Filter)
    local group g = CreateGroup()
    local integer i
    local unit p 
    local location l
    local location l2

    call GroupEnumUnitsInRange(g, X, Y, GetRandomReal(425., 575.), b) 
    set i = CountUnitsInGroup(g)

    if i > 0 and attcks > 0 and GetWidgetLife(cast) > 0.405 then
        set p = GroupPickRandomUnit(g)
        set l = GetUnitLoc(p)
        set l2 = PolarProjectionBJ(l, GetRandomReal(50.00, 175.00), GetRandomDirectionDeg())
        call SetUnitPositionLoc(cast, l2)
        call UnitDamageTargetBJ(cast, p, dmg, ATTACK_TYPE_HERO, DAMAGE_TYPE_ENHANCED) 
        call SetUnitAnimation(cast, "attack")
        call SelectUnitRemoveForPlayer(cast, GetOwningPlayer(cast))
        call DestroyEffect(AddSpecialEffectTarget(OS_FX_2(), cast, "chest"))
        call GroupRemoveUnit(g, p)
        call RemoveLocation(l)
        call RemoveLocation(l2)  
        call SetHandleReal(t, "attcks", GetHandleReal(t, "attcks") - 1)          
    else
        if GetWidgetLife(cast) > 0 then
            call ResetUnitAnimation(cast)
            call SelectUnitAddForPlayer(cast, GetOwningPlayer(cast))
        endif
        call SetUnitInvulnerable(cast, false)
        call SetUnitVertexColorBJ(cast, 100, 100, 100, 0)
        call DestroyEffect(fx)
        call FlushHandleLocals(t)
        call PauseTimer(t)
        call DestroyTimer(t)
    endif

    call DestroyBoolExpr(b)    
    call DestroyGroup(g)

    set t = null
    set cast = null
    set fx = null
    set b = null
    set g = null
    set p = null
    set l = null
    set l2 = null
endfunction

function Omnislash_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local unit cast = GetTriggerUnit()
    local unit targ = GetSpellTargetUnit()    
    local real attcks = GetUnitAbilityLevel(cast, 'A000') + 2 
    local real dmg = (GetUnitAbilityLevel(cast, 'A000') * 25.00 ) + 25.00     
    local effect fx = AddSpecialEffectTarget(OS_FX_1(), cast, "weapon")  
   
    call SetUnitInvulnerable(cast, true)
    call SetUnitVertexColorBJ(cast, 100, 100, 100, 50)
    call SetUnitPosition(cast, GetUnitX(targ), GetUnitY(targ))
    call UnitDamageTargetBJ(cast, targ, dmg, ATTACK_TYPE_HERO, DAMAGE_TYPE_ENHANCED)
    call SetUnitAnimation(cast, "attack")
    call SelectUnitRemoveForPlayer(cast, GetOwningPlayer(cast))
    call DestroyEffect(AddSpecialEffectTarget(OS_FX_2(), cast, "chest"))

    call SetHandleHandle(t, "cast", cast)
    call SetHandleReal(t, "attcks", attcks)
    call SetHandleReal(t, "dmg", dmg)
    call SetHandleHandle(t, "fx", fx)
    call TimerStart(t, Attack_Delay(), true, function Blink_to_Targets)

    set t = null
    set cast = null
    set targ = null
    set fx = null
endfunction

function InitTrig_Omnislash takes nothing returns nothing
    set gg_trg_Omnislash = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Omnislash, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Omnislash, Condition( function Omnislash_Conditions ) )
    call TriggerAddAction( gg_trg_Omnislash, function Omnislash_Actions )
endfunction


--

KaTTaNa's local handle variable system.

Copy the following code and paste it into your map's trigger header(It looks like the icon of a WC3 map):
JASS:
function H2I takes handle h returns integer
    return h
    return 0
endfunction

function LocalVars takes nothing returns gamecache
    return udg_GameCache
endfunction

function SetHandleHandle takes handle subject, string name, handle value returns nothing
    if value==null then
        call FlushStoredInteger(LocalVars(),I2S(H2I(subject)),name)
    else
        call StoreInteger(LocalVars(),I2S(H2I(subject)), name, H2I(value))
    endif
endfunction

function SetHandleInt takes handle subject, string name, integer value returns nothing
    if value==0 then
        call FlushStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreInteger(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleBoolean takes handle subject, string name, boolean value returns nothing
    if value==false then
        call FlushStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreBoolean(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreReal(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function SetHandleString takes handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(LocalVars(), I2S(H2I(subject)), name)
    else
        call StoreString(LocalVars(), I2S(H2I(subject)), name, value)
    endif
endfunction

function GetHandleHandle takes handle subject, string name returns handle
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function GetHandleInt takes handle subject, string name returns integer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
endfunction
 
function GetHandleBoolean takes handle subject, string name returns boolean
    return GetStoredBoolean(LocalVars(), I2S(H2I(subject)), name)
endfunction

function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(LocalVars(), I2S(H2I(subject)), name)
endfunction

function GetHandleString takes handle subject, string name returns string
    return GetStoredString(LocalVars(), I2S(H2I(subject)), name)
endfunction

function GetHandleUnit takes handle subject, string name returns unit
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function GetHandleTimer takes handle subject, string name returns timer
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function GetHandleTrigger takes handle subject, string name returns trigger
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function GetHandleEffect takes handle subject, string name returns effect
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function GetHandleGroup takes handle subject, string name returns group
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function GetHandleLoc takes handle subject, string name returns location
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function GetHandleLightning takes handle subject, string name returns lightning
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function GetHandleWidget takes handle subject, string name returns widget
    return GetStoredInteger(LocalVars(), I2S(H2I(subject)), name)
    return null
endfunction

function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(LocalVars(), I2S(H2I(subject)) )
endfunction


Thanks for reading.

Tinki3
 
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top