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

[Trigger] Generating an Animal Enclosure

Status
Not open for further replies.
Level 4
Joined
May 16, 2004
Messages
76
I have been trying to create a trigger that generates a square shaped animal enclosure (from doodad fences). The reason why doodad fences are used, is the fact that the pathing map can be rotated to the angle that the fence faces. An enclosure of this type will be used to keep critters from wandering away and predators from getting in.

Now there are two types of fences that are used in generating the enclosure. Fence Vertical (Fence doodad rotated Vertically) and Fence Horizontal (Self Explanatory).

The enclosure is generated right after being built and I have attached a screenshot as to my problem. The left enclosure is one i constructed in the world editor ( it has perfect dimensions ). The right one is the resulting enclosure from my trigger. As you can see it is not quite a perfect square.

Here is the current trigger data i have made for this (not leakproof yet) and i am wondering as how would i fix it to make it a perfect square enclosure?

  • Fence Construction
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Livestock Pen [Actual]
    • Actions
      • Set TempPlayer = (Owner of (Constructed structure))
      • Set TempPoint = (Position of (Constructed structure))
      • Set Point_FenceEnclosure = (TempPoint offset by 256.00 towards 90.00 degrees)
      • Destructible - Create a Fence Horizontal at (Point_FenceEnclosure offset by 128.00 towards 180.00 degrees) facing (Random angle) with scale 1.00 and variation 0
      • Destructible - Create a Fence Horizontal at (Point_FenceEnclosure offset by 128.00 towards 0.00 degrees) facing (Random angle) with scale 1.00 and variation 0
      • Set Point_FenceEnclosure = (TempPoint offset by 256.00 towards 270.00 degrees)
      • Destructible - Create a Fence Horizontal at (Point_FenceEnclosure offset by 128.00 towards 180.00 degrees) facing (Random angle) with scale 1.00 and variation 0
      • Destructible - Create a Fence Horizontal at (Point_FenceEnclosure offset by 128.00 towards 0.00 degrees) facing (Random angle) with scale 1.00 and variation 0
      • Set Point_FenceEnclosure = (TempPoint offset by 256.00 towards 0.00 degrees)
      • Destructible - Create a Fence (Vertical) at (Point_FenceEnclosure offset by 128.00 towards 90.00 degrees) facing (Random angle) with scale 1.00 and variation 0
      • Destructible - Create a Fence (Vertical) at (Point_FenceEnclosure offset by 128.00 towards 270.00 degrees) facing (Random angle) with scale 1.00 and variation 0
      • Set Point_FenceEnclosure = (TempPoint offset by 256.00 towards 180.00 degrees)
      • Destructible - Create a Fence (Vertical) at (Point_FenceEnclosure offset by 128.00 towards 90.00 degrees) facing (Random angle) with scale 1.00 and variation 0
      • Destructible - Create a Fence (Vertical) at (Point_FenceEnclosure offset by 128.00 towards 270.00 degrees) facing (Random angle) with scale 1.00 and variation 0
debugenclosure.jpg


This may be a tough problem, all help is greatly appreciated. :thumbs_up:
 
Level 8
Joined
Aug 4, 2006
Messages
357
i think the problem is that your (Position of (Constructed structure)) is not exactly in the middle of a pathing square. to fix this, you'd need to do some math involving rounding each coordinate of TempPoint to the nearest 32 pixels. try this (i also fixed leaks):
  • Fence Construction
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Livestock Pen [Actual]
    • Actions
      • Set TempPlayer = (Owner of (Constructed structure))
      • Set TempPoint = (Position of (Constructed structure))
      • Set TempPointX = (X of TempPoint)
      • Set TempPointY = (Y of TempPoint)
      • Custom script: call RemoveLocation(TempPoint)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempPointX Greater than or equal to 0.00
        • Then - Actions
          • Custom script: set udg_TempPoint2X = I2R(R2I( ( udg_TempPointX + ( 16 ) ) / 32 )) * 32
        • Else - Actions
          • Custom script: set udg_TempPoint2X = I2R(R2I( ( udg_TempPointX - ( 16 ) ) / 32 )) * 32
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempPointY Greater than or equal to 0.00
        • Then - Actions
          • Custom script: set udg_TempPoint2Y = I2R(R2I( ( udg_TempPointY + ( 16 ) ) / 32 )) * 32
        • Else - Actions
          • Custom script: set udg_TempPoint2Y = I2R(R2I( ( udg_TempPointY - ( 16 ) ) / 32 )) * 32
      • Set TempPoint2 = Point( TempPoint2X, TempPoint2Y )
      • Set Point_FenceEnclosure = (TempPoint2 offset by 256.00 towards 90.00 degrees)
      • Set TempPoint = (Point_FenceEnclosure offset by 128.00 towards 180.00 degrees)
      • Custom script: call RemoveLocation(Point_FenceEnclosure)
      • Destructible - Create a Fence Horizontal at TempPoint facing (Random angle) with scale 1.00 and variation 0
      • Custom script: call RemoveLocation(TempPoint)
      • Set TempPoint = (Point_FenceEnclosure offset by 128.00 towards 0.00 degrees)
      • Destructible - Create a Fence Horizontal at TempPoint facing (Random angle) with scale 1.00 and variation 0
      • Custom script: call RemoveLocation(TempPoint)
      • Set Point_FenceEnclosure = (TempPoint2 offset by 256.00 towards 270.00 degrees)
      • Set TempPoint = (Point_FenceEnclosure offset by 128.00 towards 180.00 degrees)
      • Custom script: call RemoveLocation(Point_FenceEnclosure)
      • Destructible - Create a Fence Horizontal at TempPoint facing (Random angle) with scale 1.00 and variation 0
      • Custom script: call RemoveLocation(TempPoint)
      • Set TempPoint = (Point_FenceEnclosure offset by 128.00 towards 0.00 degrees)
      • Destructible - Create a Fence Horizontal at TempPoint facing (Random angle) with scale 1.00 and variation 0
      • Custom script: call RemoveLocation(TempPoint)
      • Set Point_FenceEnclosure = (TempPoint2 offset by 256.00 towards 0.00 degrees)
      • Set TempPoint = (Point_FenceEnclosure offset by 128.00 towards 90.00 degrees)
      • Custom script: call RemoveLocation(Point_FenceEnclosure)
      • Destructible - Create a Fence (Vertical) at TempPoint facing (Random angle) with scale 1.00 and variation 0
      • Custom script: call RemoveLocation(TempPoint)
      • Set TempPoint = (Point_FenceEnclosure offset by 128.00 towards 270.00 degrees)
      • Destructible - Create a Fence (Vertical) at TempPoint facing (Random angle) with scale 1.00 and variation 0
      • Custom script: call RemoveLocation(TempPoint)
      • Set Point_FenceEnclosure = (TempPoint2 offset by 256.00 towards 180.00 degrees)
      • Set TempPoint = (Point_FenceEnclosure offset by 128.00 towards 90.00 degrees)
      • Custom script: call RemoveLocation(Point_FenceEnclosure)
      • Destructible - Create a Fence (Vertical) at TempPoint facing (Random angle) with scale 1.00 and variation 0
      • Custom script: call RemoveLocation(TempPoint)
      • Set TempPoint = (Point_FenceEnclosure offset by 128.00 towards 270.00 degrees)
      • Destructible - Create a Fence (Vertical) at TempPoint facing (Random angle) with scale 1.00 and variation 0
      • Custom script: call RemoveLocation(TempPoint)
      • Custom script: call RemoveLocation(TempPoint2)
you need to make 3 more variables for this to work: point TempPoint2, real TempPoint2X, real TempPoint2Y.

let me know if this works.
 
Level 4
Joined
May 16, 2004
Messages
76
Ok, i tried your method but to no avail it still comes out weird. I have a question that might help to the solution, the fences are an 8x2 Pathing Map. So that would mean its an area of 16 Points, Correct?

Well i believe that my initial calculations are wrong, 256 was just a guess as to how far out the fences would need to be placed to have a nice 2 fence length square.

What type of maths would we need to implement to work out the placement of the fences from the center? The interior, free area would be 16x16 culminating to a total area of 256.
 
Level 8
Joined
Aug 4, 2006
Messages
357
okay i (think i) found the problem. 256 is not the right number. say we want to place a vertical fence, which is 8 squares long and 2 squares wide. if we want to get the x position of it, we need to go the full length of one fence from the center, plus an extra square. that's 8 squares + 1. since each square is 32 pixels, we need to go 32 x 9 pixels from the center (288).

so, all you have to do is replace all the 256 with 288.
 
Status
Not open for further replies.
Top