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

Trigger suddenly works when converted to custom text?

Status
Not open for further replies.
Level 5
Joined
May 12, 2014
Messages
133
Hey! Testing out some of the new trigger stuff that got added a while back (waaaay late to the party I know). I wanted to make use of "Unit - Set Attack Interval". At first the action wasn't working, so I figured it might have been a 0 indexed thing. Converted the trigger to custom text and slapped a 0 on it. It works! Used a custom line in a GUI trigger with the same action and... it doesn't work.

These 2 triggers are pretty much the exact same thing right? Why does the custom text one work but not the GUI one?
  • Hero Attack Rate
    • Events
      • Player - Player 1 (Red) types a chat message containing test as An exact match
    • Conditions
    • Actions
      • Game - Display to (All players) the text: testing
      • Custom script: call BlzSetUnitAttackCooldown( gg_unit_Hmkg_0163, 0.30, 0 )
      • Trigger - Turn off (This trigger)
      • Wait 6.00 seconds
      • Game - Display to (All players) the text: done testing
      • Trigger - Turn on (This trigger)
      • Custom script: call BlzSetUnitAttackCooldown( gg_unit_Hmkg_0163, 2.22, 0 )
Code:
function Trig_Hero_Attack_Rate_Copy_Actions takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_716" )
    call BlzSetUnitAttackCooldown( gg_unit_Hmkg_0163, 0.30, 0 )
    call DisableTrigger( GetTriggeringTrigger() )
    call TriggerSleepAction( 6.00 )
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_723" )
    call EnableTrigger( GetTriggeringTrigger() )
    call BlzSetUnitAttackCooldown( gg_unit_Hmkg_0163, 2.22, 0 )
endfunction
//===========================================================================
function InitTrig_Hero_Attack_Rate_Copy takes nothing returns nothing
    set gg_trg_Hero_Attack_Rate_Copy = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Hero_Attack_Rate_Copy, Player(0), "test", true )
    call TriggerAddAction( gg_trg_Hero_Attack_Rate_Copy, function Trig_Hero_Attack_Rate_Copy_Actions )
endfunction

Also included a test map that has this issue. typing "test1" runs a trigger in GUI, and typing "test2" runs a trigger converted to custom text.

EDIT: Forgot to include the triggers from the test map! They're pretty much the same thing as above, but refer to different mountain kings each. Ya know, just in case I might've did things differently and didn't notice, or someone doesn't have access to WE atm. Test 1 (GUI trigger) fails, whereas Test 2 (custom text trigger) works correctly. Test 2 Preconvert fails also.

  • Attack Rate Test 1
    • Events
      • Player - Player 1 (Red) types a chat message containing test1 as An exact match
    • Conditions
    • Actions
      • Game - Display to (All players) the text: test1
      • Custom script: call BlzSetUnitAttackCooldown( gg_unit_Hmkg_0000, 0.30, 0 )
      • Trigger - Turn off (This trigger)
      • Wait 5.00 seconds
      • Game - Display to (All players) the text: done test1
      • Custom script: call BlzSetUnitAttackCooldown( gg_unit_Hmkg_0000, 2.22, 0 )
      • Trigger - Turn on (This trigger)
Code:
function Trig_Attack_Rate_Test_2_Actions takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_009" )
    call BlzSetUnitAttackCooldown( gg_unit_Hmkg_0001, 0.30, 0 )
    call DisableTrigger( GetTriggeringTrigger() )
    call TriggerSleepAction( 5.00 )
    call DisplayTextToForce( GetPlayersAll(), "TRIGSTR_010" )
    call BlzSetUnitAttackCooldown( gg_unit_Hmkg_0001, 2.22, 0 )
    call EnableTrigger( GetTriggeringTrigger() )
endfunction

//===========================================================================
function InitTrig_Attack_Rate_Test_2 takes nothing returns nothing
    set gg_trg_Attack_Rate_Test_2 = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Attack_Rate_Test_2, Player(0), "test2", true )
    call TriggerAddAction( gg_trg_Attack_Rate_Test_2, function Trig_Attack_Rate_Test_2_Actions )
endfunction
  • Attack Rate Test 2 Preconvert
    • Events
      • Player - Player 1 (Red) types a chat message containing test2 as An exact match
    • Conditions
    • Actions
      • Game - Display to (All players) the text: test2
      • Custom script: call BlzSetUnitAttackCooldown( gg_unit_Hmkg_0001, 0.30, 0 )
      • Trigger - Turn off (This trigger)
      • Wait 5.00 seconds
      • Game - Display to (All players) the text: done test2
      • Custom script: call BlzSetUnitAttackCooldown( gg_unit_Hmkg_0001, 2.22, 0 )
      • Trigger - Turn on (This trigger)
 

Attachments

  • Attack Rate Test.w3m
    9.3 KB · Views: 26
Last edited:
Level 5
Joined
Oct 16, 2007
Messages
67
In case you haven't solved this yet.

Warcraft 3 has some weird behaviours, this is one.
If you reference a unit in custom script using "gg_unit_Hmkg_0000" Warcraft 3 does not create a variable (yes the name is a unit variable WC3 creates for you). You can see the error by clicking "Validate Map Triggers".
Just do any GUI function with a reference to this unit and the script will work (print name, set life... whatever and wherever).
In the placement Trigger for units (autogenerated and not visible in the editor) the game puts unit in variables if they are referenced somwhere.
It's interessting to know that Warcraft notices this reference in jass only triggers and creates this variable.

Hope this helps you,
Lartin
 
Level 5
Joined
May 12, 2014
Messages
133
Thanks for the info! Admittably this wasn't much of an issue, since it's easy as heck to work around. The curious little frogger in me was just wondering why this works this way and not the way you'd expect it to. ^_^

At worse, I'd say this was just a bit of a pain, since converting the trigger made it work fine. Haha.

Still kind of wondering if attack rate really is 0-indexed, since the GUI function only allows you to put in 1 or 2. Would be a very silly oversight on blizzard's end. :p
 
Level 5
Joined
Oct 16, 2007
Messages
67
It used to be 1 for attack 1 and 2 for attack 2. Then they changed it to 0 for attack 1 and 1 for attack 2 to go with the other functions. Set Ablity Level Integer Field and the other functions also use 0 for level 1.
However in this function they never fixed that so you can't enter a 0 in GUI. You can set a integer variable to 0 and then use this one to make this function work in GUI.
 
Status
Not open for further replies.
Top