| 01-26-2012, 03:43 AM | #1 |
Does anyone know how to reference a unit resulting from a couple ability (eg: mount hippogryph), or the two units resulting from a de-couple. If there is already a thread or post about this can you please redirect me. Specifically if there is a function such as GetTriggerUnit(). (Referencing 'summoned unit' or 'last created unit' does not work. I already tried those.) Thanks in advance. |
| 01-27-2012, 09:23 PM | #2 |
Hmm, I have no experience with coupling/decoupling. Which trigger events even run when you do a couple/decouple? |
| 01-27-2012, 11:07 PM | #3 |
There are no events I think, just orders: JASS:
public constant integer coupleinstant=852508 // archer order and hippogryph order (when they press ability)
public constant integer coupletarget=852507 // hippogryph order (after being called by archer to mount)
public constant integer decouple=852509 // decouple
When ever a mount happens: archer and hippogryph units are REMOVED from game and replaced with NEW hippogryph rider unit. When ever a dismount happens: hippogryph rider unit is REMOVED from game and replaced with NEW archer and NEW hippogryph units. So this spell is basically a bounch of CreateUnit and RemoveUnit calls mixed together. The only way to detect anything here is "Unit Enters Rect" event on entire map. BTW: what is it exactly that you are trying to do? |
| 01-27-2012, 11:33 PM | #4 |
Just did some tests. Couldn't find any way to get the new unit(s) when coupling/decoupling but I'll post the other stuff I found anyway, someone might find it useful. It fires all spell events. EVENT_PLAYER_UNIT_SPELL_EFFECT being the most useful. GetTriggerUnit() will return the casting unit and GetSpellTargetUnit() will return the unit target for the couple. Both will point to the Decoupling unit on when decoupling. It will do some weird stuff if both Mount X had "Move To Partner" set to true and Mount Y has it on false. If you cast Mount Y and the units are not within range, the event will first fire for the unit you cast it with and then unit X will move into range and the event will fire again for the unit X. So it's best if you have both to move to partners on true. |
| 01-29-2012, 02:17 AM | #5 |
thanks guys, i'll try out the entering unit event, that seems the most likely to work. @anitarf: triggering unit, dying unit (but NOT killing unit), and as someone else mentioned the casting events. Summoned unit and any other that seemed remotely likely didn't work. @cohadar: i am trying to carry over custom values to the hippo-rider from the archer at the moment (and vice-versa) - i have other ideas for when i figure out a way to do this though. Its basically a tally for a few specific units though, so if anyone can think of a better way to do it then i'm all ears. does anyone know if it is possible to alter the source code of the ability? or more specifically to open the source code to put a 'set LastCreatedUnit()' or similar call in? |
| 01-29-2012, 07:07 AM | #6 | ||
Quote:
(This is not as hard as it seems) Other alternative would be 2 arrays of <unit, integer> pairs When archer is issued mount order save his unit handle and custom data in that pair of arrays. Also save archer unit if it is a target of hyppogs mount order. When a mountedHyppogrif unit enters the map check if there are any units in array whose GetUnitUserData returns zero (this means they are removed) and give the mounted unit the number that is paired with removed archer unit. Than you have to remove that pair from arrays, like this: JASS:set archers[Removed] = archers[Last] set numbers[Removed] = numbers[Last] set Last = Last - 1 Quote:
|
| 01-29-2012, 10:46 AM | #7 | |
Quote:
Cohadar's idea would likely work. Whenever an archer was ordered to mount a hippo you would add the archer to the array (you would first need to check if that archer is already in the array in case the order was issued multiple times), then whenever a hippo rider entered the map you would loop through that array to find an archer that no longer exists; once you find one, that will be the archer that mounted the hippo. You could use a similar method to detect dismounts, although you could run into some trouble when multiple hippo riders dismount at the same time. I'm not sure if the issue-order triggers and unit-enters-map triggers would run in the same order; if not, two archers might end up swapping their data. |
| 01-29-2012, 07:24 PM | #8 |
You'd be better off using EVENT_PLAYER_UNIT_SPELL_EFFECT than the order, since it will only happen once (provided both abilities move to partner). Or just use the ability that does move and not the other one. |
