Maybe I'm stupid, but why doesn't this work?

Level 2
Joined
Apr 16, 2025
Messages
12
The gist of it is this: a hero uses an ability and after three seconds they are given a rune. It doesn't matter which one. I've tried two methods, but they both fail about 10% of the time.

1: Simply issuing a rune after three game seconds.

2: I set the hero to a unit variable. = When I press the ability, a 3 second timer starts, which I also set to a variable. = I create a new trigger: when the timer (this one) expires, give the rune to (this one) the hero. AND IT DOESN'T WORK 10% OF THE TIME! What am I doing wrong?

(sorry, I don't know how to insert triggers here)
 
Level 2
Joined
Apr 16, 2025
Messages
12
This should basically do what you want:
  • Give Item after 3 sec
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Thunder Clap
    • Actions
      • Wait 3.00 seconds
      • Hero - Create Tome of Experience and give it to (Triggering unit)
I have the same code, only the waiting time is game-like, which eliminates errors due to the pause. And it only works in 90% of cases.
 
Level 2
Joined
Apr 16, 2025
Messages
12
Can you post your trigger(s)? There's a link in my signature on how to do it.
JASS:
function Trig_TRIGGER_Conditions takes nothing returns boolean
if ( not ( GetSpellAbilityId() == 'Absk' ) ) then
return false
endif
return true
endfunction

function Trig_TRIGGER_Actions takes nothing returns nothing
call PolledWait( 3.00 )
call UnitAddItemByIdSwapped( 'rres', udg_MoonGlaive )
endfunction

//===========================================================================
function InitTrig_TRIGGER takes nothing returns nothing
set gg_trg_TRIGGER = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_TRIGGER, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_TRIGGER, Condition( function Trig_TRIGGER_Conditions ) )
call TriggerAddAction( gg_trg_TRIGGER, function Trig_TRIGGER_Actions )
endfunction

MoonGlaive is a unit that is pre-entered into a variable.

I converted it to jass because my editor has a different language than English.

I'm far from a beginner, I can manipulate the damage engine system quite well, but at such a stupid moment something doesn't work right. Tried through the timer = the same thing.
 
Last edited:
Level 2
Joined
Apr 16, 2025
Messages
12
what unit is udg_MoonGlaive at the time the wait finishes?
One way to find out would be to write name of the unit inside udg_MoonGlaive as game message.
Also, what happens if you replace udg_MoonGlaive for GetTriggerUnit()?
I tried both options, and ended up adding the unit to the variable, but the result was the same. The unit inside the variable is set once when choosing a hero. And in general, as I already said, in 90% of cases the trigger works correctly, it's just that sometimes for some mysterious reason they fire blanks.I also have a trigger in the map that removes runes to avoid leaks, but this is unlikely because of this, since I set the issuance of 5 runes, but sometimes it also does not work.


In fact, in a single player game I didn't notice any problems, but in a 4 player game, yes, it happens.
In other words, this error only occurs during online play.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I tried both options, and ended up adding the unit to the variable, but the result was the same. The unit inside the variable is set once when choosing a hero. And in general, as I already said, in 90% of cases the trigger works correctly, it's just that sometimes for some mysterious reason they fire blanks.I also have a trigger in the map that removes runes to avoid leaks, but this is unlikely because of this, since I set the issuance of 5 runes, but sometimes it also does not work.


In fact, in a single player game I didn't notice any problems, but in a 4 player game, yes, it happens.
Disable the trigger that removes runes, I'm almost certain that's the problem.
 
Top