![]() |
#1 |
Alcopops
Tools & Tutorials Moderator
|
![]() So I went through my old scripts at www.wc3jass.com and found this one. I decided to remake it as a library with some minor improvements. The IsDestructableTree function should come in handy for certain spells and systems. It works for the standard trees as well as custom trees (destructables based off trees). I've also included IsDestructableDead for completeness. It uses the unmodified footman as a dummy with the ghoul harvest ability, so there are no changes in the object editor required.
![]() library DestructableLib initializer Initialization //* ============================================================================ * //* Made by PitzerMike * //* * //* I made this to detect if a destructable is a tree or not. It works not only * //* for the standard trees but also for custom destructables created with the * //* object editor. It uses a footie as a dummy with the goul's harvest ability. * //* The dummy ids can be changed though. I also added the IsDestructableDead * //* function for completeness. * //* ============================================================================ * globals private constant integer DUMMY_UNIT_ID = 'hfoo' // footman private constant integer HARVEST_ID = 'Ahrl' // ghouls harvest private constant player OWNING_PLAYER = Player(15) private unit dummy = null endglobals function IsDestructableDead takes destructable dest returns boolean return GetDestructableLife(dest) <= 0.405 endfunction function IsDestructableTree takes destructable dest returns boolean local boolean result = false if (dest != null) then call PauseUnit(dummy, false) set result = IssueTargetOrder(dummy, "harvest", dest) call PauseUnit(dummy, true) // stops order endif return result endfunction private function Initialization takes nothing returns nothing set dummy = CreateUnit(OWNING_PLAYER, DUMMY_UNIT_ID, 0.0, 0.0, 0.0) call ShowUnit(dummy, false) // cannot enumerate call UnitAddAbility(dummy, HARVEST_ID) call UnitAddAbility(dummy, 'Aloc') // unselectable, invulnerable call PauseUnit(dummy, true) endfunction endlibrary I've also included a test map with standard and custom trees to validate the script. It's not too exciting though. Can you think of anything else that could be useful in a DestructableLib? PS: Anyone noticed how similar this looks to Dusquo's PathabilityCheck? ![]() Last edited by PitzerMike : 01-03-2009 at 02:48 PM. |
![]() |
![]() |
Sponsored Links - Login to hide this ad! |
|
![]() |
#2 |
Lackadaisically Absent.
Respected User
|
![]() Giving a unit Aloc also makes it invulnerable and it also removes its pathing, so aren't these two lines useless?
__________________![]() call SetUnitPathing(dummy, false) call UnitAddAbility(dummy, 'Avul') // invulnerable |
![]() |
![]() |
![]() |
#4 |
Alcopops
Tools & Tutorials Moderator
|
![]() I wasn't exactly sure about the properties of Aloc, I'll just remove the two lines.
__________________Also updated the demo map. |
![]() |
![]() |
![]() |
#5 |
retired coder | real ilfe
|
![]() Does this only works for trees or can it work for other things such as bridges and other destructibles such as boxes?
__________________ |
![]() |
![]() |
![]() |
#6 |
User
Join Date: Oct 2006
Posts: 1,490
![]() |
![]() A wood abilitie can target only a tree or a custom destructable based on a tree, that's your anwser.
__________________Last edited by Troll-Brain : 01-03-2009 at 03:07 PM. |
![]() |
![]() |
![]() |
#8 |
Alcopops
Tools & Tutorials Moderator
|
![]() Thanks, Dusk and Pyro. :)
__________________ |
![]() |
![]() |
![]() |
#9 |
Shadow Daemon
|
![]() Hmm...
__________________1. Why not creating ghoul ('ugho'), which is already have harvest ability, instead of footman? This can get rid of another two lines in script :) 2. GetWidgetLife(dest) is a little bit faster than GetDestructableLife(dest) (not noticeable, in fact...) |
![]() |
![]() |
![]() |
#10 |
Lackadaisically Absent.
Respected User
|
![]() Because what if someone edits the default ghoul unit on their map to not have the harvest ability? Then it doesn't matter what unit it is because you still have to add the harvest ability to it, so it's better to be safe and do it the way he has done.
__________________Last edited by Pyrogasm : 01-04-2009 at 08:43 AM. |
![]() |
![]() |
![]() |
#11 |
User
|
![]() This library could be shortened to just this:
![]() library IsDestructableTree //* ============================================================================ * //* Made by PitzerMike * //* * //* I made this to detect if a destructable is a tree or not. It works not only * //* for the standard trees but also for custom destructables created with the * //* object editor. It uses a locust as a dummy with the ghoul's harvest ability. * //* ============================================================================ * globals private constant integer HARVEST_ABIL = 'Ahrl' // ghouls harvest private constant integer HARVEST_ID = 0xD0032 // harvest order ID private constant integer DUMMY_ID = 'uloc' // locust unit type private unit u = null endglobals function IsDestructableTree takes destructable d returns boolean return IssueTargetOrderById(u, HARVEST_ID, d) endfunction private module M private static method onInit takes nothing returns nothing set u = CreateUnit(Player(15), DUMMY_ID, 0, 0, 0) // unselectable, untargetable, can't be enumerated call ShowUnit(u, false) //Invisible call UnitAddAbility(u, HARVEST_ABIL) call UnitRemoveAbility(u, 'Amov') // the unit can never follow through with order, so endmethod // you don't need to pause/unpause the unit. endmodule private struct S extends array implement M endstruct endlibrary Last edited by Bribe : 09-24-2011 at 05:34 AM. |
![]() |
![]() |
![]() |
#12 |
User
Join Date: Aug 2009
Posts: 9
![]() |
![]() Instead of call UnitAddAbility(u, HARVEST_ID) should be:
call UnitAddAbility(u, HARVEST_ABIL) Last edited by Bannar : 09-23-2011 at 09:55 PM. |
![]() |
![]() |
![]() |
#13 |
User
|
![]() Thanks Spinnaker, I messed it up when I changed the order ID to be a constant and took over the old name.
|
![]() |
![]() |
![]() |
#14 |
User
Join Date: Feb 2006
Posts: 28
![]() |
![]() Bribe, your version is incorrect because hidden units can move and destroy trees. See attached map. Also see http://www.hiveworkshop.com/forums/j...letree-248054/
|
![]() |
![]() |
![]() |
#15 |
default string
|
![]() They tend to struggle at moving if they've had the move ability removed though :p
call UnitRemoveAbility(u, 'Amov') Last edited by Fledermaus : 05-07-2014 at 11:58 PM. |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
|