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

"Create Units in random point in region" - creates units in "impossible" places

Status
Not open for further replies.
Level 4
Joined
Apr 29, 2020
Messages
59
I've been using the "create units in random point in region" for a cell-to-cell dungeon crawler that i am designing. I have discovered that the function is very literal in the sense that it will place a unit on a point whether that unit actually fits on that point or not. The biggest problem is it will create units on top of walls and in trees in places where the player cannot see the created unit. I know i can make separate regions between walls but im trying to err away from that as that makes replicating my script much more tedious and opens it up to bugs of other sorts. here is a picture of an example of the "create unit" points that are messing me up... if you need more details on exactly what it is im trying to do i'd be happy to share with you but im currently just looking for some way to make sure units dont get placed in impossible locations or at least to kill them if they are created there... i cannot find any sort of "terrain height" condition and while i might be able to use "terrain type" in my condition, i cannot figure out how to use it properly or even if it will work (given the specific cliff wall im working with does not belong to any of the terrain types of the map type). Im trying to figure out if i can use "within range of" for destructibles but im just not figuring it out. any help would be greatly appreciated :)
 

Attachments

  • help.png
    help.png
    1.6 MB · Views: 29
Would the use of a JASS System be suitable enough for the problem?
If so, you can use a pathing library to detect whether the creep can be placed there or not:
(Link to resource: PathingLib v1.6)

function IsTerrainWalkable takes real x, real y returns boolean

To perform the check, you'll have to use Custom Script, storing the random location to a variable
and using the x and y coordinates of said variable as parameters to said function.
So, it would look like this:

  • Set <random_loc> = (Random point in <region>)
  • Custom Script: set udg_<creep_flag> = IsTerrainWalkable(GetLocationX(udg_<random_loc>), GetLocationY(udg_<random_loc>))
  • -------- Now, we check if the unit can be created at that point --------
  • If (All Conditions are true) then do (Then - Actions) else do (Else - Actions)
    • If - Conditions
      • <creep_flag> Equal to True
    • Then - Actions
      • -------- Create the desired unit at that location --------
    • Else - Actions
  • -------- Clean up the random location --------
  • Custom Script: call RemoveLocation(udg_<random_loc>)
 
Level 4
Joined
Apr 29, 2020
Messages
59
Would the use of a JASS System be suitable enough for the problem?
If so, you can use a pathing library to detect whether the creep can be placed there or not:
(Link to resource: PathingLib v1.6)

function IsTerrainWalkable takes real x, real y returns boolean

To perform the check, you'll have to use Custom Script, storing the random location to a variable
and using the x and y coordinates of said variable as parameters to said function.
So, it would look like this:

  • Set <random_loc> = (Random point in <region>)
  • Custom Script: set udg_<creep_flag> = IsTerrainWalkable(GetLocationX(udg_<random_loc>), GetLocationY(udg_<random_loc>))
  • -------- Now, we check if the unit can be created at that point --------
  • If (All Conditions are true) then do (Then - Actions) else do (Else - Actions)
    • If - Conditions
      • <creep_flag> Equal to True
    • Then - Actions
      • -------- Create the desired unit at that location --------
    • Else - Actions
  • -------- Clean up the random location --------
  • Custom Script: call RemoveLocation(udg_<random_loc>)

ooof im a huge noob and a lot of what you've given me is a bit beyond me. I think i can write the exact script you have an image capture of for me but i do not know how to use JASS. can i import the resource you have posted into my map file? I'm sorry, i'm sure you dont want to hold my hand and walk me through this, where would be a good place for me to go in order to learn how to do this?
 
can i import the resource you have posted into my map file?

Of course.

where would be a good place for me to go in order to learn how to do this?

You might find the following tutorials useful:
As a footnote, global variables in GUI are appended with the following prefix: "udg_"
Every <> you see in the trigger example is a global variable
 
Level 4
Joined
Apr 29, 2020
Messages
59
@MyPad Ah, i figured it out. I did not need an outside script. However, you totally pointed me in the right direction.... I have yet to test it without "ISeeDeadPeople" but it totally works to use the Boolean>Environment>terrainwalkable function to accomplish what i need. i use the event: unit enters region (current camera bounds), condition: position of (triggering unit) of type walkability is off = true, event: kill unit. .... Its works as far as i can tell, its kind of hard to tell because it happens fairly rarely, but as i was chugging along i would occasionally come across a dead unit on top of a wall :D will keep testing and let you know how it works. thanks much
 
Level 4
Joined
Apr 29, 2020
Messages
59
Of course.



You might find the following tutorials useful:
As a footnote, global variables in GUI are appended with the following prefix: "udg_"
Every <> you see in the trigger example is a global variable
Excellent, thank you so much. i will be checking these out. I really have no programming experience so i'm a bit behind the curve here, but io feel my life will be made a whole lot easier once i have an understanding of how to create and use my own variables and custom scripts. thx again :)
 
Status
Not open for further replies.
Top