Snippet Create Random Effect

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
I used this for a spell I made and I figured, "Why not spread it."
rm = random model
You create a local string array, I'm using the name b. Then you set each array part to a model and call it with a string variable and it will give you a random model.
Implement Inst.
Copy function rm
set b[x] to your models and change in 'return b[GetRandomInt(1, 6)] the 6 to the largest array #.

JASS:
function rm takes nothing returns string
    local string array b
    set b[1] = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdx"
    set b[2] = "Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdx"
    set b[3] = "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdx"
    set b[4] = "Abilities\\Spells\\Demon\\ReviveDemon\\ReviveDemon.mdx"
    set b[5] = "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdx"
    set b[6] = "Abilities\\Spells\\Human\\Resurrect\\Resurrecttarget.mdx"
    return b[GetRandomInt(1, 6)]
endfunction

function actions takes nothing returns nothing
    local string modl = rm()
    call DestroyEffect(AddSpecialEffectTarget(modl, GetTriggerUnit(), "origin"))
endfunction


Spell
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
That is do-able in GUI, too. Very easily, by the way. Also, the current function doesn't allow one to choose a unit(location) to attach the effect. I would have it done it this way.

JASS:
function AddRandomSpecialEffectTarget takes unit target, string attachPoint returns effect
    local string array b
    local effect e
    set b[1] = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdx"
    set b[2] = "Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdx"
    set b[3] = "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdx"
    set b[4] = "Abilities\\Spells\\Demon\\ReviveDemon\\ReviveDemon.mdx"
    set b[5] = "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdx"
    set b[6] = "Abilities\\Spells\\Human\\Resurrect\\Resurrecttarget.mdx"    
    set e = AddSpecialEffectTarget( b[GetRandomInt(1, 6)], target, attachPoint )
    return e
endfunction
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
Nice, but..

JASS:
function actions takes nothing returns nothing
    local string modl = rm()
    call DestroyEffect(AddSpecialEffectTarget(modl, GetTriggerUnit(), "origin"))
endfunction


To:

JASS:
function actions takes nothing returns nothing
    call DestroyEffect(AddSpecialEffectTarget(rm(), GetTriggerUnit(), "origin"))
endfunction

The reason its like that is because I use it several times, I see what you mean though.

That is do-able in GUI, too. Very easily, by the way. Also, the current function doesn't allow one to choose a unit(location) to attach the effect. I would have it done it this way.

JASS:
function AddRandomSpecialEffectTarget takes unit target, string attachPoint returns effect
    local string array b
    local effect e
    set b[1] = "Abilities\\Spells\\Human\\MassTeleport\\MassTeleportTarget.mdx"
    set b[2] = "Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdx"
    set b[3] = "Abilities\\Spells\\Human\\DispelMagic\\DispelMagicTarget.mdx"
    set b[4] = "Abilities\\Spells\\Demon\\ReviveDemon\\ReviveDemon.mdx"
    set b[5] = "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdx"
    set b[6] = "Abilities\\Spells\\Human\\Resurrect\\Resurrecttarget.mdx"    
    set e = AddSpecialEffectTarget( b[GetRandomInt(1, 6)], target, attachPoint )
    return e
endfunction

Any functions that I have using takes X screw up on me, I'm not the most advanced JASSer out there so heh ^^
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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