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.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top