• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Owner of local unit not detected?

Status
Not open for further replies.
Level 5
Joined
Dec 25, 2018
Messages
110
  • Custom script: local unit udg_Devour_Caster
  • Set Devour_Caster = (Triggering unit)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (((Owner of Devour_Caster) Equal to Player 1 (Red)) or ((Owner of Devour_Caster) Equal to Player 2 (Blue))) or (((Owner of Devour_Caster) Equal to Player 3 (Teal)) or (((Owner of Devour_Caster) Equal to Player 4 (Purple)) or ((Owner of Devour_Caster) Equal to Player 5 (Yellow))))
    • Then - Actions
    • [...]
  • Custom script: set udg_Devour_Caster= null
So my problem here is that if I make unit a local, condition is not getting detected.
If I remove custom script part then condition is met, but I need unit there to be local.
Any ideas?
 
Level 6
Joined
Aug 28, 2015
Messages
213
The issue is that the trigger checks the if conditions in another function and so don't has access to the local variable of the original function.
You can work around by creating your own if with custom script as well.
  • Custom script: local unit udg_Devour_Caster = GetTriggerUnit()
  • Custom script: local player udg_Devour_Caster_Player = GetOwningPlayer(udg_Devour_Caster)
  • Custom script: if (udg_Devour_Caster_Player == Player(0) or udg_Devour_Caster_Player == Player(1) or udg_Devour_Caster_Player == Player(2) or udg_Devour_Caster_Player == Player(3) ) then
  • Unit - Explode Devour_Caster
  • Player - Set Devour_Caster_Player Current gold to 750
  • Custom script: endif
  • Custom script: set udg_Devour_Caster = null
  • Custom script: set udg_Devour_Caster_Player = null
 
Level 5
Joined
Dec 25, 2018
Messages
110
Thanks for help guys.
The issue is that the trigger checks the if conditions in another function and so don't has access to the local variable of the original function.
You can work around by creating your own if with custom script as well.
  • Custom script: local unit udg_Devour_Caster = GetTriggerUnit()
  • Custom script: local player udg_Devour_Caster_Player = GetOwningPlayer(udg_Devour_Caster)
  • Custom script: if (udg_Devour_Caster_Player == Player(0) or udg_Devour_Caster_Player == Player(1) or udg_Devour_Caster_Player == Player(2) or udg_Devour_Caster_Player == Player(3) ) then
  • Unit - Explode Devour_Caster
  • Player - Set Devour_Caster_Player Current gold to 750
  • Custom script: endif
  • Custom script: set udg_Devour_Caster = null
  • Custom script: set udg_Devour_Caster_Player = null
This worked like a charm for me. :)
 
Status
Not open for further replies.
Top