Snippet AutoFly

Azlier

Old World Ghost
Reaction score
461
This simple, efficient script makes it so that [lJASS]SetUnitFlyHeight[/lJASS] automatically works on the units in your map. It should be more efficient than adding and removing Crow Form each time a spell is cast. ;)

JASS:
// AutoFly - by Azlier
//  Requires a vJass preprocessor

// How to import:
//  1. Create a new trigger called AutoFly.
//  2. Convert the trigger to custom script, and replace all the code inside with this.

library_once AutoFly

private function Actions takes nothing returns boolean
    return UnitAddAbility(GetFilterUnit(), 'Amrf') and UnitRemoveAbility(GetFilterUnit(), 'Amrf')
endfunction

private struct Hack extends array

    static method onInit takes nothing returns nothing
        local region r = CreateRegion()
        local rect re = GetWorldBounds()
        local group g = CreateGroup()
        local integer i = 15
        call RegionAddRect(r, re)
        call TriggerRegisterEnterRegion(CreateTrigger(), r, Filter(function Actions))
        call RemoveRect(re)
        set re = null
        
        loop
            call GroupEnumUnitsOfPlayer(g, Player(i), Filter(function Actions))
            exitwhen i == 0
            set i = i - 1
        endloop
        call DestroyGroup(g)
        set g = null

    endmethod

endstruct

endlibrary


AIDS version. Credit goes to kenny!.
JASS:
// AutoFly - by Azlier, AIDS version by Jesus4Lyf
//  Requires a vJass preprocessor, AIDS

// How to import:
//  1. Create a new trigger called AutoFly.
//  2. Convert the trigger to custom script, and replace all the code inside with this.
//  3. Import AIDS if it is not in your map already.

library AutoFly requires AIDS
    private struct Hack extends array
        private static method AIDS_filter takes unit u returns boolean
            return UnitAddAbility(u, 'Amrf') and UnitRemoveAbility(u, 'Amrf')
        endmethod
        //! runtextmacro AIDS()
    endstruct
endlibrary

Non-vJass version.
JASS:
// AutoFly - by Azlier

// How to import:
//  1. Create a new trigger called AutoFly.
//  2. Convert the trigger to custom script, and replace all the code inside with this.

function AutoFly__Actions takes nothing returns boolean
    return UnitAddAbility(GetFilterUnit(), 'Amrf') and UnitRemoveAbility(GetFilterUnit(), 'Amrf')
endfunction

function InitTrig_AutoFly takes nothing returns nothing
    local region r = CreateRegion()
    local rect re = GetWorldBounds()
    local group g = CreateGroup()
    local integer i = 15
    call RegionAddRect(r, re)
    call TriggerRegisterEnterRegion(CreateTrigger(), r, Filter(function AutoFly__Actions))
    call RemoveRect(re)
    set re = null
        
    loop
        call GroupEnumUnitsOfPlayer(g, Player(i), Filter(function AutoFly__Actions))
        exitwhen i == 0
        set i = i - 1
    endloop
    call DestroyGroup(g)
    set g = null

endfunction
 

Romek

Super Moderator
Reaction score
963
Why do you need a custom ability for something like this?

Also, this won't work on units created in struct initializers, so I suggest you initialize this in struct too. :p

JASS:
private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local region r = CreateRegion()
    call RegionAddRect(r, GetWorldBounds())
    call TriggerRegisterEnterRegion(t, r, Filter(function Actions))
endfunction

Could be:
JASS:
private function Init takes nothing returns nothing
    local region r = CreateRegion()
    call RegionAddRect(r, GetWorldBounds())
    call TriggerRegisterEnterRegion(CreateTrigger(), r, Filter(function Actions))
endfunction
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
It does not work on units created outside of the map area
True.

But, you can't create units outside the map area, even the playable map area :D
Only SetUnitX/Y can do that.
So your function MakeUnitFlyable is useless.

This trigger can so fire several times for the same unit, but anyway i think i'm the only one crazy dude witch do that :p
 

Azlier

Old World Ghost
Reaction score
461
>But, you can't create units outside the map area, even the playable map area

Yay! I'll remove it right away.

>Why do you need a custom ability for something like this?

It avoids strange bugs.

Making changes...
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Instead of delete the line, comment the object merger line is a better option.
 

Azlier

Old World Ghost
Reaction score
461
Indeed it is. But that requires more brain power to get pretty much the same result.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Yes. If only humans were less ... humans.

I guess this is fine like it, to preserve users from themselves.
 

Romek

Super Moderator
Reaction score
963
> It avoids strange bugs.
Such as? :p
 

Azlier

Old World Ghost
Reaction score
461
Adding and removing Storm Crow form will break Druids of the Talon.

You need a check to prevent that, and this beats that in efficiency.
 

Romek

Super Moderator
Reaction score
963
And [ljass]if UnitAddAbility(...)[/ljass] wouldn't work?
It probably takes more time loading that ability at map init than the time you save between using a new ability in the actual map.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Personally i would define/hook the function CreateUnit.
It would be irrelevant compare to the time required of the unit creation by itself.
In this way i'm sure it won't have unneeded enter region events fired.

If you wonder why the hell i put some units outside the whole map, check this link :
http://www.wc3c.net/showpost.php?p=1106773&postcount=70

Anyway i don't really care about it, since i already use it like that, i just wanted to give my opinion.

Hmm, i haven't played with the "chaos" abilities because of the issues, i simply leave the unit specific event leak and don't recycle units, except dummies ones , but does this still work with such units ?
 

Azlier

Old World Ghost
Reaction score
461
Alright. Make two maps with two versions of this, one with Storm Crow, the other with the dummy ability. Give them the same name, and put them in the Maps folder at random. Can you tell which is which from inside Warcraft?

>but does this still work with such units ?

Excellent question. I'll test that.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Uhh ...

Just forget what i've said about the hook/define, usually, units are not only created with the native function CreateUnit :banghead:
They can be trained, bought, summoned, built ...
 

Azlier

Old World Ghost
Reaction score
461
It works on Chaosed units. Yay.

A unit morphing via Chaos doesn't fire the event again, as expected.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
A unit morphing via Chaos doesn't fire the event again, as expected.
I didn't wanted to mean that.
I mean, you can still change the flying height of a not flying unit after the unit have gotten a chaos ability?
In other words, the flying bug is still valid, or you have to add/remove the ability one more time ?
 

Azlier

Old World Ghost
Reaction score
461
Just a useless bit of info. I placed a footman, gave it Siege Engine chaos, ordered it, and set flying height.

Wait a minute. I forgot to wait until the footman fully changed form. Hold on.

EDIT: Works flawlessly.
 

Azlier

Old World Ghost
Reaction score
461
If that's what you want. Sigh.
 

Romek

Super Moderator
Reaction score
963
> Can you tell which is which from inside Warcraft?
No. Which is exactly why you should just do what I said instead of using object merger to create an ability (which can then be a nuisance), increase the map size (both insignificantly and unnecessarily), and make the user have to delete the line.
Yes, you may be thinking "Oh noes, big deal". Though notice that all of that is completely unnecessary.

As for making Azlier change this snippet just because you move the occasional unit outside the map area, I think that's pointless.
The event firing again does no harm. And I can assure you that the vast majority of users will not be moving units so far outside the map.
 

Azlier

Old World Ghost
Reaction score
461
FYI, it's already been changed to use Crow Form.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1

      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