darth-yoda
New Member
- Reaction score
- 15
Arcane Explosion
Gives a chance that when ever a nearby unit casts a spell, random explosions of magical energy will appear around the casting unit. Number of explosions is equal to number of enemy units near the caster x2.
Coded in - JASS
MUI - No
Leaks - None I'm aware of
Constant Functions - Yes
Import/Edit Difficulty - Low
Yay my first (good) JASS spell It's not MUI because of 1 Global unit variable that I don't know how to get around Perhaps someone else knows how. Any and all comments on the spell/ coding are greatly appreciated.
Heres the code...
Edit: sry, best screenshots I could get. Looks much better in game.
Edit 2: Updated the spell. Improved the coding (Big thanks to Steel) Still working on making it MUI, my last attempt resulted in a Critical Error :banghead:
Edit 3: A few slight change to coding (Just made it more flexible). Fixed a small glitch in the terrain. Also added the heal ability to the hero so it's easier to set off the spell.
Gives a chance that when ever a nearby unit casts a spell, random explosions of magical energy will appear around the casting unit. Number of explosions is equal to number of enemy units near the caster x2.
Coded in - JASS
MUI - No
Leaks - None I'm aware of
Constant Functions - Yes
Import/Edit Difficulty - Low
Yay my first (good) JASS spell It's not MUI because of 1 Global unit variable that I don't know how to get around Perhaps someone else knows how. Any and all comments on the spell/ coding are greatly appreciated.
Heres the code...
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 039;B000039; //Set this to your Custom Buffs ID
endfunction
constant function ArcaneExplosion_abilityid takes nothing returns integer
return 039;A000039; //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_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(udg_AE_Owner, 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 nothing returns boolean
local boolean bool1 = not(IsUnitType(GetFilterUnit(), UNIT_TYPE_STRUCTURE))
local boolean bool2 = IsUnitAliveBJ(GetFilterUnit())
local boolean bool3 = IsUnitEnemy(GetFilterUnit(), GetOwningPlayer(udg_AE_Owner))
return (bool1 and bool2 and bool3)
endfunction
function Trig_Arcane_Explosion_Damage takes nothing returns nothing
local integer lvl = GetUnitAbilityLevel(udg_AE_Owner, ArcaneExplosion_abilityid())
call UnitDamageTarget(udg_AE_Owner, 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 integer lvl = GetUnitAbilityLevel(udg_AE_Owner, 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() )
set h = GetUnitsInRangeOfLocMatching(ArcaneExplosion_AOE_area(lvl), targ, bexpr)
call ForGroupBJ( 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
Edit: sry, best screenshots I could get. Looks much better in game.
Edit 2: Updated the spell. Improved the coding (Big thanks to Steel) Still working on making it MUI, my last attempt resulted in a Critical Error :banghead:
Edit 3: A few slight change to coding (Just made it more flexible). Fixed a small glitch in the terrain. Also added the heal ability to the hero so it's easier to set off the spell.