| 01-14-2009, 09:02 PM | #1 |
Suppose that you have a widget w local widget w And it gets assigned to a widget Is there a way to tell if the widget w is a unit as opposed to not a unit? |
| 01-14-2009, 09:17 PM | #2 |
dw, thanks to griffen's help you can just typecast the widget to a unit and use GetUnitTypeId to tell if its a unit or not |
| 01-15-2009, 07:14 PM | #3 |
GetUnitTypeId will return 0 if it's not a unit, or the unit has decayed. Important difference sometimes. |
| 01-15-2009, 07:26 PM | #4 | |
Quote:
If it's decayed, it is no longer a unit; it was a unit, but now is not. It's nothing. It's a free index. Or possibly a leaked index. But it's not a unit. |
| 01-15-2009, 08:31 PM | #5 | |
Quote:
Yes, but it used to be a unit and part of your map might still be treating it as a unit. For example, consider an ability which has a different initial effect on destructables and units, then a common later effect. Suppose you want to cleanup that initial effect when the later effect happens. If you expected handles to hold their type, you might simply attach a widget to a timer and let the later call figure out what to cleanup using GetUnitTypeId. That's a leak or even a bug waiting to happen if the unit expires in the mean-time. Contrived? A little. But it's important to know these types of weird details. ... Also PandaMine now knows he can use it to detect decay. |
