Spell Arcane Explosion

darth-yoda

New Member
Reaction score
15
Wow thanks alot Steel. Fixed everything you showed, including the tooltips.
Now I just need to make it MUI. Shouldn't be too hard.
 

Sim

Forum Administrator
Staff member
Reaction score
534
Are you updating this any time soon? removing it from the approval list otherwise.
 

darth-yoda

New Member
Reaction score
15
oh yeah sry kinda forgot about it...was waiting for Steel to help me with some more code problems but he hasn't responded so I've been stuck. Heres my attempt at making it MUI...

JASS:
//=============================================================================\\
//>>>>>>>>>>>>>>>>>>>>>>Arcane Explosion<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\\
//                          made by                                            \\
//                         darthyoda                                           \\
//                    with help from Steel                                     \\
//Things you'll need for this spell to work in your map from the Object Editor \\
//     1. Copy'n'paste the spell 'Arcane Explosion' into your map              \\
//     2. Copy'n'paste the buff 'Arcane Explosion' into your map               \\
//                                                                             \\
//Things you'll need for this spell to work in your map from the Trigger Editor\\                                                                   
//     1. Copy'n'paste the trigger named 'Set Arcane Explosion'                \\                                                
//     2. Copy'n'paste the trigger named 'Arcane Explosion'                    \\                                           
//     3. Set the First 2 functions named 'buffid' and 'abilityid' to the id   \\
//        codes of your spell and buff. Note press 'CTRL+D' to view them in the\\
//        Object Editor                                                        \\
//And now it should be working!! Edit the first set of functions to make the   \\
//spell just how you want it.                                                  \\
//=============================================================================\\

constant function ArcaneExplosion_buffid takes nothing returns integer
    return 'B000' //Set this to your Custom Buffs ID
endfunction

constant function ArcaneExplosion_abilityid takes nothing returns integer
    return 'A000' //Set this to Arcanes Explosions ID
endfunction

constant function ArcaneExplosion_chance takes integer lvl returns real
    return lvl * 10.  //Sets the chance of the spell activating
endfunction

constant function ArcaneExplosion_damage takes integer lvl returns real
     return lvl * 25. + 25. //How much damage each explosion deals
endfunction

constant function ArcaneExplosion_AOE_explosionMAX takes nothing returns real 
    return 350.   //The Max Distants the explosions can be made from the triggering unit
endfunction

constant function ArcaneExplosion_AOE_explosionMIN takes nothing returns real
    return 100. // The Min Distants the explosions can be made from the triggering unit
endfunction

constant function ArcaneExplosion_AOE_area takes nothing returns integer
    return 200   //The area around each explosion that takes damage
endfunction

constant function ArcaneExplosion_AOE_aura takes nothing returns integer
    return 1000    //This should be set to your base spells AOE (Checks units in range with buff)
endfunction

constant function ArcaneExplosion_AOE_group takes nothing returns integer
    return 500    //Counts the number of enemy units around the triggering unit
endfunction 

constant function ArcaneExplosion_unitmultiplier takes integer lvl returns integer
    return lvl * 0 + 2   //Set the number of explosions. For example the Math currently is set to; number of nearby units x2
endfunction

constant function ArcaneExplosion_waittime takes nothing returns real
    return 0.20  //Ammount of time between each explosion 
endfunction

constant function ArcaneExplosion_SFX takes nothing returns string
    return "Units\\NightElf\\Wisp\\WispExplode.mdl"  //The explosions Model path name. Note: Path name must written as, Unit\\MyUnit\\Footman instead of Unit\MyUnit\Footman. 
endfunction

//=========================================================================================================
//========================DO NOT EDIT PAST HERE UNLESS YOU KNOW WHAT YOUR DOING============================
//=========================================================================================================  

function Trig_Arcane_Explosion_Conditions takes unit hero returns boolean
    local integer lvl = GetUnitAbilityLevel(hero, ArcaneExplosion_abilityid())
    local integer c = GetRandomInt(1,100)
    local boolean bool = ((GetUnitAbilityLevel(GetTriggerUnit(), ArcaneExplosion_buffid()) > 0))
    if c <= ArcaneExplosion_chance(lvl) then
    return (bool)
endif
return false
endfunction

function Arcane_Explosion_Check takes unit hero returns boolean
    local boolean bool1 = not(IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE))
    local boolean bool2 = IsUnitAliveBJ(GetFilterUnit()) 
    local boolean bool3 = IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(hero))
    return (bool1 and bool2 and bool3)
endfunction

function ArcaneExplosion_Hero takes nothing returns boolean
    return (GetUnitAbilityLevel(GetFilterUnit(), ArcaneExplosion_abilityid()) > 0 == true)
endfunction

function Trig_Arcane_Explosion_damage takes unit hero returns nothing
    local integer lvl = GetUnitAbilityLevel(hero, ArcaneExplosion_abilityid())
    call UnitDamageTarget(hero, GetEnumUnit(), ArcaneExplosion_damage(lvl), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
endfunction



function Trig_Arcane_Explosion_Actions takes nothing returns nothing
    local location cast =  GetUnitLoc(GetTriggerUnit())
    local location targ
    local group g = CreateGroup()
    local group h = CreateGroup()
    local integer a = 1
    local integer b
    local boolexpr gethero = (Condition(function ArcaneExplosion_Hero))
    local group randomhero = GetUnitsInRangeOfLocMatching(ArcaneExplosion_AOE_aura(), cast,gethero)
    local unit hero = FirstOfGroup(randomhero)
    local integer lvl = GetUnitAbilityLevel(hero, ArcaneExplosion_abilityid())
    local boolexpr bexpr = (Condition(function Arcane_Explosion_Check))
        set g = GetUnitsInRangeOfLocMatching(ArcaneExplosion_AOE_group(), cast, bexpr)
        set b = ( CountUnitsInGroup(g) * ArcaneExplosion_unitmultiplier(lvl) )
        loop
            exitwhen a > b
            set targ = PolarProjectionBJ(cast, GetRandomReal(ArcaneExplosion_AOE_explosionMIN(), ArcaneExplosion_AOE_explosionMAX()), GetRandomReal(0, 360.00))
            call AddSpecialEffectLoc(ArcaneExplosion_SFX(), targ)
            call DestroyEffect( GetLastCreatedEffectBJ() )
            call TriggerSleepAction( ArcaneExplosion_waittime() )
            set h = GetUnitsInRangeOfLocMatching(ArcaneExplosion_AOE_area(), targ, bexpr)
            call ForGroup( h, function Trig_Arcane_Explosion_damage )
            call DestroyGroup (h)
            call RemoveLocation (targ)
            set a = a + 1
        endloop
    call DestroyGroup (g)
    set g = null
    call DestroyBoolExpr(bexpr)
    set bexpr = null
    call RemoveLocation (cast)
    set cast = null
    set targ = null
    set h = null
endfunction

//===========================================================================
function InitTrig_Arcane_Explosion takes nothing returns nothing
    set gg_trg_Arcane_Explosion = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Arcane_Explosion, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Arcane_Explosion, Condition( function Trig_Arcane_Explosion_Conditions ) )
    call TriggerAddAction( gg_trg_Arcane_Explosion, function Trig_Arcane_Explosion_Actions )
endfunction


In JassCraft it says its all fine and dandy but when I test ingame I get a critical error...All help is greatly appreciated...again.
 

Steel

Software Engineer
Reaction score
109
Ah yes, Ill get with you on this. I've just been dealing with the release of my RPG, sorry.
 

Sim

Forum Administrator
Staff member
Reaction score
534
Comment all lines in the trigger.

Then, uncomment the lines one by one until it crashes again. You will find your buggy line ;)

Hint: Don't comment the constant functions...
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
@darth-yoda:

>DestroyBoolExpr()

Never use this for conditions. Boolexprs don't leak if they are conditions. If they leaked, then every single GUI trigger would leak and be unchangeable unless in JASS. As you may have noticed, trigger conditions take the trigger then do [Condition(function Trig_Test_Conditions)]. If this leaks, then each GUI trigger would leak. Fortunately, it doesn't so GUI triggers don't leak. :)
 

Steel

Software Engineer
Reaction score
109
Dax, this spell is good for approval (code wise). I can't think of a particularly good way to make it MUI, but it should be just fine.
 

Sim

Forum Administrator
Staff member
Reaction score
534
Why does it activate when an enemy unit casts a spell? Fix that.

Otherwise... neat!
 

Tom Jones

N/A
Reaction score
437
Some random notes for your future work:

Instead of using two groups, you could in this functions use one. Simply use the GroupClear() call when your done with the first group. On a related note, you could also get rid of the ForGroup() call by looping trough the group,etc.:
JASS:
function...
    local group g = CreateGroup()
    local unit v

    call GroupEnumUnitsInRange(g,somex,somey,100,Condition(function somefunction))
    loop
        set v = FirstOfGroup(g)
        exitwhen v == null
        //Do stuff to unit v
        call GroupRemoveUnit(g,v)
    endloop
endfunction
Since this is a aura, it's actually pretty simple to make it mui. If two units has the same aura, the units under the auras effect will get the greater buff of the two auras. This means that we can check for units in range of the caster with the aura, selecting the unit with the greatest level of the aura etc.:
JASS:

function GroupFilter takes nothing returns boolean
    return GetUnitAbilityLevel(GetFilterUnit(),AuraId) > 0
endfunction

function...
    local group g = CreateGroup()
    local integer i = 0
    local integer a
    local unit c = GetTriggerUnit()
    local unit tempu
    local unit u
    local real x = GetUnitX(c)
    local real y = GetUnitY(c)

    call GroupEnumUnitsInRange(g,x,y,500,Condition(function GroupFilter))
    loop
         set tempu = FirstOfGroup(g)
         exitwhen tempu == null
         set a = GetUnitAbilityId(u,AuraId)
         if a > i then
             set u = tempu
         endif
         call GroupRemoveUnit(g,tempu)
    endloop
    //unit u is now the unit with the greatest level of the AuraId spell, and must therefore be the buffing unit.
endfunction
 

darth-yoda

New Member
Reaction score
15
Thanks much Tom Jones. I almost had it MUI but hit the snag with this line...
Code:
function Arcane_Explosion_Check takes nothing returns boolean
    local boolean bool1 = not(IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE))
    local boolean bool2 = IsUnitAliveBJ(GetFilterUnit()) 
    [B]local boolean bool3 = IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_AE_Owner))[/B]
    return (bool1 and bool2 and bool3)
endfunction

Because when I call the function I cant give it anything(like units...) and I couldn't figure out a way around it.

Also your method of finding the triggering unit would cause the lower level spell to never get the kills right? If so I'd still rather pick a unit randomly.

Why does it activate when an enemy unit casts a spell? Fix that.

Otherwise... neat!

You can change that yourself in the Object Editor, I kinda like it effecting both enemy's and allies :p
 

Sim

Forum Administrator
Staff member
Reaction score
534
> Because when I call the function I cant give it anything(like units...) and I couldn't figure out a way around it.

Pick every units in playable map area matching they have the buff "Arcane Explosions". Then, look if GetEnumUnit() has the ability too. If it has the ability, it means it is the "AE_Owner", or any other "AE_Owner" for all that matters, as long as they have the ability.
 

darth-yoda

New Member
Reaction score
15
yay I think I got it MUI:eek: :p But now I have found a new problem:rolleyes: The spell damages your own units...I can't figure out why, It may have always done this and I just diddnt notice but I sure noticed it now(watched my hero die for no apparent reason) Anyway heres the new code...

JASS:
constant function ArcaneExplosion_buffid takes nothing returns integer
    return 'B000' //Set this to your Custom Buffs ID
endfunction

constant function ArcaneExplosion_abilityid takes nothing returns integer
    return 'A000' //Set this to Arcanes Explosions ID
endfunction

constant function ArcaneExplosion_chance takes integer lvl returns real
    return lvl * 10.  //Sets the chance of the spell activating
endfunction

constant function ArcaneExplosion_damage takes integer lvl returns real
     return lvl * 25. + 25. //How much damage each explosion deals
endfunction

constant function ArcaneExplosion_AOE_explosionMAX takes integer lvl returns real 
    return lvl * 0 + 350.   //The Max Distants the explosions can be made from the triggering unit
endfunction

constant function ArcaneExplosion_AOE_explosionMIN takes integer lvl returns real
    return lvl * 0 + 100. // The Min Distants the explosions can be made from the triggering unit
endfunction

constant function ArcaneExplosion_AOE_area takes integer lvl returns integer
    return lvl * 0 + 200   //The area around each explosion that takes damage
endfunction

constant function ArcaneExplosion_AOE_aura takes nothing returns integer
    return 1000    //This should be set to your base spells AOE (Checks units in range with buff)
endfunction

constant function ArcaneExplosion_AOE_group takes integer lvl returns integer
    return lvl * 0 + 500    //Counts the number of enemy units around the triggering unit
endfunction 

constant function ArcaneExplosion_unitmultiplier takes integer lvl returns integer
    return lvl * 0 + 2   //Set the number of explosions. For example the Math currently is set to; number of nearby units x2
endfunction

constant function ArcaneExplosion_waittime takes nothing returns real
    return 0.20  //Ammount of time between each explosion 
endfunction

constant function ArcaneExplosion_SFX takes nothing returns string
    return "Units\\NightElf\\Wisp\\WispExplode.mdl"  //The explosions Model path name. Note: Path name must written as, Unit\\MyUnit\\Footman instead of Unit\MyUnit\Footman. 
endfunction


//=========================================================================================================
//========================DO NOT EDIT PAST HERE UNLESS YOU KNOW WHAT YOUR DOING============================
//=========================================================================================================  

function Trig_Arcane_Explosion_Conditions takes nothing returns boolean
    local integer lvl = GetUnitAbilityLevel(GetTriggerUnit(), ArcaneExplosion_buffid())
    local integer c = GetRandomInt(1,100)
    local boolean bool = ((GetUnitAbilityLevel(GetTriggerUnit(), ArcaneExplosion_buffid()) > 0))
    if c <= ArcaneExplosion_chance(lvl) then
    return (bool)
endif
return false
endfunction

function Arcane_Explosion_Check takes nothing returns boolean
    local boolean bool1 = IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(GetTriggerUnit()))
    local boolean bool2 = not(IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE))
    local boolean bool3 = IsUnitAliveBJ(GetFilterUnit()) 
    return (bool1 and bool2 and bool3)
endfunction

function ArcaneExplosion_Hero takes nothing returns boolean
    return (GetUnitAbilityLevel(GetFilterUnit(), ArcaneExplosion_abilityid()) > 0 == true)
endfunction

function Trig_Arcane_Explosion_Actions takes nothing returns nothing
    local location cast =  GetUnitLoc(GetTriggerUnit())
    local location targ
    local unit u
    local group g = CreateGroup()
    local integer a = 1
    local integer b
    local boolexpr gethero = (Condition(function ArcaneExplosion_Hero))
    local group randomhero = GetUnitsInRangeOfLocMatching(ArcaneExplosion_AOE_aura(), cast,gethero)
    local unit hero = FirstOfGroup(randomhero)
    local integer lvl = GetUnitAbilityLevel(hero, ArcaneExplosion_abilityid())
    local boolexpr bexpr = (Condition(function Arcane_Explosion_Check))
    set g = GetUnitsInRangeOfLocMatching(ArcaneExplosion_AOE_group(lvl), cast, bexpr)
    set b = ( CountUnitsInGroup(g) * ArcaneExplosion_unitmultiplier(lvl) )
    loop
        exitwhen a > b
        set targ = PolarProjectionBJ(cast, GetRandomReal(ArcaneExplosion_AOE_explosionMIN(lvl), ArcaneExplosion_AOE_explosionMAX(lvl)), GetRandomReal(0, 360.00))
        call AddSpecialEffectLoc(ArcaneExplosion_SFX(), targ)
        call DestroyEffect( GetLastCreatedEffectBJ() )
        call PolledWait( ArcaneExplosion_waittime() )
        call GroupClear(g)
        set g = GetUnitsInRangeOfLocMatching(ArcaneExplosion_AOE_area(lvl), targ, bexpr)
        loop
            set u = FirstOfGroup(g)
            exitwhen u == null
            call GroupRemoveUnit(g,u)
            call UnitDamageTarget(hero, u, ArcaneExplosion_damage(lvl), true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)
        endloop
        call DestroyGroup (g)
        call RemoveLocation (targ)
        set a = a + 1
    endloop
    call DestroyGroup (g)
    set g = null
    call DestroyBoolExpr(bexpr)
    set bexpr = null
    call RemoveLocation (cast)
    set cast = null
    set targ = null
endfunction

//===========================================================================
function InitTrig_Arcane_Explosion takes nothing returns nothing
    set gg_trg_Arcane_Explosion = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Arcane_Explosion, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Arcane_Explosion, Condition( function Trig_Arcane_Explosion_Conditions ) )
    call TriggerAddAction( gg_trg_Arcane_Explosion, function Trig_Arcane_Explosion_Actions )
endfunction


Again I have no idea why it damages your own units, maybe something simple I keep overlooking but it's driving me crazy. I guess this is what I get for thinking I finally finished the spell...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top