• 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.

[Trigger] Torch Vision triggers

Status
Not open for further replies.
Level 17
Joined
Nov 26, 2007
Messages
1,964
Okay, so what I'm trying to do is that when unit X enters within # range of a unit Y, and unit Y has a torch item, unit X is granted vision of that unit (so he sees the extended sight radius that unit Y has as a result of the torch)

You come near a unit with a torch and can see farther, makes sense, right?

It's not working for some reason though, this is what I've got:


This is just to set the item:

  • TorchAct
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Multiple ConditionsOr - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to (==) Basic Torch
          • (Item-type of (Item being manipulated)) Equal to (==) Traveller's Torch
    • Actions
      • Set STEEL_Torch[(Player number of (Owner of (Hero manipulating item)))] = (Item being manipulated)
      • Trigger - Turn on Torch Check <gen>
This one checks if a unit is in range

  • Torch Check
    • Events
      • Time - Every 0.30 seconds of game time
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (STEEL_Hero[(Integer A)] has buff Torch Glow ) Equal to (==) True
            • Then - Actions
              • Unit Group - Pick every unit in (Units within 800.00 of (Position of STEEL_Hero[(Integer A)]) matching (((Matching unit) has an item of type (Item-type of STEEL_Torch[(Player number of (Owner of (Matching unit)))])) Equal to (==) True)) and do (Actions)
                • Loop - Actions
                  • Unit - Grant shared vision of (Picked unit) to (Owner of STEEL_Hero[(Integer A)])
                  • Unit Group - Add (Picked unit) to Torch_Bearer[(Player number of (Owner of STEEL_Hero[(Integer A)]))]
            • Else - Actions
              • Unit Group - Pick every unit in Torch_Bearer[(Player number of (Owner of STEEL_Hero[(Integer A)]))] and do (Actions)
                • Loop - Actions
                  • Unit - Deny shared vision of (Picked unit) to (Owner of STEEL_Hero[(Integer A)])
                  • Unit Group - Remove (Picked unit) from Torch_Bearer[(Player number of (Owner of STEEL_Hero[(Integer A)]))]
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Multiple ConditionsAnd - All (Conditions) are true
            • Conditions
              • STEEL_Torch[1] Equal to (==) No item
              • STEEL_Torch[2] Equal to (==) No item
              • STEEL_Torch[3] Equal to (==) No item
              • STEEL_Torch[4] Equal to (==) No item
              • STEEL_Torch[5] Equal to (==) No item
              • STEEL_Torch[6] Equal to (==) No item
              • STEEL_Torch[7] Equal to (==) No item
              • STEEL_Torch[8] Equal to (==) No item
              • STEEL_Torch[9] Equal to (==) No item
              • STEEL_Torch[10] Equal to (==) No item
              • STEEL_Torch[11] Equal to (==) No item
              • STEEL_Torch[12] Equal to (==) No item
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Do nothing

This one just sets the torch to no item if a hero drops it.


  • TorchDet
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • Multiple ConditionsOr - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to (==) Basic Torch
          • (Item-type of (Item being manipulated)) Equal to (==) Traveller's Torch
    • Actions
      • Set STEEL_Torch[(Player number of (Owner of (Hero manipulating item)))] = No item

Any ideas?
 
Group is empty thats why it doesn't work:
  • Unit Group - Pick every unit in (Units within 800.00 of (Position of STEEL_Hero[(Integer A)]) matching (((Matching unit) has an item of type (Item-type of STEEL_Torch[(Player number of (Owner of (Matching unit)))])) Equal to (==) True)) and do (Actions)
Only units with tourch can get additional vision what doesn't make sense at all.
By the way, your trigger leaks and can be improved a lot. Will do this in second.

EDIT Try this:
Uses Bribe's Unit Indexer.
  • TorchAct
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to (==) Basic Torch
          • (Item-type of (Item being manipulated)) Equal to (==) Traveller's Torch
    • Actions
      • Unit Group - Add (Triggering unit) to TorchGroup
      • Trigger - Turn on Torch Check <gen>
  • Torch Check
    • Events
      • Time - Every 0.30 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in TorchGroup and do Actions
        • Loop - Actions
          • Set tempunit = (Picked unit)
          • Set tempp1 = (Position of (Picked unit))
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 800.00 of tempp1 matching <your PROPER conditions eg only allies> and do (Actions)
            • Loop - Actions
              • Unit - Grant shared vision of tempunit to (Owner of (Picked unit))
              • Set key = (Custom value of (Picked unit))
              • Set Visiongiver[key] = tempunit
              • Unit Group - Add (Picked unit) to TempTorchGroup
          • Custom script: call RemoveLocation(udg_tempp1)
      • Unit Group - Pick every unit in TempTorchGroup and do Actions
        • Loop - Actions
          • Set key = (Custom value of (Picked unit))
          • Set tempp1 = (Position of (Picked unit))
          • Set tempp2 = (Position of Visiongiver[key])
          • If (All conditions are true) then do (Then Actions) else do (Else Actions)
            • If - conditions
              • (((Distance between tempp1 and tempp2) Greater than 800) or ((Visiongive[key] is in TorchGroup) Equal to False))
            • Then - Actions
              • Unit - Deny shared vision of Visiongiver[key] to (Owner of (Picked unit))
              • Unit Group - Remove (Picked unit) from TempTorchGroup
              • Set Visiongiver[key] = No unit
            • Else - Actions
          • Custom script: call RemoveLocation(udg_tempp1)
          • Custom script: call RemoveLocation(udg_tempp2)
      • If (All conditions are true) then do (Then Actions) else do (Else Actions)
        • If - conditions
          • (TorchGroup is Empty) Equal to True
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
  • TorchDet
    • Events
      • Unit - A unit Loses an item
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Item-type of (Item being manipulated)) Equal to (==) Basic Torch
          • (Item-type of (Item being manipulated)) Equal to (==) Traveller's Torch
    • Actions
      • Unit Group - Remove (Triggering unit) from TorchGroup
 
Last edited:
Level 17
Joined
Nov 26, 2007
Messages
1,964
Ok so I did all that and it works only when I approach the unit.

When I move my hero away from the torch unit, I lose vision for a millisecond and then I gain vision of the unit again, so vision isn't removed! I think something is wrong with this part

  • If (All conditions are true) then do (Then Actions) else do (Else Actions)
  • If - conditions
  • (((Distance between tempp1 and tempp2) Greater than 800) or ((Visiongive[key] is in TorchGroup) Equal to False))
  • Then - Actions
  • Unit - Deny shared vision of Visiongiver[key] to (Owner of (Picked unit))
  • Unit Group - Remove (Picked unit) from TempTorchGroup
  • Set Visiongiver[key] = No unit
  • Else - Actions
  • Custom script: call RemoveLocation(udg_tempp1)
  • Custom script: call RemoveLocation(udg_tempp2)
 
Level 17
Joined
Nov 26, 2007
Messages
1,964
My bad, it actually works perfectly! Thank you!

I hate to be a bother but I have one more problem I might as well ask for help here. I tried using the same method for another trigger. Basically, it's supposed to be like, when you type "-info (text here)", it sets a string to the unit selected. So when a unit uses an ability "Interact" on it, it displays over that unit in floating text. So people can set and make observations for the units they use this command on.

Here's what I have:


  • Info
    • Events
      • Player - Player 1 (Red) types a chat message containing -info as A substring
      • Player - Player 2 (Blue) types a chat message containing -info as A substring
      • Player - Player 3 (Teal) types a chat message containing -info as A substring
      • Player - Player 4 (Purple) types a chat message containing -info as A substring
      • Player - Player 5 (Yellow) types a chat message containing -info as A substring
      • Player - Player 6 (Orange) types a chat message containing -info as A substring
      • Player - Player 7 (Green) types a chat message containing -info as A substring
      • Player - Player 8 (Pink) types a chat message containing -info as A substring
      • Player - Player 9 (Gray) types a chat message containing -info as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -info as A substring
      • Player - Player 11 (Dark Green) types a chat message containing -info as A substring
      • Player - Player 12 (Brown) types a chat message containing -info as A substring
    • Conditions
    • Actions
      • Set a_tmpUnitGroup01[(Player number of (Triggering player))] = (Units owned by (Triggering player))
      • Unit Group - Pick every unit in a_tmpUnitGroup01[(Player number of (Triggering player))] and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Multiple ConditionsAnd - All (Conditions) are true
                • Conditions
                  • ((Picked unit) is selected by (Triggering player)) Equal to (==) True
                  • (Unit-type of (Picked unit)) Not equal to (!=) |cffffd700 DM Spawner |r (SPECIAL)
            • Then - Actions
              • Set STEEL_Key = (Custom value of (Picked unit))
              • Set STEEL_Info[STEEL_Key] = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
            • Else - Actions
      • Unit Group - Destroy unit group a_tmpUnitGroup01[(Player number of (Triggering player))]


And the ability trigger:



  • Interact
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) Interact
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Multiple ConditionsOr - Any (Conditions) are true
            • Conditions
              • (Destructible-type of (Target destructible of ability being cast)) Equal to (==) Door (Horizontal)
              • (Destructible-type of (Target destructible of ability being cast)) Equal to (==) Door (Vertical)
        • Then - Actions
          • Destructible - Open (Target destructible of ability being cast)
        • Else - Actions
          • Destructible - Pick every destructible within 150.00 of (Target point of ability being cast) and do (Actions)
            • Loop - Actions
              • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Multiple ConditionsOr - Any (Conditions) are true
                    • Conditions
                      • (Destructible-type of (Picked destructible)) Equal to (==) Door (Horizontal)
                      • (Destructible-type of (Picked destructible)) Equal to (==) Door (Vertical)
                • Then - Actions
                  • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked destructible) is dead) Equal to (==) True
                    • Then - Actions
                      • Destructible - Close (Picked destructible)
                    • Else - Actions
                      • Destructible - Open (Picked destructible)
                • Else - Actions
                  • Set STEEL_Key = (Custom value of (Target unit of ability being cast))
                  • Floating Text - Create floating text that reads STEEL_Info[STEEL_Key] above (Target unit of ability being cast) with Z offset 50.00, using font size 8.00, color (70.00%, 70.00%, 70.00%), and 10.00% transparency
                  • Floating Text - Show (Last created floating text) for (All players matching ((Matching player) Equal to (==) (Owner of (Casting unit))))
                  • Floating Text - Change the age of (Last created floating text) to (0.50 x (Real((Length of STEEL_Info[STEEL_Key])))) seconds
                  • Floating Text - Change the lifespan of (Last created floating text) to (0.50 x (Real((Length of STEEL_Info[STEEL_Key])))) seconds
                  • Floating Text - Change (Last created floating text): Disable permanence

Thanks a lot.
 
Since your group is temporary lets clear it immidiately, dont use 'All conditions are true' since that function does it by default 'If (All conditions are true) then do (then Actions) else do (Else Actions):
  • Info
    • Events
      • Player - Player 1 (Red) types a chat message containing -info as A substring
      • Player - Player 2 (Blue) types a chat message containing -info as A substring
      • Player - Player 3 (Teal) types a chat message containing -info as A substring
      • Player - Player 4 (Purple) types a chat message containing -info as A substring
      • Player - Player 5 (Yellow) types a chat message containing -info as A substring
      • Player - Player 6 (Orange) types a chat message containing -info as A substring
      • Player - Player 7 (Green) types a chat message containing -info as A substring
      • Player - Player 8 (Pink) types a chat message containing -info as A substring
      • Player - Player 9 (Gray) types a chat message containing -info as A substring
      • Player - Player 10 (Light Blue) types a chat message containing -info as A substring
      • Player - Player 11 (Dark Green) types a chat message containing -info as A substring
      • Player - Player 12 (Brown) types a chat message containing -info as A substring
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in a_(Units owned by (Triggering player)) and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is selected by (Triggering player)) Equal to (==) True
              • (Unit-type of (Picked unit)) Not equal to (!=) |cffffd700 DM Spawner |r (SPECIAL)
            • Then - Actions
              • Set STEEL_Key = (Custom value of (Picked unit))
              • Set STEEL_Info[STEEL_Key] = (Substring((Entered chat string), 7, (Length of (Entered chat string))))
            • Else - Actions
Give a second for next trigger. Use 'Starts effect effect of ability' - it's more accurate. Hope your ability can target destructibles ^^. If destructible is dead - close it? isn't that silly? And cut the trigger in half since you check for all doors in AoE anyways.
>> I do not understand something. Target can be destructible and.. a unit!?
  • Interact
    • Events
      • Unit - A unit Starts effect of ability
    • Conditions
      • (Ability being cast) Equal to (==) Interact
    • Actions
      • Set temppoint = (Target point of ability being cast)
      • Destructible - Pick every destructible within 150.00 of temppoint and do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Picked destructible) Not equal to No destructible
              • ((Picked destructible) is dead) Not equal to (==) True
              • Multiple ConditionsOr - Any (Conditions) are true
                • Conditions
                  • (Destructible-type of (Picked destructible)) Equal to (==) Door (Horizontal)
                  • (Destructible-type of (Picked destructible)) Equal to (==) Door (Vertical)
            • Then - Actions
              • Destructible - Open (Picked destructible)
            • Else - Actions
      • Custom script: call RemoveLocation(udg_temppoint)
I have to understand the idea behind the spell to continue. However, one change here about the floating text: Instead of (Owner of (Casting unit)) use Triggering player.
 
Level 17
Joined
Nov 26, 2007
Messages
1,964
Oh, the destructible part works fine actually. Sorry I included that but its all in the same spell.

It's kind of like a LOAP map, a roleplaying map. Yes, my ability can target destructibles or a unit, and its so people can open/close doors to houses and shops and stuff. That part works fine.

The second part (the "Interact" ability is multipurpose, you can use it to interaction with doors or with units) displays the string set by -info in the previous trigger above the target unit's head with floating text.

So lets say I select a peasant, type -info This peasant is an old man.

When anyone uses "interact" on that peasant, it should display a floating text above his head saying "This peasant is an old man". That's the idea.


btw, thanks a lot for all your help.
 
Level 17
Joined
Nov 26, 2007
Messages
1,964
Umm... it's very complicated if I post the map, trust me you'll be even more confused and will get lost at the dozens of triggers there.


Look, basically, there are 2 parts. I will try to explain it better, ignore the destructible/concept part and just focus on this part which im having trouble with:

The command "-info (text here)".

This part, when a player types -info ..., it will save a string to the unit that the player is selecting. So like an RPG, you want to describe your character if people use interact on him. You select unit X and type -info Bob is an old man, for example.

This will set the string "Bob is an old man" to the unit the player is currently selecting.

Now, "Interact" is an ability all heroes have. They can use it to interact with doors, objects and people. I'm not having trouble with it EXCEPT for the "-info" command.

When you use "Interact" on the unit X the player was describing as Bob, it should display floating text over unit X saying the string "Bob is an old man".

So this command should be able to tie any unique string to a selected unit, through the command.

Is it more clear now? lol trust me it would be a lot more trouble if I posted the map.
 
Status
Not open for further replies.
Top