HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Unit Groups and Aloc

03-22-2008, 08:25 PM#1
Burning Rose
So I'm trying to create an ultimate for a Hero that works well with another spell of hers:
First spell drains mana from nearby units, Works like this:
Trigger:
Enveloping Fog Copy Copy Copy
Collapse Events
Time - Every 1.00 seconds of game time
Collapse Conditions
(Arcanist has buff Mana Tap ) Equal to True
Collapse Actions
Collapse Unit Group - Pick every unit in (Units within 500.00 of (Position of Arcanist) matching (((Mana of (Matching unit)) Greater than or equal to (4.00 + (Real((Level of Mana Tap for Arcanist))))) and (((Matching unit) is alive) Equal to True))) and do (Actions)
Collapse Loop - Actions
Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - (4.00 + (Real((Level of Mana Tap for Arcanist)))))
Unit - Set mana of Arcanist to ((Mana of Arcanist) + (4.00 + (Real((Level of Mana Tap for Arcanist)))))
Special Effect - Create a special effect attached to the origin of (Picked unit) using war3mapImported\DarkRitualQuick.mdx
Collapse Unit Group - Pick every unit in (Units within 500.00 of (Position of Arcanist) matching (((Mana of (Matching unit)) Less than (4.00 + (Real((Level of Mana Tap for Arcanist))))) and (((Matching unit) is alive) Equal to True))) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Mana of (Picked unit)) Greater than 0.00
Collapse Then - Actions
Unit - Set mana of Arcanist to ((Mana of Arcanist) + (Mana of (Picked unit)))
Unit - Set mana of (Picked unit) to 0.00
Special Effect - Create a special effect attached to the origin of (Picked unit) using war3mapImported\DarkRitualQuick.mdx
Else - Actions
Pretty simple. Second spell is supposed to be like Locust Swarm, but different. Instead of giving back health, the locusts would gain mana porportionate to the damage they dealt. That part works. The problem is, however, that the Arcanist can't drain their mana. Apparently units with Aloc (Like the Locusts, obviously) aren't picking in Unit Groups like they were hidden with triggers. So now, my dilemma is how to make her Mana Tap spell drain mana from the Locusts too, because otherwise her ult is pretty useless.

Any Ideas on how? I've already tried using a Unit Group variable instead, which adds the locusts like this:
Trigger:
Mana Storm Summon
Collapse Events
Unit - A unit Spawns a summoned unit
Collapse Conditions
(Unit-type of (Summoned unit)) Equal to Mana Storm Bit
Collapse Actions
Unit Group - Add (Summoned unit) to Mana_Storm
03-22-2008, 08:29 PM#2
Rising_Dusk
Quote:
Any Ideas on how? I've already tried using a Unit Group variable instead, which adds the locusts like this:
This method will work. It's actually what I was going to suggest anyways.
03-22-2008, 08:48 PM#3
Burning Rose
Hmm.. I've tried and it doesn't seem to. Maybe the event "Spawns a summoned unit" Doesn't work with Locust Swarm?
03-22-2008, 09:19 PM#4
Troll-Brain
i dunno but's it's easy to test, just display the summoned unit name.
If it display nothing, then it doesn't work for an unit with 'Aloc'
03-22-2008, 09:22 PM#5
moyack
The problem is that the picked unit function can't get units with locust. So you'll have to use loop over the group (usign FirstofGroup()) in order to catch and use them.
03-22-2008, 09:31 PM#6
Burning Rose
hmm.... Alright. I need to get more acquainted with JASS. How exactly would I do that? :(

EDIT: Apparently Locust Swarm doesn't work with "Spawns a Summoned Unit" Either. Fantastic.

EDIT: So, should this work? I'm not very good at JASS >_<:
Collapse JASS:
function Trig_Enveloping_Fog_Copy_Copy_Copy_Copy_Actions takes nothing returns nothing
local group g = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_Enveloping_Fog_Copy_Copy_Copy_Copy_Func002002002))
local unit u
loop
    set u = FirstOfGroup(g)
    exitwhen u == null
        if ( Trig_Enveloping_Fog_Copy_Copy_Copy_Copy_Func003C() ) then
            call SetUnitManaBJ( GetEnumUnit(), ( GetUnitStateSwap(UNIT_STATE_MANA, u) - ( 4.00 + I2R(GetUnitAbilityLevelSwapped('A07L', udg_Arcanist)) ) ) )
            call SetUnitManaBJ( udg_Arcanist, ( GetUnitStateSwap(UNIT_STATE_MANA, udg_Arcanist) + ( 4.00 + I2R(GetUnitAbilityLevelSwapped('A07L', udg_Arcanist)) ) ) )
            call AddSpecialEffectTargetUnitBJ( "origin", u, "war3mapImported\\DarkRitualQuick.mdx" )
        else
        endif
        if ( Trig_Enveloping_Fog_Copy_Copy_Copy_Copy_Func004C() ) then
            call SetUnitManaBJ( udg_Arcanist, ( GetUnitStateSwap(UNIT_STATE_MANA, udg_Arcanist) + GetUnitStateSwap(UNIT_STATE_MANA, u) ) )
            call SetUnitManaBJ( u, 0.00 )
            call AddSpecialEffectTargetUnitBJ( "origin", u, "war3mapImported\\DarkRitualQuick.mdx" )
        else
        endif
    call GroupRemoveUnit(g,u)
endloop
set g = null
set u = null
endfunction
03-23-2008, 08:57 AM#7
Spec
Omg ~_~
GroupEnumUnitsInRange will NOT work with locust units

This code is tested and working properly (i hope so ^^)
Collapse JASS:
globals
    group   gr        = CreateGroup() // >> you can use this group in other AoE-type functions
    string  fx_name   = "war3mapImported\\DarkRitualQuick.mdx"
    string  fx_attach = "origin"
    integer id_buff   = 'B000' // >> Mana Tap buff id
endglobals

// function needed to check distance between units
// because used enumerate function haven't it
function GetUnitsDist takes unit u1, unit u2 returns real
    local real x = GetUnitX(u2) - GetUnitX(u1)
    local real y = GetUnitY(u2) - GetUnitY(u1)
    return SquareRoot(x * x + y * y)
endfunction

function Enveloping_Actions takes nothing returns boolean
    return GetUnitAbilityLevel(udg_Arcanist, id_buff) > 0
endfunction

function Enveloping_Actions takes nothing returns nothing
    local unit    a = udg_Arcanist // just for more readable code
    local unit    u = null
    local integer i = 0
    local player  p = null
    local real amplifier   = GetUnitAbilityLevel(a, id_spell) + 4.0
    local real caster_mana = GetUnitState(a, UNIT_STATE_MANA)
    local real target_mana = 0
    loop
        exitwhen i > 15
        set p = Player(i)
        set i = i + 1
        if GetPlayerController(p) != MAP_CONTROL_NONE then
            call GroupEnumUnitsOfPlayer(gr, p, null) // >> this enumerate function also picks units with 'Aloc'

            loop
                set u = FirstOfGroup(gr)
                exitwhen u == null
                call GroupRemoveUnit(gr, u)
                // ----- actions -----
                // >> necessary checks - "unit is alive" + "unit within 500 of arcanist" + "unit != arcanist"
                if GetWidgetLife(u) > 0.405 and GetUnitsDist(u, a) < 500 and u != a then
                    set target_mana = GetUnitState(u, UNIT_STATE_MANA)
                    if target_mana >= amplifier then
                        call SetUnitState(a, UNIT_STATE_MANA, caster_mana + amplifier)
                        call SetUnitState(u, UNIT_STATE_MANA, target_mana - amplifier)
                    else
                        call SetUnitState(a, UNIT_STATE_MANA, caster_mana + target_mana)
                        call SetUnitState(u, UNIT_STATE_MANA, 0)
                    endif
                    call DestroyEffect(AddSpecialEffectTarget(fx_name, u, fx_attach))
                endif
            endloop

        endif // >> if GetPlayerController(p)
    endloop
    set a = null
    set p = null
endfunction

function InitTrig_Enveloping takes nothing returns nothing
    local trigger tr = CreateTrigger()
    call TriggerAddAction(tr, function Enveloping_Actions)
    call TriggerAddCondition(tr, Condition(function Enveloping_Conditions))
    call TriggerRegisterTimerEvent(tr, 1.0, true)
    set tr = null
endfunction

Further you can improve this code to vJass standards (scopes, private funcs, etc.)
03-23-2008, 09:09 AM#8
Gorman
GUI can pick units into a group, even if they hav aloc...
im not realy sure what the whole problem is, but i think what you should do is just have a periodic event which finds caster units (finds the buff) and selects all units owned by that player in range, that is easier right?
03-23-2008, 05:42 PM#9
Burning Rose
No, GUI doesn't pick units with ALoc. It's kind of annoying, but clearly there are workarounds.

Oh boy. That's intimidating, Spec. I'll see if I can figure out how to use that =_=

EDIT: I think I'll just adapt my old trigger so that they just give the mana they drain straight to the Arcanist. Thanks for the help anyways, I may need this later.
03-24-2008, 12:59 AM#10
Gorman
Erm, i hav a hero right now im doing, and i can assure u, GUI picks up units with aloc.

If not then its an incredible co-incidence that the units that should have been picked, and have aloc, magicly get into the right group. Which is unlikely, though obviously possible!
03-24-2008, 01:05 AM#11
TheSecretArts
I had this problem in spell session #9. I ended up just getting rid of aloc.