• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

destructible count

Status
Not open for further replies.
Level 17
Joined
Nov 13, 2006
Messages
1,814
how can i know the number of destructibles/trees in a circle

NOTE: if there is a way to know if there is a tree in a circle will be good too

like this?

  • Destructible - Pick every destructible within 256.00 of Point_Variable and do (Actions)
    • Loop - Actions
maybe after that check if its tree or no, have more solution for that, depend how much tree type u use on ur map, if only few then maybe use if else use tree detection system from spell section, i guess Almia posted the last
 
Level 17
Joined
Jul 17, 2011
Messages
1,863
[trigger=s]
Untitled Trigger 004
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
Destructible - Pick every destructible within 2323.00 of (Position of (Triggering unit)) and do (Actions)
Loop - Actions
Custom script: if GetDestructableTypeId(GetEnumDestructable() ) == 'soid' then
Custom script: set udg_counter = udg_counter + 1
Custom script: endif

[/trigger]
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
[trigger=s]
Untitled Trigger 004
Events
Time - Every 0.10 seconds of game time
Conditions
Actions
Destructible - Pick every destructible within 375.00 of (Position of (Blend_Into_Nature_Target)) and do (Actions)
Loop - Actions
Custom script: if GetDestructableTypeId(GetEnumDestructable() ) == 'soid' then
Custom script: set udg_x = udg_cx + 1
Custom script: endif

[/trigger]

not working and btw what is soid? "I changed a bit the trigger to look like mine

wich is it:
  • Blend into Nature End
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Set x = 0
      • Destructible - Pick every destructible within 375.00 of (Position of Blend_Into_Nature_Target) and do (Actions)
        • Loop - Actions
          • Custom script: if GetDestructableTypeId(GetEnumDestructable() ) == 'soid' then
          • Set x = (x + 1)
          • Custom script: endif
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • x Greater than 0
        • Then - Actions
          • Do nothing
        • Else - Actions
          • Unit - Remove Blend Into Nature buff from Blend_Into_Nature_Target
          • Set Blend_nito_Nature_Target = (Target unit of ability being cast)
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,219
  • Untitled Trigger 001
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Destructible - Pick every destructible within 256.00 of (Center of (Playable map area)) and do (Actions)
        • Loop - Actions
          • Set i = (i + 1)
          • -------- This will count dests --------
      • Destructible - Pick every destructible within 256.00 of (Center of (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
            • Then - Actions
              • -------- do stuff --------
            • Else - Actions
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
  • Untitled Trigger 001
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • Destructible - Pick every destructible within 256.00 of (Center of (Playable map area)) and do (Actions)
        • Loop - Actions
          • Set i = (i + 1)
          • -------- This will count dests --------
      • Destructible - Pick every destructible within 256.00 of (Center of (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Summer Tree Wall
            • Then - Actions
              • -------- do stuff --------
            • Else - Actions

I tries this but i think there is something wrong, it isn't accurate i think
And i used every 0,1 seconds :p
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
here is the trigger
I made x to be shown when the trigger occures but it shows always 0
  • Blend into Nature End
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
      • Blend_nito_Nature_Target Not equal to No unit
    • Actions
      • Set x = (0)
      • Destructible - Pick every destructible within 375.00 of (Position of Blend_nito_Nature_Target) and do (Actions)
        • Loop - Actions
          • Custom script: if GetDestructableTypeId(GetEnumDestructable() ) == 'soid' then
          • Custom script: set udg_x = udg_x + 1
          • Custom script: endif
      • Game - Display to (All players) the text: (String(x))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • x Not Equal to 0
        • Then - Actions
          • Do nothing
        • Else - Actions
          • Unit - Remove Blend Into Nature buff from Blend_nito_Nature_Target
          • Set Blend_nito_Nature_Target = (No Unit)
I saw something in JassCraft:

JASS:
function IsDestructableTree takes destructable d returns boolean
 local gamecache g=CSCache()
 local string k=I2S(GetDestructableTypeId(d))
 local boolean b

    if HaveStoredBoolean(g,"trees",k) then
        set b=GetStoredBoolean(g,"trees",k)
        set g=null
        return b
    else
        set b=IsDestructableTree_withcs(d)
        call StoreBoolean(g,"trees",k,b)
    endif
 set g=null
 return b
endfunction
Can someone explain how to do this thing
 
Level 17
Joined
Jul 17, 2011
Messages
1,863
oh yea there are systems that check if a destructable is a tree or not http://www.hiveworkshop.com/forums/spells-569/isdestree-v1-2-a-224623/?prev=search=tree&d=list&r=20 this is a pretty good system
1. copy the system in your map - create an empty trigger, convert it to custom text, delete all the text, copy this code below
JASS:
library IsDestTree
/**************************************************
*
*
*    IsDestTree
*     BY: Almia
*
*
***************************************************
*
*  Allows to check trees
*  Also has a function that destroys trees
*
***************************************************
*
*  API
*
*  function IsDestTree takes destructable d returns boolean
*  - Checks if destructable is tree or not
*  function DestroyTree takes destructable d returns nothing
*  - Destroys trees
*
****************************************************/
    globals
        private unit HARVESTER
    endglobals
    
    function IsDestTree takes destructable d returns boolean
        return IssueTargetOrderById(HARVESTER,852018,d) and IssueImmediateOrderById(HARVESTER,851972)
    endfunction
    
    function DestroyTree takes destructable d returns nothing
        if IsDestTree(d) and GetWidgetLife(d) > 0.405 then
            call KillDestructable(d)
        endif
    endfunction
    
    private module Init
        private static method onInit takes nothing returns nothing
            set HARVESTER = CreateUnit(Player(15),'hpea',0,0,0)
            call ShowUnit(HARVESTER,false)
            call UnitAddAbility(HARVESTER,'Aloc')
        endmethod
    endmodule
    
    private struct SysInit
        implement Init 
    endstruct
endlibrary

2. use this code for your detect destructable trigger
[trigger=t]
Ability Cast
Events
Time - Every 1.00 seconds of game time
Conditions
Actions
Destructible - Pick every destructible within 256.00 of (Position of Footman 0089 <gen>) and do (Actions)
Loop - Actions
Custom script: if IsDestTree(GetEnumDestructable()) then
Custom script: set udg_x = udg_x + 1
Custom script: endif
Game - Display to (All players) the text: (String(x))

[/trigger]

just replace footman with your unit

thats all you have to do i tested it and it works fine


the problem with the trigger you posted is that 'soid' is probably not the id of any destructable in your map i just wrote it as an example so the condition returns false every time the trigger runs thus not setting x + 1 if you are to replace 'soid' with a standart id then it will work you can find the id of the destructable go to the destructables tab in the object editor and press ctrl + d however you dont need to do this with the system i posted above because it automatically checks if the destructable is a TREE or some other type like barrel or cage
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
DO NOT USE
  • Destructible - Pick every destructible within 256.00 of point and do (Actions)
    • Loop - Actions
USE THIS INSTEAD
  • Destructible - Pick every destructible in region and do (Actions)
    • Loop - Actions
The first one leaks and there is nothing you can do about that. It also creates a region from the radius and point and then calls the region verion.
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
oh yea there are systems that check if a destructable is a tree or not http://www.hiveworkshop.com/forums/spells-569/isdestree-v1-2-a-224623/?prev=search=tree&d=list&r=20 this is a pretty good system
1. copy the system in your map - create an empty trigger, convert it to custom text, delete all the text, copy this code below
JASS:
library IsDestTree
/**************************************************
*
*
*    IsDestTree
*     BY: Almia
*
*
***************************************************
*
*  Allows to check trees
*  Also has a function that destroys trees
*
***************************************************
*
*  API
*
*  function IsDestTree takes destructable d returns boolean
*  - Checks if destructable is tree or not
*  function DestroyTree takes destructable d returns nothing
*  - Destroys trees
*
****************************************************/
    globals
        private unit HARVESTER
    endglobals
    
    function IsDestTree takes destructable d returns boolean
        return IssueTargetOrderById(HARVESTER,852018,d) and IssueImmediateOrderById(HARVESTER,851972)
    endfunction
    
    function DestroyTree takes destructable d returns nothing
        if IsDestTree(d) and GetWidgetLife(d) > 0.405 then
            call KillDestructable(d)
        endif
    endfunction
    
    private module Init
        private static method onInit takes nothing returns nothing
            set HARVESTER = CreateUnit(Player(15),'hpea',0,0,0)
            call ShowUnit(HARVESTER,false)
            call UnitAddAbility(HARVESTER,'Aloc')
        endmethod
    endmodule
    
    private struct SysInit
        implement Init 
    endstruct
endlibrary

2. use this code for your detect destructable trigger
[trigger=t]
Ability Cast
Events
Time - Every 1.00 seconds of game time
Conditions
Actions
Destructible - Pick every destructible within 256.00 of (Position of Footman 0089 <gen>) and do (Actions)
Loop - Actions
Custom script: if IsDestTree(GetEnumDestructable()) then
Custom script: set udg_x = udg_x + 1
Custom script: endif
Game - Display to (All players) the text: (String(x))

[/trigger]

just replace footman with your unit

thats all you have to do i tested it and it works fine


the problem with the trigger you posted is that 'soid' is probably not the id of any destructable in your map i just wrote it as an example so the condition returns false every time the trigger runs thus not setting x + 1 if you are to replace 'soid' with a standart id then it will work you can find the id of the destructable go to the destructables tab in the object editor and press ctrl + d however you dont need to do this with the system i posted above because it automatically checks if the destructable is a TREE or some other type like barrel or cage

I created a new trigger, converted it into text, removed everything in it pasted the script you posted, disabled then enabled the trigger there is something wrong and about that I think there is a problem at the begining:

JASS:
/**************************************************
*
*
*    IsDestTree
*     BY: Almia
*
*
***************************************************
*
*  Allows to check trees
*  Also has a function that destroys trees
*
***************************************************

DO NOT USE
Destructible - Pick every destructible within 256.00 of point and do (Actions)
Loop - Actions

USE THIS INSTEAD
Destructible - Pick every destructible in region and do (Actions)
Loop - Actions

I may use the region as you say but could you tell me what leaks?
 
ok downloaded it and extracted it

now what?


I opened newgen world edit

and when i loaded my map

a message came: this map has been saved by a recent version of world editor
continue loading
yes? no?

i choosed no


you will be fine just click yes
JNGP was made on an older version which means some of the gui stuff isnt usable but all of the jass is usable.
note: even if ur map has the gui stuff tht isnt in this one it will not break ur map.

if ur still a little scared make a copy of ur map save it to a new location then load the other one onto jngp and there u go now u have a backup
 
Level 16
Joined
Jul 31, 2012
Messages
2,217
you will be fine just click yes
JNGP was made on an older version which means some of the gui stuff isnt usable but all of the jass is usable.
note: even if ur map has the gui stuff tht isnt in this one it will not break ur map.

if ur still a little scared make a copy of ur map save it to a new location then load the other one onto jngp and there u go now u have a backup

I was faster than you :grin:
 
Status
Not open for further replies.
Top