How do i make an Electric Shield

Kahiera

Active Member
Reaction score
9
What I'm asking is how to make something similar to WoW's shaman ability. It can only cast on the caster, and what it does is gives a shield that has 3 stacks. each time the shaman is attacked, a charge of the shield goes away and it deals damage to the attacker. there is a time requirement before the next stack can be used. how would this be recreated into wc3?
 

johnnymra

New Member
Reaction score
14
Actually, yes, it is already an ability called like this ingame but it's made to be an item ability and can be casted only on others than the caster.
Your only needed work would be to create a custom ability that is based on that one, at which you modify the damage dealt by a charge... the number of levels for the spell (if it's for a hero), manacost, cooldown, etc.
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
613
Lightning Shield doesn't have an effect cooldown or layers. It just does damage to all units around the target for the duration of the spell.

You'll need a dummy ability that places the buff on the target, then detect whenever it gets attacked. If the number of stacks is higher than 0 and the duration since the last cast is higher than the cooldown, deal the damage.

Rather than explain further, I'd rather make a demo map with this ability.
 

Kahiera

Active Member
Reaction score
9
that's close, but i want the ability to be active not passive.
this is what i've been able to trigger for it so far. it seems to work for 3 of the 5 'stacks'
Trigger:
  • SpellInit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Disable Electric Shield (SB) for (Player((Integer A)))
          • Set ElectricShieldStacks[(Integer A)] = 0

Trigger:
  • ElectricShieldCast
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Electric Shield
    • Actions
      • Set ElectricShieldStacks[(Player number of (Owner of (Casting unit)))] = 5
      • Countdown Timer - Start ElectricShield_Timer[(Player number of (Owner of (Casting unit)))] as a One-shot timer that will expire in 3.00 seconds
      • Unit - Add Electric Shield (SB) to (Casting unit)

Trigger:
  • ElectricShieldLoop
    • Events
      • Unit - A unit Is attacked
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ElectricShieldStacks[(Player number of (Owner of (Attacked unit)))] Not equal to 0
          • (Remaining time for ElectricShield_Timer[(Player number of (Owner of (Attacked unit)))]) Equal to 0.00
        • Then - Actions
          • Countdown Timer - Start ElectricShield_Timer[(Player number of (Owner of (Casting unit)))] as a One-shot timer that will expire in 3.00 seconds
          • Set ElectricShieldStacks[(Player number of (Owner of (Attacked unit)))] = (ElectricShieldStacks[(Player number of (Owner of (Attacked unit)))] - 1)
          • Unit - Cause (Attacked unit) to damage (Attacking unit), dealing (((Real((Level of (Attacking unit)))) x 20.00) + 50.00) damage of attack type Spells and damage type Lightning
        • Else - Actions
          • Unit - Remove Electric Shield (SB) from (Casting unit)
          • Unit - Remove Electric Shield (Dummy) from (Casting unit)

the attachment also doesn't remove, that's why i tried removing both the spell book and the dummy spells
 

Kahiera

Active Member
Reaction score
9
omg that seems to work amazingly. i'm not very familiar with jass, so would you mind telling me where i can modify the damage?
to clarify how i want the damage done, i want 5% damage returned (why i prefer thorns aura being involved) and 20x attacker level + 50

but i guess i can go without the 5% if it'd be complicated

edit: oh and 5 levels of the spell, if that changes the trigger
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
you could try this
make a spell with the base ability bloodlust (assuming you dont use this ability on the same hero already)
remove the effects and add the lightning shield artwork to the ability on the units origin/head w/e u want it
change the bloodlust buff to reflect lightning shield or create a new one and change the ability to properly show the buff

now a trigger

Trigger:
  • Trigger:
    • Events
      • A unit finishes casting an ability
    • Conditions
      • Ability equal to lightning shield is true (boolean)
    • Actions
      • Set Shield_Charges = 3 (integer variable)


new trigger

Trigger:
  • Trigger:
    • Events
      • A unit is attacked
    • Condition
      • Attacking Unit has buff Shield is true (boolean)
    • Actions
      • If (Conditions) Then (Actions) Else (Else Actions)
        • If (Conditions)
          • Shield_Cooldown = True
        • Then (Actions)
          • Unit - Cause Triggering Unit to damage Attacking unit for (shield damage)
          • Set Shield_Cooldown[player number of owner of triggering unit] = False
          • Countdown Timer - Create Shield_Timer (this must be player specific) as a one shot timer for (min time between damage)
          • If (Conditions) Then (Actions) Else (Else Actions)
            • If (Conditions)
              • Shield_Charges is greater than 1
            • Then
              • Set Shield_Charges = Shield_Charges - 1
            • Else
              • Set Shield_Charges = 0
              • Unit - Remove Buff Lightning Shield


new trigger

Trigger:
  • Trigger (1 required for each player)
    • Events
      • Shield_Timer[#(1-12)] expires
    • Conditions
    • Actions
      • Set Shield_Cooldown[#] = true


then whenever purge is casted or something like that just set their shield count to 0 :)

and i just thought of something

you could give thorns aura in a spellbook with the spellbook disabled to the unit, then when the unit is attacked remove the spellbook and cast a buff with the same description as ur version of thorns, then when that buff is removed give the spellbook back
that way you dont need a timer to return the damage capabilities to normal, just a buff with a duration equal to the time you need the damage to stop
 

NotInTheFace

Member
Reaction score
17
Yeah, let me try to explain the trigger in detail. (I've also made a few improvements)

JASS:

function lightning_shield_delay takes nothing returns nothing //this function runs 2 seconds after our shielded unit gets attacked
    local timer tim = GetExpiredTimer()
    local trigger trig = LoadTriggerHandle(udg_HASHTABLE, GetHandleId(tim), 0)
    call EnableTrigger(trig) //we re-enable our trigger
    call FlushChildHashtable(udg_HASHTABLE, GetHandleId(tim)) //cleanup our saved hashtable values
    call DestroyTimer(tim) //destroy this timer
    set tim = null //clean up our handle variables so they don't leak
    set trig = null
endfunction

function lightning_shield_attacked takes nothing returns boolean //this one runs when our shielded unit gets attacked
    local trigger trig = GetTriggeringTrigger()
    local timer tim = LoadTimerHandle(udg_HASHTABLE, GetHandleId(trig), 0)
    local integer key = GetHandleId(tim) //All of our settings are saved to the timer's key
    local integer count = LoadInteger(udg_HASHTABLE, key, 2) //Pull our saved settings from the hashtable
    local integer level = LoadInteger(udg_HASHTABLE, key, 3)
    local unit dummy = LoadUnitHandle(udg_HASHTABLE, key, 5 + count) //Note that this is the last dummy in the list
    local unit caster = LoadUnitHandle(udg_HASHTABLE, key, 0)
    local unit target = GetAttacker() //this is the unit attacking us, note that the trigger doesn't distinguish friend from foe
    local real damage = 100. * level //the damage the spell will deal. I set it to be just 100 * the spell level

    call DisableTrigger(trig) //we have to turn off this trigger, or it will run on every attack. We want a delay between triggering attacks
    call RemoveUnit(dummy) //remove a dummy
    //here is where we damage the attacker, I have the spell caster dealing the damage
    call UnitDamageTarget(caster, target, 100. * level, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_FIRE, null)
    //Display a lightning effect on the attacker
    call DestroyEffect(AddSpecialEffect("Abilities\\Weapons\\Bolt\\BoltImpact.mdl", GetUnitX(target), GetUnitY(target)))
    if count == 1 then //if this was the last charge on the shield, we need to clean up the whole thing
        call UnitRemoveAbility(LoadUnitHandle(udg_HASHTABLE, GetHandleId(tim), 1), 'Blsh') //clear the lightning shield buff
        call FlushChildHashtable(udg_HASHTABLE, GetHandleId(tim)) //clean up the saved hashtable values
        call FlushChildHashtable(udg_HASHTABLE, GetHandleId(trig))
        call DestroyTimer(tim) //destroy the timer and the trigger we created
        call DestroyTrigger(trig)
    else //if we have more charges, save the new number of charges, then create a new timer to turn this trigger back on after 2 sec
        call SaveInteger(udg_HASHTABLE, key, 2, count - 1)
        set tim = CreateTimer()
        call SaveTriggerHandle(udg_HASHTABLE, GetHandleId(tim), 0, trig) //save this trigger in the new timer
        call TimerStart(tim, 2., false, function lightning_shield_delay)
    endif
    set trig = null //clean up our handle variables so they don't leak
    set tim = null
    set dummy = null
    set caster = null
    set target = null
    return false
endfunction

function lightning_shield_tick takes nothing returns nothing //Runs 32 times a second, handles the animation
    local timer tim = GetExpiredTimer()
    local integer key = GetHandleId(tim)
    local unit caster = LoadUnitHandle(udg_HASHTABLE, key, 0) //pull the saved variables out of the hashtable
    local unit target = LoadUnitHandle(udg_HASHTABLE, key, 1)
    local integer count = LoadInteger(udg_HASHTABLE, key, 2)
    local real angle = LoadReal(udg_HASHTABLE, key, 4)
    local trigger trig = LoadTriggerHandle(udg_HASHTABLE, key, 5)
    local unit dummy
    local real x = GetUnitX(target)
    local real y = GetUnitY(target)
    local real dist = 70. + I2R(count * 5) //The distance the dummies are offset from the shielded unit
    local integer i = 0
    local boolean wantCleanup = GetUnitAbilityLevel(target, 'Blsh')<1 //If the lightning shield buff is gone, cleanup the spell

    loop //this loop runs from i=0 to i=count-1
        exitwhen i >= count
        set dummy = LoadUnitHandle(udg_HASHTABLE, key, 6 + i)
        if wantCleanup then //if the shield is gone, we destroy the dummies
            call RemoveUnit(dummy)
        else
            call SetUnitX(dummy, x + dist * Cos(angle)) //otherwise, we space them evenly around our shielded unit
            call SetUnitY(dummy, y + dist * Sin(angle))
            set angle = angle + 2 * bj_PI / count
        endif
        set i = i + 1
    endloop
    set angle = angle - 0.2 //this is how the dummies rotate - we change the starting angle a little bit each time the timer runs.
      //if we set this to a bigger number, they rotate faster, if we change the - to a + they rotate counter-clockwise
    if angle < 0 then
        set angle = angle + 2 * bj_PI //keep our angles between 0 and 2*PI
    endif
    call SaveReal(udg_HASHTABLE, key, 4, angle) //save our new starting angle for next time
    if wantCleanup then //if the shield is gone, cleanup our hashtable and destroy both the timer and the trigger
        call FlushChildHashtable(udg_HASHTABLE, key)
        call FlushChildHashtable(udg_HASHTABLE, GetHandleId(trig))
        call DisableTrigger(trig)
        call DestroyTrigger(trig)
        call DestroyTimer(tim)
    endif
    set tim = null //clean up our handle variables so they don't leak
    set caster = null
    set target = null
    set dummy = null
    set trig = null
endfunction

function lightning_shield takes unit caster, unit target returns nothing //runs once when the spell is first cast
    local timer tim = CreateTimer() //A timer for the animation
    local trigger trig = CreateTrigger() //A trigger for the shield's effect
    local integer key = GetHandleId(tim)
    local real x = GetUnitX(target)
    local real y = GetUnitY(target)
    local real dist = 95. //distance from the target to create the dummies
    local real angle = 0. //starting angle to create the dummies from
    local unit dummy
    local player p = GetOwningPlayer(target)
    local integer i = 0 //counter varible for our loop
    local integer level = GetUnitAbilityLevel(caster, 'A000') //the level of the ability for the caster
    local integer count = level + 2 //the number of charges in the shield

    call SaveUnitHandle(udg_HASHTABLE, key, 0, caster) //Global initialized hashtable variable, save the caster
    call SaveUnitHandle(udg_HASHTABLE, key, 1, target) //save the target
    call SaveInteger(udg_HASHTABLE, key, 2, count) //save the number of charges in the shield
    call SaveInteger(udg_HASHTABLE, key, 3, level) //save the level of the ability for the caster
    call SaveReal(udg_HASHTABLE, key, 4, 0.) //save the initial rotational angle
    call SaveTriggerHandle(udg_HASHTABLE, key, 5, trig) //save the trigger for disabling later

    loop //set up the dummy units, this loop runs from i=0 to i=count-1
        exitwhen i >= count
        set dummy = CreateUnit(p, 'h000', x + dist * Cos(angle), y + dist * Sin(angle), 0.) //Your dummy unit ID
        call SaveUnitHandle(udg_HASHTABLE, key, 6 + i, dummy)
        set angle = angle + 2 * bj_PI / count //set the angle, dividing a full circle by the number of dummies
        set i = i + 1
    endloop
    call SaveTimerHandle(udg_HASHTABLE, GetHandleId(trig), 0, tim) //save the timer (which has everything elsed saved to it) to the trigger
    call TriggerAddCondition(trig, Condition(function lightning_shield_attacked)) //this is the function than runs when our shilded unit gets attacked
    call TriggerRegisterUnitEvent(trig, target, EVENT_UNIT_ATTACKED) //this is the event that triggers it - being attacked
    call TimerStart(tim, 0.03125, true, function lightning_shield_tick) //set our timer to run 32 times a second
    set tim = null //have to clean up our handle variables to prevent leaks
    set dummy = null
    set trig = null
endfunction

function lightning_shield_trig takes nothing returns boolean
    //we only want to run our trigger function if the right ability is being cast AND the target doesn't already have a shield on them
    if GetSpellAbilityId() == 'A000' and GetUnitAbilityLevel(GetSpellTargetUnit(), 'Blsh')==0 then //Your Ability ID
        call lightning_shield(GetTriggerUnit(), GetSpellTargetUnit())
    endif
    return false
endfunction

//===========================================================================
function InitTrig_Lightning_Shield takes nothing returns nothing
    set gg_trg_Lightning_Shield = CreateTrigger(  )
    call TriggerAddCondition(gg_trg_Lightning_Shield, Condition(function lightning_shield_trig))
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Lightning_Shield, EVENT_PLAYER_UNIT_SPELL_EFFECT)
endfunction


Hope this helps!
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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