• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Destructible Dies: Get Killing Unit

Status
Not open for further replies.
Level 6
Joined
Feb 12, 2008
Messages
207
Well... I have this trigger but it doesn't seem to work. Is there any event response to get the unit which is killing the destructible?

  • WoodDropping
    • Events
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Killing unit)) Equal to (==) Worker
        • Then - Actions
          • Hero - Add 10 experience to (Killing unit), Show level-up graphics
        • Else - Actions
      • Set TreeRandomer = (Random integer number between 1 and 30)
      • Set Destructible_Point = (Position of (Dying destructible))
      • Item - Create Wood at Destructible_Point
      • Item - Create Wood at Destructible_Point
      • Item - Create Wood at Destructible_Point
      • Item - Create Tinder at Destructible_Point
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TreeRandomer Equal to (==) 20
          • Then - Actions
            • Item - Create Egg at Destructible_Point
            • Custom script: call RemoveLocation (udg_Destructible_Point)
          • Else - Actions
            • Custom script: call RemoveLocation (udg_Destructible_Point)
 
Level 13
Joined
Mar 24, 2010
Messages
950
  • trig
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Destructible-type of (Target destructible of issued order)) Equal to Summer Tree Wall
    • Actions
      • -------- ***If the target destructable you want is "being attacked or dead" then continue on like this in some way.. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Target destructible of issued order) is dead) Equal to True
        • Then - Actions
        • Else - Actions
If it doesnt register that the tree or whatever is dead right away try adding a short wait time at the very beginning of the trigger, or theres other ways also

Let me know if you need more help :)
 
Level 6
Joined
Feb 12, 2008
Messages
207
But that will trigger only when the unit is issued the order, and not every time the unit attacks the tree, so it doesn't work for me.
By the way I'm using another trigger to add the event to the WoodDropping trigger. So the trigger would have "A Destructible Dies" as event
 
Level 13
Joined
Mar 24, 2010
Messages
950
well first off you cant use this
  • (Unit-type of (Killing unit)) Equal to (==) Worker
there is no unit being killed in the first place..

I havent really checked but im pretty sure theres no way to get the triggering unit of a destructible dying thats why you have to try it my way ^ the unit targetting the Destructible dying can be assumed it was the attacking unit and then you can go from there addressing that triggering unit.

but not much time so i'll edit this in a little bit.. and further answer you if you need..
 
Last edited:
Level 19
Joined
Feb 25, 2009
Messages
2,004
But that will trigger only when the unit is issued the order, and not every time the unit attacks the tree, so it doesn't work for me.
By the way I'm using another trigger to add the event to the WoodDropping trigger. So the trigger would have "A Destructible Dies" as event

Everything action in Warcraft involves doing an order, so the trigger given above will work for everything, from casting ability or attacking the specified object.
 
Level 13
Joined
Mar 24, 2010
Messages
950
there i guess use this, its more exact lol
i'm still not 100% sure what you wanna do with this when it dies but if its not just trees and you cant just use harvest as the order action ask again..

  • Untitled Trigger 001
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Issued order) Equal to (Order(harvest))
      • (Destructible-type of (Target destructible of issued order)) Equal to Summer Tree Wall
    • Actions
      • Hero - Add 10 experience to (Target unit of issued order), Show level-up graphics
 
Level 6
Joined
Feb 12, 2008
Messages
207
  • Unit - A unit Is issued an order targeting an object
That is my problem. That will only trigger when the order is issued, and after a while when the destructible dies, the trigger wouldn't check again when the tree dies. I don't know if you get what I'm saying but I need to give the XP to the hero in the moment the destructible dies. The trees are getting destroyed by attacking them with an Orb Effect based item to change the attack and enabling to attack trees (Woodcutting Axe).

The only thing I can think of is 'Picking every unit in range' and then giving XP to everyone near the tree... but that would give XP to someone very close to the tree. So thinking again, maybe checking if the unit has the axe.. but still if some other guy has another axe, he will get XP again.

Just give some ideas, that trigger with Issued order will trigger once, when the unit STARTS to attack/harvest/whatever and not in the next 4 or 5 attacks before the tree goes down... That is what I mean when I say that it triggers once MortAr-
 
Level 6
Joined
Feb 12, 2008
Messages
207
Nice idea, it would not only allow me to do this XP thing but will solve a lot of problems I have with them as Destructibles. The only problem is that I have something around 12.000 trees in the map, what's the unit limit for a map? Won't this lag a lot?
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Bond009, your trigger there will add 10 experience each time a unit is issued an order to harvest from a Summer Tree Wall, though that will hardly help detect when the tree is killed due to an attack. What is going to happen if two units are being issued the same order on the same tree? That will screw the assumption that when a tree dies, any unit that was attacking/harvesting must have been the killing unit.

The only problem is that I have something around 12.000 trees in the map, what's the unit limit for a map? Won't this lag a lot?

Plus you can't give a unit a destructable model and expect it to work. It will show up as a white "canvas" of the model, and no texture will be visible. I'm not sure if there is a solution to this, perhaps there is some trick that lets you change the model of a unit to a destructable without having any problems with the textures.
 
Level 13
Joined
Mar 24, 2010
Messages
950
Yeah you cant use units as trees will be too laggy with too many units.

and i tested my idea real fast and wont work..

But maybe try this.. Find a model on the Hive or somewhere that will allow you to make a unit have a tree model.
Then make a footmen or something name it Tree make it neutral passive or something and make a trigger that once a real tree dies of that type remove that destructible and create a Tree unit there in that place it died.
Then make all units within 150 area range of the dying destructible of that tree attack it (make the Unit-tree have 1 hp with 0 armor) that way you can address the attacking unit and do anything you want after it kills the tree unit.

This will make it so you can still use trees and not have like 12,000 units on the map making it lag out xD

If you like my idea..Once you find the tree model, if you need help with the triggers making it happen let me know.
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
Concidentally I made a tree damage detection system :grin:
Known problems:
  • if a tree is attacked more than once in 0.01 sec the damage will stack with the first blow (probably impossible to fix)
  • only the first unit which attacked a tree will get the xp even if it's not a hero but this can be changed easily if every player has only one of them (would require a twice that long trigger + it will waste a lot of memory)
  • if the unit stops harvesting the tree won't be removed from the list (same as above)

  • Ini
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Custom script: set udg_harvester = CreateUnit(Player(15), 'hpea', 0.00, 0.00, 0.00)
      • Unit - Hide harvester
  • AddTree
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Triggering unit) Not equal to harvester
      • (Target destructible of issued order) Not equal to No destructible
    • Actions
      • Set d = (Target destructible of issued order)
      • -------- Apply tree check --------
      • Unit - Order harvester to Harvest d
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Current order of harvester) Equal to (Order(harvest))
        • Then - Actions
          • -------- Tree --------
          • For each (Integer i) from 1 to TreeCount, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Tree[i] Equal to d
                • Then - Actions
                  • -------- Tree indexed already --------
                  • Unit - Order harvester to Stop
                  • Skip remaining actions
                • Else - Actions
          • Set TreeCount = (TreeCount + 1)
          • Set Tree[TreeCount] = d
          • Set TreeHP[TreeCount] = (Current life of d)
          • Set TreeHarvester[TreeCount] = (Triggering unit)
        • Else - Actions
          • -------- No tree --------
      • Unit - Order harvester to Stop
      • Trigger - Turn on CheckTree <gen>
  • CheckTree
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • For each (Integer i) from 1 to TreeCount, do (Actions)
        • Loop - Actions
          • Set r = (Current life of Tree[i])
          • -------- Saved hp not equal to current hp? --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TreeHP[i] Not equal to r
            • Then - Actions
              • -------- Tree still alive? --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • r Greater than or equal to 0.41
                • Then - Actions
                  • -------- Update hp --------
                  • Custom script: call Text(udg_Tree[udg_i], I2S(R2I(udg_TreeHP[udg_i] - udg_r)))
                  • Floating Text - Change the color of (Last created floating text) to (30.00%, 100.00%, 30.00%) with 0.00% transparency
                  • Set TreeHP[i] = r
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (TreeHarvester[i] is A Hero) Equal to True
                    • Then - Actions
                      • -------- XP --------
                      • Hero - Add 10 experience to TreeHarvester[i], Show level-up graphics
                      • Custom script: call Text(udg_TreeHarvester[udg_i], I2S(10))
                      • Floating Text - Change the color of (Last created floating text) to (100.00%, 100.00%, 0.00%) with 0.00% transparency
                    • Else - Actions
                  • -------- Sort tree list --------
                  • Set Tree[i] = Tree[TreeCount]
                  • Set TreeHP[i] = TreeHP[TreeCount]
                  • Set TreeHarvester[i] = TreeHarvester[TreeCount]
                  • Set TreeCount = (TreeCount - 1)
                  • Set i = (i - 1)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TreeCount Less than 1
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
JASS:
function Text takes widget w, string s returns nothing
    set bj_lastCreatedTextTag = CreateTextTag()
    call SetTextTagText(bj_lastCreatedTextTag, s, 0.02)
    call SetTextTagPos(bj_lastCreatedTextTag, GetWidgetX(w), GetWidgetY(w), 0)
    call SetTextTagPermanent(bj_lastCreatedTextTag, false)
    call SetTextTagLifespan(bj_lastCreatedTextTag, 2.00)
    call SetTextTagVelocity(bj_lastCreatedTextTag, 0.00, 0.05)
    call SetTextTagFadepoint(bj_lastCreatedTextTag, 1.00)
endfunction
 

Attachments

  • TreeDamageDetection.w3x
    21.8 KB · Views: 76
Status
Not open for further replies.
Top