I wanted to ask whether it is okay to use pre-loaded functions. What I mean by this is to create some functions beforehand and then use them in other spells. This significantly increases map saving time, so I wondered whether it can effect performance. Here is an example:
JASS:
#include "cj_types_priv.j"
hashtable h = InitHashtable()
group g = CreateGroup()
unit E = null
boolexpr Base
function Condition_Base takes player p,unit e returns boolean
return IsUnitEnemy(e,p) && !IsUnitType(e,UNIT_TYPE_DEAD) && !IsUnitType(e,UNIT_TYPE_STRUCTURE)
endfunction
function BaseBool takes nothing returns boolean
return GetUnitAbilityLevel(GetFilterUnit(),'Aloc') == 0 and not IsUnitType(GetFilterUnit(),UNIT_TYPE_DEAD) and not IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)
endfunction
function GetAngleBetweenPoints takes real x1, real x2, real y1, real y2 returns real
real result = bj_RADTODEG * Atan2(y2 - y1, x2 - x1)
return result
endfunction
function GetXWithOffset takes real x, real distance, real angle returns real
local real xWithOffset = x + distance * Cos(angle * bj_DEGTORAD)
return xWithOffset
endfunction
function GetYWithOffset takes real y, real distance, real angle returns real
local real yWithOffset = y + distance * Sin(angle * bj_DEGTORAD)
return yWithOffset
endfunction
function GetDistanceBetweenCoordinates takes real x1, real x2, real y1, real y2 returns real
local real dx = x2 - x1
local real dy = y2 - y1
return SquareRoot(dx * dx + dy * dy)
endfunction
function setUnitPosition takes unit u, real x, real y returns nothing
SetUnitX(u, x)
SetUnitY(u, y)
u = null
endfunction