Spell Electrical Discharge

Immolation

Member
Reaction score
20
Electrical Discharge​
Gives a chance to release lightning bolts upon damaging an enemy. A single enemy cannot be hit often.

GUI
/vJASS= vJASS
Leakless?= Yes.
Lagless= Yes.
MUI/MPI?= MUI
Requires: AIDS, DummyCaster, Event, T32, Lightning and Damage.
Changelog:
v1.10a:
-Improved preload function.
-Improved code.

v1.10:
-Revamped code.
-Now uses Lightning and T32 to handle lightnings.
-Uses DummyCaster instead of recreating dummies.
-Added more options for customizing the spell.

v1.00:
-Initial release.

Code:
JASS:
scope ElectricalDischarge initializer Init
//-------------------------------------------------------------
//             Electrical Discharge by Immolation                
//-------------------------------------------------------------

// Description:
//---------------------------
//Gives a chance to release lightning bolts upon damaging an enemy.
//A single enemy cannot be hit often.

// What do I need to import it in my map?
//---------------------------
// You need to download JASS NewGen, available at the following links:
//
// -http://www.thehelper.net/forums/showthread.php?t=73936
// -http://www.wc3c.net/showthread.php?t=90999
//
//Install it and then read the following paragraph.

// How do I put it in my map?
//---------------------------
// 1. Copy:
//  a. Copy the buff found in the Buff tab in the Object Editor.
//  b. Copy the Abilities found in the Abilities tab in the Object Editor.
//  c. Copy all the triggers found in the folder where this trigger is located.
//     Check the Damage and DummyCaster triggers for implementation instructions about those systems.
// 2. Press CTRL + D while in Abilities section in Object Editor to find out the rawcode of:
//  a. The "Electrical Discharge" ability. Change the SPELL_ID to the rawcode that you find(it's 'A000' in this map).
//  b. The "Static Remnant(Electrical Discharge)" ability. Change the BUFFSPELL_ID to the rawcode that you find(it's 'A001' in this map).
//  c. The "Static Remnant" buff. Change the BUFF_ID to the rawcode that you find(it's 'B000' in this map).
// 3. You have succesfully imported the spell <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite8" alt=":D" title="Big Grin    :D" loading="lazy" data-shortname=":D" />

// Changelog:
//---------------------------
//v1.10a:
//-Improved preload function.
//-Improved code.

//v1.10:
//-Revamped code.
//-Now uses Lightning and T32 to handle lightnings.
//-Uses DummyCaster instead of recreating dummies.
//-Added more options for customizing the spell.

// v1.00
// -Public release.

//---------------------------
// TheHelper.net

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//                             LIST OF CONFIGURABLES
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
//About Configurables:
//Units won&#039;t get hit by this spell more than once every X seconds. The amount of time
//in which the units will not get hit by this spell is a buff applied through the
//Static Remnant(Electrical Discharge) spell. Set the duration there.

    globals
        //Rawcodes
        private constant integer SPELL_ID = &#039;A000&#039; 
        private constant integer BUFFSPELL_ID = &#039;A001&#039;
        private constant integer BUFF_ID = &#039;B000&#039;
        
        //Other stuff:
        private constant boolean EFFECT_ON_HIT = true //Create effects on damaged units?
        private constant string EFFECT_NAME = &quot;Abilities\\Weapons\\Bolt\\BoltImpact.mdl&quot; //Which effect?
        private constant string EFFECT_ATTACHMENT = &quot;origin&quot; //Where to attach the effect?
        
        //Lightning settings:
        private constant string LIGHTNING_EFFECT = &quot;CLPB&quot; //See the Lightning trigger for a complete list of lightning effects.
        private constant real LIGHTNING_DURATION = 1.00
        
        //Preload:
        private constant boolean PRELOAD = true //Removes lag when first casting the spell.
    endglobals

    private function ChanceToFire takes integer level returns integer
        return 17 + (level * 3)
    endfunction
    
    private function Damage takes integer level returns real
        return 15.00 + (level * 5.00)
    endfunction
    
    private function Targets takes integer level returns integer
        return R2I(2.50 + level * 0.51)
    endfunction
    
    private function Range takes integer level returns real
        return 500.00
    endfunction
    
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

    globals
        private group g = CreateGroup()
    endglobals

    private function PreloadSpell takes nothing returns nothing
        call UnitAddAbility(DUMMY, SPELL_ID)
        call UnitRemoveAbility(DUMMY, SPELL_ID)
        call UnitAddAbility(DUMMY, BUFFSPELL_ID)
        call UnitRemoveAbility(DUMMY, BUFFSPELL_ID)
        call Preload(EFFECT_NAME)
    endfunction

    private function GroupFilter takes nothing returns boolean
        return IsPlayerEnemy(GetOwningPlayer(GetEventDamageSource()), GetOwningPlayer(GetFilterUnit())) == true and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) &gt; 0 /*
        */ and GetUnitTypeId(GetFilterUnit()) != DUMMY_TYPE and GetUnitAbilityLevel(GetFilterUnit(), BUFF_ID) == 0 
    endfunction

     private function Main takes nothing returns boolean
        local unit caster = GetEventDamageSource()
        local unit damaged
        local real x
        local real y
        local integer level = GetUnitAbilityLevel(caster, SPELL_ID)
        local integer loopStart
        local unit target
        if GetRandomInt(1, 100) &lt;= 100 then
            set loopStart = 0
            set damaged = GetTriggerUnit()
            set x = GetUnitX(damaged)
            set y = GetUnitY(damaged)
            if level &gt; 0 and IsPlayerEnemy(GetOwningPlayer(caster), GetOwningPlayer(damaged)) == true then
                if EFFECT_ON_HIT == true then
                    call DestroyEffect(AddSpecialEffectTarget(EFFECT_NAME, damaged, EFFECT_ATTACHMENT))
                endif
                call UnitAddAbility(DUMMY, BUFFSPELL_ID)
                call SetUnitAbilityLevel(DUMMY, BUFFSPELL_ID, level)
                call IssueTargetOrder(DUMMY, &quot;cripple&quot;, damaged)
                call UnitRemoveAbility(DUMMY, BUFFSPELL_ID) //Prevents conflict with other spells with the same orderstring.
                call GroupEnumUnitsInRange(g, x, y, Range(level), Condition(function GroupFilter))
                loop
                    set target = FirstOfGroup(g)
                    exitwhen target == null or loopStart == Targets(level)
                    if EFFECT_ON_HIT == true then
                        call DestroyEffect(AddSpecialEffectTarget(EFFECT_NAME, target, EFFECT_ATTACHMENT))
                    endif
                    call UnitAddAbility(DUMMY, BUFFSPELL_ID)
                    call SetUnitAbilityLevel(DUMMY, BUFFSPELL_ID, level)
                    call IssueTargetOrder(DUMMY, &quot;cripple&quot;, target)
                    call UnitRemoveAbility(DUMMY, BUFFSPELL_ID) //Prevents conflict with other spells with the same orderstring.
                    call Damage_EnableEvent(false)
                    call Damage_Spell(caster, target, Damage(level))
                    call Damage_EnableEvent(true)
                    call Lightning_UnitUnit(LIGHTNING_EFFECT, damaged, target, 1.00, true)
                    set loopStart = loopStart + 1
                    call GroupRemoveUnit(g, target)
                endloop
            endif
            set target = null
            set damaged = null
        endif
        return false
    endfunction
    //===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call Damage_RegisterEvent(t)
        call TriggerAddCondition(t, Condition(function Main))
        if PRELOAD == true then
            call PreloadSpell()
        endif
    endfunction
endscope
Screenshot:

I know it's simple, but I find it a good alternative to standard old boring splash.
(And this has got more eye-candy! Yummy.)

Need feedback ;)

Edit by Flare: Screenshot put in SPOILER tags (it was stretching the page)
 

Attachments

  • Electrical Discharge v1.10a.w3x
    103 KB · Views: 188

Weep

Godspeed to the sound of the pounding
Reaction score
400
Nice eye-candy for a splash ability. :) I like the idea of a per-target cooldown.

Your dummy unit probably should not be flying - I attacked the footman near the tree, and the lightning bolts came from the air above its head, because the flying dummy was positioned higher due to the proximity of the tree.

Ideally, you would have two dummy unit-types, one set to hover and one set to fly, and use the appropriate one for the movement type of the target (with additional SetUnitX/Y since a ground unit cannot be created exactly on top of another). You also should set its fly height to match that of the target.

It's the little things that give an ability polish. :thup:
 
Reaction score
341
  • Just say it requires damage.
  • The LoopEnd local is useless, just directly use Targets(level) in the loop
  • Your dynamically creating dummies. Just use a single one and move it. Constantly creating and removing units is idiotic.
  • Now that I look at it, your doing your group completely wrong. The following would be better;
    JASS:
    //
        call GroupEnumUnitsInRange(g, x, y, 500.00, Condition(function GroupFilter))
        loop
            set target = FirstOfGroup(g)
            exitwhen target == null
            // actions
            call GroupRemoveUnit(g, target)
        endloop
 

Flare

Stops copies me!
Reaction score
662
The LoopEnd local is useless, just directly use Targets(level) in the loop
It's not useless... if you input the function call into the exitwhen condition, you end up calling that function everytime the loop runs (to check if the values match up as they are intended to) so, inevitably, you end up calling Targets multiple times. The Targets calls may be inlined, but I don't think R2I will be (I don't know much about inlining, but it seems implausible that you can inline natives)

So, which would you prefer - 1 R2I call, or 3 (4, at level 3 of the skill) R2I calls? Your choice :)

Now that I look at it, your doing your group completely wrong. The following would be better;
Given the spell description, you're also doing it wrong. If you don't mind altering the spell to only allow each target to get hit by (at most) 1 lightning bolt per discharge, then you could do
JASS:
//If we move the GroupEnum outside of the loop, units can only be enumerated once per discharge, thus limiting them to being hit once
call GroupEnumUnitsInRange(g, x, y, 500.00, Condition(function GroupFilter))                loop
                    exitwhen LoopStart &gt; LoopEnd
                    set target = GroupPickRandomUnit(g)
                    set dummy = CreateUnit(p, DUMMY_ID, x, y, 0.00)
                    call UnitAddAbility(dummy, BUFFSPELL_ID)
                    call SetUnitAbilityLevel(dummy, BUFFSPELL_ID, level)
                    call IssueTargetOrder(dummy, &quot;cripple&quot;, target)
                    set dummy = CreateUnit(p, DUMMY_ID, x, y, 0.00)
                    call UnitAddAbility(dummy, EFFECT_ID)
                    call IssueTargetOrder(dummy, &quot;chainlightning&quot;, target)
                    call Damage_EnableEvent(false)
                    call Damage_Spell(att, target, Damage(level))
                    call Damage_EnableEvent(true)
                    set LoopStart = LoopStart + 1
//now, to ensure that our random unit isn&#039;t randomly selected again on the next loop iteration, we remove it from the group
//this unit can no longer be hit by lightning bolts from this specific discharge
                    call GroupRemoveUnit (g, target)
                endloop


If you want to allow units to be hit multiple times, you could place that call GroupRemoveUnit (g, target) within an if that has a random condition
JASS:
if GetRandomInt (1, 2) == 1
  call GroupRemoveUnit (g, target)
endif

That way, anytime a unit is struck by a lightning bolt, there is a 50% chance they will be exempt from being target by any other lightning bolts from the same discharge, and a 50% chance that they will still be elligible targets for any other lightning bolts from that discharge

EDIT:
Just say it requires damage
Well, there's absolutely nothing wrong with letting people know exactly what is required (and linking to it, which is quite helpful :))
 

Immolation

Member
Reaction score
20
Updated.

v1.10:

-Revamped code.
-Now uses Lightning and T32 to handle lightnings.
-Uses DummyCaster instead of recreating dummies.
-Added more options for customizing the spell.

Need feedback! Thanks ;)

~Immo
 

Executor

I see you
Reaction score
57
JASS:
private function Main takes nothing returns boolean
        local unit damaged
        local real x
        local real y
        local unit caster = GetEventDamageSource()
        local integer level = GetUnitAbilityLevel(caster, SPELL_ID)
        local integer loopStart
        local integer loopEnd
        local unit target
        if GetUnitAbilityLevel(GetEventDamageSource(), SPELL_ID) &gt; 0                                                /*
           */ and IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetEventDamageSource())) == false /*
           */ and ChanceToFire(level) &lt;= GetRandomInt(1,100)  then
           
            set damaged = GetTriggerUnit()
            set x = GetUnitX(damaged)
            set y = GetUnitY(damaged)
            ...
        ...
...


Better?
 

RaiJin

New Member
Reaction score
40
JASS:
private function Main takes nothing returns boolean
        local unit damaged
        local real x
        local real y
        local unit caster = GetEventDamageSource()
        local integer level = GetUnitAbilityLevel(caster, SPELL_ID)
        local integer loopStart
        local integer loopEnd
        local unit target
        if GetUnitAbilityLevel(GetEventDamageSource(), SPELL_ID) &gt; 0                                                /*
           */ and IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(GetEventDamageSource())) == false /*
           */ and ChanceToFire(level) &lt;= GetRandomInt(1,100)  then
           
            set damaged = GetTriggerUnit()
            set x = GetUnitX(damaged)
            set y = GetUnitY(damaged)
            ...
        ...
...


Better?

whats the point of declaring caster=GetEventDamageSource() if your just going to end up using GetEventDamageSource()?

JASS:
        if GetUnitAbilityLevel(caster, SPELL_ID) &gt; 0                                                /*
           */ and IsPlayerAlly(GetOwningPlayer(GetTriggerUnit()), GetOwningPlayer(caster)) == false /*
           */ and ChanceToFire(level) &lt;= GetRandomInt(1,100)  then
           
            set damaged = GetTriggerUnit()
            set x = GetUnitX(damaged)
            set y = GetUnitY(damaged)
            ...
 

Jesus4Lyf

Good Idea™
Reaction score
397
v1.10:[/B]
-Revamped code.
-Now uses Lightning and T32 to handle lightnings.
-Uses DummyCaster instead of recreating dummies.
-Added more options for customizing the spell.
Just wanted to say, it's good to see you using these things. :thup:

Keep up the good work. :)
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
The ability still works, but I don't see any actual lightning bolts anymore - only the hit effect...
 

Immolation

Member
Reaction score
20
Uploaded the testmap with the fixed lightning, there was a problem with the lightning index. I wrote 'CLBP' instead of 'CLPB' :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • WildTurkey WildTurkey:
    is there a stephen green in the house?
    +1
  • The Helper The Helper:
    What is up WildTurkey?
  • The Helper The Helper:
    Looks like Google fixed whatever mistake that made the recipes on the site go crazy and we are no longer trending towards a recipe site lol - I don't care though because it motivated me to spend alot of time on the site improving it and at least now the content people are looking at is not stupid and embarrassing like it was when I first got back into this like 5 years ago.
  • The Helper The Helper:
    Plus - I have a pretty bad ass recipe collection now! That section of the site is 10 thousand times better than it was before
  • The Helper The Helper:
    We now have a web designer at my job. A legit talented professional! I am going to get him to redesign the site theme. It is time.
  • Varine Varine:
    I got one more day of community service and then I'm free from this nonsense! I polished a cop car today for a funeral or something I guess
  • Varine Varine:
    They also were digging threw old shit at the sheriff's office and I tried to get them to give me the old electronic stuff, but they said no. They can't give it to people because they might use it to impersonate a cop or break into their network or some shit? idk but it was a shame to see them take a whole bunch of radios and shit to get shredded and landfilled
  • The Helper The Helper:
    whatever at least you are free
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • 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 Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top