HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Jass Spell: Bladestorm

02-18-2007, 07:34 PM#1
Fulla
Bladestorm: Spins units around the Blademaster that stray to close, whilst in effect. Thrwos all units outwards at the end.

I tried copying bits and peices from other spells ive seen, with little success. mainly setting angles with Cos/Sin

need a little help, this spells goes haywirem with units ending up on other side of the map.

Collapse JASS:
    //####################################################################################\\
    //                            Spell Name: Bladestorm                                  \\
    //                            Spell Auth: Fulla                                       \\
    //####################################################################################\\


            //################################################################\\
            //                                                                \\
            //                     Configuration Section                      \\
            //                                                                \\
            //################################################################\\


constant function Bladestorm_AbilId takes nothing returns integer
    return 'A076' // Main ability id
endfunction

constant function Bladestorm_Duration takes nothing returns integer
    return 80 // How long Spell lasts, Amount entered * 0.05 = Duration in seconds. (Currently 4 sec) 
endfunction


            //################################################################\\
            //                                                                \\
            //                        Spell Section                           \\
            //                                                                \\
            //################################################################\\


function Trig_Bladestorm_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Bladestorm_AbilId()
endfunction

function Filter_Bladestorm takes nothing returns boolean
    return IsUnitInGroup(GetFilterUnit(), udg_BladestormGroup) == false and (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.) and (IsUnitEnemy(GetFilterUnit(), udg_tempplayer)) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false)
endfunction

function Bladestorm takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local string s = GetAttachmentTable(t)
    
    local unit c = GetTableUnit(s, "C")
    local integer i = GetTableInt(s, "I")
    local player o = GetOwningPlayer(c)
    local real x = GetUnitX(c)
    local real y = GetUnitY(c)
    local real x1
    local real y1
    local boolexpr b = Filter(function Filter_Bladestorm)
    //local integer lvl = GetUnitAbilityLevel(c, Bladestorm_AbilId())   
    local unit d
    local group g = CreateGroup()
    local real ang
    set udg_tempplayer = o
    
    call GroupEnumUnitsInRange(g, x, y, 250, b)
    loop
        set d = FirstOfGroup(g)
        exitwhen d == null
        call SetUnitPathing(d, false)
        call GroupAddUnit(udg_BladestormGroup, d)
        call GroupRemoveUnit(g, d)
    endloop
    
    call GroupAddGroup(udg_BladestormGroup, g)
    
    loop
        set d = FirstOfGroup(g)
        exitwhen d == null
        set x1 = GetUnitX(d)
        set y1 = GetUnitY(d)
        set ang = bj_RADTODEG * Atan2(y1 - y, x1 - x)
        
        set x1 = x1 * Cos(ang * bj_DEGTORAD)
        set y1 = y1 * Sin(ang * bj_DEGTORAD)
        
        call SetUnitX(d, x1)
        call SetUnitX(d, y1)
        
        call GroupRemoveUnit(g, d)
    endloop
    
    set i = i - 1      
     
    if i == 0 then
    
        loop
            set d = FirstOfGroup(udg_BladestormGroup)
            exitwhen d == null
            set x1 = GetUnitX(d)
            set y1 = GetUnitY(d)
            set ang = bj_RADTODEG * Atan2(y1 - y, x1 - x)
            call KnockbackFunctions_KBUnit(d, ang, 500., 1.10, .05, true, true)
            call SetUnitPathing(d, true)
            call GroupRemoveUnit(udg_BladestormGroup, d)
        endloop
        
        call GroupClear(udg_BladestormGroup)
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set g = null
        set b = null
        set o = null
        set c = null
        set d = null
        call ClearTimer(t)    
    else     
        call SetTableInt(s, "I", i)
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set g = null
        set b = null
        set o = null
        set c = null
        set d = null 
    endif 
endfunction

function Trig_Bladestorm_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local string s = GetAttachmentTable(t)
    
    local unit c = GetTriggerUnit()
    local integer i =  Bladestorm_Duration()  

    call SetTableObject(s, "C", c)
    call SetTableInt(s, "I", i)
    call TimerStart(t, 0.05, true, function Bladestorm)    
endfunction

//===========================================================================
function InitTrig_Bladestorm takes nothing returns nothing
    set gg_trg_Bladestorm = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Bladestorm, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Bladestorm, Condition(function Trig_Bladestorm_Conditions))
    call TriggerAddAction(gg_trg_Bladestorm, function Trig_Bladestorm_Actions)
endfunction
02-18-2007, 09:14 PM#2
oNdizZ
if its only the polars your having problems with.
Collapse JASS:
newx = oldx + dist * Cos(angle * bj_DEGTORAD)
newy = oldy + dist * Sin(angle * bj_DEGTORAD)

then take a look at what you've done:

Collapse JASS:
        set x1 = x1 * Cos(ang * bj_DEGTORAD)
        set y1 = y1 * Sin(ang * bj_DEGTORAD)




btw:
you might wanna fix this common error:
Collapse JASS:
        call SetUnitX(d, x1)
        call SetUnitX(d, y1)
02-19-2007, 01:52 PM#3
Fulla
Ok Ive semi got it working now.

It works, except it units Never stop spinning.
I cant see anything wrong with it, the timer should expire?

Collapse JASS:
    //####################################################################################\\
    //                            Spell Name: Bladestorm                                  \\
    //                            Spell Auth: Fulla                                       \\
    //####################################################################################\\


            //################################################################\\
            //                                                                \\
            //                     Configuration Section                      \\
            //                                                                \\
            //################################################################\\


constant function Bladestorm_AbilId takes nothing returns integer
    return 'A076' // Main ability id
endfunction

constant function Bladestorm_Duration takes nothing returns integer
    return 80 // How long Spell lasts, Amount entered * 0.05 = Duration in seconds. (Currently 4 sec) 
endfunction


            //################################################################\\
            //                                                                \\
            //                        Spell Section                           \\
            //                                                                \\
            //################################################################\\


function Trig_Bladestorm_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Bladestorm_AbilId()
endfunction

function Filter_Bladestorm takes nothing returns boolean
    return IsUnitInGroup(GetFilterUnit(), udg_BladestormGroup) == false and (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.) and (IsUnitEnemy(GetFilterUnit(), udg_tempplayer)) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false)
endfunction

function Bladestorm takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local string s = GetAttachmentTable(t)
    
    local unit c = GetTableUnit(s, "C")
    local integer i = GetTableInt(s, "I")
    local player o = GetOwningPlayer(c)
    local real x = GetUnitX(c)
    local real y = GetUnitY(c)
    local real x1
    local real y1
    local boolexpr b = Filter(function Filter_Bladestorm)
    //local integer lvl = GetUnitAbilityLevel(c, Bladestorm_AbilId())   
    local unit d
    local group g = CreateGroup()
    local real ang
    set udg_tempplayer = o
    
    call GroupEnumUnitsInRange(g, x, y, 250, b)
    loop
        set d = FirstOfGroup(g)
        exitwhen d == null
        call SetUnitPathing(d, false)
        call GroupAddUnit(udg_BladestormGroup, d)
        call GroupRemoveUnit(g, d)
    endloop
    
    call GroupAddGroup(udg_BladestormGroup, g)
    
    loop
        set d = FirstOfGroup(g)
        exitwhen d == null
        set x1 = GetUnitX(d)
        set y1 = GetUnitY(d)
        set ang = bj_RADTODEG * Atan2(y - y1, x - x1)        
        call SetUnitPositionLoc(d, PolarProjectionBJ(Location(x, y), 125., ang + 20))        
        call GroupRemoveUnit(g, d)
    endloop
    
    set i = i - 1      
     
    if i == 0 then
    
        loop
            set d = FirstOfGroup(udg_BladestormGroup)
            exitwhen d == null
            set x = GetUnitX(c)
            set y = GetUnitY(c)
            set x1 = GetUnitX(d)
            set y1 = GetUnitY(d)
            set ang = bj_RADTODEG * Atan2(y - y1, x - x1)
            call KnockbackFunctions_KBUnit(d, ang, 25., 1.10, .05, true, true)
            call Resume_Attack(d, 3.)
            call SetUnitPathing(d, true)
            call GroupRemoveUnit(udg_BladestormGroup, d)
        endloop
        
        call SetUnitPathing(c, true)
        call GroupClear(udg_BladestormGroup)
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set g = null
        set b = null
        set o = null
        set c = null
        set d = null
        call ClearTimer(t)    
    else     
        call SetTableInt(s, "I", i)
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set g = null
        set b = null
        set o = null
        set c = null
        set d = null 
    endif 
endfunction

function Trig_Bladestorm_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local string s = GetAttachmentTable(t)
    
    local unit c = GetTriggerUnit()
    local integer i =  Bladestorm_Duration()
    call SetUnitPathing(c, false)  

    call SetTableObject(s, "C", c)
    call SetTableInt(s, "I", i)
    call TimerStart(t, 0.05, true, function Bladestorm)    
endfunction

//===========================================================================
function InitTrig_Bladestorm takes nothing returns nothing
    set gg_trg_Bladestorm = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Bladestorm, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Bladestorm, Condition(function Trig_Bladestorm_Conditions))
    call TriggerAddAction(gg_trg_Bladestorm, function Trig_Bladestorm_Actions)
endfunction

thx for any help
02-19-2007, 04:54 PM#4
diablo-dk
you have to call SetTableInt() when you change the i value,

Collapse JASS:
    set i = i - 1
            call SetTableInt(s,"I",i)

this is atleast what i think
02-20-2007, 04:26 PM#5
Fulla
I recoded the order of it, still same problem. The spinning never stops.

Collapse JASS:
    //####################################################################################\\
    //                            Spell Name: Bladestorm                                  \\
    //                            Spell Auth: Fulla                                       \\
    //####################################################################################\\


            //################################################################\\
            //                                                                \\
            //                     Configuration Section                      \\
            //                                                                \\
            //################################################################\\


constant function Bladestorm_AbilId takes nothing returns integer
    return 'A076' // Main ability id
endfunction

constant function Bladestorm_Duration takes nothing returns integer
    return 80 // How long Spell lasts, Amount entered * 0.05 = Duration in seconds. (Currently 4 sec) 
endfunction


            //################################################################\\
            //                                                                \\
            //                        Spell Section                           \\
            //                                                                \\
            //################################################################\\


function Trig_Bladestorm_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Bladestorm_AbilId()
endfunction

function Filter_Bladestorm takes nothing returns boolean
    return IsUnitInGroup(GetFilterUnit(), udg_BladestormGroup) == false and (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.) and (IsUnitEnemy(GetFilterUnit(), udg_tempplayer)) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false)
endfunction

function Bladestorm takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local string s = GetAttachmentTable(t)
    
    local unit c = GetTableUnit(s, "C")
    local integer i = GetTableInt(s, "I")
    local player o = GetOwningPlayer(c)
    local real x = GetUnitX(c)
    local real y = GetUnitY(c)
    local real x1
    local real y1
    local boolexpr b = Filter(function Filter_Bladestorm)
    //local integer lvl = GetUnitAbilityLevel(c, Bladestorm_AbilId())   
    local unit d
    local group g = CreateGroup()
    local real ang
    set udg_tempplayer = o
    
    call GroupEnumUnitsInRange(g, x, y, 250, b)
    loop
        set d = FirstOfGroup(g)
        exitwhen d == null
        call SetUnitPathing(d, false)
        call GroupAddUnit(udg_BladestormGroup, d)
        call GroupRemoveUnit(g, d)
    endloop
    
    call GroupAddGroup(udg_BladestormGroup, g)
    
    loop
        set d = FirstOfGroup(g)
        exitwhen d == null
        set x1 = GetUnitX(d)
        set y1 = GetUnitY(d)
        set ang = bj_RADTODEG * Atan2(y - y1, x - x1)        
        call SetUnitPositionLoc(d, PolarProjectionBJ(Location(x, y), 125., ang + 20))        
        call GroupRemoveUnit(g, d)
    endloop      
     
    if i != 0 then
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set g = null
        set b = null
        set o = null
        set c = null
        set d = null
        set i = i - 1
        call SetTableInt(s, "I", i)        
    else     
        loop
            set d = FirstOfGroup(udg_BladestormGroup)
            exitwhen d == null
            set x = GetUnitX(c)
            set y = GetUnitY(c)
            set x1 = GetUnitX(d)
            set y1 = GetUnitY(d)
            set ang = bj_RADTODEG * Atan2(y - y1, x - x1)
            call KnockbackFunctions_KBUnit(d, ang, 25., 1.10, .05, true, true)
            call Resume_Attack(d, 3.)
            call SetUnitPathing(d, true)
            call GroupRemoveUnit(udg_BladestormGroup, d)
        endloop
        
        call SetUnitPathing(c, true)
        call GroupClear(udg_BladestormGroup)
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set g = null
        set b = null
        set o = null
        set c = null
        set d = null
        call ClearTimer(t) 
    endif 
endfunction

function Trig_Bladestorm_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local string s = GetAttachmentTable(t)
    
    local unit c = GetTriggerUnit()
    local integer i =  Bladestorm_Duration()
    call SetUnitPathing(c, false)  

    call SetTableObject(s, "C", c)
    call SetTableInt(s, "I", i)
    call TimerStart(t, 0.05, true, function Bladestorm)    
endfunction

//===========================================================================
function InitTrig_Bladestorm takes nothing returns nothing
    set gg_trg_Bladestorm = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Bladestorm, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Bladestorm, Condition(function Trig_Bladestorm_Conditions))
    call TriggerAddAction(gg_trg_Bladestorm, function Trig_Bladestorm_Actions)
endfunction
02-20-2007, 06:24 PM#6
diablo-dk
strange, cant see anything wrong. unless there is something wrong with the ClearTimer() function.

by the way you forgot to nullify some variables.
02-22-2007, 09:59 AM#7
Fulla
I managed to stop the 'spinning' never stopping.
Now the knockback functions have stopped working.

Any takers?
Collapse JASS:
    //####################################################################################\\
    //                            Spell Name: Bladestorm                                  \\
    //                            Spell Auth: Fulla                                       \\
    //####################################################################################\\


            //################################################################\\
            //                                                                \\
            //                     Configuration Section                      \\
            //                                                                \\
            //################################################################\\

globals
    group BladestormGroup = CreateGroup()
    player TempPlayer
endglobals

constant function Bladestorm_AbilId takes nothing returns integer
    return 'A076' // Main ability id
endfunction

constant function Bladestorm_Duration takes nothing returns integer
    return 80 // How long Spell lasts, Amount entered * 0.05 = Duration in seconds. (Currently 4 sec)
endfunction


            //################################################################\\
            //                                                                \\
            //                        Spell Section                           \\
            //                                                                \\
            //################################################################\\


function Trig_Bladestorm_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == Bladestorm_AbilId()
endfunction

function Filter_Bladestorm takes nothing returns boolean
    return IsUnitInGroup(GetFilterUnit(), BladestormGroup) == false and (GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.) and (IsUnitEnemy(GetFilterUnit(), TempPlayer)) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == false) and (IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE) == false)
endfunction

function Release takes nothing returns nothing
    local timer t1 = GetExpiredTimer()
    local string s1 = GetAttachmentTable(t1)
    local unit c = GetTableUnit(s1, "C")
    local unit d = GetTableUnit(s1, "D")
    local real x = GetUnitX(c)
    local real y = GetUnitY(c)
    local real x1 = GetUnitX(d)
    local real y1 = GetUnitY(d)
    local real ang = bj_RADTODEG * Atan2(y - y1, x - x1)
    
    call BJDebugMsg("Works")
    call KnockbackFunctions_KBUnit(d, ang, 25., 1.10, .05, true, true)
    call Resume_Attack(d, 3.)
    call SetUnitPathing(d, true)        
endfunction

function Bladestorm takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local string s = GetAttachmentTable(t)
    local timer t1
    local string s1
    
    local unit c = GetTableUnit(s, "C")
    local integer i = GetTableInt(s, "I")
    local player o = GetOwningPlayer(c)
    local real x = GetUnitX(c)
    local real y = GetUnitY(c)
    local real x1
    local real y1
    local boolexpr b = Filter(function Filter_Bladestorm)
    //local integer lvl = GetUnitAbilityLevel(c, Bladestorm_AbilId())
    local unit d
    local group g = CreateGroup()
    local real ang
    set TempPlayer = o
    
    call GroupEnumUnitsInRange(g, x, y, 250, b)
    loop
        set d = FirstOfGroup(g)
        exitwhen d == null
        call SetUnitPathing(d, false)
        call GroupAddUnit(BladestormGroup, d)
        call GroupRemoveUnit(g, d)
    endloop
    
    call GroupAddGroup(BladestormGroup, g)
    
    loop
        set d = FirstOfGroup(g)
        exitwhen d == null
        set x1 = GetUnitX(d)
        set y1 = GetUnitY(d)
        set ang = bj_RADTODEG * Atan2(y - y1, x - x1)
        call SetUnitPositionLoc(d, PolarProjectionBJ(Location(x, y), 125., ang + 20))
        call GroupRemoveUnit(g, d)
    endloop
    
    set i = i + 1
    if i >= Bladestorm_Duration() then
        
        loop
            set d = FirstOfGroup(BladestormGroup)
            exitwhen d == null
            set t1 = CreateTimer()
            set s1 = GetAttachmentTable(t1)
            call SetTableObject(s, "C", c) 
            call SetTableObject(s, "D", d)         
            call TimerStart(t1, 0.1, false, function Release)
            call GroupRemoveUnit(BladestormGroup, d)
        endloop
        
        call SetUnitPathing(c, true)
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set g = null
        set b = null
        set o = null
        //set c = null
        //set d = null
        call ClearTimer(t)
    else
        call DestroyGroup(g)
        call DestroyBoolExpr(b)
        set g = null
        set b = null
        set o = null
        set c = null
        set d = null
        call SetTableInt(s, "I", i)
    endif
endfunction

function Trig_Bladestorm_Actions takes nothing returns nothing
    local timer t = CreateTimer()
    local string s = GetAttachmentTable(t)
    
    local unit c = GetTriggerUnit()
    local integer i = 0
    call SetUnitPathing(c, false)
    
    call SetTableObject(s, "C", c)
    call SetTableInt(s, "I", i)
    call TimerStart(t, 0.05, true, function Bladestorm)
endfunction

//===========================================================================
function InitTrig_Bladestorm takes nothing returns nothing
    set gg_trg_Bladestorm = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Bladestorm, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Bladestorm, Condition(function Trig_Bladestorm_Conditions))
    call TriggerAddAction(gg_trg_Bladestorm, function Trig_Bladestorm_Actions)
endfunction
02-22-2007, 10:33 AM#8
Toink
Instead of knockbacking units one by one in a loop just use the group effect.


Seriously, this has too many lines for an effect like this. Just make ONE timer and make it call the KBGroupEffect dude, it will save you time. You only need 2 functions with that, the first one for the timer and attachments, the second for getting the data and calling the groupeffect to knockback units, it's that simple really.