• 🏆 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!

[JASS] TriggerSleepAction() Error

Status
Not open for further replies.
ok, as it says in name, the trigger below is doing the same thing twice, once with damage and one without, im going to convert the dmg one with the nondmg one, which will be finished. Anyways i thought and have seen that JASS functions with TriggerSleepAction() and 'stack' so that both can be called and both can work without any problems, unless using the same global.
JASS:
function Trig_Arcane_Bombardment_Conditions takes nothing returns boolean
    return GetSpellAbilityId()=='AHtc'
endfunction
function Trig_Arcane_Bombardment_add takes location l returns nothing//This is ware my problem is
    local effect e=AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl",l)
    call TriggerSleepAction(2.60)
    call DestroyEffect(e)
    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\ReviveHuman\\ReviveHuman.mdl",l))
    call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl",l))
endfunction//End problem (lol)
function Trig_Arcane_Bombardment_Actions takes nothing returns nothing
    local unit u=GetSpellAbilityUnit()
    local integer i=50
    local effect array e
    local location array l
    loop
        exitwhen i==0
        call Trig_Arcane_Bombardment_add(GetUnitLoc(u))
        set l[50-i]=GetUnitLoc(GroupPickRandomUnit(GetUnitsInRangeOfLocAll(750,GetUnitLoc(u))))
        set e[50-i]=AddSpecialEffectLoc("Abilities\\Spells\\NightElf\\Starfall\\StarfallCaster.mdl",l[50-i])
        set i=i-1
        call TriggerSleepAction(.01)
    endloop
    call TriggerSleepAction(2.667)
    loop
        exitwhen i>50
        call DestroyEffect(e[i])
        call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\ReviveHuman\\ReviveHuman.mdl",l[i]))
        call DestroyEffect(AddSpecialEffectLoc("Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl",l[i]))
        call UnitDamagePointLoc(u,0,250,l[i],100,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_MAGIC)
        call RemoveLocation(l[i])
        set i=i+1
    endloop
endfunction
function InitTrig_Arcane_Bombardment takes nothing returns nothing
    set gg_trg_Arcane_Bombardment=CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(gg_trg_Arcane_Bombardment,EVENT_PLAYER_UNIT_SPELL_CAST)
    call TriggerAddCondition(gg_trg_Arcane_Bombardment,Condition(function Trig_Arcane_Bombardment_Conditions))
    call TriggerAddAction(gg_trg_Arcane_Bombardment,function Trig_Arcane_Bombardment_Actions)
endfunction
-Thanks
 
Last edited:
OK, yes The Reborn Devil is right, it's i>50, but i was wondering why it waits the 2.667 secs then does the next loop, rather then doing the main loop really fast and aster 2.667 the first effect it removed then the rest really fast, hence multi-instancebility, what should i use to fix that?

Edit: the triggersleepaction(.01) is so i get smallest time, i heard that putting -1 makes it go faster, like .3 to .1 (it's random), but i wanted a very small wait, without using timers
 
TSA screws up most (99%) things that use loops and, in most (99%) cases, breaks multi-instanceability...

The exitwhen condition is the same as "never execute" xD

TSA don't disrupt the MUIness for me when I use JASS(based on my experience, also tried it in loops) though I find it really not that accurate, mostly it waits longer.
 
Level 15
Joined
Dec 18, 2007
Messages
1,098
Why did you use
JASS:
set i = i + -1
Please don't make things more difficult than they are.

Timer works really well together with Hashtables. Since they are Handles as well, you can store the values in GetHandleId(timer), 0-99999999, of Whatever Hashtable.

Next, don't use Locations. Use X/Y. They are much better and don't leak.

Also, note that BJ should not be used as far as possible. You could make your script cleaner by doing some small tweaks. For example, AddSpecialEffect returns an effect. Therefore, you can use:
JASS:
call DestroyEffect(AddSpecialEffect(...,...,...)

Anyway, Timers are still the best way. You'll love them more the longer you use JASS. That's my personal opinion.
 
OK thanks all!
-it should me set i=i-1 since im counting down from 50 to 0.
-call DestroyEffect(AddSpecialEffect(...,...,...)) doesn't work, tried it, or it's just me.
the function Trig_Arcane_Bombardment_add is only using locals and a given variable (which is a local).
-ignore the 1<50, it should be i>50 and it is fixed.
-I don't care (much) about the millisecond accuracy, it's not a cinimatic.
-I know a bout loc x/y, if i used one i can't see it.

-Again, thanks all! (PS: if you test it in map(only need this trigger and a mountain king) you'll see what i mean)

Edit: The destroy(addeffect(...)) works, wierd, when i tried it last it didn't work, now it does o_O.
 
Last edited:
Status
Not open for further replies.
Top