;// Shock Dust by Fishion
;//

?(!CFG_Addon_EXP_Shock_Dust):goto "ende"

_retard_time = _this select 1

;//************************************
;//********** LOD Section *************
;//************************************

;// Calculate Level of Detail
?((player distance (_this select 0))<= CFG_Addon_EXP_Shock_Dust_LOD1):goto "sm_300"
?(((player distance (_this select 0))> CFG_Addon_EXP_Shock_Dust_LOD1) && ((player distance (_this select 0))<= CFG_Addon_EXP_Shock_Dust_LOD2)):goto "LOD_1_2"
?(((player distance (_this select 0))> CFG_Addon_EXP_Shock_Dust_LOD2) && ((player distance (_this select 0))<= CFG_Addon_EXP_Shock_Dust_LOD3)):goto "LOD_2_3"

;// if player to far away don't show effect at all
?((player distance (_this select 0))> CFG_Addon_EXP_Shock_Dust_LOD3):goto "ende"

goto "LOD_end"

;//Set details.

;// distance under 300 m
#sm_300
;---------

_c_ratio = CFG_Addon_EXP_Shock_Dust_c_ratio

;------------- 300 m end
goto "LOD_end"


;// distance 300-600 m
#LOD_1_2
;---------

_c_ratio = (CFG_Addon_EXP_Shock_Dust_c_ratio/1.5)

;------------- 300-600 m end
goto "LOD_end"

;// distance 600-900 m
#LOD_2_3
;---------

_c_ratio = (CFG_Addon_EXP_Shock_Dust_c_ratio/2)

;------------- 600-900 m end
goto "LOD_end"

;//****************************************
;//********** LOD Section END *************
;//****************************************
#LOD_end

_max_radius = CFG_Addon_EXP_Shock_Dust_max_radius
_d_ratio = CFG_Addon_EXP_Shock_Dust_d_ratio
_circles = _max_radius/_c_ratio
_exp_speed = CFG_Addon_EXP_Shock_Dust_exp_speed
_w_time = _max_radius/_exp_speed
;//Size self explanatory
_size = [4, 7]

;color correction
_color1 = CFG_Addon_EXP_Shock_Dust_color1
_color2 = CFG_Addon_EXP_Shock_Dust_color2
_color3 = (CFG_Addon_EXP_Shock_Dust_color3 + [0])
_max_opacity = CFG_Addon_EXP_Shock_Dust_max_opacity
_mid_opacity = CFG_Addon_EXP_Shock_Dust_mid_opacity

;//Height off Ground
_height = 0.1

;//Normal lifetime
_lifetime = 6

;//Radius Factor & Radius init
_rad_r = _max_radius / _circles
_rad = 0

;//Wind
_Wind = CFG_Addon_EXP_Shock_Dust_Wind
_Wind_dir = CFG_Addon_EXP_Shock_Dust_Wind_dir
_Wind_var = 1
_Wind_dir_var = 20
_vel = [_Wind*sin(_Wind_dir),_Wind*cos(_Wind_dir),0]

;// calculate the opacity change along the radius
_max_op_rate = (_max_opacity / _circles)
_mid_op_rate = (_mid_opacity / _circles)

;// Position
_tank = _this select 0
_pos = getpos _tank
_x = _pos select 0
_y = _pos select 1


;//wating retard time
~_retard_time

;//Outer Loop
_j = 0
#loop
_rad = _rad + _rad_r
_drops = _rad*_d_ratio
_color = [(_color1 + [_max_opacity - _max_op_rate*_j]),(_color2 + [_mid_opacity - _mid_op_rate*_j]),_color3]
[CFG_Addon_EXP_Shock_Dust_lifetime,_vel,_rad,_height,_size,_color,_x,_y,_Wind_var,_Wind_dir_var,_drops] call CFG_Addon_EXP_Shock_Dust_make_circle

~_w_time

_j = _j + 1
?(_j < _circles):goto "loop"

#ende
exit