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

How to prevent only certain player units from entering a region

Status
Not open for further replies.
Level 5
Joined
Dec 27, 2014
Messages
95
Good day!

Please, how can I make only (for example) Red and Blue player units not able to enter a region, while units of other players (even neutral) will be able to enter and pass through that specific region?

The situation is the following: I have created a mountain pass and I want to make some players not be able to move their units through that mountain pass, while the units of other players (creeps, for example) will be able to pass through it.

I am looking forward to your replies.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,185
Uhh, hard to make that happen without drawbacks.
Creating pathing blockers for the local player might work, I am not sure. If it does, it's probably the best solution.

You can make a loop and check units position. If the region contains the unit move it backwards. Something like:
Move unit to position of unit offset by 10 towards facing of unit - 180
 
Level 25
Joined
May 11, 2007
Messages
4,651
Pseudo code but you get the idea.

Events - A unit enters region
Conditions: Owner of unit == Player 1 or Owner of unit == Player 2
Actions:
set tempPoint1 = regionTeleportTo
Special effect - teleportation effect
Special effect destroy last effect
move unit to tempPoint1
cleanup tempPoint1

Both teleports and causes the unit to stop.

You didn't say anything about the AI of the units moving around the mountain pass, so I'm assuming the above should work for ya.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Uhh, hard to make that happen without drawbacks.
Creating pathing blockers for the local player might work, I am not sure. If it does, it's probably the best solution.

You can make a loop and check units position. If the region contains the unit move it backwards. Something like:
Move unit to position of unit offset by 10 towards facing of unit - 180
I am almost certain that local player pathing blockers will cause them to disconnect.

"Local player" is weird to explain lol. I'll put it this way. If we are both playing on my map together, on my computer, "GetLocalPlayer()" is me, but on yours, it is you. You can make different things happen for different people, but a lot of these things will cause the game to desync between players which will automatically disconnect them.
 
Level 5
Joined
Dec 27, 2014
Messages
95
Thank you, LordDz, for your entry. I have great reservations in relation to the teleportation of the units due to my intention to make the game look as much realistic as possible. I am afraid that I will have to avoid or let this by only my final option.

Thank you, SAUS. I did not know if the term "local player" has some sort of specific connotation in relation to the World Editor, so thank you for making this relation clearer to me, as well as explaining the context for my case.
 
Level 25
Joined
May 11, 2007
Messages
4,651
Your tower idea is ugly too :p

A different simple way would be to simply remove control of the unit when it enters the region and then order it to leave the region, by adding the ward classification and intercept its orders like in Castle Fight.
And then removing the ward classification and ordering when the unit leaves the region.

Or even simplier and shittier:
Change ownership of the unit, order it to move back, change ownership back when leaving the region.

So now you have:
Local units with a chance of crashes
Teleport
Tower
Order ward
Order player change
 
Level 5
Joined
Dec 27, 2014
Messages
95
A different simple way would be to simply remove control of the unit when it enters the region and then order it to leave the region, by adding the ward classification and intercept its orders like in Castle Fight.
And then removing the ward classification and ordering when the unit leaves the region.

Or even simplier and shittier:
Change ownership of the unit, order it to move back, change ownership back when leaving the region.

So now you have:
Local units with a chance of crashes
Teleport
Tower
Order ward
Order player change

Thank you, again, LordDz. I need to keep the ownership intact and not cause any operations which will interfere with the player´s control over the units. Specifically: There is a dangerous fighting to take place nearby that problematic location, and the fight can easily occur or move right next to that location, which will result in a possibility of an unintentional stepping to it.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,232
When a unit enters the region it is not allowed to then change ownership of it to a neutral player and order it away from the region until within a certain "safe" zone before returning ownership, displaying a message to the player such as "you are not allowed to enter". This looks natural as it uses the standard walking mechanic, it is commonly used in real games such as Legend of Zelda to prevent one from entering certain areas before intended.

Another approach is the "force wall". When a unit enters a region it is not allowed to then added it to a displacement group. This displacement group will be pushed away from the region every 0.03 (or 0.016) seconds using SetUnitX and SetUnitY natives (not available in GUI). Pushing continues until outside the region. Recommended push speed is at least 600 units per second so that maximum movement speed units cannot ignore the force. The result will appear that the unit is walking against a wall but constantly being pushed back. The nature of SetUnitX/Y means that orders are not interrupted so the player retains full control over the unit even when being pushed.
 
Level 5
Joined
Dec 27, 2014
Messages
95
When a unit enters the region it is not allowed to then change ownership of it to a neutral player and order it away from the region until within a certain "safe" zone before returning ownership, displaying a message to the player such as "you are not allowed to enter". This looks natural as it uses the standard walking mechanic, it is commonly used in real games such as Legend of Zelda to prevent one from entering certain areas before intended.

Another approach is the "force wall". When a unit enters a region it is not allowed to then added it to a displacement group. This displacement group will be pushed away from the region every 0.03 (or 0.016) seconds using SetUnitX and SetUnitY natives (not available in GUI). Pushing continues until outside the region. Recommended push speed is at least 600 units per second so that maximum movement speed units cannot ignore the force. The result will appear that the unit is walking against a wall but constantly being pushed back. The nature of SetUnitX/Y means that orders are not interrupted so the player retains full control over the unit even when being pushed.

Dr Super Good, I am afraid that a time needed for the change of ownership, moving away and returning of ownership will be (in case of my map) threatening, as players depend heavily on each other: if one of them looses control over their hero, they might not be able to take action vital for cooperation (healing, attack in critical moment, and other such cases).

If these are all the options, then I am, most probably, going to resort to the second option you, Dr Super Good, and previously Chaosy, have proposed. Thank you, Dr Super Good, for your entry and contribution.
 
Status
Not open for further replies.
Top