• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Problem with Special Effect

Status
Not open for further replies.
Level 2
Joined
Jun 10, 2013
Messages
8
Hello guys, here's the deal:
JASS:
//======================================SPECIAL EFFECT==================================
private function Effect takes nothing returns nothing

    local location spellLoc = GetSpellTargetLoc()
    local location effectPos
    local integer effectCount = 0
    
    set effectPos = PolarProjectionBJ(spellLoc, GetRandomReal(0.00, 150.00), GetRandomDirectionDeg())
    
    loop
    exitwhen effectCount == 20
        call DestroyEffect(AddSpecialEffectLoc(DAMAGE_EFFECT, effectPos))
        set effectCount = effectCount + 1
        call TriggerSleepAction(1.00)
    endloop
    
    call RemoveLocation(spellLoc)
    call RemoveLocation(effectPos)
    set spellLoc = null
    set effectPos = null

    
endfunction
I want this special effect to fire 20 times, 1 time every 0.15/sec when the spell is casted.
I dont know much about special effects but i think this should have worked.
Can anyone fix this to me ? ps: I'm trying to do it without using another trigger. Thanks and sorry for my english. :thumbs_up:
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
This is the main idea. I'm not handy with the private stuff and else, but this is a good way to achieve what you want. Feel free to change function names and the "private" thingy, the Hash name, and stuff to adjust it to the way you code.

Basically you store the data in the TimerID, and start the timer, and each time the timer expires you retrieve the data from it to do what you want. After it's done, you destroy the timer and clean everything. I know there are vJASS resources to make this faster, without using the Hashtable, but I don't know about that.

JASS:
globals
    hashtable Hash = InitHashtable()
endglobals

//======================================SPECIAL EFFECT==================================
function TimerEffect takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local integer id = GetHandleId(t)
    local real x = LoadReal(Hash, id, 0)
    local real y = LoadReal(Hash, id, 1)
    local integer count = LoadInteger(Hash, id, 2)
    
    call DestroyEffect(AddSpecialEffect(DAMAGE_EFFECT, x, y))
    
    set count = count+1
    
    if count == 20 then
        call PauseTimer(t)
        call DestroyTimer(t)
        call FlushChildHashtable(Hash, id)
    else
        call SaveInteger(Hash, id, 2, count)
    endif
    
    set t = null
endfunction


function Effect takes nothing returns nothing

    local timer t = CreateTimer()
    local real r = GetRandomReal(0.00, 150.00)
    local real a = GetRandomReal(0, 359) * bj_DEGTORAD
    local real x = GetSpellTargetX() + r * Cos(a)
    local real y = GetSpellTargetY() + r * Sin(a)
    local integer id = GetHandleId(t)
    
    call SaveReal(   Hash, id, 0, x)
    call SaveReal(   Hash, id, 1, y)
    call SaveInteger(Hash, id, 2, 0)

    call TimerStart(t, 0.15, true, function TimerEffect)
    
    set t = null
endfunction
 
Level 2
Joined
Jun 10, 2013
Messages
8
Thanks again Spartipilo.
About your DOT sys, it worked just fine but it isn't showing the correct damage, and yes I'm using the weep damage detection sys, you know how to fix it ? Thanks. :thumbs_up:
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
About the DOT:
It's probably because of ATTACK_TYPE_MAGIC, or DAMAGE_TYPE_NORMAL since armor and Magic Resist reduces magic and normal damage. Also because it's not showing decimals. Damage 20.9 may be shown as "20" though it reduces hp by 21. You can make the damage "Chaos" or "Universal" (or something like that) to make it "Pure" damage.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
You're right. I did several tests, found problems, and fixed the code. Also added some stuff. Added a test map too.
 
Status
Not open for further replies.
Top