Nova Spell not working

Nevyll

New Member
Reaction score
1
Hi again, I'm coding a nova spell for a map o' mine, but there is a problem.
The dummy units are not moving :S
Here's the spell code:

JASS:
function Trig_Water_Nova_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'Awrs'
endfunction

function Trig_Water_Nova_Filter takes nothing returns boolean
    return IsPlayerEnemy( GetOwningPlayer( GetTriggerUnit() ), GetOwningPlayer( GetFilterUnit() ) ) and GetWidgetLife( GetFilterUnit() ) > 0.405 and not IsUnitType( GetFilterUnit(), UNIT_TYPE_FLYING ) and not IsUnitType( GetFilterUnit(), UNIT_TYPE_STRUCTURE )
endfunction


function Trig_Water_Nova_Main takes nothing returns nothing
    local timer tiSpellTimer = GetExpiredTimer()
    local integer nTimerID = H2I( tiSpellTimer )
    local group gDamageGroup = CreateGroup()
    local unit array uDummyUnits
    local integer nDummyAmount = LoadInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ) )
    local real rDamageAmount = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Damage" ) )
    local real rMaxDuration = LoadReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ) )
    local real rCurrentDuration = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Current" ) )
    local integer nIndex = 0
    local real array rDummyX
    local real array rDummyY
    local boolexpr beGroupFilter = Condition( function Trig_Water_Nova_Filter )
    local unit uFirstOfGroup
    local real array rDummyFacing
    local real rDistanceAmount = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Distance" ) )

    loop
        exitwhen nIndex == nDummyAmount

        set uDummyUnits[nIndex] = LoadUnitHandle( udg_AbilityTable, nTimerID, nIndex )
        set rDummyX[nIndex] = GetUnitX( uDummyUnits[nIndex] )
        set rDummyY[nIndex] = GetUnitY( uDummyUnits[nIndex] )
        set rDummyFacing[nIndex] = GetUnitFacing( uDummyUnits[nIndex] )

        set nIndex = nIndex + 1
    endloop

    if not ( rCurrentDuration == rMaxDuration ) then
        set nIndex = 0
        call BJDebugMsg( "MOVING" )

        loop
            exitwhen nIndex == nDummyAmount

            call GroupEnumUnitsInRange( gDamageGroup, rDummyX[nIndex], rDummyY[nIndex], 40, beGroupFilter )

            loop
                exitwhen gDamageGroup == null

                set uFirstOfGroup = FirstOfGroup( gDamageGroup )
                call UnitDamageTarget( uDummyUnits[nIndex], uFirstOfGroup, rDamageAmount, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null )

                call GroupRemoveUnit( gDamageGroup, uFirstOfGroup )
            endloop
            // These are the 2 lines that are supposed to move the targeted dummy
            call SetUnitX( uDummyUnits[nIndex], rDummyX[nIndex] + rDistanceAmount * Cos( rDummyFacing[nIndex] ) )
            call SetUnitY( uDummyUnits[nIndex], rDummyY[nIndex] + rDistanceAmount * Sin( rDummyFacing[nIndex] ) )

            set nIndex = nIndex + 1
        endloop

        set rCurrentDuration = rCurrentDuration + 0.05

        call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Damage" ), rDamageAmount )
        call SaveReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ), rMaxDuration )
        call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Current" ), rCurrentDuration )
        call SaveInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ), nDummyAmount )

        set nIndex = 0
        loop
            exitwhen nIndex == nDummyAmount

            call SaveUnitHandle( udg_AbilityTable, nTimerID, nIndex, uDummyUnits[nIndex] )

            set nIndex = nIndex + 1
        endloop

    else
        call DestroyTimer( tiSpellTimer )
        call DestroyGroup( gDamageGroup )

        set gDamageGroup = null
        set uFirstOfGroup = null

        set nIndex = 0
        loop
            exitwhen nIndex == nDummyAmount

            call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl", GetUnitX( uDummyUnits[nIndex] ), GetUnitY( uDummyUnits[nIndex] ) ) )
            call RemoveUnit( uDummyUnits[nIndex] )

            set uDummyUnits[nIndex] = null

            set nIndex = nIndex + 1
        endloop

        call FlushChildHashtable( udg_AbilityTable, nTimerID )
    endif
endfunction

function Trig_Water_Nova_Actions takes nothing returns nothing
    local integer nAbilityId = 'Awrs'
    local unit uCastUnit = GetTriggerUnit()
    local player plCastOwner = GetOwningPlayer( uCastUnit )
    local integer nDummyId = 'h00E'
    local timer tiSpellTimer = CreateTimer()
    local unit array uADummyUnits
    local real rDamageAmount = 25. * udg_PLAYER_MAXNUM
    local integer nIndex = 0
    local integer nDummyAmount = 8
    local real rCastX = GetUnitX( uCastUnit )
    local real rCastY = GetUnitY( uCastUnit )
    local real rFrequency = 0.05
    local real rDistancePerTick = 20
    local real rTotalDuration = 1.5
    local real rCurrentDuration = 0.
    local integer nTimerID = H2I( tiSpellTimer )
    local real array rDummyFacing

    loop
        exitwhen nIndex == nDummyAmount

        set uADummyUnits[nIndex] = CreateUnit( plCastOwner, nDummyId, rCastX, rCastY, 45. * ( nIndex + 1 ) )

        set nIndex = nIndex + 1
    endloop

    set nIndex = 0
    loop
        exitwhen nIndex == nDummyAmount

        call SaveUnitHandle( udg_AbilityTable, nTimerID, nIndex, uADummyUnits[nIndex] )

        set nIndex = nIndex + 1
    endloop

    call SaveInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ), nDummyAmount )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Damage" ), rDamageAmount )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ), rTotalDuration )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Current" ), rCurrentDuration )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Distance" ), rDistancePerTick )

    call TimerStart( tiSpellTimer, rFrequency, true, function Trig_Water_Nova_Main )

    set tiSpellTimer = null
    set plCastOwner = null
    set uCastUnit = null

    set nIndex = 0
    loop
        exitwhen nIndex == nDummyAmount

        set uADummyUnits[nIndex] = null

        set nIndex = nIndex + 1
    endloop

endfunction

function InitTrig_Water_Nova takes nothing returns nothing
    set gg_trg_Water_Nova = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Water_Nova, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Water_Nova, Condition( function Trig_Water_Nova_Conditions ) )
    call TriggerAddAction( gg_trg_Water_Nova, function Trig_Water_Nova_Actions )
endfunction


+ rep for anything helpful :thup:
By the way, I'm just using the world editor, no NewGen pack for me, no nothing ^^
 

Anteo

Active Member
Reaction score
3
If your dummy unit has the locust ability, you cant move it by using [ljass] SetUnitX[/ljass] and [ljass]SetUnitY[/ljass]. Use [ljass] SetUnitPositionLoc[/ljass] instead
 

Nevyll

New Member
Reaction score
1
Thank you good sir, + rep for you :thup:

Another problem; I use PolarProjectionBJ now, and the units still wont move.

Also, the trigger seems to get stuck in an endless iteration at these lines:

JASS:
            loop
                exitwhen gDamageGroup == null

                set uFirstOfGroup = FirstOfGroup( gDamageGroup )
                call UnitDamageTarget( uDummyUnits[nIndex], uFirstOfGroup, rDamageAmount, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null )

                call GroupRemoveUnit( gDamageGroup, uFirstOfGroup )
            endloop
 

Anteo

Active Member
Reaction score
3
For your PolarProjectionBJ problem. Try this.

JASS:
function MyFunc takes nothing returns nothing
    local location originLoc = //Get your original Location here
    local location loc = PolarProjectionBJ(originLoc, dist, angle)//Get the new Location
    call SetUnitPositionLoc(Unit, loc)  //Set the unit loc
    //Clear the Leaks
    call RemoveLocation(originLoc)
    set originLoc = null
    call RemoveLocation(loc)
    set loc = null
endfunction


For your second problem, you are removing units from a group, when the group is empty, is still referenced as a group. So the group will never be null.
What you have to do is ...

JASS:
local unit u
loop
     set u = FirstOfGroup( gDamageGroup )  //Get The first Unit
     exitwhen u== null    //If the first unit is null (a.k.a. the group is empty) then stop this!!
     call UnitDamageTarget( uDummyUnits[nIndex], uFirstOfGroup, rDamageAmount, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null )  //Your actions
     call GroupRemoveUnit( gDamageGroup, uFirstOfGroup ) //Remove the unit from the group 
endloop


Be carefully, as a unit that has been removed from the game and is still referenced by a group, will return null, even if the group is not empty. Is still safe if you use a group that was created in the same function.

Edit : A very usefull post : link!
from here!
 

Nevyll

New Member
Reaction score
1
Ah, thank you, I see now I just made some minor logigal errors :thup:

Edit: Thanks, now the dummys are moving, but there are 2 problems:
The spell is a bit laggy and
No damage is being dealt.

JASS:
function Trig_Water_Nova_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'Awrs'
endfunction

function Trig_Water_Nova_Filter takes nothing returns boolean
    return IsPlayerEnemy( GetOwningPlayer( GetTriggerUnit() ), GetOwningPlayer( GetFilterUnit() ) ) and GetWidgetLife( GetFilterUnit() ) > 0.405 and not IsUnitType( GetFilterUnit(), UNIT_TYPE_FLYING ) and not IsUnitType( GetFilterUnit(), UNIT_TYPE_STRUCTURE )
endfunction

function Trig_Water_Nova_Damage takes nothing returns nothing
    local unit uCastUnit = LoadUnitHandle( udg_AbilityTable, 0, StringHash( "Caster" ) )
    local real rDamageAmount = LoadReal( udg_AbilityTable, 0, StringHash( "Damage" ) )
    call BJDebugMsg( R2S(rDamageAmount) )

    call UnitDamageTarget( uCastUnit, GetEnumUnit(), rDamageAmount, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS )
endfunction


function Trig_Water_Nova_Main takes nothing returns nothing
    local timer tiSpellTimer = GetExpiredTimer()
    local integer nTimerID = H2I( tiSpellTimer )
    local group gDamageGroup = CreateGroup()
    local unit array uDummyUnits
    local integer nDummyAmount = LoadInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ) )
    local real rMaxDuration = LoadReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ) )
    local real rCurrentDuration = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Current" ) )
    local integer nIndex = 0
    local real array rDummyX
    local real array rDummyY
    local boolexpr beGroupFilter = Condition( function Trig_Water_Nova_Filter )
    local unit uFirstOfGroup
    local real array rDummyFacing
    local location locOrigin
    local location locNew
    local real rDistanceAmount = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Distance" ) )

    loop
        exitwhen nIndex == nDummyAmount

        set uDummyUnits[nIndex] = LoadUnitHandle( udg_AbilityTable, nTimerID, nIndex )
        set rDummyFacing[nIndex] = GetUnitFacing( uDummyUnits[nIndex] )
        set rDummyX[nIndex] = GetUnitX( uDummyUnits[nIndex] )
        set rDummyY[nIndex] = GetUnitY( uDummyUnits[nIndex] )

        set nIndex = nIndex + 1
    endloop

    set nIndex = 0

    loop
        exitwhen nIndex == nDummyAmount

        call GroupEnumUnitsInRangeOfLoc( gDamageGroup, GetUnitLoc( uDummyUnits[nIndex] ), 40, beGroupFilter )

        call ForGroup( gDamageGroup, function Trig_Water_Nova_Damage )

        set gDamageGroup = null

        set locOrigin = GetUnitLoc( uDummyUnits[nIndex] )
        set locNew =  PolarProjectionBJ( locOrigin, rDistanceAmount, rDummyFacing[nIndex] )
        call SetUnitPositionLoc( uDummyUnits[nIndex], locNew )

        call RemoveLocation( locOrigin )
        call RemoveLocation( locNew )
        set locOrigin = null
        set locNew = null

        set nIndex = nIndex + 1
    endloop

    set rCurrentDuration = rCurrentDuration + 0.05

    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ), rMaxDuration )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Current" ), rCurrentDuration )
    call SaveInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ), nDummyAmount )

    set nIndex = 0
    loop
        exitwhen nIndex == nDummyAmount

        call SaveUnitHandle( udg_AbilityTable, nTimerID, nIndex, uDummyUnits[nIndex] )

        set nIndex = nIndex + 1
    endloop

    if ( rCurrentDuration >= rMaxDuration ) then
        call DestroyTimer( tiSpellTimer )
        call DestroyGroup( gDamageGroup )

        set uFirstOfGroup = null

        set nIndex = 0
        loop
            exitwhen nIndex == nDummyAmount

            call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl", GetUnitX( uDummyUnits[nIndex] ), GetUnitY( uDummyUnits[nIndex] ) ) )
            call RemoveUnit( uDummyUnits[nIndex] )

            set uDummyUnits[nIndex] = null

            set nIndex = nIndex + 1
        endloop

        call FlushChildHashtable( udg_AbilityTable, nTimerID )
    endif

endfunction

function Trig_Water_Nova_Actions takes nothing returns nothing
    local integer nAbilityId = 'Awrs'
    local unit uCastUnit = GetTriggerUnit()
    local player plCastOwner = GetOwningPlayer( uCastUnit )
    local integer nDummyId = 'h00E'
    local timer tiSpellTimer = CreateTimer()
    local unit array uADummyUnits
    local real rDamageAmount = 25. + 25 * udg_PLAYER_MAXNUM
    local integer nIndex = 0
    local integer nDummyAmount = 8
    local real rCastX = GetUnitX( uCastUnit )
    local real rCastY = GetUnitY( uCastUnit )
    local real rFrequency = 0.05
    local real rDistancePerTick = 20
    local real rTotalDuration = 1.5
    local real rCurrentDuration = 0.05
    local integer nTimerID = H2I( tiSpellTimer )
    local real array rDummyFacing

    loop
        exitwhen nIndex == nDummyAmount

        set uADummyUnits[nIndex] = CreateUnit( plCastOwner, nDummyId, rCastX, rCastY, 45. * ( nIndex + 1 ) )

        set nIndex = nIndex + 1
    endloop

    set nIndex = 0
    loop
        exitwhen nIndex == nDummyAmount

        call SaveUnitHandle( udg_AbilityTable, nTimerID, nIndex, uADummyUnits[nIndex] )

        set nIndex = nIndex + 1
    endloop

    call SaveInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ), nDummyAmount )
    call SaveReal( udg_AbilityTable, 0, StringHash( "Damage" ), rDamageAmount )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ), rTotalDuration )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Current" ), rCurrentDuration )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Distance" ), rDistancePerTick )
    call SaveUnitHandle( udg_AbilityTable, 0, StringHash( "Caster" ), uCastUnit )

    call TimerStart( tiSpellTimer, rFrequency, true, function Trig_Water_Nova_Main )

    set tiSpellTimer = null
    set plCastOwner = null
    set uCastUnit = null

    set nIndex = 0
    loop
        exitwhen nIndex == nDummyAmount

        set uADummyUnits[nIndex] = null

        set nIndex = nIndex + 1
    endloop

endfunction

function InitTrig_Water_Nova takes nothing returns nothing
    set gg_trg_Water_Nova = CreateTrigger(  )
    call Preload( "Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl" )
    call Preload( "Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveMissile.mdl" )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Water_Nova, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Water_Nova, Condition( function Trig_Water_Nova_Conditions ) )
    call TriggerAddAction( gg_trg_Water_Nova, function Trig_Water_Nova_Actions )
endfunction


That's the code so far.
2nd Edit: Replaced the loop with a ForGroup() call, but it still doesn't work :(
 

Chaos_Knight

New Member
Reaction score
39
Ah, thank you, I see now I just made some minor logigal errors :thup:

Edit: Thanks, now the dummys are moving, but there are 2 problems:
The spell is a bit laggy and
No damage is being dealt.

JASS:

function Trig_Water_Nova_Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'Awrs'
endfunction

function Trig_Water_Nova_Filter takes nothing returns boolean
    return IsPlayerEnemy( GetOwningPlayer( GetTriggerUnit() ), GetOwningPlayer( GetFilterUnit() ) ) and GetWidgetLife( GetFilterUnit() ) > 0.405 and not IsUnitType( GetFilterUnit(), UNIT_TYPE_FLYING ) and not IsUnitType( GetFilterUnit(), UNIT_TYPE_STRUCTURE )
endfunction


function Trig_Water_Nova_Main takes nothing returns nothing
    local timer tiSpellTimer = GetExpiredTimer()
    local integer nTimerID = H2I( tiSpellTimer )
    local group gDamageGroup = CreateGroup()
    local unit array uDummyUnits
    local integer nDummyAmount = LoadInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ) )
    local real rDamageAmount = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Damage" ) )
    local real rMaxDuration = LoadReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ) )
    local real rCurrentDuration = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Current" ) )
    local integer nIndex = 0
    local real array rDummyX
    local real array rDummyY
    local boolexpr beGroupFilter = Condition( function Trig_Water_Nova_Filter )
    local unit uFirstOfGroup
    local real array rDummyFacing
    local location locOrigin
    local location locNew
    local real rDistanceAmount = LoadReal( udg_AbilityTable, nTimerID, StringHash( "Distance" ) )

    loop
        exitwhen nIndex == nDummyAmount

        set uDummyUnits[nIndex] = LoadUnitHandle( udg_AbilityTable, nTimerID, nIndex )
        set rDummyFacing[nIndex] = GetUnitFacing( uDummyUnits[nIndex] )
        set rDummyX[nIndex] = GetUnitX( uDummyUnits[nIndex] )
        set rDummyY[nIndex] = GetUnitY( uDummyUnits[nIndex] )

        set nIndex = nIndex + 1
    endloop

    set nIndex = 0

    loop
        exitwhen nIndex == nDummyAmount

        call GroupEnumUnitsInRange( gDamageGroup, rDummyX[nIndex], rDummyY[nIndex], 40, beGroupFilter )

        loop
            set uFirstOfGroup = FirstOfGroup( gDamageGroup )
            exitwhen uFirstOfGroup == null

            call UnitDamageTarget( uDummyUnits[nIndex], uFirstOfGroup, rDamageAmount, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null )
            call GroupRemoveUnit( gDamageGroup, uFirstOfGroup )
        endloop

        set locOrigin = GetUnitLoc( uDummyUnits[nIndex] )
        set locNew =  PolarProjectionBJ( locOrigin, rDistanceAmount, rDummyFacing[nIndex] )
        call SetUnitPositionLoc( uDummyUnits[nIndex], locNew )

        call RemoveLocation( locOrigin )
        call RemoveLocation( locNew )
        set locOrigin = null
        set locNew = null

        set nIndex = nIndex + 1
    endloop

    set rCurrentDuration = rCurrentDuration + 0.05
    call BJDebugMsg( R2S(rCurrentDuration) )

    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Damage" ), rDamageAmount )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ), rMaxDuration )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Current" ), rCurrentDuration )
    call SaveInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ), nDummyAmount )

    set nIndex = 0
    loop
        exitwhen nIndex == nDummyAmount

        call SaveUnitHandle( udg_AbilityTable, nTimerID, nIndex, uDummyUnits[nIndex] )

        set nIndex = nIndex + 1
    endloop

    call BJDebugMsg( R2S( rCurrentDuration ) )

    if ( rCurrentDuration >= rMaxDuration ) then
        call DestroyTimer( tiSpellTimer )
        call DestroyGroup( gDamageGroup )

        set gDamageGroup = null
        set uFirstOfGroup = null

        set nIndex = 0
        loop
            exitwhen nIndex == nDummyAmount

            call DestroyEffect( AddSpecialEffect( "Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl", GetUnitX( uDummyUnits[nIndex] ), GetUnitY( uDummyUnits[nIndex] ) ) )
            call RemoveUnit( uDummyUnits[nIndex] )

            set uDummyUnits[nIndex] = null

            set nIndex = nIndex + 1
        endloop

        call FlushChildHashtable( udg_AbilityTable, nTimerID )
    endif

endfunction

function Trig_Water_Nova_Actions takes nothing returns nothing
    local integer nAbilityId = 'Awrs'
    local unit uCastUnit = GetTriggerUnit()
    local player plCastOwner = GetOwningPlayer( uCastUnit )
    local integer nDummyId = 'h00E'
    local timer tiSpellTimer = CreateTimer()
    local unit array uADummyUnits
    local real rDamageAmount = 25. + 25 * udg_PLAYER_MAXNUM
    local integer nIndex = 0
    local integer nDummyAmount = 8
    local real rCastX = GetUnitX( uCastUnit )
    local real rCastY = GetUnitY( uCastUnit )
    local real rFrequency = 0.05
    local real rDistancePerTick = 20
    local real rTotalDuration = 1.5
    local real rCurrentDuration = 0.05
    local integer nTimerID = H2I( tiSpellTimer )
    local real array rDummyFacing

    loop
        exitwhen nIndex == nDummyAmount

        set uADummyUnits[nIndex] = CreateUnit( plCastOwner, nDummyId, rCastX, rCastY, 45. * ( nIndex + 1 ) )

        set nIndex = nIndex + 1
    endloop

    set nIndex = 0
    loop
        exitwhen nIndex == nDummyAmount

        call SaveUnitHandle( udg_AbilityTable, nTimerID, nIndex, uADummyUnits[nIndex] )

        set nIndex = nIndex + 1
    endloop

    call SaveInteger( udg_AbilityTable, nTimerID, StringHash( "DummyAmount" ), nDummyAmount )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Damage" ), rDamageAmount )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "MaxDur" ), rTotalDuration )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Current" ), rCurrentDuration )
    call SaveReal( udg_AbilityTable, nTimerID, StringHash( "Distance" ), rDistancePerTick )

    call TimerStart( tiSpellTimer, rFrequency, true, function Trig_Water_Nova_Main )

    set tiSpellTimer = null
    set plCastOwner = null
    set uCastUnit = null

    set nIndex = 0
    loop
        exitwhen nIndex == nDummyAmount

        set uADummyUnits[nIndex] = null

        set nIndex = nIndex + 1
    endloop

endfunction

function InitTrig_Water_Nova takes nothing returns nothing
    set gg_trg_Water_Nova = CreateTrigger(  )
    call Preload( "Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl" )
    call Preload( "Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveMissile.mdl" )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Water_Nova, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Water_Nova, Condition( function Trig_Water_Nova_Conditions ) )
    call TriggerAddAction( gg_trg_Water_Nova, function Trig_Water_Nova_Actions )
endfunction


That's the code so far.

When you save the map with NewGen, doesnt it tell you about this
[LJASS]call GetUnitLoc(udg_YourUnit)[/LJASS]
??
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Off-topic, but..
Why aren't you using NewGen?

I've not found a down-side to using NewGen.. yet.
And I probably never will ._.
 

Anteo

Active Member
Reaction score
3
Off-topic, but..
Why aren't you using NewGen?

I've not found a down-side to using NewGen.. yet.
And I probably never will ._.

Maybe he is a Mac user??

On Topic :
That line
[LJASS]call BJDebugMsg( R2S(rDamageAmount) )
[/LJASS]
Do you get the debug msg in game?
 

Nevyll

New Member
Reaction score
1
Maybe he is a Mac user??

On Topic :
That line
call BJDebugMsg( R2S(rDamageAmount) )
Do you get the debug msg in game?

No, I do not get the message, perhaps I will switch to NewGen after all.

Does anyone know a good tutorial or something for NewGen and vJass in general? :rolleyes:
 

Anteo

Active Member
Reaction score
3
I think I know why it isn't working.

JASS:
function Trig_Water_Nova_Filter takes nothing returns boolean
    return IsPlayerEnemy( GetOwningPlayer( GetTriggerUnit() ), GetOwningPlayer( GetFilterUnit() )  ) and GetWidgetLife( GetFilterUnit() ) > 0.405 and not IsUnitType( GetFilterUnit(), UNIT_TYPE_FLYING ) and not IsUnitType( GetFilterUnit(), UNIT_TYPE_STRUCTURE )
endfunction


Here :
[LJASS]GetOwningPlayer( GetTriggerUnit() )[/LJASS]


That Filter is wrong : [LJASS]GetTriggerUnit()[/LJASS] won't work. Remember that Trig_Water_Nova_Main is being called after a Timer has expired. So there is no TriggerUnit.

My suggestion is

JASS:
function Trig_Water_Nova_Main takes nothing returns nothing
//Lots of ACtions
//....
//....
loop
        exitwhen nIndex == nDummyAmount
        set udg_Caster=LoadUnitHandle( /**/)//Let's save that unit in a Global, only to use it in the Filter
        call GroupEnumUnitsInRange( gDamageGroup, rDummyX[nIndex], rDummyY[nIndex], 40, beGroupFilter ) //Get all the units in range Using your filter
        set udg_Caster = null // We can null it now if we want. But it is not necessary
//......
endloop


Filter :

JASS:
function Trig_Water_Nova_Filter takes nothing returns boolean
    return IsUnitEnemy (  GetFilterUnit(),GetOwningPlayer( udg_Caster)) and GetWidgetLife( GetFilterUnit() ) > 0.405 and not IsUnitType( GetFilterUnit(), UNIT_TYPE_FLYING ) and not IsUnitType( GetFilterUnit(), UNIT_TYPE_STRUCTURE )
endfunction


Also. You don't need to fill the group and use that loop thing ([LJASS]loop[/LJASS] [LJASS]exitwhen u = null[/LJASS]) to damage every unit.
This is another way to damage every enemy unit around your dummy unit.
New Filter :
JASS:
function Trig_Water_Nova_New_Filter takes nothing returns boolean
    //When using a filter, ALL the units around will enter to this function as the FilterUnit
    //Knowing that, we can do this :
    if IsUnitEnemy (  GetFilterUnit(),GetOwningPlayer( udg_Caster))  then 
    //If the filter unit is Enemy then Damage it
         call UnitDamageTarget( udg_Caster, GetFilterUnit(), 400, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, null )
         //If you want to use data from your hashtable, save it in a global and use it here, just like udg_Caster
    endif
    //Now, all enemy units near the dummy were damaged. 
    //We are working in a Filter, if we return true, the filterunit will be added to the group. 
    //Do we need it in the group?? I don't think so, let's return false.
    return false
endfunction


Sadly. This fix will not be enough. I'm quite sure you'll face another problem. The chances are that you will deal 4x or 5x times the damage you wanted in the first place. Wanna know why? I'll edit this later.
 

Nevyll

New Member
Reaction score
1
Anteo, thank you. ALOT!

Also, don't use PolarProjectionBJ, use this.

Jass:

//wiki.thehelper.net
local real x = GetLocationX(source) + dist * Cos(angle * bj_DEGTORAD)
local real y = GetLocationY(source) + dist * Sin(angle * bj_DEGTORAD)

Well, you can't move a unit that has the locust ability with coordinates :(
 

Hatebreeder

So many apples
Reaction score
381
If your dummy unit has the locust ability, you cant move it by using [ljass] SetUnitX[/ljass] and [ljass]SetUnitY[/ljass]. Use [ljass] SetUnitPositionLoc[/ljass] instead

LIES !!!

You can move your Unit with [ljass]SetUnitX(u) & SetUnitY(u)[/ljass]. However, your Dummy unit needs at LEAST 1 Movespeed.
 

Nevyll

New Member
Reaction score
1
Ah, I see... well, I'll reconsider making the spell all over again, this time with improved code, I mean, it cannot be worse :thup:
 

tooltiperror

Super Moderator
Reaction score
231
Ah, I see... well, I'll reconsider making the spell all over again, this time with improved code, I mean, it cannot be worse :thup:

Hurrah for learning.

But, in response to

Well, you can't move a unit that has the locust ability with coordinates

Not what I meant.

Replace the variables with the values you want (doink).

JASS:

//wiki.thehelper.net
local real x = (your x) + distance * Cos(your angle * bj_DEGTORAD)
local real y = (your y) + distance * Sin(your angle * bj_DEGTORAD)


Then just use [ljass]Location(x,y)[/ljass] as your location.
 
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