• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Can't import this boomerang ability to my map

Status
Not open for further replies.
Level 1
Joined
Aug 4, 2006
Messages
5
constant function Boomer_SpellId takes nothing returns integer
return 'A023'
endfunction
constant function Boomer_Speed takes nothing returns real
return 1000.0
endfunction
constant function Boomer_Angle takes nothing returns real
return 18.0
endfunction
constant function Boomer_Range takes nothing returns real
return 600.0
endfunction
constant function Boomer_Radius takes nothing returns real
return 250.0
endfunction
constant function Boomer_Collision takes nothing returns real
return 80.0
endfunction
constant function Boomer_AnimTimer takes nothing returns real
return 0.025
endfunction
constant function Boomer_Damage takes real level returns real
return 50*level
endfunction
function Boomer_DamageOptions takes nothing returns integer
return DamageTypes(ATTACK_TYPE_NORMAL,DAMAGE_TYPE_FORCE)+DamageOnlyEnemies()
endfunction
function Boomer_Conditions takes nothing returns boolean
return GetSpellAbilityId() == Boomer_SpellId()
endfunction
function BoomerTimer2Loc takes timer t, string s returns location
return Location(GetAttachedReal(t,"X"+s),GetAttachedReal(t,"Y"+s))
endfunction
function BoomerAbsoluteAngle takes real a returns real
if (a<0) then
return a + 360
endif
return a
endfunction
function Boomer_AxeMove takes nothing returns nothing
local timer t = GetExpiredTimer()
local timer tx = GetAttachedTimer(t,"tx")
local unit c = GetAttachedUnit(t,"c")
local unit u = GetAttachedUnit(t,"u")
local unit picked
local integer i = GetUnitAbilityLevel(u,Boomer_SpellId())
local integer mode = GetAttachedInt(t,"mode")
local integer direction = GetAttachedInt(t,"dir")
local group victim = GetAttachedGroup(t,"g")
local group inrange = CreateGroup()
local location l
local location lc = GetUnitLoc(c)
local location lu = GetUnitLoc(u)
local location t1 = BoomerTimer2Loc(t,"1")
local location t2 = BoomerTimer2Loc(t,"2")
local location t3 = BoomerTimer2Loc(t,"3")
local location o = PolarProjectionBJ(lu,80,GetUnitFacing(u)+(Boomer_Angle()*-direction))
local real a = GetAttachedReal(t,"a")
local real d = (Boomer_Speed()*Boomer_AnimTimer()*(2*a+180))/((Boomer_Radius()*bj_PI)*(a/90+1))
local real dist
local boolean end = false
if mode == 1 then
if (DistanceBetweenPoints(lc,t2) >= Boomer_Speed()*Boomer_AnimTimer()) then
set dist = Boomer_Speed()*Boomer_AnimTimer()
else
set dist = DistanceBetweenPoints(lc,t2)
call AttachInt(t,"mode",2)
endif
set l = PolarProjectionBJ(lc,dist,AngleBetweenPoints(lc,t2))
call SetUnitPositionLoc(c,l)
elseif mode == 2 then
if (direction == 1) then
set a = BoomerAbsoluteAngle(AngleBetweenPoints(t1,t3)+AngleBetweenPoints(t1,t2))-BoomerAbsoluteAngle(AngleBetweenPoints(t1,lc)+d+AngleBetweenPoints(t1,t2))
set end = (a >= 0) or ((a < -40) and (a > -360))
else
set a = BoomerAbsoluteAngle(AngleBetweenPoints(t1,t3)-AngleBetweenPoints(t1,t2))-BoomerAbsoluteAngle(AngleBetweenPoints(t1,lc)-d-AngleBetweenPoints(t1,t2))
set end = (a <= 0) or ((a > 40) and (a < 360))
endif
if end then
if (direction == 1) then
set l = PolarProjectionBJ(t1,Boomer_Radius(),AngleBetweenPoints(t1,lc)+d)
else
set l = PolarProjectionBJ(t1,Boomer_Radius(),AngleBetweenPoints(t1,lc)-d)
endif
else
set l = t3
call AttachInt(t,"mode",3)
call AttachInt(tx,"mode",3)
endif
call SetUnitPositionLoc(c,l)
set end = false
elseif mode == 3 then
if (DistanceBetweenPoints(lc,o) >= Boomer_Speed()*Boomer_AnimTimer()) then
set dist = Boomer_Speed()*Boomer_AnimTimer()
else
set dist = DistanceBetweenPoints(lc,o)
set end = true
endif
set l = PolarProjectionBJ(lc,dist,AngleBetweenPoints(lc,o))
call SetUnitPositionLoc(c,l)
endif
call DamageTreesInCircleLoc(l,Boomer_Collision())
call GroupEnumUnitsInRangeOfLoc(inrange,l,Boomer_Collision(),null)
loop
set picked = FirstOfGroup(inrange)
exitwhen picked == null
if IsUnitInGroup(picked,victim) == false then
call GroupAddUnit(victim,picked)
set a=GetDamageFactorByOptions(u,picked,Boomer_DamageOptions())
if a!=0 then
call UnitDamageTarget(u,picked,Boomer_Damage(i)*a,true,false,null,null,null)
call DestroyEffect(AddSpellEffectByIdLoc(Boomer_SpellId(),EFFECT_TYPE_SPECIAL,l))
endif
endif
call GroupRemoveUnit(inrange,picked)
endloop
call DestroyGroup(inrange)
call RemoveLocation(o)
call RemoveLocation(l)
call RemoveLocation(lc)
call RemoveLocation(lu)
call RemoveLocation(t1)
call RemoveLocation(t2)
call RemoveLocation(t3)
if end then
call DestroyGroup(victim)
call DestroyEffect(GetAttachedEffect(c,"fx"))
call AttachObject(c,"fx",null)
call ExplodeUnitBJ(c)
call CleanAttachedVars(t)
call DestroyTimer(t)
endif
endfunction
function Boomer_Init takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit array c
local effect array e
local location array l
local timer t1 = CreateTimer()
local timer t2 = CreateTimer()
local real a
local integer i = 1
set l[0] = GetUnitLoc(u)
set l[1] = PolarProjectionBJ(l[0],80,GetUnitFacing(u)-Boomer_Angle())
set l[2] = PolarProjectionBJ(l[0],80,GetUnitFacing(u)+Boomer_Angle())
set l[3] = PolarProjectionBJ(l[0],Boomer_Range(),GetUnitFacing(u)-Boomer_Angle())
set l[4] = PolarProjectionBJ(l[0],Boomer_Range(),GetUnitFacing(u)+Boomer_Angle())
set l[5] = PolarProjectionBJ(l[3],Boomer_Radius(),GetUnitFacing(u)-90)
set a = AngleBetweenPoints(l[0],l[3])-AngleBetweenPoints(l[0],l[5])
set l[6] = PolarProjectionBJ(l[3],Boomer_Radius(),GetUnitFacing(u)-90-a)
set l[7] = PolarProjectionBJ(l[4],Boomer_Radius(),GetUnitFacing(u)+90+a)
set l[8] = PolarProjectionBJ(l[3],Boomer_Radius(),GetUnitFacing(u)+90+a)
set l[9] = PolarProjectionBJ(l[4],Boomer_Radius(),GetUnitFacing(u)-90-a)
loop
exitwhen i > 2
set c=AddCaster()
call SetUnitOwner(c,GetOwningPlayer(u),true)
call SetUnitFlyHeight(c,S2R(GetAbilityEffectById(Boomer_SpellId(),EFFECT_TYPE_SPECIAL,1)),0)
call SetUnitPositionLoc(c,l)
call AttachObject(c,"fx",AddSpellEffectTargetById(Boomer_SpellId(),EFFECT_TYPE_SPECIAL,c,"origin"))
set i=i+1
endloop
call AttachInt(t1,"dir",1)
call AttachInt(t2,"dir",-1)
call AttachInt(t1,"mode",1)
call AttachInt(t2,"mode",1)
call AttachObject(t1,"c",c[1])
call AttachObject(t2,"c",c[2])
call AttachObject(t1,"u",u)
call AttachObject(t2,"u",u)
call AttachObject(t1,"g",CreateGroup())
call AttachObject(t2,"g",CreateGroup())
call AttachObject(t1,"tx",t2)
call AttachObject(t2,"tx",t1)
call AttachReal(t1,"X1",GetLocationX(l[3]))
call AttachReal(t2,"X1",GetLocationX(l[4]))
call AttachReal(t1,"X2",GetLocationX(l[6]))
call AttachReal(t2,"X2",GetLocationX(l[7]))
call AttachReal(t1,"X3",GetLocationX(l[8]))
call AttachReal(t2,"X3",GetLocationX(l[9]))
call AttachReal(t1,"Y1",GetLocationY(l[3]))
call AttachReal(t2,"Y1",GetLocationY(l[4]))
call AttachReal(t1,"Y2",GetLocationY(l[6]))
call AttachReal(t2,"Y2",GetLocationY(l[7]))
call AttachReal(t1,"Y3",GetLocationY(l[8]))
call AttachReal(t2,"Y3",GetLocationY(l[9]))
call AttachReal(t1,"a",a)
call AttachReal(t2,"a",a)
call TimerStart(t1,0,false,function Boomer_AxeMove)
call TimerStart(t2,0,false,function Boomer_AxeMove)
call TimerStart(t1,Boomer_AnimTimer(),true,function Boomer_AxeMove)
call TimerStart(t2,Boomer_AnimTimer(),true,function Boomer_AxeMove)
set i = 0
loop
exitwhen i > 9
call RemoveLocation(l)
set l = null
set i = i + 1
endloop
endfunction
function InitTrig_Boomer takes nothing returns nothing
set gg_trg_Boomer=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Boomer,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Boomer,Condition(function Boomer_Conditions))
call TriggerAddAction(gg_trg_Boomer,function Boomer_Init)
endfunction

:cry: i need help importing this boomerang ability cause i'm really bad with jass!!! can someone pleaaassse help??!?! :cry:
 
Level 5
Joined
May 22, 2006
Messages
150
Readable at last:

JASS:
constant function Boomer_SpellId takes nothing returns integer 
  return 'A023'
endfunction

constant function Boomer_Speed takes nothing returns real 
  return 1000.0
endfunction

constant function Boomer_Angle takes nothing returns real 
  return 18.0
endfunction

constant function Boomer_Range takes nothing returns real 
  return 600.0
endfunction

constant function Boomer_Radius takes nothing returns real 
  return 250.0
endfunction

constant function Boomer_Collision takes nothing returns real 
  return 80.0 
endfunction

constant function Boomer_AnimTimer takes nothing returns real 
  return 0.025 
endfunction

constant function Boomer_Damage takes real level returns real 
  return 50*level 
endfunction

function Boomer_DamageOptions takes nothing returns integer 
  return DamageTypes(ATTACK_TYPE_NORMAL,DAMAGE_TYPE_FORCE)+DamageOnlyEnemies() 
endfunction

function Boomer_Conditions takes nothing returns boolean 
  return GetSpellAbilityId() == Boomer_SpellId() 
endfunction

function BoomerTimer2Loc takes timer t, string s returns location 
  return Location(GetAttachedReal(t,"X"+s),GetAttachedReal(t,"Y"+s)) 
endfunction

function BoomerAbsoluteAngle takes real a returns real 
  if (a<0) then 
    return a + 360 
  endif 
  return a 
endfunction

function Boomer_AxeMove takes nothing returns nothing 
  local timer t = GetExpiredTimer() 
  local timer tx = GetAttachedTimer(t,"tx") 
  local unit c = GetAttachedUnit(t,"c") 
  local unit u = GetAttachedUnit(t,"u") 
  local unit picked 
  local integer i = GetUnitAbilityLevel(u,Boomer_SpellId()) 
  local integer mode = GetAttachedInt(t,"mode") 
  local integer direction = GetAttachedInt(t,"dir") 
  local group victim = GetAttachedGroup(t,"g") 
  local group inrange = CreateGroup() 
  local location l 
  local location lc = GetUnitLoc(c) 
  local location lu = GetUnitLoc(u) 
  local location t1 = BoomerTimer2Loc(t,"1") 
  local location t2 = BoomerTimer2Loc(t,"2") 
  local location t3 = BoomerTimer2Loc(t,"3") 
  local location o = PolarProjectionBJ(lu,80,GetUnitFacing(u)+(Boomer_Angle()*-direction)) 
  local real a = GetAttachedReal(t,"a") 
  local real d = (Boomer_Speed()*Boomer_AnimTimer()*(2*a+180))/((Boomer_Radius()*bj_PI)*(a/90+1)) 
  local real dist 
  local boolean end = false 
  if mode == 1 then 
    if (DistanceBetweenPoints(lc,t2) >= Boomer_Speed()*Boomer_AnimTimer()) then 
      set dist = Boomer_Speed()*Boomer_AnimTimer() 
    else 
      set dist = DistanceBetweenPoints(lc,t2) 
      call AttachInt(t,"mode",2) 
    endif 
    set l = PolarProjectionBJ(lc,dist,AngleBetweenPoints(lc,t2)) 
    call SetUnitPositionLoc(c,l) 
  elseif mode == 2 then 
    if (direction == 1) then 
      set a = BoomerAbsoluteAngle(AngleBetweenPoints(t1,t3)+AngleBetweenPoints(t1,t2))-BoomerAbsoluteAngle(AngleBetweenPoints(t1,lc)+d+AngleBetweenPoints(t1,t2)) 
      set end = (a >= 0) or ((a < -40) and (a > -360)) 
    else 
      set a = BoomerAbsoluteAngle(AngleBetweenPoints(t1,t3)-AngleBetweenPoints(t1,t2))-BoomerAbsoluteAngle(AngleBetweenPoints(t1,lc)-d-AngleBetweenPoints(t1,t2)) 
      set end = (a <= 0) or ((a > 40) and (a < 360)) 
    endif 
    if end then 
      if (direction == 1) then 
        set l = PolarProjectionBJ(t1,Boomer_Radius(),AngleBetweenPoints(t1,lc)+d) 
      else 
        set l = PolarProjectionBJ(t1,Boomer_Radius(),AngleBetweenPoints(t1,lc)-d) 
      endif 
    else 
      set l = t3 
      call AttachInt(t,"mode",3) 
      call AttachInt(tx,"mode",3) 
    endif 
    call SetUnitPositionLoc(c,l) 
    set end = false 
  elseif mode == 3 then 
    if (DistanceBetweenPoints(lc,o) >= Boomer_Speed()*Boomer_AnimTimer()) then 
      set dist = Boomer_Speed()*Boomer_AnimTimer() 
    else 
      set dist = DistanceBetweenPoints(lc,o) 
      set end = true 
    endif 
    set l = PolarProjectionBJ(lc,dist,AngleBetweenPoints(lc,o)) 
    call SetUnitPositionLoc(c,l) 
  endif 
  call DamageTreesInCircleLoc(l,Boomer_Collision()) 
  call GroupEnumUnitsInRangeOfLoc(inrange,l,Boomer_Collision(),null) 
  loop 
    set picked = FirstOfGroup(inrange) 
    exitwhen picked == null 
    if IsUnitInGroup(picked,victim) == false then 
      call GroupAddUnit(victim,picked) 
      set a=GetDamageFactorByOptions(u,picked,Boomer_DamageOptions()) 
      if a!=0 then 
        call UnitDamageTarget(u,picked,Boomer_Damage(i)*a,true,false,null,null,null) 
        call DestroyEffect(AddSpellEffectByIdLoc(Boomer_SpellId(),EFFECT_TYPE_SPECIAL,l)) 
      endif 
    endif 
    call GroupRemoveUnit(inrange,picked) 
  endloop 
  call DestroyGroup(inrange) 
  call RemoveLocation(o) 
  call RemoveLocation(l) 
  call RemoveLocation(lc) 
  call RemoveLocation(lu) 
  call RemoveLocation(t1) 
  call RemoveLocation(t2) 
  call RemoveLocation(t3) 
  if end then 
    call DestroyGroup(victim) 
    call DestroyEffect(GetAttachedEffect(c,"fx")) 
    call AttachObject(c,"fx",null) 
    call ExplodeUnitBJ(c) 
    call CleanAttachedVars(t) 
    call DestroyTimer(t) 
  endif 
endfunction

function Boomer_Init takes nothing returns nothing 
  local unit u = GetTriggerUnit() 
  local unit array c 
  local effect array e 
  local location array l 
  local timer t1 = CreateTimer() 
  local timer t2 = CreateTimer() 
  local real a 
  local integer i = 1 
  set l[0] = GetUnitLoc(u) 
  set l[1] = PolarProjectionBJ(l[0],80,GetUnitFacing(u)-Boomer_Angle()) 
  set l[2] = PolarProjectionBJ(l[0],80,GetUnitFacing(u)+Boomer_Angle()) 
  set l[3] = PolarProjectionBJ(l[0],Boomer_Range(),GetUnitFacing(u)-Boomer_Angle()) 
  set l[4] = PolarProjectionBJ(l[0],Boomer_Range(),GetUnitFacing(u)+Boomer_Angle()) 
  set l[5] = PolarProjectionBJ(l[3],Boomer_Radius(),GetUnitFacing(u)-90) 
  set a = AngleBetweenPoints(l[0],l[3])-AngleBetweenPoints(l[0],l[5]) 
  set l[6] = PolarProjectionBJ(l[3],Boomer_Radius(),GetUnitFacing(u)-90-a) 
  set l[7] = PolarProjectionBJ(l[4],Boomer_Radius(),GetUnitFacing(u)+90+a) 
  set l[8] = PolarProjectionBJ(l[3],Boomer_Radius(),GetUnitFacing(u)+90+a) 
  set l[9] = PolarProjectionBJ(l[4],Boomer_Radius(),GetUnitFacing(u)-90-a) 
  loop 
    exitwhen i > 2 
    set c[i]=AddCaster() 
    call SetUnitOwner(c[i],GetOwningPlayer(u),true) 
    call SetUnitFlyHeight(c[i],S2R(GetAbilityEffectById(Boomer_SpellId(),EFFECT_TYPE_SPECIAL,1)),0) 
    call SetUnitPositionLoc(c[i],l[i]) 
    call AttachObject(c[i],"fx",AddSpellEffectTargetById(Boomer_SpellId(),EFFECT_TYPE_SPECIAL,c[i],"origin")) 
    set i=i+1 
  endloop 
  call AttachInt(t1,"dir",1) 
  call AttachInt(t2,"dir",-1) 
  call AttachInt(t1,"mode",1) 
  call AttachInt(t2,"mode",1) 
  call AttachObject(t1,"c",c[1]) 
  call AttachObject(t2,"c",c[2]) 
  call AttachObject(t1,"u",u) 
  call AttachObject(t2,"u",u) 
  call AttachObject(t1,"g",CreateGroup()) 
  call AttachObject(t2,"g",CreateGroup()) 
  call AttachObject(t1,"tx",t2) 
  call AttachObject(t2,"tx",t1) 
  call AttachReal(t1,"X1",GetLocationX(l[3])) 
  call AttachReal(t2,"X1",GetLocationX(l[4])) 
  call AttachReal(t1,"X2",GetLocationX(l[6])) 
  call AttachReal(t2,"X2",GetLocationX(l[7])) 
  call AttachReal(t1,"X3",GetLocationX(l[8])) 
  call AttachReal(t2,"X3",GetLocationX(l[9])) 
  call AttachReal(t1,"Y1",GetLocationY(l[3])) 
  call AttachReal(t2,"Y1",GetLocationY(l[4])) 
  call AttachReal(t1,"Y2",GetLocationY(l[6])) 
  call AttachReal(t2,"Y2",GetLocationY(l[7])) 
  call AttachReal(t1,"Y3",GetLocationY(l[8])) 
  call AttachReal(t2,"Y3",GetLocationY(l[9])) 
  call AttachReal(t1,"a",a) 
  call AttachReal(t2,"a",a) 
  call TimerStart(t1,0,false,function Boomer_AxeMove) 
  call TimerStart(t2,0,false,function Boomer_AxeMove) 
  call TimerStart(t1,Boomer_AnimTimer(),true,function Boomer_AxeMove) 
  call TimerStart(t2,Boomer_AnimTimer(),true,function Boomer_AxeMove) 
  set i = 0 
  loop 
    exitwhen i > 9 
    call RemoveLocation(l[i]) 
    set l[i] = null 
    set i = i + 1 
  endloop 
endfunction

function InitTrig_Boomer takes nothing returns nothing 
  set gg_trg_Boomer=CreateTrigger() 
  call TriggerRegisterAnyUnitEventBJ(gg_trg_Boomer,EVENT_PLAYER_UNIT_SPELL_EFFECT) 
  call TriggerAddCondition(gg_trg_Boomer,Condition(function Boomer_Conditions)) 
  call TriggerAddAction(gg_trg_Boomer,function Boomer_Init) 
endfunction

Well okay, these steps are to be done:

1. You need a trigger.

Create a trigger named "Boomer" and convert it into custom text.
Now simply copy and paste this script into the trigger, overwriting everything, which is allready inside it.

2. You need a dummy ability.

What kind of ability that is you have to ask the writer of this script.
Once having that ability, replace the id in this line with it's one:
JASS:
return 'A023'

3. You need a hero.

Pick a hero of your choice and give him the dummy ability, you selected.

If this script is working, that was all...
 
Level 1
Joined
Aug 4, 2006
Messages
5
:? It still doesnt work and i think it's because the auther said you need a "cs"(whatever that is) for this spell to work. :?
 
Level 5
Joined
May 22, 2006
Messages
150
Ah, I see.
"DamageTypes" and "DamageOnlyEnemies" seem not to be included in "common.j" or "blizzard.j".

They have to be self-written functions and so they have to be included into the script header...

Now you have to choose what to do:
You may seek these functions, find them and write them down here for me to include them into the whole thing...
Or you may describe, how this spell is supposed to work and I will rewrite it from zero.
 
Level 1
Joined
Aug 4, 2006
Messages
5
I DID IT!!!!!!!!! thanks so much...the hardest part was finding where you put custom scripts and stuff... o_O lol thanks again, LordZsar1
 
Status
Not open for further replies.
Top