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

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