• 🏆 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!

[General] Structure building lockdown?

Status
Not open for further replies.
Level 12
Joined
Mar 6, 2008
Messages
1,057
I didn't really know how to name this one properly in the title, so yeah... I am planning to make a campaign where I'll ensure to have a unique type of resource gathering, not the usual Warcraft III style where workers chop trees down and such stuff. I'd, instead, want to have structures which would generate resources over time when having a player controlled structure would be built on top of them.

Now here goes how I planned it. It would suck to have a random "Lumber Mill" resource gathering structure placed somewhere where there are no forests at all. So I had an idea in my mind to have something like the Undead or Night Elf gold mine type of resource gathering structure.

To have pre-placed spots (such as default gold mines but in terms of circles of powers) which would define where certain buildings can be built on. For example I'd have pre-placed "Forest Region" structure near the woods, and players would be able to build "Lumber Mill" only on top of it. Now I've been looking around the Object Editor for such stuff, and haven't really found a solution.

Is there any way to have this possible without the use of triggers, or do I have to enhance such system with structure placing/building with them? Thanks in advance for your answers.
 
Level 11
Joined
Dec 19, 2012
Messages
411
Trigger still required, but only for checking whether the building do built correctly.

You would have "circle of power" to indicate the area which is able to build resource building . (circle of power would have no pathing texture, no collision, no placement requirement, basically equal to unit with locust ability I think, just selectable)

Next, here trigger comes, 2 options :
1. Check when building just started to build
2. Check when building completely built

After determine which option you want, with the event, pick unit in X range of position of building with Y type of circle power. If circle power doesn't exist, remove/destroy building, or continue build, but once finished would unable to gather any resources.

If you want to limit 1 resource building per circle power, simply modify X range to be a small value would works.
 
Level 12
Joined
Mar 6, 2008
Messages
1,057
Trigger still required, but only for checking whether the building do built correctly.

You would have "circle of power" to indicate the area which is able to build resource building . (circle of power would have no pathing texture, no collision, no placement requirement, basically equal to unit with locust ability I think, just selectable)

Next, here trigger comes, 2 options :
1. Check when building just started to build
2. Check when building completely built

After determine which option you want, with the event, pick unit in X range of position of building with Y type of circle power. If circle power doesn't exist, remove/destroy building, or continue build, but once finished would unable to gather any resources.

If you want to limit 1 resource building per circle power, simply modify X range to be a small value would works.
That is awesome! Thanks a lot, I am going to try that out definitely! Will post up how it went down, thanks a lot once again!
 
Level 12
Joined
Mar 6, 2008
Messages
1,057
What am I doing wrong here?

  • Lumber Mill Test
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Constructing structure)) Equal to (==) Lumber Mill
          • (Number of units in (Units in (Region centered at (Position of (Constructing structure)) with size (100.00, 100.00)) matching ((Unit-type of (Matching unit)) Equal to (==) Forest Region (Dummy)))) Greater than or equal to (>=) 1
        • Then - Actions
          • Game - Display to (All players) the text: You have properly p...
        • Else - Actions
          • Unit - Remove (Constructing structure) from the game
          • Game - Display to (All players) the text: You can only build ...
I have just did a quickie' for testing purposes. From my looks, it looks good and should determine whether the area contains supposed unit to allow player to build the wood gathering structure. However, it keeps telling me the message I've put under "Else" saying the following:
"You can only build the wood gathering structure on 'Forest Region' indicated spots."
 
Level 12
Joined
Mar 6, 2008
Messages
1,057
try increasing the size of the region until it works.

I have tried to increase the region measurement by 1000 as well. No help at all. Still keep getting the same message and building removed from the game. There seems to be a problem with the script not recognizing the dummy unit.

I have just seen that I've made it from "Peasant" and not a structure. Could that be the problem? However yes, that circle of power is unable to move at all or perform any actions. It's there just as a visible dummy so players would know where the post their stuff.
 
Level 12
Joined
Jan 2, 2016
Messages
973
Why don't you try something else?:
set some points (array) to the positions of the circles.
set them in the initialization "set point[0] to position of (some cirlce), set point[1] to (another circle), etc"
And when the worker begins construction - run loop from 0 to ~the amount of circles - 1~
and check if the distance between point[loop] is less than 100 from the position of the constructing structure. During that loop - if it's true - set some boolean to true, and after the loop - if the boolean is true do "then" actions, else do "else" actions.
Don't forget to re-set the boolean to false in the end of the trigger.
 
Level 12
Joined
Mar 6, 2008
Messages
1,057
Why don't you try something else?:
set some points (array) to the positions of the circles.
set them in the initialization "set point[0] to position of (some cirlce), set point[1] to (another circle), etc"
And when the worker begins construction - run loop from 0 to ~the amount of circles - 1~
and check if the distance between point[loop] is less than 100 from the position of the constructing structure. During that loop - if it's true - set some boolean to true, and after the loop - if the boolean is true do "then" actions, else do "else" actions.
Don't forget to re-set the boolean to false in the end of the trigger.

I'll see to come up with some system, yeah. Thanks for the help and guidelines!
 
If you need help with the refund part of the system let me know (vm).

Also, you may be able to do this is a much more simple way.

  • Lumber Mill Test
    • Events
      • Unit - A unit Begins construction
    • Conditions
    • Actions
      • Set TempLoc equals (position of (triggering unit))
      • Multiple Functions If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Constructing structure)) Equal to Lumber Mill
          • Multiple - Or
            • TempLoc is in region RegionName1
            • TempLoc is in region RegionName2
            • TempLoc is in region RegionName3
        • Then - Actions
        • Else - Actions
          • Unit - Remove (Constructing structure) from the game
          • Game - Display to (All players) the text: You can only build ...
            • Player - Add 200 gold to (triggering Player)
        • Custom script: call RemoveLocation(udg_TempLoc)
 
Level 11
Joined
Dec 19, 2012
Messages
411
@WereElf
Your suggestion would works, just would be problematic if there is large number of points.

@Legal_Ease
Your trigger would works too, just gonna be a large condition block if there is large number of regions.



Of course, if your points is less, solutions provided would would be fine.

For me, if there contains large number of circle of power (more than 100 as example)
I would just rather go and do like this :
  • Set temp_point = Position of (Constructing building)
  • Custom script: set bj_wantDestroyGroup=true
  • Unit Group - Pick every unit (Units within X of (temp_point)) and do actions
    • If (All Conditions are true) then do (Then actions) else do (Else actions)
      • If - Conditions
        • ------Conditions for checking put here-------
      • Then - actions
        • ------performs any actions that stratify the conditions------
      • Else - actions
        • ------performs any actions that not stratify the conditions------
  • Custom script: call RemoveLocation(udg_temp_point)
 
Last edited:
Level 12
Joined
Jan 2, 2016
Messages
973
Well, he could make the process automatic in the map initialization:
Unit Group - Pick every unit in playable map area
If picked unit is equal to circle of power then
set count = count + 1
set point[count] = position of picked unit

No need to set the points manually :p
 
Level 11
Joined
Dec 19, 2012
Messages
411
Well, it's about operator limit problem. Looping for continuously checking whether constructing building near a correct point is not a good solution.

A side note : If your map contains large amount of unit, the Unit Group - Pick every unit in playable map area have chance for hitting operation limit. And if creating a circle of power via trigger wouldn't get index automatically.

My solution provided would be much safer and easier.
 
Well, it's about operator limit problem. Looping for continuously checking whether constructing building near a correct point is not a good solution.

A side note : If your map contains large amount of unit, the Unit Group - Pick every unit in playable map area have chance for hitting operation limit. And if creating a circle of power via trigger wouldn't get index automatically.

My solution provided would be much safer and easier.

I like your solution if I understand it correctly. It picks every circle of power and indexes them. Then it checks to make sure the location of the build unit order is withing a range of the location of the circle of power. If distance is less than 100 then nothing (let the mill be built). If not, then remove the mill and issue the error message and refund the money.

Is that your idea? Because if so, then I like it!
 
Level 11
Joined
Dec 19, 2012
Messages
411
Well, my trigger is meant to pick for units within the X range of (Constructing building) instead of ALL circle of power, because if you have over 100 circle of powers, you still end up looping over 100 times for checking the constructing building position.

Picking unit within X range of (Constructing building) would decreases the looping amount to a very less amount (depends on the value of X), which would have more efficient/safer trigger.


But, if you only have (lets say 50), looping 50 times still consider as a safe amount, unless you have heavy functions inside the actions, continuously looping for 50 times for checking the distances still ok.
 
Well, my trigger is meant to pick for units within the X range of (Constructing building) instead of ALL circle of power, because if you have over 100 circle of powers, you still end up looping over 100 times for checking the constructing building position.

Picking unit within X range of (Constructing building) would decreases the looping amount to a very less amount (depends on the value of X), which would have more efficient/safer trigger.


But, if you only have (lets say 50), looping 50 times still consider as a safe amount, unless you have heavy functions inside the actions, continuously looping for 50 times for checking the distances still ok.

Even better. I will sign on to this as the best solution so far in the thread.

So, I think I have this right.

-----------------------------------------------------------

Event - A unit is issued an order targeting a point.

Condition - Order is equal to (build mill) ////you will need to find the order string////

Actions -
Set bool to CanBuildHere = false
Set target of order = tempPoint
Pick all units within x of tempPoint
If picked unit = type of unit (circle of power)
Then - Set bool to CanBuildHere = true

If CanBuildHere = true
then nothing (allow build)
If Else then
remove mill / refund gold
 
Status
Not open for further replies.
Top