Creating an item when a tree dies

  • Thread starter Thread starter ThE-eNiGmA
  • Start date Start date
T

ThE-eNiGmA

Guest
I was fiddling around in the editor, and one of the requirements of my map is that when you cut a tree down, a bundle of wood is dropped. Problem is, there doesn't seem to be a generic "destructible dies" event. Why is this a problem? I can't detect when a tree dies so I can drop the wood, and I don't feel like grouping all the trees in little regions. I am trying to keep the code as streamlined as possible. Any ideas?
 
uhm... why do you need that when you can do conditions :D
Code:
Tree
    Events
        Unit - A unit Dies
    Conditions
        (Destructible-type of (Last created destructible)) Equal to Summer Tree Wall
    Actions
        Item - Create <your item> at (Position of(Dying unit))
 
hmm..... dunno then....
unless you make your trees units...
because you cant use destrictable-type or destrictible variables...
 
making the trees units...would probably create all new problems. Now... i just thought of a clever workaround. What I do is allow the tree to be cut down, and the peasant can ferry it back to base. Every time he does, an item is created (a trigger detects wood coming in, and subtracts the wood and creatss a bundle of wood.)
 
there is an event destructible dies dude
woops nevermind you want generic like not specific destructible dies nm
 
That limit of 64 destructibles is completely arbitrary... it's only there because Warcraft has to go through every single destructible... you can use this custom script in your initialization trigger if you want to do it anyway and don't create any destructibles afterwards.
Code:
Custom script:   set bj_destInRegionDiesTrig = gg_trg_[i]<your trigger name>[/i]
Custom script:   set bj_destInRegionDiesCount = -100000
Custom script:   call EnumDestructablesInRect(GetWorldBounds(), null, function RegisterDestDeathInRegionEnum)
(Note that your trigger name must uses underscores "_" instead of spaces.)
 
Could you explain what those custom scripts do? Specifically I mean? I'd like to understand it for possible future use.
 
pladams9 said:
Could you explain what those custom scripts do? Specifically I mean? I'd like to understand it for possible future use.
Ah, okay. All right, well, when you use the regular "Destructible in region dies" trigger, Warcraft calls this function:
Code:
function TriggerRegisterDestDeathInRegionEvent takes trigger trig, rect r returns event
    set bj_destInRegionDiesTrig = trig
    set bj_destInRegionDiesCount = 0
    call EnumDestructablesInRect(r, null, function RegisterDestDeathInRegionEnum)
    return trig
endfunction
Which uses this function:
Code:
function RegisterDestDeathInRegionEnum takes nothing returns nothing
    set bj_destInRegionDiesCount = bj_destInRegionDiesCount + 1
    if (bj_destInRegionDiesCount <= bj_MAX_DEST_IN_REGION_EVENTS) then
        call TriggerRegisterDeathEvent(bj_destInRegionDiesTrig, GetEnumDestructable())
    endif
endfunction
The general thing it does is:
  1. Set global variable A to the trigger we want to add these events to.
  2. Set global variable B to 0, since we haven't added any events yet.
  3. Run the RegisterDestDeathInRegionEnum function for every destructible in the region (like the "pick every destructible in region" actions in the Destructible category).
The RegisterDestDeathInRegionEnum function does this:
  1. Add one to global variable B.
  2. If B is less than or equal to 64, add the event for this destructible.
All my custom script does is emulate the first function... except instead of setting global variable B to 0, it sets it to a huge negative number... so it will take an extremely long time for it to ever exceed 64.

If you wanted to avoid this, you could just add "pick every destructible in region" action to your initialization trigger, and just add this custom script to it:
Code:
Custom script:   call TriggerRegisterDeathEvent(gg_trg_[i]<your trigger name>[/i], GetEnumDestructable())
 
LOL, yes I did. OK, well it makes sense. Although, before he explained it I thought it was something else. I didn't realize that the problem was the 64 limit. I didn't even know that existed.
 
I'sn't it possible to make trees drop items? Just click a tree twice, go to the items dropped tab, and Voila!
 
Noobster said:
I'sn't it possible to make trees drop items? Just click a tree twice, go to the items dropped tab, and Voila!

Genious!

+Rep you beat custom script Lol
 
Noobster said:
I'sn't it possible to make trees drop items? Just click a tree twice, go to the items dropped tab, and Voila!
For every single tree on the map? :confused:
 
or if thats your only doodad drag over all of them, then double click on one.
 
Starlite said:
or if thats your only doodad drag over all of them, then double click on one.
That is the equivalent of creating one trigger for every tree.

Not a good idea, really.
 
no because then you just drag over all your trees and double click on one, change the field you want hit ok. then all of them have that same property
 
Starlite said:
no because then you just drag over all your trees and double click on one, change the field you want hit ok. then all of them have that same property
Look at the Jass script that makes. :P
 
how would i do that?
hey while your at it! whats a sticky thread?

ohhh dear... 31 points of rep in like 5 or 6 days... wow thats nuts...
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    Happy Thursday!
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    we were down for a minute - think a log file or something got too big
    +1
  • Ghan Ghan:
    The alerts say it was down for a while unfortunately.
  • Ghan Ghan:
    Didn't know what was going on while I was at work.
  • Ghan Ghan:
    Disk filled up with logs. Fixed now.
    +1
  • The Helper The Helper:
    not a problem at all thanks for getting us back up
  • The Helper The Helper:
    I think the bots are finding a way to get through the anubis
  • The Helper The Helper:
    Happy Wednesday Everyone! Hope everyone has a Fantastic Day!
    +1
  • The Helper The Helper:
    Yeah, stats are showing big bot influx like 12k page views.
  • Wizard Wizard:
    :wave:
    +1
  • Ghan Ghan:
    TH changed his avatar again. 6 more weeks of summer.
    +3
  • Wizard Wizard:
    lol
    +1
  • The Helper The Helper:
    Guys just a heads up I am going to be shutting the site down soon. I am just waiting on the NUON people to decide whether they want to transfer forum data and keep the discord. My email is [email protected] for anyone that wants to keep in touch and I have a facebook too. I will make an official post later. Love you guys and will miss everyone!
    +1
  • V-SNES V-SNES:
    Sent a pm @The Helper
  • Stephen Stephen:
    Oh no - please don't lose the Nuon content
    +1
  • The Helper The Helper:
    Someone email AtariAge and see if they want me to transfer the forum data over to it
  • Ghan Ghan:
    Could probably keep NUON stuff around here if we wanted.
  • Ghan Ghan:
    Hmm what to do about the World Editor site though?
  • Stephen Stephen:
    I'd rather personally just own a backup of the Nuon data than see it go to AtariAge honestly. If it gets enshittified as per usual, or if some of the "regular" Jaguar folks get there, it's not gonna be fun
  • The Helper The Helper:
    There will be a github of the forum data so the NUON Forum Data I guess would be available there
  • The Helper The Helper:
    World Editor is technically Ryoko stuff not mine you guys can keep that I am not in that even
  • jonas jonas:
    :( end of an era :(
  • The Helper The Helper:
    Dont think of it as an end jonas - think of it as a beginning, because really my friend that is what it is.

The Helper Discord

Members online

No members online now.

Affiliates

Hive Workshop NUON Dome World Editor Tutorials
Back
Top