1. Find your way through the deepest dungeon in the 18th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A brave new world lies beyond the seven seas. Join the 34th Modeling Contest today!
    Dismiss Notice
  3. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
Hive 3 Remoosed BETA - NOW LIVE. Go check it out at BETA Hive Workshop! Post your feedback in this new forum BETA Feedback.
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[JASS] adding more levels to Omnislash

Discussion in 'Triggers & Scripts' started by SunTzu7387, Jun 2, 2009.

  1. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    Omnislash help

    This spell is by emjir3 who to my knowledge does not sign in anymore and hasn't for quite a while. I want to make omnislash go to level five but it only goes to level three. Can someone help me?

    Heres the trigger

    Omnislash
    Code (vJASS):
    function Trig_Omnislash_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A007'        
    endfunction

    function Unit_Group takes nothing returns boolean
        return GetBooleanAnd( IsUnitAliveBJ(GetFilterUnit()) == true, IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit())) == true )
    endfunction

    function Trig_Omnislash_Actions takes nothing returns nothing
        local unit Caster = GetTriggerUnit()
        local integer i = 0
        local group UnitGroup
        local unit TargetRandom
        local unit Target = GetSpellTargetUnit()
        local effect Phoenix    
        local location R
        local real Damage = 100
        local integer Amount = 1 + ( GetUnitAbilityLevelSwapped('A007', Caster) * 2 )
        call TriggerSleepAction( 0.20 )
        call SelectUnitRemove( Caster )
        call SetUnitVertexColor( Caster, 150, 150, 150, 150 )
        call SetUnitInvulnerable( Caster, true )    
        set Phoenix = AddSpecialEffectTarget("Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl",Caster,"weapon" )
        call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", Caster, "chest" ))
        call SetUnitPositionLocFacingBJ( Caster, PolarProjectionBJ(GetUnitLoc(Target), 50.00, GetRandomDirectionDeg()), AngleBetweenPoints(GetUnitLoc(Caster), GetUnitLoc(Target)) )
        call UnitDamageTarget( Caster, Target, Damage, false, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_AXE_MEDIUM_CHOP )
        call SetUnitAnimation( Caster, "attack" )
        call TriggerSleepAction( 0.25 )
        call SelectUnitRemove( Caster )    
        loop
            set i = i + 1        
            exitwhen i > Amount
                set UnitGroup = GetUnitsInRangeOfLocMatching(600.00, GetUnitLoc(Caster), Condition(function Unit_Group))
                if ( IsUnitGroupEmptyBJ(UnitGroup) == false ) then
                    set TargetRandom = GroupPickRandomUnit(UnitGroup)
                    set R = GetUnitLoc(TargetRandom)
                    call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", Caster, "chest" ))
                    call SetUnitPositionLocFacingBJ( Caster, PolarProjectionBJ(R, 50.00, GetRandomDirectionDeg()), AngleBetweenPoints(GetUnitLoc(Caster), GetUnitLoc(TargetRandom)) )
                    call UnitDamageTarget( Caster, TargetRandom, Damage, false, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_AXE_MEDIUM_CHOP )
                    call SetUnitAnimation( Caster, "attack" )
                    call RemoveLocation ( R )
                    call TriggerSleepAction( 0.25 )
                    call SelectUnitRemove( Caster )                
                else
                endif
                call DestroyGroup(UnitGroup)          
            endloop    
        call SelectUnitForPlayerSingle( Caster, GetTriggerPlayer() )
        call SetUnitInvulnerable( Caster, false )
        call SetUnitVertexColor( Caster, 255, 255, 255, 255 )
        call DestroyEffect( Phoenix )  
        set Phoenix = null    
        set Caster = null    
        set UnitGroup = null
        set TargetRandom = null
        set Target = null    
        set Amount = 0
        set R = null
        set Damage = 0
    endfunction

    //===========================================================================
    function InitTrig_Omnislash takes nothing returns nothing
        set gg_trg_Omnislash = CreateTrigger(  )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Omnislash, EVENT_PLAYER_UNIT_SPELL_CAST )
        call TriggerAddCondition( gg_trg_Omnislash, Condition( function Trig_Omnislash_Conditions ) )
        call TriggerAddAction( gg_trg_Omnislash, function Trig_Omnislash_Actions )
    endfunction
     
    Last edited: Jun 2, 2009
  2. ap0calypse

    ap0calypse

    Joined:
    Jan 26, 2007
    Messages:
    4,776
    Resources:
    2
    Spells:
    1
    Tutorials:
    1
    Resources:
    2
    This is my 3th day learning JASS (and still making progress :D), but it reacts to the level of the ability, so it would work for all levels.


    More Info

    The code

    Code (vJASS):
    local integer Amount = 1 + ( GetUnitAbilityLevelSwapped('A007', Caster) * 2 )


    means that the amount of targets (variable "Amount") depends on the level of the spell.

    Here is a little info about the number of targets and the spell level:
    • Level 1: 3 Targets (1 + 1*2)
    • Level 2: 5 Targets (1 + 2*2)
    • Level 3: 7 Targets (1 + 3*2)
    • Level 4: 9 Targets (1 + 4*2)
    • Level 5: 11 Targets (1 + 5*2)
    • ...

    Since 11 targets is a lot, I would change the code to:

    Code (vJASS):
    local integer Amount = 2 + ( GetUnitAbilityLevelSwapped('A007', Caster))


    Which will begin with 3 targets and add 1 more target per level, ending with 8 targets at level 5.


    So you just need to adjust the ability in the object editor to get more levels.
     
  3. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Oh god, this is really bad jass...either emjir was drunk or he made this in his early JASS days.

    If you want, I can modify this a bit, because it has leaks too.

    Btw, apocalypse is right, it supports all levels.

    Apocalypse, pretty impressive for the third day :D (if you need some help with (v)jass, you can PM me).
     
  4. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    oh really it has leaks too? great... lol yes please Silvenon can you modify it for me? plus rep for you both for the help. Oh ya ap0calypse you are rite i checked it again and it does work but it was just that my math on how many targets the caster attacked was wrong, im new to jass.
     
  5. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Code (vJASS):
    function Trig_Omnislash_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A007'
    endfunction

    function Unit_Group takes nothing returns boolean
        return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0 and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit()))
    endfunction

    function Trig_Omnislash_Actions takes nothing returns nothing
        local unit Caster = GetTriggerUnit()
        local integer i = 0
        local group UnitGroup
        local unit TargetRandom
        local unit Target = GetSpellTargetUnit()
        local effect Phoenix
        local real Damage = 100
        local integer Amount = 1 + GetUnitAbilityLevel(Caster, 'A007') * 2
        local real x1 = GetUnitX(Caster)
        local real y1 = GetUnitY(Caster)
        local real x2 = GetUnitX(Target)
        local real y2 = GetUnitY(Target)
        local real a = GetRandomReal(0, 2 * bj_PI)
        call TriggerSleepAction( 0.20 )
        call SelectUnit( Caster, false )
        call SetUnitVertexColor( Caster, 150, 150, 150, 150 )
        call SetUnitInvulnerable( Caster, true )
        set Phoenix = AddSpecialEffectTarget("Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl",Caster,"weapon" )
        call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", Caster, "chest" ))
        call SetUnitPosition(Caster, x2 + 50 * Cos(a), y2 + 50 * Sin(a))
        call SetUnitFacing(Caster, Atan2(y2 - y1, x2 - x1) * bj_RADTODEG)
        call UnitDamageTarget( Caster, Target, Damage, false, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_AXE_MEDIUM_CHOP )
        call SetUnitAnimation( Caster, "attack" )
        call TriggerSleepAction( 0.25 )
        call SelectUnit( Caster, false )
        loop
            set i = i + 1
            exitwhen i > Amount
                set UnitGroup = CreateGroup()
                call GroupEnumUnitsInRange(UnitGroup, x1, y1, 600, Condition(function Unit_Group))
                if ( IsUnitGroupEmptyBJ(UnitGroup) == false ) then
                    set TargetRandom = GroupPickRandomUnit(UnitGroup)
                    set x2 = GetUnitX(TargetRandom)
                    set y2 = GetUnitY(TargetRandom)
                    set a = GetRandomReal(0, 2 * bj_PI)
                    call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", Caster, "chest" ))
                    call SetUnitPosition(Caster, x2 + 50 * Cos(a), y2 + 50 * Sin(a))
                    call SetUnitFacing(Caster, Atan2(y2 - y1, x2 - x1) * bj_RADTODEG)
                    call UnitDamageTarget( Caster, TargetRandom, Damage, false, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_AXE_MEDIUM_CHOP )
                    call SetUnitAnimation( Caster, "attack" )
                    call TriggerSleepAction( 0.25 )
                    call SelectUnit( Caster, false )
                endif
                call DestroyGroup(UnitGroup)
            endloop
        if GetLocalPlayer() == GetTriggerPlayer() then
            call ClearSelection()
            call SelectUnit(Caster, true)
        endif
        call SetUnitInvulnerable( Caster, false )
        call SetUnitVertexColor( Caster, 255, 255, 255, 255 )
        call DestroyEffect( Phoenix )
        set Phoenix = null
        set Caster = null
        set UnitGroup = null
        set TargetRandom = null
        set Target = null
    endfunction

    //===========================================================================
    function InitTrig_Omnislash takes nothing returns nothing
        set gg_trg_Omnislash = CreateTrigger( )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Omnislash, EVENT_PLAYER_UNIT_SPELL_CAST )
        call TriggerAddCondition( gg_trg_Omnislash, Condition( function Trig_Omnislash_Conditions ) )
        call TriggerAddAction( gg_trg_Omnislash, function Trig_Omnislash_Actions )
    endfunction


    Ok here it is. I hope I didn't screw something up, you should better test it. There are probably few more improvements I could've added, but then I would go into vJass, I should better leave it like this.

    Definitely the dumbest lines were:

    Code (vJASS):
    set Damage = 0
    set Amount = 0


    But you guys probably don't know what's funny here, so you can't laugh with me.
     
  6. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    I tested it several times and at level one the hero attacks 2wice at level 2 it attacks 6 times at 3, 8 at 4, 10 and at level 5, 13 (just checking to c if thats wat you intended to make it at). I counted this over ten to twenty times. Oh but I did c something that you might not have intended to do which was the hero will attack nothing with omnislash for example, the hero will attack random unit then attack the air then come back and attack more random units. Again if you intended that to be like that for the sake of the hero randomly attacking anything then its fine with me, im just happy as long as the leaks you saw are gone. Also thank you so much for helping me like this that is very nice of you.
     
  7. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Actually, the idea was to improve the performance, I didn't intend to mess the spell up. That's bad then, I'll try to fix it soon.

    It wasn't working like that before, right?
     
  8. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    no it was not working like that before. And thank you so much agian for your help when I can Ill give you more rep and also credit you on my map.
     
  9. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Change
    GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) <= 0
    to
    GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) >= 0
    (that's in the Unit_Group function). Check if it works now :D
     
  10. TriggerHappy

    TriggerHappy

    Code Moderator

    Joined:
    Jun 23, 2007
    Messages:
    3,833
    Resources:
    22
    Spells:
    11
    Tutorials:
    2
    JASS:
    9
    Resources:
    22
    If you need to contact him, do it either on thehelper.net or wc3c.net.

    And I would avoid using this spell.
     
  11. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Tnx.

    Yeah, I would avoid it too. Because it's a copy of a dota spell and because it has TriggerSleepActions in it.
     
  12. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    ok thank for the help
     
  13. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Did you try what I said two posts above?
     
  14. SunTzu7387

    SunTzu7387

    Joined:
    Mar 28, 2009
    Messages:
    66
    Resources:
    0
    Resources:
    0
    ya it didnt work...
     
  15. Silvenon

    Silvenon

    Joined:
    Nov 22, 2006
    Messages:
    1,233
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Code (vJASS):
    function Trig_Omnislash_Conditions takes nothing returns boolean
        return GetSpellAbilityId() == 'A007'
    endfunction

    function Unit_Group takes nothing returns boolean
        return GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0 and IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit()))
    endfunction

    function Trig_Omnislash_Actions takes nothing returns nothing
        local unit Caster = GetTriggerUnit()
        local integer i = 0
        local group UnitGroup
        local unit Target = GetSpellTargetUnit()
        local effect Phoenix
        local real Damage = 100
        local integer Amount = 1 + GetUnitAbilityLevel(Caster, 'A007') * 2
        local real x1 = GetUnitX(Caster)
        local real y1 = GetUnitY(Caster)
        local real x2 = GetUnitX(Target)
        local real y2 = GetUnitY(Target)
        local real a = GetRandomReal(0, 2 * bj_PI)
        call TriggerSleepAction( 0.20 )
        call SelectUnit( Caster, false )
        call SetUnitVertexColor( Caster, 150, 150, 150, 150 )
        call SetUnitInvulnerable( Caster, true )
        set Phoenix = AddSpecialEffectTarget("Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile.mdl",Caster,"weapon" )
        call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", Caster, "chest" ))
        call SetUnitPosition(Caster, x2 + 50 * Cos(a), y2 + 50 * Sin(a))
        call SetUnitFacing(Caster, Atan2(y2 - y1, x2 - x1) * bj_RADTODEG)
        call UnitDamageTarget( Caster, Target, Damage, false, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_AXE_MEDIUM_CHOP )
        call SetUnitAnimation( Caster, "attack" )
        call TriggerSleepAction( 0.25 )
        call SelectUnit( Caster, false )
        loop
            set i = i + 1
            exitwhen i > Amount
                set UnitGroup = CreateGroup()
                call GroupEnumUnitsInRange(UnitGroup, x1, y1, 600, Condition(function Unit_Group))
                if ( IsUnitGroupEmptyBJ(UnitGroup) == false ) then
                    set Target = GroupPickRandomUnit(UnitGroup)
                    set x2 = GetUnitX(Target)
                    set y2 = GetUnitY(Target)
                    set a = GetRandomReal(0, 2 * bj_PI)
                    call DestroyEffect(AddSpecialEffectTarget( "Abilities\\Spells\\NightElf\\Blink\\BlinkCaster.mdl", Caster, "chest" ))
                    call SetUnitPosition(Caster, x2 + 50 * Cos(a), y2 + 50 * Sin(a))
                    call SetUnitFacing(Caster, Atan2(y2 - y1, x2 - x1) * bj_RADTODEG)
                    call UnitDamageTarget( Caster, Target, Damage, false, true, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_AXE_MEDIUM_CHOP )
                    call SetUnitAnimation( Caster, "attack" )
                    call TriggerSleepAction( 0.25 )
                    call SelectUnit( Caster, false )
                endif
                call DestroyGroup(UnitGroup)
            endloop
        if GetLocalPlayer() == GetTriggerPlayer() then
            call ClearSelection()
            call SelectUnit(Caster, true)
        endif
        call SetUnitInvulnerable( Caster, false )
        call SetUnitVertexColor( Caster, 255, 255, 255, 255 )
        call DestroyEffect( Phoenix )
        set Phoenix = null
        set Caster = null
        set UnitGroup = null
        set Target = null
    endfunction

    //===========================================================================
    function InitTrig_Omnislash takes nothing returns nothing
        set gg_trg_Omnislash = CreateTrigger( )
        call TriggerRegisterAnyUnitEventBJ( gg_trg_Omnislash, EVENT_PLAYER_UNIT_SPELL_CAST )
        call TriggerAddCondition( gg_trg_Omnislash, Condition( function Trig_Omnislash_Conditions ) )
        call TriggerAddAction( gg_trg_Omnislash, function Trig_Omnislash_Actions )
    endfunction


    This is the code I used.

    I tried both versions and they seem to work equally, except that the code in your first post crashed my game, but before it crashed it seemed to work the same.