• 🏆 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] Restrict Building Area

Status
Not open for further replies.
Level 1
Joined
Jan 26, 2015
Messages
4
(Hang about: I just realised I posted this in the wrong section. How does one delete a post so I can repost it in the right section?)

What ho!

I'm having a bit of a tiff down here with my triggers, would highly appreciate your help!

Here's basically what I'd like the code to do:

- Unit begins construction
- Check if Constructing Structure is placed next to Unit-type of unit "Road" (It's a building.. Unit.. Same thing init? :p)
- If not, cancel construction, refund construction costs and show text message "You can only build next to a road" to triggering unit owner

Unfortunately I am unable to find anything that checks for nearby constructions and buildings. I tried working with a buff but that'd mean the constructing structure needs to have the buff and I assume it'd get destroyed before getting the buff unless I put down a wait section. But I feel as if it won't work. Might be wrong!

The idea comes from a game called Heroes and Empires on Warcraft III. Jolly inspiring stuff, I say!

Thanks in advance!
Pip pip

- Shinela
 
Last edited:
Level 11
Joined
Jan 2, 2016
Messages
472
Well here is an idea, though not so practical.

You could create three arrays.An array of units that would contain buildings, gold cost for each building, lumber cost for each building.You would have to set all these manually.

Then when an unit begins construction you kill the constructed unit, and match the constructed unit with the array and return its gold and lumber cost to the player.

EDIT: Forgot to mention, the condition you are looking for is:

  • Conditions
    • (Distance between ( Position of YourBuilding ) and ( Position of Road ) ) less than or equal to YourRange
Which is under real comparison.
 
Level 1
Joined
Jan 26, 2015
Messages
4
Well bugger me with a fishfork, I hadn't found that!

Thank you indeed, that will do. I'll be able to sort out the rest from here on!
 
Status
Not open for further replies.
Top