• 🏆 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] You shall not pass!! The best way to stop units from passing certan areas

Which metod to use ?

  • 3) Waygates

    Votes: 0 0.0%
  • 4) Other. Please specify in post.

    Votes: 0 0.0%

  • Total voters
    14
  • Poll closed .
Status
Not open for further replies.
Level 12
Joined
Mar 24, 2011
Messages
1,082
So here is the situation: I got an area where the user player can build stuff. He can form parties with the units he has to explore the map.
Units can't leave the build area without being in a party
There is a max number of parties a user player can have at a time.
Parties stay together. ( Units dont strand )
There is a limit to the number of units which can join a party.

So a user player units can't leave the build area without being in a party but there are npc players (3 of them) which can atack the build areas of user players >> Their units need to be able to enter build areas.

So which is the best way to make some units able to pass through lets call it a gate and some can't.

I have a few ideas of my own but I would like to know if there is a better way and what i have to watch for.

Some of the ways I thought:
--1) Make them fully unpassable(cliffs/doodads/patchingblockers)and use regions to move units from side to side.
Cons I see : Hard to use. Needs to register a lot of regions or points. Would look ugly (the unit wont walk through but be tp through).
Pros I see: Well... ... ... it would work...

--2) Using patching blockers. The units which can pass will become flying.
Cons I see: Idk how that would look like. Will test sometime. Afraid to not fail with heights to make them look like ground units.
Pros: Easy and fast to use. Just paste some patchingblockers and some triggering (if making a flying unit look like ground isn't too complicated)

--3) Make them fully unpassable(cliffs/doodads/patchingblockers) and use Waygates.
Cons I see: Would look ugly (the unit won't walk through but be tp through (it would look a bit better than 1) ) ).
Pros I see: A lot less triggering and registering than 1).

--4) Other ideas ?

Edit//I would go with 2) but don't know if there would be any problems or if therr is a better way. I am asking because I am far away from the party system and units and npc players. If I was near it I would have tested right away.

Edit2// I see now that I named metod 2) Patching blockers. It should be Make units flying... idk how to edit polls if it's even possible...
 
Level 7
Joined
Nov 15, 2009
Messages
225
Regions :)

What about this way?

JASS:
scope BaseStay initializer Init

    globals
        group PartyGroup = CreateGroup()
    endglobals

    private function StayInBase takes nothing returns nothing
        local unit u = GetTriggerUnit()
        local player p = GetOwningPlayer(u)
        local real x
        local real y
        local real x2
        local real y2
        if GetOwningPlayer(u) != Player(11) and IsUnitInGroup(u, PartyGroup) != true then
            set x = GetUnitX(u)
            set y = GetUnitY(u)
            set x2 = GetStartLocationX(GetPlayerId(p))
            set y2 = GetStartLocationY(GetPlayerId(p))
            if GetLocalPlayer() == Player(GetPlayerId(p)) then
                call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 5, "|Cffff0000Unit is not in a party!|r" )
            endif
            call SetUnitOwner(u, Player(PLAYER_NEUTRAL_PASSIVE), false)
            call SetUnitPathing(u, false)
            call IssuePointOrder(u, "move", x2, y2)
            call TriggerSleepAction(SquareRoot(((x - x2) * (x - x2)) + ((y - y2) * (y - y2))) / GetUnitMoveSpeed(u))
            call SetUnitPathing(u, true)
            call SetUnitOwner(u, p, false)
        endif
        set u = null
        set p = null
    endfunction

    function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local region Region = CreateRegion()
        call RegionAddRect(Region, gg_rct_Army)
        call TriggerRegisterLeaveRegion(t, Region, null)
        call TriggerAddAction(t, function StayInBase)
    
        call BJDebugMsg("Select units and press esc to add them to party group.")
    
        set t = null
    endfunction

endscope
This is just an example, I don't recomment to switch units owner.
But you could teleport them to their base or whatever..
 

Attachments

  • StayInBase.w3x
    18.2 KB · Views: 61

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Use Gandalf!

A good region system would need to pull units back in (like a force sucks them back) to prevent the annoying "teleport" and look more professional. The idea would be to have 2 regions, one inside the other. When a unit leaves the outer region it gets pulled towards the centre of both regions with a simple projectile system trigger. When it then enters the smaller internal region you remove it from the projectile system stopping it.
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
As I read some of your posts I realised that I have totaly forgotten that there is a Unit leaves region event.
So it will be with regions.

@Dr Super Good Won't a projectile system be an overkill ?

Edit//@SeriousEnemy Something similar :) But I'll turn it in GUI...
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Yes but would avoid the ugly teleport effect.

Erm what about:

trig1
Event
unit leaves big region
Conditions
Unit type of trig unit != unit type which can pass
Action
Order trig unit to move to center of inner region
Add unit to unitgroup
Turn on trig2
Turn on trig3

trig2
Event
unit enters inner region
Action
Remove trig unit from unitgroup
If №of units in unitgroup = 0 turn off this trigger turn off trig 3

trig3
Event
Player selects a unit
Conditions
Trig unit is in unitgroup
Action
Clear selection for trig player

Edit// On the other hand I'd need to register all the regions and loop through them in trig1 or create a lot of triggers...
 
Last edited:
Why not use pathing blockers, have units that are not in a party be considered flying, and use blockers that ONLY block flying around the base, when a group of units join up as a party; replace them with ground versions, they can then seamlessly pass through the barriers.

If your buildings are only in the base; make the buildings also block air as well as ground to disallow units 'walking' inside them. If you use air units though... you'll have to get creative with the naval pathing 'channel'

Edit: This requires importing of pathing maps, this is easy to do and the maps are very small in filesize. (unless used for a giant blocker, like 128x128) Pathing Map Tut
 
Level 14
Joined
Oct 8, 2012
Messages
498
Here's mah test map, it sucks the a certain unit (Dr_Super_Good's idea) while the other units can travel freely. You can pretty much do this without using regions, but points instead, the area will be in circle though. I can make it if you want ;]

Btw, you can order the unit to stop while it's being sucked. Add in Loop trigger.
I wonder how to make the sucking movement smoother?
 

Attachments

  • Help - Wall Sucks.w3x
    14.7 KB · Views: 46

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Wouldn't that backfire if the unit has low ms or the user spams move command ? Or you mean it only for the Kyousuke Imadoris suggestion ?
No because it is always dragged towards the centre until within a certain distance (or region). Especially when using SetUnitX/Y with a period of 0.03 this would give the nice result of having the unit appear to keep walking out but not moving.
 
Why not just track all orders in the map and compare the order target position to the unit position?
If the order target is outside the allowed move area, simply issue a stop command.

Most elegant and easy solution.
No regions, no crappy move triggers, no problems.

As additional security, in case a unit is ordered to follow another unit, simply issue a move command back to the save zone when it reaches the door.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
Why not just track all orders in the map and compare the order target position to the unit position?
If the order target is outside the allowed move area, simply issue a stop command.
Until you order a group of units to the edge and find that they are starting to push each other outside...

As additional security, in case a unit is ordered to follow another unit, simply issue a move command back to the save zone when it reaches the door.
No mater how safe you make it, I am sure there are ways out.
 
Until you order a group of units to the edge and find that they are starting to push each other outside...
If that happens, you can always add the "when door area is reached, order the unit to walk back" thing.
No mater how safe you make it, I am sure there are ways out.
No there aren't. I used a script like that plenty of times and there is no way out.
Even if you spam click outside, the unit won't give a shit and just stand there.
 
Status
Not open for further replies.
Top