wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 01-03-2009, 12:39 PM   #1
PitzerMike
Alcopops
 
PitzerMike's Avatar


Tools & Tutorials Moderator
 
Join Date: Jan 2003
Posts: 2,794

Submissions (12)

PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)

Approved Map: Pitzer's Minesweeper

Default IsDestructableTree

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.


Collapse Library:
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?
Attached Files
File Type: w3x DestructableLib.w3x (19.7 KB, 96 views)
__________________
Zoom (requires log in)

Last edited by PitzerMike : 01-03-2009 at 02:48 PM.
PitzerMike is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 01-03-2009, 01:35 PM   #2
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

Giving a unit Aloc also makes it invulnerable and it also removes its pathing, so aren't these two lines useless?
Collapse JASS:
call SetUnitPathing(dummy, false)
call UnitAddAbility(dummy, 'Avul') // invulnerable
Aside from that, I see no downsides and nothing wrong with this system, plus the demo map works, FWIW. If you remove those lines or explain why they're necessary I'll approve this.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 01-03-2009, 01:41 PM   #3
Vestras
User


Project Member: LoC
 
Join Date: Dec 2007
Posts: 756

Submissions (4)

Vestras will become famous soon enough (40)Vestras will become famous soon enough (40)

Default

So many of these (I mean types... the IsSomethingSomething)... but very useful, I've needed one of those many times.

Last edited by Vestras : 01-03-2009 at 01:42 PM.
Vestras is offline   Reply With Quote
Old 01-03-2009, 02:36 PM   #4
PitzerMike
Alcopops
 
PitzerMike's Avatar


Tools & Tutorials Moderator
 
Join Date: Jan 2003
Posts: 2,794

Submissions (12)

PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)

Approved Map: Pitzer's Minesweeper

Default

I wasn't exactly sure about the properties of Aloc, I'll just remove the two lines.
Also updated the demo map.
__________________
Zoom (requires log in)
PitzerMike is offline   Reply With Quote
Old 01-03-2009, 02:56 PM   #5
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Does this only works for trees or can it work for other things such as bridges and other destructibles such as boxes?
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 01-03-2009, 03:06 PM   #6
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

A wood abilitie can target only a tree or a custom destructable based on a tree, that's your anwser.
__________________
Cool != Useful

Last edited by Troll-Brain : 01-03-2009 at 03:07 PM.
Troll-Brain is offline   Reply With Quote
Old 01-03-2009, 08:13 PM   #7
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Yeah, approved.
__________________
Rising_Dusk is offline   Reply With Quote
Old 01-03-2009, 08:43 PM   #8
PitzerMike
Alcopops
 
PitzerMike's Avatar


Tools & Tutorials Moderator
 
Join Date: Jan 2003
Posts: 2,794

Submissions (12)

PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)PitzerMike is a splendid one to behold (643)

Approved Map: Pitzer's Minesweeper

Default

Thanks, Dusk and Pyro. :)
__________________
Zoom (requires log in)
PitzerMike is offline   Reply With Quote
Old 01-04-2009, 07:47 AM   #9
Spec
Shadow Daemon
 
Spec's Avatar
 
Join Date: Mar 2008
Posts: 102

Submissions (2)

Spec has a spectacular aura about (118)Spec has a spectacular aura about (118)Spec has a spectacular aura about (118)Spec has a spectacular aura about (118)

Send a message via ICQ to Spec
Default

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...)
__________________
Button Manager v1.8.2 - The icon making tool.

BLP Laboratory v0.5.0 - Texture viewer & converter.
Spec is offline   Reply With Quote
Old 01-04-2009, 08:35 AM   #10
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

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.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request Thread Done for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.

Last edited by Pyrogasm : 01-04-2009 at 08:43 AM.
Pyrogasm is offline   Reply With Quote
Old 09-06-2011, 09:58 AM   #11
Bribe
User
 
Bribe's Avatar
 
Join Date: Mar 2010
Posts: 233

Submissions (1)

Bribe will become famous soon enough (30)Bribe will become famous soon enough (30)

Send a message via AIM to Bribe
Default

This library could be shortened to just this:

Collapse JASS:
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.
Bribe is offline   Reply With Quote
Old 09-23-2011, 09:55 PM   #12
Bannar
User
 
Join Date: Aug 2009
Posts: 9

Bannar has little to show at this moment (4)

Default

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.
Bannar is offline   Reply With Quote
Old 09-24-2011, 05:35 AM   #13
Bribe
User
 
Bribe's Avatar
 
Join Date: Mar 2010
Posts: 233

Submissions (1)

Bribe will become famous soon enough (30)Bribe will become famous soon enough (30)

Send a message via AIM to Bribe
Default

Thanks Spinnaker, I messed it up when I changed the order ID to be a constant and took over the old name.
Bribe is offline   Reply With Quote
Old 05-07-2014, 02:21 PM   #14
cokemonkey11
User
 
Join Date: Feb 2006
Posts: 28

cokemonkey11 has little to show at this moment (0)

Default

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/
Attached Files
File Type: w3m treeTest.w3m (15.7 KB, 6 views)
cokemonkey11 is offline   Reply With Quote
Old 05-07-2014, 11:23 PM   #15
Fledermaus
default string
 
Fledermaus's Avatar
 
Join Date: May 2006
Posts: 705

Submissions (1)

Fledermaus is a jewel in the rough (194)Fledermaus is a jewel in the rough (194)Fledermaus is a jewel in the rough (194)

Send a message via MSN to Fledermaus
Default

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.
Fledermaus is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 06:04 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services