Unit gets stuck in cliff

SnowCrow

New Member
Reaction score
7
I have a hero respawn trigger which revives the hero in random location in the map. But theres a problem, because the hero might respawn inside cliff, getting stuck. Is there a solution to this?
I've thought of adding antistuck-regions to those cliffs, and when the unit enters it, it moves the unit elsewhere.
I guess there is easier way, could anyone help? :)
 

Lanboy

TH.net Regular
Reaction score
22
you might be able to do a terrain type check at the point. i dont know whether you can check for cliffs or not but yeah.
 

2-P

I will work hard tomorrow
Reaction score
325
There's a boolean comparison called "Environment - Terrain Pathing is off".

You can use it to check if the "Walkability" is off for example.
 

Ryuu

I am back with Chocolate (:
Reaction score
64
Try putting Pathing Blockers (Both) for every single part of your cliff. Then, in your trigger, put:

Code:
Hero Revival (One Trigger)
   Hero - Revive Hero Instantly at (Random Point in (Playable map area)

There, the hero will spawn anywhere except the cliff. But alternately, you could use anti-stuck regions, just like what you said :D
 

SnowCrow

New Member
Reaction score
7
There's a boolean comparison called "Environment - Terrain Pathing is off".

You can use it to check if the "Walkability" is off for example.

Thanks.
But now I don't know how to trigger it now. Could you guide me a bit how its done?
Code:
Woo 1
    Events
        Unit - A unit owned by Player 1 (Red) Dies
    Conditions
        (Player 1 (Red) slot status) Equal to Is playing
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Wait 5.00 seconds
        ?
 

Void

New Member
Reaction score
16
Pathing Check

Do a pathing check to see if the respawn area is walkable... I think its under boolean but it might be under something else...
 

SnowCrow

New Member
Reaction score
7
Yes I get it, but I don't get how to trigger it.
Code:
Actions
    Wait 5.00 seconds
    Hero - Instantly revive (Triggering Unit) at (Random Point of (Playable map area)), Hide revival graphics
Or must I create a point variable and revive the hero at it? But I still don't know how to do it.
 

Tom Jones

N/A
Reaction score
437
Set a variable to a random point on the map. Run the variable trough a pathing check. If it's true then revive the hero, if it's false pick a new random point.
 

SnowCrow

New Member
Reaction score
7
Damn, now I have another problem. I have these triggers:
Code:
Random Points
    Events
        Time - Every 1.00 seconds of game time
    Conditions
    Actions
        Set RandomPoint1 = (Random point in Respawn <gen>)
Respawn <gen> is a region that covers almost the whole playable area.

Code:
Woo 1
    Events
        Unit - A unit owned by Player 1 (Red) Dies
    Conditions
        (Player 1 (Red) slot status) Equal to Is playing
        ((Triggering unit) is A Hero) Equal to True
    Actions
        Wait 5.00 seconds
        Trigger - Run Respawn 1 <gen> (checking conditions)

Code:
Respawn 1
    Events
    Conditions
    Actions
        If ((Terrain pathing at RandomPoint1 of type Walkability is off) Equal to False) then do (Hero - Instantly revive (Triggering unit) at RandomPoint1, Hide revival graphics) else do (Trigger - Run (This trigger) (checking conditions))
        Camera - Pan camera for (Owner of (Triggering unit)) to (Position of (Triggering unit)) over 1.00 seconds
        Unit - Set mana of (Triggering unit) to 100.00%
        Unit - Make (Triggering unit) Invulnerable
        Wait 2.00 seconds
        Unit - Make (Triggering unit) Vulnerable

Now the problem is, almost everytime I test my map, and my hero dies, the whole WC crashes. This doesn't happen at every death, but more like every 3rd death. Any help?

//Omfg wtf, am I really so stupid that I use triggering unit in a trigger that doesnt have events. I copied it from the other trigger which had events. Lol! I'll fix it.
 

Rinpun

Ex TH Member
Reaction score
105
Even so, you might want to look at a better method. Creating a leaked location every second is ugly. You should try using reals instead of a location for a thing as simple as this. If you use the center x times two and center y times two you'll get the ranges of the reals. That is, you'll want to get a random real between negative center x times two and positive center x times two for the x coordinate and then you'll want to get a random real between negative center y times two and positive center y times two for the y coordinate.

Then again, if I remember it correctly, the "center" coordinates of WC3 are kind of fugged up. The center of the map is 0,0 and stuff like that, so you might want to play with getting the full x dimension and full y dimension of the rect (get the center, times it by two, and take the absolute value, then you can take its negative and positive to get an accurate random number).
 

SnowCrow

New Member
Reaction score
7
How could I fix the leak? I've never studied on leaks, so I don't know a lot about them.
 

Rinpun

Ex TH Member
Reaction score
105
You have to remove the location after you use it. However, for your current use, you can't really, because you might use it and you might not.

I'd suggest finding the random point of the respawn in the trigger that checks if it's walkable. Then you can call RemoveLocation(udg_RandomPoint1) using custom script after the execution of it's trigger (or before you rerun the trigger-I suggest you make that an if then else with multiple actions).
 
I

IKilledKEnny

Guest
Code:
custom script: loop
custom script: exitwhen IsTerrainPathableBJ(udg_location, PATHING_TYPE_WALKABILITY) == true
custom script: call RemoveLocation(udg_location)
custom script: set udg_location = GetRandomLocInRect(GetWorldBounds())
custom script: endloop
//Revive hero at location
custom script: call RemoveLocation(udg_location)
 

Rinpun

Ex TH Member
Reaction score
105
Should have a RemoveLocation(udg_location) before the set udg_location =.

Then there should be a RemoveLocation(udg_location) after "// revive hero at location". Other than that, using a loop is better than continuously running the trigger.
 
I

IKilledKEnny

Guest
Thank you Rinpun I forgot to add the leak removal. *Edited*
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top