• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Change Custom Value

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
I wanted to temporarily change the custom value of a unit. Initially set the custom value to 1, wait 3 seconds, change back to 0. Simple as that. It needs to be MUI. Trouble is, this trigger doesn't save. Various error messages appear which disables the trigger.

I have almost NO knowledge of Jass. I modified this trigger from my other map, which someone created for me. I was just instructed to change values. Please make any instructions clear for a non Jass user. Thanks.

  • Heal Drone Buff
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Heal (Lvl 1)
          • (Ability being cast) Equal to Heal (Lvl 2)
          • (Ability being cast) Equal to Heal (Lvl 3)
    • Actions
      • Unit - Set the custom value of (Triggering unit) to 1
      • -------- -------- --------
      • Custom script: local integer HEALWAIT
      • Custom script: local timer OURTIMER
      • Custom script: local unit OURDRONE
      • Custom script: set OURDRONE = GetTriggeringUnit()
      • Custom script: set HEALWAIT = 3
      • Custom script: set OURTIMER = CreateTimer()
      • Custom script: call StartTimerBJ( OURTIMER, false, ( I2R(HEALWAIT) ))
      • Custom script: call PolledWait( HEALWAIT )
      • Custom script: call SetUnitUserData( GetOURDRONE(), 0 )
      • Custom script: call UnitAddItemByIdSwapped( 'pnvu', OURHERO )
 
Also in gui you could make this MUI. Just use wait function, and after the wait you can work with "TriggeringUnit" again. TriggeringUnit is kind of special, it always works MUI. (also DyingUnit)

But here is correction:

If you declare local variables, jass requires them to be on top of the function.. these:
  • Custom script: local integer HEALWAIT
  • Custom script: local timer OURTIMER
  • Custom script: local unit OURDRONE
And a tip... ater declaration you also can initialisize them, so:
  • Custom script: local integer HEALWAIT = 3
  • Custom script: local timer OURTIMER = CreateTimer()
  • Custom script: local unit OURDRONE = GetTriggerUnit()

For what you even need this timer? And why you start it? (remove it, else I will show you the function without BJ)

For wait: "call TriggerSleepAction(HEALWAIT)" .. But actually you do not need a variable here, because youn only use it once so --> "call TriggerSleepAction(3)"

  • Custom script: call SetUnitUserData( GetOURDRONE(), 0 )
OURDRONE already completly represents your "GetTriggerUnit", so only it like this, -->
  • Custom script: call SetUnitUserData( OURDRONE, 0 )

  • Custom script: call UnitAddItemByIdSwapped( 'pnvu', OURHERO )
Why you use "OURHERO" here? There is no local variable like this. And this is better -->
  • Custom script: UnitAddItemById(OURDRONE, 'pnvu')

In end of function you have to null local hanles(only) agents (ty edo;) ). So it would be:
  • Custom script: set OURDRONE = null
( + and null timer, if you hold it)

And as tip, you can use easy variable names for locals. No other function can read it and so can't come in conflict. For unit most use a simple "u" for example. ( and please don't use capslock here ^^)
 
Last edited:
Level 16
Joined
Mar 27, 2011
Messages
1,349
I forgot triggering unit is MUI, but now that I've started, I may as well finish this and learn something :) Btw, thx for helping me here.

I still get errors trying to enable the trigger. Here's my updated trigger:

  • Heal Drone Buff
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Heal (Lvl 1)
          • (Ability being cast) Equal to Heal (Lvl 2)
          • (Ability being cast) Equal to Heal (Lvl 3)
    • Actions
      • Custom script: local unit OURDRONE = GetTriggeringUnit()
      • Unit - Set the custom value of (Triggering unit) to 1
      • -------- -------- --------
      • Custom script: call TriggerSleepAction(3)
      • Custom script: call PolledWait( 3 )
      • Custom script: call SetUnitUserData( GetOURDRONE(), 0 )
pic2.jpg
 
Remove the PolledWait.

Look in my first post again what I do with "Custom script: call SetUnitUserData( GetOURDRONE(), 0 )".

Also, now you store TriggeringUnit in a variable, so for first custom value change it's now also recomended to change it to custom script, and use the variable.

Do not forget to null the unit in the very end.
 
Level 16
Joined
Mar 27, 2011
Messages
1,349
Think I'm nearly there. Whats wrong with my setting of the variable? Its the only action which is reporting an error when trying to enable the trigger.

  • Heal Drone Buff
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Ability being cast) Equal to Heal (Lvl 1)
          • (Ability being cast) Equal to Heal (Lvl 2)
          • (Ability being cast) Equal to Heal (Lvl 3)
    • Actions
      • Custom script: local unit OURDRONE
      • Custom script: set OURDRONE = GetTriggeringUnit()
      • Custom script: call SetUnitUserData( OURDRONE, 1 )
      • Custom script: call TriggerSleepAction( 3 )
      • Custom script: call SetUnitUserData( OURDRONE, 0 )
      • Custom script: set OURDRONE = null
 
Status
Not open for further replies.
Top