The only reason I am asking this is because I have been getting mixed signals on where or not this is MUI. I was looking over on another site and it seemed as though a script like mine (not a knockback one, just using struct arrays) is 100% MUI, but when posting on here I get the feeling that it isn't. So this time I'm making sure buy making a big deal out of it .
So heres my script as of now:
A clearly defined and definite answer will be greatly appreciated, and +repped.
So heres my script as of now:
JASS:
library KBS initializer Init
globals
// CONFIGURABLES:
private constant integer Dummy_id = 039;h000039; // This is the dummy unit.
private constant real Period = 0.03125 // Recommended Interval.
private constant real Radius = 150.00 // Radius for killing trees.
private constant string Attachment_point = "origin" // Attachment point for effects.
private constant string Water_SFX = "SlideWater.mdx" // Water slide effect.
private constant string Dirt_SFX = "Dust.mdx" // Ground slide effect.
endglobals
globals
private integer Total = 0
private integer array DataArray
private real Game_maxX
private real Game_minX
private real Game_maxY
private real Game_minY
private rect Rect1 = Rect(0.00,0.00,1.00,1.00)
private timer Timer = CreateTimer()
endglobals
private function KillEnumDestructables takes nothing returns nothing
call KillDestructable(GetEnumDestructable())
endfunction
// Thanks to PitzerMike for this function.
private function TreeCheck takes nothing returns boolean
local destructable dest = GetFilterDestructable()
local boolean bool = IsDestructableInvulnerable(dest)
local unit dummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),Dummy_id,GetDestructableX(dest),GetDestructableY(dest),0.00)
local boolean result = false
call UnitAddAbility(dummy,039;Ahrl039;)
if bool then
call SetDestructableInvulnerable(dest,false)
endif
set result = IssueTargetOrder(dummy,"harvest",dest)
call RemoveUnit(dummy)
if bool then
call SetDestructableInvulnerable(dest,true)
endif
set dest = null
set dummy = null
return result
endfunction
private struct Data
unit targ
real speed
real decrease
real sin
real cos
effect SFX
integer sfxmode
boolean killdest
// Checking for terrain type.
static method TerrainType takes unit u, string sfx returns integer
local real x = GetUnitX(u)
local real y = GetUnitY(u)
if sfx != "" and sfx != null then
return 0
elseif IsTerrainPathable(x,y,PATHING_TYPE_FLOATABILITY) then
return 1
elseif not IsTerrainPathable(x,y,PATHING_TYPE_WALKABILITY) then
return 2
endif
return 3
endmethod
static method create takes unit Target, real Startspeed, real Deceleration, real Angle, string Specialeffect, boolean Killtrees returns Data
local Data d
if Target == null or Startspeed <= 0.00 or Deceleration <= 0.00 then
call BJDebugMsg("Error: Invalid input in KBS_Begin") // Error message.
return 0
endif
// Allocates struct members to user defined variables.
set d = Data.allocate()
set d.targ = Target
set d.speed = Startspeed
set d.decrease = Deceleration
set d.sin = Sin(Angle)
set d.cos = Cos(Angle)
set d.killdest = Killtrees
set d.sfxmode = d.TerrainType(d.targ,Specialeffect)
// Adding effects to the unit.
if d.sfxmode == 0 then
set d.SFX = AddSpecialEffectTarget(Specialeffect,d.targ,Attachment_point)
elseif d.sfxmode == 1 then
set d.SFX = AddSpecialEffectTarget(Dirt_SFX,d.targ,Attachment_point)
elseif d.sfxmode == 2 then
set d.SFX = AddSpecialEffectTarget(Water_SFX,d.targ,Attachment_point)
elseif d.sfxmode == 3 then
call BJDebugMsg("Error: Unknown terrain type (KBS)")
endif
if Total == 0 then
call TimerStart(Timer,Period,true,function Data.Execute)
endif
set DataArray[Total] = integer(d)
set Total = Total + 1
return d
endmethod
static method Execute takes nothing returns nothing
local integer i = Total - 1
local Data d
local real x
local real y
local real newx
local real newy
loop
exitwhen i < 0
set d = Data(DataArray<i>)
set x = GetUnitX(d.targ)
set y = GetUnitY(d.targ)
if d.speed <= 0 or (x > Game_maxX or y > Game_maxY or x < Game_minX or y < Game_minY) then
call d.destroy() // Finish knockback if speed == 0 or unit has hit map borders.
set Total = Total - 1
if Total < 0 then
call PauseTimer(Timer)
set Total = 0
else
set DataArray<i> = DataArray[Total]
endif
else
set newx = x+d.speed*d.cos
set newy = y+d.speed*d.sin
call SetUnitPosition(d.targ,newx,newy)
if d.killdest then // Kills trees if boolean is true.
call SetRect(Rect1,x-Radius,y-Radius,x+Radius,y+Radius)
call EnumDestructablesInRect(Rect1,Condition(function TreeCheck),function KillEnumDestructables)
endif
if d.sfxmode == 0 then
set d.sfxmode = d.TerrainType(d.targ,"sfx")
else
set d.sfxmode = d.TerrainType(d.targ,"")
endif
// Adds special effects.
if d.sfxmode == 1 then
call DestroyEffect(d.SFX)
set d.SFX = AddSpecialEffectTarget(Dirt_SFX,d.targ,Attachment_point)
set d.sfxmode = 2
elseif d.sfxmode == 2 then
call DestroyEffect(d.SFX)
set d.SFX = AddSpecialEffectTarget(Water_SFX,d.targ,Attachment_point)
set d.sfxmode = 1
elseif d.sfxmode == 3 then
call BJDebugMsg("Error: Unknown terrain type (KBS)")
endif
set d.speed = d.speed - d.decrease
endif
set i = i - 1
endloop
endmethod
private method onDestroy takes nothing returns nothing
set .targ = null
if .SFX != null then
call DestroyEffect(.SFX)
set .SFX = null
endif
endmethod
endstruct
public function BeginEx takes unit Target, real Startspeed, real Deceleration, real Angle, string SpecialEffect, boolean Killtrees returns nothing
call Data.create(Target,Startspeed,Deceleration,(Angle*0.01745328),SpecialEffect,Killtrees)
endfunction
public function Begin takes unit Target, real Startspeed, real Deceleration, real Angle, boolean Killtrees returns nothing
call KBS_BeginEx(Target,Startspeed,Deceleration,(Angle*0.01745328),"",Killtrees)
endfunction
// Sets map boundries.
private function Init takes nothing returns nothing
set Game_maxX = GetRectMaxX(bj_mapInitialPlayableArea)-50.00
set Game_maxY = GetRectMaxY(bj_mapInitialPlayableArea)-50.00
set Game_minX = GetRectMinX(bj_mapInitialPlayableArea)+50.00
set Game_minY = GetRectMinY(bj_mapInitialPlayableArea)+50.00
endfunction
endlibrary</i></i>
A clearly defined and definite answer will be greatly appreciated, and +repped.