HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

AutoEvents

06-06-2009, 05:33 AM#1
grim001
Requires AutoIndex

AutoEvents is an add-on library for AutoIndex. It gives you events that detect the following things: when units resurrect, when units are raised with Animate Dead, when units begin reincarnating, when units finish reincarnatinging, and when transports load and unload units. It also provides other useful functions. You can check if a unit is currently raised with Animate Dead, get the transport carrying a unit, get the number of a units in a transport, get the passenger in a specific slot of a transport, and enumerate through all of the units in a transport.

Expand JASS:
06-21-2009, 11:39 AM#2
Anitarf
This has waited too long, approved.
06-22-2009, 02:08 PM#3
grim001
Updated the thread to include both StatusEvents and TransportEvents, you can kill the other thread.

Also updated TransportEvents to include the function GetPassengerBySlot(transport, slot). Aside from the obvious point of getting the passenger in a specific slot of a transport, it enables a way to manually iterate through the units in a transport, as shown in a new example.
07-22-2009, 04:03 PM#4
ToukoAozaki
It would be great if this supports detecting the start/end of reincarnation... I really need that feature.

I've made something like below for workaround.

Expand JASS:
07-23-2009, 07:06 AM#5
grim001
I'll try to add support for that if you think it's useful. In a few days.
07-30-2009, 10:42 PM#6
Archmage Owenalacaster
I've encountered what may be a bug.

A creature that doesn't leave a corpse dies. The OnDeath callback is called. Then it completes its decay. The OnLeave callback is called and pops an error message.

AutoIndex error: Null unit passed to GetUnitId.

Both the callbacks call a struct.get method (implementing AutoData) to retrieve that unit's struct, so I think a null unit is being passed to it, when it shouldn't.

I've included a null-unit check in my script to compensate, but OnLeave should be called before the unit is actually removed, yes?
07-31-2009, 05:09 AM#7
grim001
I'll check that out sometime soon.
07-31-2009, 05:08 PM#8
Archmage Owenalacaster
I've encountered a similar issue with OnUnload event callbacks, around which I have not yet found a compensatory measure.

EDIT: Regarding OnUnload event callbacks, I positioned a debug message call at the top of the callback, commented out the other content and tested. The error message occurs before my debug message, so this must also be a bug.

Units being issued on-orders for toggleable state abilities (Immolation, Mana Shield) OnEnter also pop the "filtered unit" error message. I've removed such abilities from units' initially activated ability field to compensate.

EDIT: It applies to any initially active ability, it seems; autocasts also popped the error.
08-16-2009, 07:07 PM#9
Mr.Malte
This doesnt compile. It says, Ive got two macros of the same thing.
Both in your systems.
08-16-2009, 07:13 PM#10
Archmage Owenalacaster
Quote:
Originally Posted by StatusEvents
Collapse JASS:
//===========================================================================
// How to install StatusEvents:
//==============================
//
// 1.) Copy and paste AutoIndex into your map and follow its directions.
// 2.) Modify the configuration section of AutoIndex as it instructs you to
//     to avoid compile errors.
Quote:
Originally Posted by AutoIndex
Collapse JASS:
//     If you add StatusEvents or TransportEvents to your map, you will need to modify
// the configuration section of AutoIndex. Unfortunately, this is the closest thing there
// is to conditional compiling right now. The final version of AutoIndex will be released
// once there is a prettier way to do conditional compiling.
//
//===========================================================================
// Configuration:
//================

//! textmacro RunStatusEvent takes EVENT
//! endtextmacro
//! textmacro RunStatusEventReverse takes EVENT
//! endtextmacro
//Disable the four lines above (remove the exclamations) if you are using StatusEvents.
//If you don't, you will get a "textmacro redeclared" compile error.
09-15-2009, 06:15 PM#11
grim001
StatusEvents & TransportEvents both updated.
  • Added OnUnitReincarnationStart and OnUnitReincarnationEnd to StatusEvents. Credit to ToukoAozaki since I was inspired by his implementation.
  • Fixed the OnUnload null unit bug in TransportEvents. Thanks for pointing it out Ownalacaster.

Quote:
Originally Posted by Archmage Owenalacaster
Units being issued on-orders for toggleable state abilities (Immolation, Mana Shield) OnEnter also pop the "filtered unit" error message. I've removed such abilities from units' initially activated ability field to compensate.

EDIT: It applies to any initially active ability, it seems; autocasts also popped the error.
I just noticed this problem in the AutoIndex thread. You're using LastOrder, correct? You'll have to edit it or just avoid having AutoCast abilities turned on initially. Dusk will be making a new version of LastOrder soon that probably works around this issue.
10-23-2009, 02:37 PM#12
grim001
Updated.
  • Changed the syntax for registering functions, a boolean is no longer required, so it is not possible to un-register a function. The function will also run as many times as you register it. Anyway, it makes the code significantly shorter in both libraries.
  • Fixed a bug in StatusEvents where dying illusions could cause an AutoIndex error message in debug mode.
  • Documentation improvements for both libraries.
10-24-2009, 03:10 PM#13
grim001
Updated.
  • StatusEvents and TransportEvents have merged into one script.
  • Due to the fact that AutoIndex gained OnUnitIndexed and OnUnitDeindexed events, OnUnitEnter and OnUnitLeave no longer exist for StatusEvents.
  • Code and documentation changes.
11-03-2009, 06:21 AM#14
StealthOfKing
There is one real flaw in using this method, that is native KillUnit takes unit whichUnit returns nothing on neutral aggressive player owned units.

Neither defend nor magicdefend are triggered if you KillUnit or SetWidgetLife(0). This exception only applies to neutral aggressive (creeps!), and is particularly hard to work around without some sort of KillUnit hook. I choose to use a replacement KillUnit function, the following will suffice and does correctly trigger neutral aggressive removal detection:
Collapse JASS:
function KillUnitEx takes unit u returns nothing
    call UnitDamageTarget(u, u, 999999, false, false, null, DAMAGE_TYPE_UNIVERSAL, null)
endfunction
11-03-2009, 03:11 PM#15
grim001
OK, I've tested what you said. The problem is actually more specific. Units that are currently asleep won't issue undefend orders if they die. Any sort of damage wakes the unit up, so only non-damaging methods of killing the unit fail.

I've already updated AutoIndex (and by extension, this library) to fix the issue by detecting the death of Player(12) creeps and forcing the status update method to run. That way, no additional hook usage was required.