Builder displacement

Level 1
Joined
Feb 3, 2021
Messages
4
Hei!

I currently need some help with a problem I have and I hope to find it here. The problem is that my workers keep teleporting over the trees.
Worker: Is an human worker but has the undead race.
Building: Is a human farm but has the night elf race.
upload_2021-2-3_18-30-16.png


Is there an easy fix for this?
 

Uncle

Warcraft Moderator
Level 48
Joined
Aug 10, 2018
Messages
4,653
You can place a Pathing Blocker (doodad) in the spots where units could get stuck.

Press "P" in the World Editor to view Pathing, you'll see a bunch of pink tiles appear which represent blocked pathing. Any gaps you see are places that your units can get stuck so you should fill them with pathing blockers or move the doodads around to close the gaps.
 
Last edited:
Level 1
Joined
Feb 3, 2021
Messages
4
The game is about hiding in the forest. The workers in this case can cut trees and find a good place to hide. The ones hunting them, can't cut the trees, meaning they have to find the openings. If a worker would to tree jump like this, there is no way for the hunter to reach it, which would give the workers an unfair advantage.

So placing a pathing blocker on every tree opening in the map, would not be a fix, since then the workers, if they would to cut the tree, couldn't get into the forest.
 
Level 11
Joined
Feb 5, 2018
Messages
485
If the unit has no place to be moved into after building something or being trained or such, it will be moved to the nearest available position by default.

I remember having units stuck back in the days playing melee warcraft when I cornered a barracks. The first footman got stuck. And the new ones were not, because the place was already filled by the first footman trained. So technically it's not really a bug or anything. Just unit placement.

Also remember playing vampfire not so long ago, the map has a short blink item, which could be abused by spamming the blink into an "unwalkable" location and then go over multiple structures, because the unit cannot be placed into a certain spot, so it moves to the nearest available spot once again.
 

Uncle

Warcraft Moderator
Level 48
Joined
Aug 10, 2018
Messages
4,653
It's quite difficult to detect "stuck" units but I imagine some kind of system could be thrown together.

In this case maybe have a trigger that runs after a worker begins or finishes construction depending on the build-type.

After it's begun/finished construction, create a "dummy" unit at the Worker's current position, then store the position of the dummy in a point variable, then remove the dummy unit, and finally move the worker to the stored point.

Note that when I say dummy unit I don't mean a unit with the Locust ability. In this case the dummy unit should have no abilities and a large collision size (64+).

So if the Worker is stuck like in your picture, the dummy unit will be created on top of it, but Warcraft 3's pathing system will kick in and shove the dummy unit to a nearby pathable point. This nearby point should hopefully be somewhere that won't get the Worker stuck again. Finally we remove the Dummy so it doesn't get in our way and move the Worker to that Point, hoping that we're no longer stuck (that is if we even were in the first place). It's not perfect but it may solve the issue most of the time.

The problem here is that it may offset the Workers too far from the structure which may be less than desirable. A potential solution would be to compare the Distance between these 2 units before you move the worker.

For example:
If Distance between Worker and Dummy is > 128 then Move the Worker, otherwise don't move it.

The actual value would probably need to be played around with. With this design you may not have to move the worker at all, since if the Dummy is close to the Worker then that implies that there was plenty of room and the Worker isn't stuck.

Also, you'll probably want to use SetUnitX/Y for the Worker when moving it so you don't interrupt it's orders. This way it'll continue building the structure even when moved.


Edit: I forgot that you can't get the Constructing Worker... You'll need a system to find the worker as well... Not so simple lol.

Edit 2: Attached a map with an example of what I described. It actually works pretty well, try it for yourself.

Mess around with the PD value, a lower value will make the Unstuck checker more strict. The more strict it is, the more likely it will try to move the Worker somewhere "pathable". You can also mess around with the size of the Pathing Checker unit. I imagine there's a sweet spot for these values but what I have it set to now seems to work just fine.

If you were to try and import this into your map there's a few things you need to know.
1) It's using a Unit Indexing system which requires the uDex ability (see Object Editor), this ability MUST have the rawcode "uDex". If you copy and paste it into your map, you NEED to set it's rawcode to "uDex".
2) It uses a custom unit called Pathing Checker (see Object Editor).
3) If you already have a Unit Indexing system in your map then I'll need to make a different version of this map that's compatible with it.
 

Attachments

  • Building Unstuck 1.w3m
    34.1 KB · Views: 15
Last edited:
Level 1
Joined
Feb 3, 2021
Messages
4
This seems to go in the right direction! Its no longer able to the tree jump. It did create a new issue, where the unit would sometimes teleport way too far away. Like for example, here:
upload_2021-2-5_15-3-12.png


X marks the spot where the builder was, then after he ended up down there.

Currently trying to make it so that if the unit travels so far, the building construction will be canceled and the worker will be returned back to the original location.
 
Level 1
Joined
Feb 3, 2021
Messages
4
After about 4 hours of trying and testing, I believe I found something. This insanely small trigger actually denies the builder from building on top of itself, making sure that you can't jump over trees or end up in random areas. It's not flawless, cause in some cases it should be alright to build on top of yourself, but for now, I'll roll with it.

upload_2021-2-5_16-33-2.png


Actually managed this on a mistake, because after unit - explode I made it so that the builder moved to location 1. But location 1 would always be over the trees. After testing the build range I forgot to put the 'move location' thing back in, and after testing, I had no idea why it worked the way it did.
 

Uncle

Warcraft Moderator
Level 48
Joined
Aug 10, 2018
Messages
4,653
You can try to play with the PD value/Collision Size of the Pathing Checker to get better results.

Your new trigger leaks a lot of Points and a Unit Group, and you'd probably want to cancel the structure, not explode it, so the player gets a refund.
 
Top