Jesus4Lyf
Good Idea™
- Reaction score
- 397
How so?
public method isWidgetBetweenCasterAndTarget takes widget whichWidget, real range returns boolean
local real x // using local x and y for target loc because the target could
local real y // have moved since this.targetX and this.targetY were set
local real distance
local real a // coefficient in the line equation Ax + By + C = 0
local real b // coefficient in the line equation Ax + By + C = 0
local real c // constant in the line equation Ax + By + C = 0
if this.targetWidget == null then
set x = this.targetX
set y = this.targetY
set distance = this.getDistanceToTargetPoint()
else
set x = GetWidgetX(this.targetWidget)
set y = GetWidgetY(this.targetWidget)
set distance = this.getDistanceToTargetWidget()
endif
set a = this.casterY() - y
set b = x - this.casterX()
set c = -(a*x + b*y)
return ( abs(a*GetWidgetX(whichWidget) + b*GetWidgetY(whichWidget) + c)/distance ) <= range
endmethod
public method getWidgetDistanceToLine takes widget whichWidget, real startX, real startY, real endX, real endY returns real
local real a=startY-endY
local real b=endX-startX
return abs(a*GetWidgetX(whichWidget)+b*GetWidgetY(whichWidget)-(a*startX+b*startY))/sqrt(a*a+b*b)
endmethod
public method getWidgetDistanceToLine takes widget whichWidget, real startX, real startY, real endX, real endY returns real
return abs((startY-endY)*GetWidgetX(whichWidget)+(endX-startX)*GetWidgetY(whichWidget)-((startY-endY)*startX+(endX-startX)*startY))/sqrt((startY-endY)*(startY-endY)+(endX-startX)*(endX-startX))
endmethod
And hence why such things are not in SpellStruct.but now it's totally irrelevant to SpellStruct