• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] YouTD and Castle Fight Combined Models

Status
Not open for further replies.
Level 9
Joined
Aug 16, 2008
Messages
318
I just figure it out how YouTD and Castle Fight made Combine models of anything it has. How ever my version has a fatal flaw on destroying or cancelling. The latest building's dummy decors die after i destroy the first or early buildings.
Here's the GUI Trigger:
cOAqN8P.png


Don't hate if i found that secret.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,657
Use a Unit Indexer and set Bureau1[Bureau1Count] to Bureau1[custom value of last created unit]. Then do the same for Bureau2.

The way you're doing it now will have all sorts of problems.

Example:
You create an Elf Bureau 2 -> Bureau1Count and Bureau2Count is now equal to 1.
You create another Elf Bureau 2 -> Bureau1Count and Bureau2Count is now equal to 2.
You create another Elf Bureau 2 -> Bureau1Count and Bureau2Count is now equal to 3.
Then you destroy ANY of the Elf Bureaus -> The trigger kills Bureau1[Bureau1Count] and Bureau2[Bureau2Count] and since both Bureau1Count and Bureau2Count are equal to 3 then only the #3 ones will die.
Then you subtract 1 from Bureau1 and 2 Count making them equal to 2. Meaning that if you were to destroy ANY Elf Bureau it will now kill the ones with BureaCount 2.

You're not actually linking these values to your buildings, they're simply stored in the order that they were created. That's why I'd recommend using a Unit Indexer, it does almost exactly what you're trying to do here. Search for "GUI Unit Indexer", Bribe has a good one on here. It's very easy to copy and paste into your map, it's just one trigger that will Index (store a unique custom value) to all of the units in your map. You can then reference your units Custom Value to do just about anything.

Also, this action leaks "Create 1 Night Elf at Position of (Constructing structure)" and will slow your game down. The position of constructing structure is what causes the leak, because it's a point that is stored in the game's memory and never removed. Try this instead:

  • Point Leak
    • Events
    • Conditions
    • Actions
      • Set Point = (Position of (Constructing structure))
      • Unit - Create 1 Night Elf for Player 1 (Red) at Point facing Default building facing degrees
      • Unit - Create 1 Sun Elf for Player 1 (Red) at Point facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_Point)
In the example above, we're setting the position of our constructing structure to a Point variable. Now the game has stored this Point into it's memory. After creating our two buildings we no longer need that Point, so we remove it using this Custom script. This tells the game that it no longer has to remember that Point and can get rid of it. Luckily, we can keep creating, using, and destroying this Point as much as we want. Just remember to ALWAYS remove the Point before you use it again.

I suggest searching for "things that leak". The main things that you'll probably use often which leak: Points, Unit Groups, and Special Effects.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,063
You’re not actually using the indices for anything.... What you need to do is really simple.

  • ———— construction trigger ————
  • Set Ind = (Custom Value of (Triggering Unit))
  • Unit - Create 1 Night Elf...
  • Set Bureau1[Ind] = (last created unit)
  • Unit - Create 1 Day Elf...
  • Set Bureau2[Ind] = (last created unit)
  • ———— cancel trigger ————
  • Set Ind = (Custom value of (Triggering Unit)
  • Unit - Kill Bureau1[Ind]
  • Unit - Kill Bureau2[Ind]
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,657
^^^ What Pyro said.

Also, you can link your triggers without the need of a picture by simply right clicking the name of the trigger and clicking Copy as Text (On the right side of the Trigger Editor where the events/conditions/actions are). Then you can paste your text and enclose it like this [*trigger]Paste your trigger here[*/trigger] but remove the *'s.
 

Attachments

  • copy as text.png
    copy as text.png
    11 KB · Views: 32
Status
Not open for further replies.
Top