# Damaging a line

Status
Not open for further replies.

#### Erkki2

Level 10
My spell has a line rotating around a point. How can I damage units who get, let's say, in 50 range of the line? How do I pick those units within the rectangle?

#### Erkki2

Level 10
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.

#### Maker

Level 37
You could post the map and/or the map. Auttais aika paljon

Usually that's a sing of a missing variable.

#### Erkki2

Level 10
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:

#### watermelon_1234

Level 14
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).

#### Erkki2

Level 10
Thanks, now it works. + rep

Status
Not open for further replies.

Replies
6
Views
698
Replies
12
Views
2K
Replies
18
Views
2K
Replies
16
Views
12K
Replies
14
Views
2K