• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Locust replacement

Status
Not open for further replies.
Level 4
Joined
Aug 20, 2004
Messages
65
I'm working on a spell that summons units around the caster and march foward to attack the first thing they come in contact with. The skill works fine, but I don't want the player to be able to move/attack with the units. I gave them locust, but it disabled the attack-move to position trigger. Is there any other way to keep the unit under the players controll, but be uncontrollable?
 
Level 6
Joined
Apr 27, 2006
Messages
186
Don't know if this helps, but make a trigger that whenever the units are ordered to do something, under the actions of that trigger just retell the unit where to move/attack to. I don't know the specifics of your trigger but that should work.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
The problem you're most likely having is that Locusts are not picked up by most group enumerators. You'll have to use a Units of Player enumeration in this case, as that's the only one available in GUI, far as I know.

Then, just run any other checks you need to simulate a different form of enumeration.
 
Level 3
Joined
Jan 20, 2007
Messages
53
sorry there fellas for being rude but you need none of that stuff just give the locust ability from the locust unit to the unit you wish not to be touched by a player
 
Level 11
Joined
Jul 20, 2004
Messages
2,760
You could try this (though I don't guarantee it will work and will most likely require JASS... give it a shot).

'Unit is selected' I don't know is actually triggered before the unit is selected or after (cuz Unit is Damaged is triggered before). If it is before, you can have a 0.00 seconds timer (wait doesn't work... you need timer) which once expires you can deselect the unit (or add locust and remove it...). Elsewhere, you will need to add locust, and after a 0.00 seconds timer (not wait, cuz it won't work) remove it.

Removing locust is not very simple, as you can't just add and remove it (just like chaos ability). You can however add it to a spellbook ability and add/remove it that way. I don't know if you can actually add the spell manually but you can do it via the rawcode 'Aloc'.

Good luck!

-Daelin
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
The code at the bottom, written by me, will pick up locusts in (range or a rect) and add them to your group. It's really meant for JASS, but it can be used in GUI somewhat. To be able to use it through Custom Script, you'll have to put it in your map's header (the JASS code space that appears when you click on the little file pic of your map at the top-left of the Triggers)

Custom Script: set udg_MyGroup = CreateGroup()
Custom Script: call GroupEnumLocustsInRange( udg_MyGroup, someX, someY, someRadius, someFilter )

otherwise, with InRect, the second line would be
Custom Script: call GroupEnumLocustsInRect( udg_MyGroup, someRect, someFilter )

where MyGroup is a Unit Group, someX is an origin X, someY is an origin Y, someRadius is the range, someRect is a rect (Playable Map Area = bj_mapInitialPlayableArea), and someFilter is null or a filter function. It's still a little ugly to use in GUI, as GUI isnt meant to have custom functions, and all that kind of junk.

Code:
function GroupEnumLocustsInRange takes group g, real x, real y, real radius, boolexpr filter returns nothing
    local group ga = CreateGroup()
    local group gaa
    local integer i = 0
    local unit u
    loop
        exitwhen i == 12
        set gaa = CreateGroup()
        call GroupEnumUnitsOfPlayer( gaa, Player( i ), filter )
        set bj_wantDestroyGroup = true
        call GroupAddGroup( gaa, ga )
        set i = i + 1
    endloop
    loop
        set u = FirstOfGroup( ga )
        exitwhen u == null
        if GetUnitAbilityLevel( u, 'Aloc' ) > 0 and IsUnitInRangeXY( u, x, y, radius ) then
            call GroupAddUnit( g, u )
        endif
        call GroupRemoveUnit( ga, u )
    endloop
    call DestroyGroup( ga )
    set ga = null
    set gaa = null
endfunction

function GroupEnumLocustsInRect takes group g, rect r, boolexpr filter returns nothing
    local group ga = CreateGroup()
    local group gaa
    local integer i = 0
    local unit u
    local region re = CreateRegion()
    call RegionAddRect( re, r )
    loop
        exitwhen i == 12
        set gaa = CreateGroup()
        call GroupEnumUnitsOfPlayer( gaa, Player( i ), filter )
        set bj_wantDestroyGroup = true
        call GroupAddGroup( gaa, ga )
        set i = i + 1
    endloop
    loop
        set u = FirstOfGroup( ga )
        exitwhen u == null
        if GetUnitAbilityLevel( u, 'Aloc' ) > 0 and IsUnitInRegion( re, u ) then
            call GroupAddUnit( g, u )
        endif
        call GroupRemoveUnit( ga, u )
    endloop
    call RegionClearRect( re, r )
    call RemoveRegion( re )
    call DestroyGroup( ga )
    set re = null
    set ga = null
    set gaa = null
endfunction
 
Status
Not open for further replies.
Top