• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Lightning Shield Spell

Status
Not open for further replies.
Level 6
Joined
May 11, 2010
Messages
236
Hey all, i'm trying to create a spell based off lightning shield. A debuff that's placed on enemies and damages the enemy it's on as well as those around it. It damages those around it by default but not the enemy it is on. Any suggestions?
 
I think the reason why this happens, is to disable the unit that bears the main buff from moving around, due to the Stats - Can Flee = True, which causes the unit to go towards various directions, in order to avoid the damage. That would cause imbalance in the game though, having a unit running around, bearing the lightning shield buff and constantly having to control it.

You can use this, if you want:
  • Hash
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set Hash = (Last created hashtable)
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Disable Hidden Ability for (Player((Integer A)))
JASS:
function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A001'
endfunction

function Timer takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local unit u = LoadUnitHandle (udg_Hash, GetHandleId (t), StringHash("unit"))
    call UnitRemoveAbility (u, 'A002')
    call FlushChildHashtable (udg_Hash, GetHandleId(u))
    set t = null
    set u = null
endfunction

function Actions takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local timer t = CreateTimer()
    local timer t1 = LoadTimerHandle (udg_Hash, GetHandleId(u), StringHash("timer"))
    if GetUnitAbilityLevel (u, 'A002') < 1 then
        call UnitAddAbility (u, 'A002')
    else
        call UnitRemoveAbility (u, 'A002')
        call PauseTimer(t1)
        call FlushChildHashtable (udg_Hash, GetHandleId(t1))
        call DestroyTimer (t1)
        call UnitAddAbility (u, 'A002')
    endif
    call SaveUnitHandle (udg_Hash, GetHandleId(t), StringHash("unit"), u)
    call SaveTimerHandle (udg_Hash, GetHandleId(u), StringHash("timer"), t)
    call TimerStart (t, 20, false, function Timer)
    set u = null
    set t = null
    set t1 = null
endfunction

//===========================================================================
function InitTrig_Lightning_Shield takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ (t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
    call TriggerAddCondition (t, Condition( function Conditions))
    call TriggerAddAction (t, function Actions)
endfunction

Test Map:
View attachment Custom Lightning Shield.w3x
 
Level 6
Joined
May 11, 2010
Messages
236
I don't actually have Jass, so I don't think I can edit the trigger in order to make it work for the custom spell, or am I wrong?
 
Level 13
Joined
Feb 18, 2009
Messages
1,381
You have JASS, it is "custom script" or "Convert to custom script", or just CnP from his map?
 
Level 6
Joined
May 11, 2010
Messages
236
Okay my bad, must be something else i'm doing wrong then. i'll look into it, thanks for your help! + rep
 
Last edited:
Status
Not open for further replies.
Top