• 🏆 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] Create Item if you have the building.

Status
Not open for further replies.
Level 3
Joined
Mar 2, 2012
Messages
35
Hello, i need help with something.. I have been trying to create this trigger, but i cant :/

This: Every 20sec of the game if you have a "Farm" create a "Claws of attack" on that building.

Can you guys help me with this?
 
Level 10
Joined
Mar 31, 2009
Messages
732
  • Untitled Trigger 001
    • Events
      • Time - Every 20.00 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area) matching ((Unit-type of (Matching unit)) Equal to Farm)) and do (Actions)
        • Loop - Actions
          • Item - Create Claws of Attack +3 at (Position of (Picked unit))
 
Level 3
Joined
Mar 2, 2012
Messages
35
Hmm, actully it dose not seem to work.. :/

  • Actions
    • Unit Group - Pick every unit in (Units owned by (Matching player) matching ((Unit-type of (Matching unit)) Equal to Sawmill)) and do (Actions)
      • Loop - Actions
    • Item - Create Wood at (Position of (Picked unit))
EDIT: Oh wait..
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
Your trigger doesn't work because you didn't put the "Item - Create Wood at (Position of (Picked unit))" into loop and it also leaks

Teelo's trigger leaks unit group and position
leakless trigger:
  • spawning items
    • Events
      • Time - Every 20.00 seconds of game time
    • Conditions
    • Actions
      • Set farms = (Units of type Farm)
      • Unit Group - Pick every unit in farms and do (Actions)
        • Loop - Actions
          • Set farmsposition = (Position of (Picked unit))
          • Item - Create Claws of Attack +15 at farmsposition
          • Custom script: call RemoveLocation(udg_farmsposition)
      • Custom script: call DestroyGroup (udg_farms)
hope it does what you want it to do
testing map:
 

Attachments

  • farmsspawningitems.w3x
    16.4 KB · Views: 60
Last edited:
Level 20
Joined
Jul 14, 2011
Messages
3,213
Actually, I've heard that creating groups of "Units of Type" leaks. The safest way is to pick every unit in playable map area and, if the Unit type of the picked unit = Farm, save it to Group2, and work with group 2.

  • spawning items
    • Events
      • Time - Every 20.00 seconds of game time
    • Conditions
      • Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in (Playable map area) and do (Actions)
      • Loop - Actions
        • If - Conditions
          • Unit Type of (Picked Unit) = Farm
        • Then - Actions
          • Unit Group - Add (Picked Unit) to Group2
        • Else - Actions
    • Custom script: set bj_wantDestroyGroup = true
    • Unit Group - Pick every unit in Group2 and do (Actions)
      • Loop - Actions
        • Set Point = (Position of (Picked unit))
        • Item - Create Claws of Attack +15 at farmsposition
        • Custom script: call RemoveLocation(udg_Point)
 
Level 10
Joined
Mar 31, 2009
Messages
732
I gave the guy a piece of code that does what he wants. He didn't come into this thread asking about leaks. If he ever wants to make his code leak-proof, he will ask us to check his code. Until then, lets not overwhelm him with an issue that is so insignificant in this day of modern computers averaging 8GB ram?
 
Level 25
Joined
May 11, 2007
Messages
4,651
I gave the guy a piece of code that does what he wants. He didn't come into this thread asking about leaks. If he ever wants to make his code leak-proof, he will ask us to check his code. Until then, lets not overwhelm him with an issue that is so insignificant in this day of modern computers averaging 8GB ram?

Fixing leaks is an easy AND important thing, if he doesn't learn it from the beginning, he's going to have a hell of a time having to go through all his code and fixing all the leaks.

And you would be suprised on how many people don't have 8 ram in average.
Especially for people using laptops, etc. Also, if I remember correctly, leaks tend to cause people to drop from Battle.net / cause server splits?
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
I gave the guy a piece of code that does what he wants. He didn't come into this thread asking about leaks. If he ever wants to make his code leak-proof, he will ask us to check his code. Until then, lets not overwhelm him with an issue that is so insignificant in this day of modern computers averaging 8GB ram?

actually warcraft 3 runs ram restricted last i checked, so 512mb and 10gb wont make a difference.

and no, your wrong

Pick all units in playable map area matching (matching unit type == x) == true then ... does not leak

theres a different function alike it that leaks

Pick all units of type x and do actions

that creates an irremovable leak
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
IF your Farm has Inventory ability and you want the claws to be inside the building (holding it in its Inventory), then you can do this
  • Hero - Create Claws of Attack and give it to FarmBuilding
It is under Hero - Create Item For Hero

Don't worry, in this case, Hero = Normal Unit

Does not requires any point and leak-removal, better and efficient.

But if it has full inventory, then it's a different story, put a condition there and create the claws of attack at the ground (requires point variable) and if you want to limit the creation of claws of attack, put a condition too

It depends on how you want the concept to be executed
 
Level 10
Joined
Mar 31, 2009
Messages
732
Fixing leaks is an easy AND important thing, if he doesn't learn it from the beginning, he's going to have a hell of a time having to go through all his code and fixing all the leaks.

And you would be suprised on how many people don't have 8 ram in average.
Especially for people using laptops, etc. Also, if I remember correctly, leaks tend to cause people to drop from Battle.net / cause server splits?
If leaks had ever been this important, Blizzard would have fixed their leaks in their own MeleeXXX() functions, and designed a smarter garbage collection system.

Server splits are only caused by incorrect usage of GetLocalPlayer() or hitting the limit of hashtables, neither of which he is using.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
If leaks had ever been this important, Blizzard would have fixed their leaks in their own MeleeXXX() functions, and designed a smarter garbage collection system.

Server splits are only caused by incorrect usage of GetLocalPlayer() or hitting the limit of hashtables, neither of which he is using.

Have you ever player ORPG in Warcraft III ?
If you don't, let me tell you this, one game lasts for average of 3 hours (playing on platform such as Garena, Hamachi, etc)

3 hours, with custom spells (requires heavy SFX creation and many point creation (not to mention other type of leaks)), can really affect the game engine if the leaks keep going on unclean

You don't expect to keep re-making the game once every 30minutes or an hour, do you ?

And you should know that not everybody is as rich as you (not all has 8GB of RAM, some of them has only 512MB RAM and the most poor is 256MB RAM), remember the poor, the world can change for a better way.
 
Level 10
Joined
Mar 31, 2009
Messages
732
So either complain to Blizzard to improve their internal gargage collection system, or build a JASS parser that adds all the variable destruction for you, without having to write all this ugly leak code "local unitgroup var = blah call DestroyGroup(var)".
 
Status
Not open for further replies.
Top