HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How To Make A Spell...

03-24-2008, 06:19 PM#1
Dead.oK
How to make dummy to cast a spell on Every Picked Unit:
Here is my trigger(don't laugh if i've done it awfuly)

-----------------------------------------------------------------
Collapse JASS:
function BattleTime_Spell takes nothing returns boolean
    return GetSpellAbilityId()=='A0K0'
endfunction

function BattleTime_Check takes nothing returns boolean
    return GetOwningPlayer(GetFilterUnit())==GetOwningPlayer(udg_U)and(GetUnitAbilityLeve(GetFilterUnit(),'A04Y')==0) or IsUnitAlly(GetFilterUnit(),GetOwningPlayer(udg_U_temp))==true
endfunction

function BattleTime_Main takes nothing returns nothing
    local timer t=GetExpiredTimer()
    local string s=H2Tx(t)
    local unit A=GetUnit(s,"Caster")
    local unit U=GetUnit(s,"Hero")
    local integer lvl=GetUnitAbilityLevel(U,'A0K0')
    local integer a=GetInteger(s,"Counter")
    local real v=GetUnitX(A)
    local real V=GetUnitY(A)
    local boolexpr W=Condition(function BattleTime_Check)
    local group g=CreateGroup()
        local unit d=GetUnit(s,"Caster2")
        local unit f
    set udg_U=U
    call GroupEnumUnitsInRange(g,v,V,435,W)
    loop
          set f=FirstOfGroup(g)
          exitwhen f==null
          if IsUnitAlly(f,GetOwningPlayer(d))==true then
             call IssueTargetOrder(d,"bloodlust",f)
             call GroupRemoveUnit(g,f)
          else
             call UnitDamageTarget(d,f,GetUnitMoveSpeed(f)*0.25,true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,null)
             call GroupRemoveUnit(g,f)
          endif
        endloop
        call GroupClear(g)
    call DestroyGroup(g)
    call DestroyBoolExpr(W)
    set a=a+1
    call SetInteger(s,"Counter",a)
    if a>30+lvl*30 then
        call RemoveUnit(A)
                call RemoveUnit(d)
        call PauseTimer(t)
        call FastFlush(s)
        call DestroyTimer(t)
    endif
        set A=null
        set U=null
        set lvl=0
        set a=0
        set v=0
        set V=0
        set W=null
        set g=null
        set d=null
        set f=null
endfunction

function BattleTime_Setting takes nothing returns nothing
    local unit U=GetTriggerUnit()
    local integer lvl=GetUnitAbilityLevel(U,'A0K0') //hero spell
    local location B=GetSpellTargetLoc()
    local real v=GetLocationX(B)
    local real V=GetLocationY(B)
    local unit A=CreateUnit(GetOwningPlayer(U),'e00Y',v,V,0) //Dummy-Aura unit around whom i pick units
        local unit d=CreateUnit(GetOwningPlayer(U),'e000',v,V,0) //simple dummy caster
        local timer t
        local string s
        call UnitAddAbility(d,'A0JZ') //bloodlust
        call SetUnitAbilityLevel(d,'A0JZ',lvl)
    set t=CreateTimer()
    set s=H2Tx(t)
    call SetHandle(s,"Caster",A)
        call SetHandle(s,"Caster2",d)
    call SetHandle(s,"Hero",U)
    call SetInteger(s,"Counter",0)
    call TimerStart(t,.1,true,function BattleTime_Main)
    call RemoveLocation(B)
endfunction

function InitTrig_Battle_Time takes nothing returns nothing
        set gg_trg_Battle_Time = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Battle_Time,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Battle_Time,Condition(function BattleTime_Spell))
    call TriggerAddAction(gg_trg_Battle_Time,function BattleTime_Setting)
endfunction


If i Create dummy caster in timer function, it starts to lag
03-24-2008, 06:24 PM#2
Salbrismind
First put your code in jass tags. The button is a little sheet of paper that says jass across it. or type "[jass]" before your code and one with a slash after.

Collapse JASS:
function BattleTime_Spell takes nothing returns boolean
    return GetSpellAbilityId()=='A0K0'
endfunction

function BattleTime_Check takes nothing returns boolean
    return GetOwningPlayer(GetFilterUnit())==GetOwningPlayer(udg_U)and(GetUnitAbilityLevel(GetFilterUnit(),'A04Y')==0) or IsUnitAlly(GetFilterUnit(),GetOwningPlayer(udg_U_temp))==true
endfunction

function BattleTime_Main takes nothing returns nothing
    local timer t=GetExpiredTimer()
    local string s=H2Tx(t)
    local unit A=GetUnit(s,"Caster")
    local unit U=GetUnit(s,"Hero")
    local integer lvl=GetUnitAbilityLevel(U,'A0K0')
    local integer a=GetInteger(s,"Counter")
    local real v=GetUnitX(A)
    local real V=GetUnitY(A)
    local boolexpr W=Condition(function BattleTime_Check)
    local group g=CreateGroup()
        local unit d=GetUnit(s,"Caster2")
        local unit f
    set udg_U=U
    call GroupEnumUnitsInRange(g,v,V,435,W)
    loop
          set f=FirstOfGroup(g)
          exitwhen f==null
          if IsUnitAlly(f,GetOwningPlayer(d))==true then
             call IssueTargetOrder(d,"bloodlust",f)
             call GroupRemoveUnit(g,f)
          else
             call UnitDamageTarget(d,f,GetUnitMoveSpeed(f)*0.25,true,false,ATTACK_TYPE_HERO,DAMAGE_TYPE_NORMAL,null)
             call GroupRemoveUnit(g,f)
          endif
        endloop
        call GroupClear(g)
    call DestroyGroup(g)
    call DestroyBoolExpr(W)
    set a=a+1
    call SetInteger(s,"Counter",a)
    if a>30+lvl*30 then
        call RemoveUnit(A)
                call RemoveUnit(d)
        call PauseTimer(t)
        call FastFlush(s)
        call DestroyTimer(t)
    endif
        set A=null
        set U=null
        set lvl=0
        set a=0
        set v=0
        set V=0
        set W=null
        set g=null
        set d=null
        set f=null
endfunction

function BattleTime_Setting takes nothing returns nothing
    local unit U=GetTriggerUnit()
    local integer lvl=GetUnitAbilityLevel(U,'A0K0') //hero spell
    local location B=GetSpellTargetLoc()
    local real v=GetLocationX(B)
    local real V=GetLocationY(B)
    local unit A=CreateUnit(GetOwningPlayer(U),'e00Y',v,V,0) //Dummy-Aura unit around whom i pick units
        local unit d=CreateUnit(GetOwningPlayer(U),'e000',v,V,0) //simple dummy caster
        local timer t
        local string s
        call UnitAddAbility(d,'A0JZ') //bloodlust
        call SetUnitAbilityLevel(d,'A0JZ',lvl)
    set t=CreateTimer()
    set s=H2Tx(t)
    call SetHandle(s,"Caster",A)
        call SetHandle(s,"Caster2",d)
    call SetHandle(s,"Hero",U)
    call SetInteger(s,"Counter",0)
    call TimerStart(t,.1,true,function BattleTime_Main)
    call RemoveLocation(B)
endfunction

function InitTrig_Battle_Time takes nothing returns nothing
        set gg_trg_Battle_Time = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Battle_Time,EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition(gg_trg_Battle_Time,Condition(function BattleTime_Spell))
    call TriggerAddAction(gg_trg_Battle_Time,function BattleTime_Setting)
endfunction

Also add this to the end of Battle Time Setting because it leaks 2 units:
Collapse JASS:
set U = null
set A = null
03-24-2008, 06:38 PM#3
Dead.oK
And what then?

It casts blood lust every 0.1 only on my hero.
03-24-2008, 06:41 PM#4
Alexander244
Quote:
Originally Posted by Dead.oK
It casts blood lust every 0.1 only on my hero.
Add a check to see if the ability level of the buff on the target unit is greater than zero.
03-24-2008, 06:48 PM#5
RolePlaynGamer
Heh you dont have to nullify non-handles like integers, reals, strings.

Just delete all the set (somehting) = 0
03-24-2008, 06:50 PM#6
Dead.oK
It doesn't help. I've tried. Alsо you can see a Condition BattleTime_Check that checks nothing/
03-24-2008, 06:57 PM#7
Salbrismind
When you add the dummy unit do you null the variable and group it belongs to?
03-24-2008, 07:03 PM#8
Alexander244
Stick the buff check where you actually cast the bloodlust, not in the condition.

You should use one global temp group that you clear, instead of creating and destroying one each time.

There is no need to destroy BoolExpr's
03-24-2008, 07:04 PM#9
Dead.oK
Yes. But before, I store it, because it won't be needed in Settings.

Can I use cache to store group instead of globals?
03-24-2008, 07:09 PM#10
Alexander244
Better to use globals...
If you don't have JNGP, get it, it makes declaring globals a lot easier. Plus you can get rid of gamecache usage altogether with structs.
03-24-2008, 08:08 PM#11
Dead.oK
I can't use vJass because it gives a lot of errors.(I'm using Caster System - there are the errors.)
03-24-2008, 08:12 PM#12
RolePlaynGamer
That's because you dont use JASS NewGen
03-24-2008, 08:12 PM#13
Dead.oK
Anybody knows how to use JNGP with Vex Caster System.
03-24-2008, 08:13 PM#14
RolePlaynGamer
-download JNGP
-Import the caster system...
03-24-2008, 08:14 PM#15
Dead.oK
RolePlaynGamer, when I saved my map in NewGen it gave me tonns of errors in Caster System.(In simple WE CSystem works perfectly)