• 💀 Happy Halloween! 💀 It's time to vote for the best terrain! Check out the entries to Hive's HD Terrain Contest #2 - Vampire Folklore.❗️Poll closes on November 14, 2023. 🔗Click here to cast your vote!
  • 🏆 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!
  • 🏆 HD Level Design Contest #1 is OPEN! Contestants must create a maze with at least one entry point, and at least one exit point. The map should be made in HD mode, and should not be openable in SD. Only custom models from Hive's HD model and texture sections are allowed. The only exceptions are DNC models and omnilights. This is mainly a visual and design oriented contest, not technical. The UI and video walkthrough rules are there to give everyone an equal shot at victory by standardizing how viewers see the terrain. 🔗Click here to enter!

Damaging a line

Status
Not open for further replies.
Level 10
Joined
Jun 6, 2007
Messages
392
Thanks, that's what I was looking for. But how do I use it? When I copy that code in a trigger and call the function, I get an error (expected a name). Can it only be used in the same trigger? I'm not very experienced with jass.
 
Level 10
Joined
Jun 6, 2007
Messages
392
Here's the checking trigger
JASS:
// Returns a boolean that tells whether the point is inside a rectangle.
    // (px , py) = Point to check
    // (cx , cy) = lower left corner of the rect
    // (ax , ay) = upper left corner
    // (bx , by) = lower right corner
    function IsPointInRect takes real px , real py , real cx , real cy , real ax , real ay , real bx , real by returns boolean        
        local real dot1 = (px-cx)*(ax-cx) + (py-cy)*(ay-cy)
        local real dot2 = (ax-cx)*(ax-cx) + (ay-cy)*(ay-cy)
        local real dot3 = (px-cx)*(bx-cx) + (py-cy)*(by-cy)
        local real dot4 = (bx-cx)*(bx-cx) + (by-cy)*(by-cy)
        
        return dot1 >= 0 and dot1 <= dot2 and dot3 >= 0 and dot3 <= dot4
    endfunction


//===========================================================================
function InitTrig_IsPointInRect takes nothing returns nothing
    set gg_trg_IsPointInRect = CreateTrigger(  )

and on this line I call the function
  • Custom script: set udg_LightningWindmillRectCheck = call IsPointInRect (50, 50, 30, 60, 30, 20, 70, 20)
It's defined in one trigger, and I'm calling it from another trigger. Should it be in a library? I'd like to be able to open the map with original world editor, so I can't use vjass.
 
Last edited:
Level 14
Joined
Nov 18, 2007
Messages
1,084
Try putting
JASS:
    function IsPointInRect takes real px , real py , real cx , real cy , real ax , real ay , real bx , real by returns boolean        
        local real dot1 = (px-cx)*(ax-cx) + (py-cy)*(ay-cy)
        local real dot2 = (ax-cx)*(ax-cx) + (ay-cy)*(ay-cy)
        local real dot3 = (px-cx)*(bx-cx) + (py-cy)*(by-cy)
        local real dot4 = (bx-cx)*(bx-cx) + (by-cy)*(by-cy)
        
        return dot1 >= 0 and dot1 <= dot2 and dot3 >= 0 and dot3 <= dot4
    endfunction
in the map header (Click on your map icon with your map name near the top of the trigger editor).
 
Status
Not open for further replies.
Top