• 🏆 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!

[JASS] adding more levels to Omnislash

Status
Not open for further replies.
Level 4
Joined
Mar 28, 2009
Messages
66
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

JASS:
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:
Level 28
Joined
Jan 26, 2007
Messages
4,789
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

JASS:
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:

JASS:
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.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
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).
 
Level 4
Joined
Mar 28, 2009
Messages
66
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.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
JASS:
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:

JASS:
set Damage = 0
set Amount = 0

But you guys probably don't know what's funny here, so you can't laugh with me.
 
Level 4
Joined
Mar 28, 2009
Messages
66
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.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
JASS:
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.
 
Status
Not open for further replies.
Top