• 🏆 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] Pop-up Base

Status
Not open for further replies.
Level 5
Joined
Jan 15, 2018
Messages
128
Here is my trigger:

Event
Unit - A unit enters Rhudaur <gen>
Condition
(Unit-type of (Triggering unit)) Equal to The Necromancer
Action
Unit - Create 1 Rhudaur for Player 4 (Purple) at (Center of (Rhudaur <gen> offset by (0.00, 0.00))) facing 180.00 degrees
Unit - Create 1 Barrow for Player 4 (Purple) at ((Center of Rhudaur <gen>) offset by (-17.00, -4.00)) facing 180.00 degrees

For some reason the barrow keeps spawning right next to Rhudaur(the town hall). Rhudaur is fine where it is but i would like the barrow to be lower, and also add some towers and another production building.

How can i position building/units within the region where i want them?
 
Level 5
Joined
Jan 15, 2018
Messages
128
Does it work like a coordinate plane? i bumped them up to the 200s and its still right next to the center.

This is literally my first trigger, so im a little confused as to why its leaking. all i need to do is type in "RemoveLocation" and its fixed?

Also are the Variables are the units?
 
Does it work like a coordinate plane? i bumped them up to the 200s and its still right next to the center.

Yes, it does.

all i need to do is type in "RemoveLocation" and its fixed?

Well, you'll need to somehow access those points so that you could remove them. See Memory Leaks.

Also are the Variables are the units?

With what you have now, yes. The variables are just generated variables, generated when you click on a unit as a parameter of sorts. You can declare a new variable with type point in the variable editor. (Ctrl+B)
 
Level 6
Joined
Aug 28, 2015
Messages
213
I think there is an easier(more visualised) way to do what you want you build your base with a template how you want it and place a region around it. then you save the data of it remove the template in the start of the map and just build it again by entering you region.
I made a testmap to show what I mean for all others here are the triggers.
  • PopUpBase SetUp
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • -------- Pick every unit in the region and add them to tempGroup --------
      • Set tempGroup = (Units in BaseSpawnRegion <gen>)
      • -------- now Pick every unit in the group to save their type and location --------
      • Unit Group - Pick every unit in tempGroup and do (Actions)
        • Loop - Actions
          • -------- Check here what kind of type you want to filter out --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A structure) Equal to True
              • (Owner of (Picked unit)) Not equal to Neutral Passive
            • Then - Actions
              • -------- save the unit data --------
              • Set popUPBase_UnitTypes[popUpBase_IndexMax] = (Unit-type of (Picked unit))
              • Set popUpBase_Locations[popUpBase_IndexMax] = (Position of (Picked unit))
              • -------- count the amount of the units inside the area --------
              • Set popUpBase_IndexMax = (popUpBase_IndexMax + 1)
              • -------- Remove unit so it looks like they never existed before you enter the region --------
              • Unit - Remove (Picked unit) from the game
            • Else - Actions
      • -------- Remove the leaks --------
      • Custom script: call DestroyGroup(udg_tempGroup)
      • Trigger - Remove PopUpBase SetUp <gen> from the trigger queue
  • PopUpBase Activate
    • Events
      • Unit - A unit enters ActivationRegion <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Blood Mage
    • Actions
      • -------- recreate the base how you build it before --------
      • For each (Integer popUpBase_Index) from 0 to popUpBase_IndexMax, do (Actions)
        • Loop - Actions
          • Unit - Create 1 popUPBase_UnitTypes[popUpBase_Index] for Player 1 (Red) at popUpBase_Locations[popUpBase_Index] facing Default building facing degrees
      • -------- Clean the Leaks --------
      • -------- I'm not 100% sure if this works like this for arrays so read maybe some tutorials about this --------
      • For each (Integer popUpBase_Index) from 0 to popUpBase_IndexMax, do (Actions)
        • Loop - Actions
          • Custom script: call RemoveLocation(udg_popUpBase_Locations[udg_popUpBase_Index])
          • Custom script: set udg_popUpBase_Locations[udg_popUpBase_Index] = null
          • Set popUPBase_UnitTypes[popUpBase_Index] = No unit-type
      • Trigger - Remove PopUpBase Activate <gen> from the trigger queue
 

Attachments

  • PopUpBase.w3x
    10.1 KB · Views: 33
Level 5
Joined
Jan 15, 2018
Messages
128
Thanks for the help, ill read up on it and see if i can fix it.

Apsyll, that is a pretty complex trigger, its beyond me. Does that version leak less than the other one? or are they the same? im not quite adavanced enough for that, but im sure ill get there. Thanks for the tutorial it is very helpful!
 
Last edited:
Level 5
Joined
Jan 15, 2018
Messages
128
upload_2018-7-11_9-40-0.png


Here is the trigger in its entirety. So i get you need to remove objects you dont need anymore, but im confused on which objects that would be. Once the actions happen and the units are there, i need to remove all of the units? Wouldn't that remove the base?

Is this the correct function? Set tempGroup = (Units in BaseSpawnRegion <gen>)
and then just remvoe those?
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Be aware that 1 Warcraft III terrain tile is exactly 128x128 game units. Each terrain tile is made up of 4x4 cells which are 32x32 each. A distance of {-17, -4} is smaller than even a single cell.

Buildings have to be cell aligned as the pathing map is cell aligned.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
View attachment 302252

Here is the trigger in its entirety. So i get you need to remove objects you dont need anymore, but im confused on which objects that would be. Once the actions happen and the units are there, i need to remove all of the units? Wouldn't that remove the base?

Is this the correct function? Set tempGroup = (Units in BaseSpawnRegion <gen>)
and then just remvoe those?
Right, what they meant by memory leaks, was for the locations. SO, if you have:
  • Unit - Create Footman for Player 1(Red) at Centre of Map area facing 100.00 Degree
You are leaking a location.
You need to do:
  • Set TempPoint = Centre of Map area
  • Unit - Create Footman for Player 1(Red) at TempPoint facing 100.00 Degree
  • Custom script: Call RemoveLocation(udg_TempPoint)
Now, TempPoint is a global variable that you have to create yourself. This is done from the variable manager on top of the trigger editor which has the icon of a yellow X.

notice that insideteh custom script it is called udg_TempPoint instead of just TempPoint
udg
stands for User Defined Global and that is present in custom scripts (JASS) when working with udg variables. In GUI (Triggers) you cannot use other variables than udg_ and <gen>, in jass there are a few other types that you may use.

Ok, you have to do this for each new point that you use:
  • Set TempPoint1 = Centre of Rhudaur <gen>
  • Unit - Create Footman for Player 1(Red) at TempPoint1 facing 100.00 Degree
  • Set TempPoint2 = TempPoint1 offset by (450.00, 500.00)
  • Unit - Create Footman for Player 1(Red) at TempPoint2 facing 100.00 Degree
  • Custom script: Call RemoveLocation(udg_TempPoint2)
  • Set TempPoint2 = TempPoint1 offset by (-500.00, 500.00)
  • Unit - Create Footman for Player 1(Red) at TempPoint2 facing 100.00 Degree
  • Custom script: Call RemoveLocation(udg_TempPoint2)
  • And so on and so on...
  • Set TempPoint2 = TempPoint1 offset by (-1000.00, 200.00)
  • Unit - Create Footman for Player 1(Red) at TempPoint2 facing 100.00 Degree
  • Custom script: Call RemoveLocation(udg_TempPoint2)
  • Custom script: Call RemoveLocation(udg_TempPoint1)
Notice that TempPoint1 is deleted only at the end of the trigger.
This is because it is required to reference the offset of all other points.


Maybe I should also explain what memory leaks are real quick?

regards
-Ned
 
Level 5
Joined
Jan 15, 2018
Messages
128
Wow, that is extremly helpful, im starting to understand a little. How can i offset the TempPoint?

How is this one?

upload_2018-7-11_17-13-56.png
 
Level 13
Joined
May 10, 2009
Messages
868
You'll need to use two point variables. The second one will use the offset function.

Something like this:
  • Actions
    • Set tmpPoint = (Center of Rhudaur <gen>)
    • -------- ---- --------
    • Set tmpAnotherPoint = (tmpPoint offset by (X-Coordinate, Y-Coordinate))
    • Unit - Create 1 Footman for Player 4 (Purple) at tmpAnotherPoint facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_tmpAnotherPoint)
    • -------- ---- --------
    • Set tmpAnotherPoint = (tmpPoint offset by (X-Coordinate, Y-Coordinate))
    • Unit - Create 1 Footman for Player 4 (Purple) at tmpAnotherPoint facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_tmpAnotherPoint)
    • -------- ---- --------
    • Custom script: call RemoveLocation(udg_tmpPoint)
Also, since you are using the first point var for all of those actions, you don't need to re-assign and destroy the same value multiple times.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Wow, that is extremly helpful, im starting to understand a little. How can i offset the TempPoint?

How is this one?

View attachment 302316
Yea... no. :)
  • Unit - Create 6 Risen Warrior for Player 6 (purple) at (Centre of (Rhudaur <gen> oddset by (500.00, 500.00))) facing (Position of(Triggering unit))
(Centre of (Rhudaur <gen> oddset by (500.00, 500.00))) this part leaks 2 points and then (Position of(Triggering unit)) this leaks a 3rd one. Those actions create new points. So, what I am making you do is:
1st Save the point in a container
  • Set TempPoint = Centre of Region
2nd Use the saved point
  • Unit - Create Footman for Player 1(Red) at TempPoint facing 100.00 Degree
3rd Clear container
  • Custom script: Call RemoveLocation(udg_TempPoint2)

SO! In your trigger you have a centre of region that you are using for all spawning.
In that case you do:
1st - Save centre of region into a container
  • Set TempPoint = Centre of Region
2nd - Save spawn point with offset from region
  • Set TempPoint2 = TempPoint1 offset by (450.00, 500.00)
3rd - Use the point
  • Unit - Create Footman for Player 1(Red) at TempPoint2 facing 100.00 Degree
4th - Clear container
  • Custom script: Call RemoveLocation(udg_TempPoint2)
And then for each spawn you repeat 2nd > 3rd > 4th
When you are done with the spawning in this region you 5th - Clear the initial container
  • Custom script: Call RemoveLocation(udg_TempPoint1)


So, your trigger would be:

1st >>>
2nd > 3rd > 4th >>>
2nd > 3rd > 4th >>>
2nd > 3rd > 4th >>>
2nd > 3rd > 4th >>>
2nd > 3rd > 4th >>>
2nd > 3rd > 4th >>>
5th

I have grouped those a bit for readability purposes.

PS: Instead of taking screenshots you can post your triggers directly.
You can right-click the trigger and there should be an option saying "Copy as text".
Then in your post you write trigger tags
Code:
[trigger]Paste trigger here between[/trigger]

Hope this helps!
-Ned
 
Level 5
Joined
Jan 15, 2018
Messages
128
  • Actions
    • Set TempPoint1 = ((Center of Rhudaur <gen>) offset by (100.00, 0.00))
    • Unit - Create 1 Rhudaur for Player 4 (Purple) at TempPoint1 facing 180.00 degrees
    • Set TempPoint2 = (TempPoint1 offset by (400.00, 500.00))
    • Unit - Create 6 Risen Warrior for Player 4 (Purple) at TempPoint2 facing 180.00 degrees
    • Custom script: call RemoveLocation(udg_TempPoint2)
    • Set TempPoint2 = (TempPoint1 offset by (-500.00, 500.00))
    • Unit - Create 6 Footman for Player 4 (Purple) at TempPoint2 facing 180.00 degrees
    • Custom script: call RemoveLocation(udg_TempPoint2)
    • Set TempPoint2 = (TempPoint1 offset by (500.00, -910.00))
    • Unit - Create 1 Barrow for Player 4 (Purple) at TempPoint2 facing 180.00 degrees
    • Custom script: call RemoveLocation(udg_TempPoint2)
    • Set TempPoint2 = (TempPoint1 offset by (-300.00, 350.00))
    • Unit - Create 1 Tower of Angmar for Player 4 (Purple) at TempPoint2 facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_TempPoint2)
    • Set TempPoint2 = (TempPoint1 offset by (-300.00, -350.00))
    • Unit - Create 1 Tower of Angmar for Player 4 (Purple) at TempPoint2 facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_TempPoint2)
    • Custom script: call RemoveLocation(udg_TempPoint1)
ok, i think i got it. How does this look?
 
Last edited:
Level 12
Joined
Mar 24, 2011
Messages
1,082
  • Actions
    • Set TempPoint1 = ((Center of Rhudaur <gen>) offset by (100.00, 0.00))
    • Unit - Create 1 Rhudaur for Player 4 (Purple) at TempPoint1 facing 180.00 degrees
    • Set TempPoint2 = (TempPoint1 offset by (400.00, 500.00))
    • Unit - Create 6 Risen Warrior for Player 4 (Purple) at TempPoint2 facing 180.00 degrees
    • Custom script: call RemoveLocation(udg_TempPoint2)
    • Set TempPoint2 = (TempPoint1 offset by (-500.00, 500.00))
    • Unit - Create 6 Footman for Player 4 (Purple) at TempPoint2 facing 180.00 degrees
    • Custom script: call RemoveLocation(udg_TempPoint2)
    • Set TempPoint2 = (TempPoint1 offset by (500.00, -910.00))
    • Unit - Create 1 Barrow for Player 4 (Purple) at TempPoint2 facing 180.00 degrees
    • Custom script: call RemoveLocation(udg_TempPoint2)
    • Set TempPoint2 = (TempPoint1 offset by (-300.00, 350.00))
    • Unit - Create 1 Tower of Angmar for Player 4 (Purple) at TempPoint2 facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_TempPoint2)
    • Set TempPoint2 = (TempPoint1 offset by (-300.00, -350.00))
    • Unit - Create 1 Tower of Angmar for Player 4 (Purple) at TempPoint2 facing Default building facing degrees
    • Custom script: call RemoveLocation(udg_TempPoint2)
    • Custom script: call RemoveLocation(udg_TempPoint1)
ok, i think i got it. How does this look?
One last thing.

  • ((Center of Rhudaur <gen>) offset by (100.00, 0.00))
This contains 2 points.

1st point is: (Center of Rhudaur <gen>) - You can read this as "Create a point in middle of region"
2nd point is: ((Center of Rhudaur <gen>) offset by (100.00, 0.00)) You can read this as "Create a point in the middle of a region and then create a second point with difference 100.00 on X and 0.00 on Y of the previously created point"

Your TempPoint1 would be (Center of Rhudaur <gen>)
And TempPoint2 would be offset from TempPoint1, meaning: (TempPoint1 offset by (100.00, 0.00)) - Now you can read this as "Create a point with difference 100.00 on X and 0.00 on Y from an already existing point"

regards
-Ned
 
Level 5
Joined
Jan 15, 2018
Messages
128
This world needs more superheroes like you Ned. Thank you for your patience.

Now since I am removing these TempPoints at the end, can I reuse them for other pop-up bases I would like to create?
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Now since I am removing these TempPoints at the end, can I reuse them for other pop-up bases I would like to create?
Yes, of course.

You can imagine them like buckets holding water.
When they are empty you can fill them with new water.
If they are full and you try to use them, you have to poor the water in your feet.
If you properly dispose the water through the drainage first, you are ok.

Edit// You are also bound to the bottom of a pool and if you poor enough water in your feet you are going to drown...

regards
-Ned
 
Level 5
Joined
Jan 15, 2018
Messages
128
Im trying to create another base type like this. Except its a researchable event(player presses button and then the base show up). I dont understand the dialog buttons, how they work and how they show up in a building.

Here it is so far:

  • Gtunnel
    • Events
      • Dialog - A dialog button is clicked for Gtunnels
    • Conditions
      • (Clicked dialog button) Equal to Gundatun
    • Actions
      • Set TempPoint1 = (Center of (Playable map area))
      • Unit - Create 1 Orc Stronghold (angmar) for Player 4 (Purple) at TempPoint1 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_TempPoint1)
The button clicked is not the same as the button in the conditions. it made me create a new variable for it.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Im trying to create another base type like this. Except its a researchable event(player presses button and then the base show up). I dont understand the dialog buttons, how they work and how they show up in a building.

Here it is so far:

  • Gtunnel
    • Events
      • Dialog - A dialog button is clicked for Gtunnels
    • Conditions
      • (Clicked dialog button) Equal to Gundatun
    • Actions
      • Set TempPoint1 = (Center of (Playable map area))
      • Unit - Create 1 Orc Stronghold (angmar) for Player 4 (Purple) at TempPoint1 facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_TempPoint1)
The button clicked is not the same as the button in the conditions. it made me create a new variable for it.
Show us the trigger where you have set up the dialog ?

-Ned
 
Level 6
Joined
Aug 28, 2015
Messages
213
When you want it to be a research then you don't need any dialogs
You would need a custom research and give it to a unit the player can access at the time you want them to creat the second base.
The trigger would be then:
Action
Generic unit finishes research
Condition
Research equal YourResearch
Action
... Build the second base like the first one.
 
Level 5
Joined
Jan 15, 2018
Messages
128
Ohhhhh gotcha. I had no idea how to do it and blindly threw a trigger together. thanks apsyll.

when they say dialog do they mean dialog as in talking? i thought the buttons (abilites units ect..) were dialog buttons.

sorry i was totally lost, there arent many good guides out there.
 
Level 5
Joined
Jan 15, 2018
Messages
128
  • Gtunnel
    • Events
      • Unit - A unit owned by Player 4 (Purple) Finishes an upgrade
    • Conditions
      • (Researched tech-type) Equal to Tunnels of Gundabad (Undead)
Here it is, without the unit spawn parts. Cant seem to get it to work though.

On a side note would you mind taking a look at a separate trigger ive been working on?
 
Level 5
Joined
Jan 15, 2018
Messages
128
  • FellbeastA
    • Events
      • Unit - A unit enters FellbeastA <gen>
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to The Necromancer
    • Actions
      • Set TempPoint1 = (Center of FellbeastA <gen>)
      • Unit - Create 3 Fell Beast for Neutral Hostile at TempPoint1 facing 250.00 degrees
      • Unit - Change ownership of Tame the Fellbeasts 0742 <gen> to Player 4 (Purple) and Change color
      • Custom script: call RemoveLocation(udg_TempPoint1)
this one works fine but it is lacking.

the goal of the trigger is that the faction purple kills the fellbeasts then is able to train them. But i cant put them as basic creeps because if someone else kills them then, they would still gain the ability to train them. So they have to spawn in, but then i cant target them for a variable or a "unit dies" event.

Fixed the previous one, stupid mistake, thanks.
 
Level 6
Joined
Aug 28, 2015
Messages
213
This could be solved in different ways I think the easiest is modifieing your trigger above to
Set point...
For Index 1 to 3
- create 1 Fellbeast...
-add last created unit to group beastGroup
Unit change owner..
RemoveLocation...

Then with the other trigger
Event
Generic unit dies
Condition
Unit is in group beastGroup equal true
Action
If integer units in group beastGroup equal 1
//The last one is killed so you can add the training action here
Also destroy the group because you won't need it anymore see things that leak ;)
Else
Remove unit from group triggering unit from beastGroup.
 
Level 5
Joined
Jan 15, 2018
Messages
128
upload_2018-7-11_9-40-0-png.302252


Been doing some testing and it turns out this happens every time "The Necromancer" Enters the Region. How can i make it so it only happens one time?
 
Level 39
Joined
Feb 27, 2007
Messages
5,011
@Ragnar9 Almost right, but you need to set a point variable before creating each unit, then remove the point before setting it again. There's a "turn off this trigger" command to stop it from running again.
  • Set TP1 = (Center of Rhudaur <gen)
  • Set TP3 = Position of (Triggering Unit)
  • Set TP2 = TP1 offset by (0.00, 0.00) //this is unnecessary for the first one (just use TP1 instead), but to show the format
  • Unit - Create 1 Rhudaur for Player 4 (Purple) at TP2 facing 180.00 degrees
  • Custom script: call RemoveLocation(udg_TP2)
  • Set TP2 = TP1 offset by (450.00, 500.00)
  • Unit - Create 6 Risen Warrior for Player 4 (Purple) at TP2 facing TP3
  • Custom script: call RemoveLocation(udg_TP2)
  • -------- and so on for all units --------
  • Custom script: call RemoveLocation(udg_TP1)
  • Custom script: call RemoveLocation(udg_TP3)
  • Trigger - turn off (this trigger)
 
Level 5
Joined
Jan 15, 2018
Messages
128
Sorry i posted the early version of the trigger, i figured out the points, and variable stuff along with the custom scrip thanks to Ned and apsyll.

So all i need to do, to make it a one time thing, is that last line?

Trigger - turn off (this trigger)
 
Status
Not open for further replies.
Top