• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Trigger] custom script, getting the player of a triggering unit.

Status
Not open for further replies.
Level 7
Joined
Dec 8, 2008
Messages
243
So, I've got this trigger.

  • If ((Owner of (Triggering unit)) Equal to (Player((Integer A)))) then do (Custom script: call CameraOn(1, false)) else do (Do nothing)
But I want it to find the triggering unit, so I need to change the (1, false)) to something like (player number of triggering unit, false).

-sigh- I really should cut down on how often I ask for help on these forums. All input is appreciated.
 
Thanks for the input, Catch Ya. :) However
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • If ((Owner of (Triggering unit)) Equal to (Player((Integer A)))) then do (Custom script: call CameraOn(GetConvertedPlayerId(Unit), false);) else do (Do nothing)
doesn't run. (by "doesn't run, I don't mean it gets incompatible builds, but it just goes to the main warcraft 3 window as though I ran wc3.exe)

Again, thanks.
 
Thanks for the input, Catch Ya. :) However
  • For each (Integer A) from 1 to 10, do (Actions)
    • Loop - Actions
      • If ((Owner of (Triggering unit)) Equal to (Player((Integer A)))) then do (Custom script: call CameraOn(GetConvertedPlayerId(Unit), false);) else do (Do nothing)
doesn't run. (by "doesn't run, I don't mean it gets incompatible builds, but it just goes to the main warcraft 3 window as though I ran wc3.exe)

Again, thanks.

Should be this:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to (Player((Integer A)))
        • Then - Actions
          • Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)
        • Else - Actions
          • -------- NEVER EVER USE DO NOTHING! --------
Hope it helped. :) Have fun.
 
It was a single IF trigger so NOTHING was necessary. Putting this trigger to turn off/on hero cameras 20 times in a trigger (10 offs/10 ons). Thats going to make every quest trigger I look at take ages to load. :(
 
Fine fine. But
  • call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)
Still isn't working.
It works if I use
  • call CameraOn(1, false)
so the returning value isn't working. Unless there's something wrong with my For loop A 1-10.
 
So, I've got this trigger.

  • If ((Owner of (Triggering unit)) Equal to (Player((Integer A)))) then do (Custom script: call CameraOn(1, false)) else do (Do nothing)
But I want it to find the triggering unit, so I need to change the (1, false)) to something like (player number of triggering unit, false).

-sigh- I really should cut down on how often I ask for help on these forums. All input is appreciated.

I don't know, but it should be Player Number (number of (owner of Triggering Unit)) so i don't know how it should look like in the Custom Script ;/ (cause i think there is the thing with the owners)

Hope this is what you wanted.

Tiche3:grin:
 
Here you go:
  • Actions
    • For each (Integer A) from 0 to 9, do (Actions)
      • Loop - Actions
        • Custom script: call BJDebugMsg(I2S(GetConvertedPlayerId(Player(GetForLoopIndexA()))))
The problem was that it would return #'s 2-11. In JASS, Player Id's are 0-11 for Player's 1-12, so this will return it properly from 1-10.

Just use 0-9 instead of 1-10 for the loop. This trigger is just a test trigger.

Ex:
  • For each (Integer A) from 0 to 9, do (Actions)
    • Loop - Actions
      • If ((Owner of (Triggering unit)) Equal to (Player((Integer A))) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing)
I might've missed a parenthesis or two.
 
Here you go:
  • Actions
    • For each (Integer A) from 0 to 9, do (Actions)
      • Loop - Actions
        • Custom script: call BJDebugMsg(I2S(GetConvertedPlayerId(Player(GetForLoopIndexA()))))
The problem was that it would return #'s 2-11. In JASS, Player Id's are 0-11 for Player's 1-12, so this will return it properly from 1-10.

Just use 0-9 instead of 1-10 for the loop. This trigger is just a test trigger.

Ex:
  • For each (Integer A) from 0 to 9, do (Actions)
    • Loop - Actions
      • If ((Owner of (Triggering unit)) Equal to (Player((Integer A))) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing)
I might've missed a parenthesis or two.

Oh yes, I think I remember reading somewhere that jass starts on 0, not 1.
Anyway, I changed the ForLoopA to 0-9. Where abouts in my trigger should I put the debug? I placed it at the bottom of the trigger, underneath when I make the camera turn back on and it crashed. By the way, thanks very much for this, I really appreciate it, and that goes to all of you.
 
Hazzar! :) I removed the debug message and made a loop integer B 1-10, (since the condition wouldn't accept 0-9. This made it work.

Once again, everyone has much utmost appreciation, especially Purge and Catch Ya.

[edit] :P Getting problems when the trigger finished. I want it to snap back to the triggering unit.

Here's the trigger, keeping it as relevant as possible.
  • For each (Integer A) from 0 to 9, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
              • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing)
              • Unit - Pause (Triggering unit)
              • Unit - Make (Triggering unit) Invulnerable
              • Unit - Make (Triggering unit) face Weak Warlock 0041 <gen> over 0.25 seconds
              • Unit - Make Weak Warlock 0041 <gen> face (Triggering unit) over 0.25 seconds
              • Quest - Display to (All players) the Quest Update message: ((Name of (Owner of (Triggering unit))) + has accepted the team quest: |cff32cd32Protect Borealis|r. See Quest Log for objectives.)
              • -------- next --------
              • Cinematic - Turn cinematic mode On for (Player group((Owner of (Triggering unit))))
              • Cinematic - Turn on letterbox mode (hide interface) for (Player group((Owner of (Triggering unit)))): fade out over 1.00 seconds
              • Cinematic - Disable user control for (Player group((Owner of (Triggering unit))))
              • Cinematic - Turn subtitle display override On
              • -------- next --------
              • Camera - Apply Quest 0 Camera <gen> for (Owner of (Triggering unit)) over 0.00 seconds
              • Cinematic - Send transmission to (Player group((Owner of (Triggering unit)))) from Weak Warlock 0041 <gen> named Weak Warlock:: Play No sound and display The town is under a.... Modify duration: Add 5.00 seconds and Don't wait
              • Wait 5.00 seconds
              • -------- next --------
              • Cinematic - Turn off letterbox mode (show interface) for (Player group((Owner of (Triggering unit)))): fade in over 1.00 seconds
              • Cinematic - Enable user control for (Player group((Owner of (Triggering unit))))
              • Cinematic - Turn cinematic mode Off for (Player group((Owner of (Triggering unit))))
              • Cinematic - Turn subtitle display override Off
              • -------- next --------
              • Unit - Unpause (Triggering unit)
              • Unit - Make (Triggering unit) Vulnerable
              • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), true)) else do (Do nothing)
            • Else - Actions
Now, I've tested ending the gui with
  • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(1, true)) else do (Do nothing)
which worked so it's nothing to do with the camera triggers. Any suggestions? I personally can't see why it isn't working considering the same trigger was used 5 seconds earlier and worked fine.
 
  • If - Conditions
  • Then - Actions
    • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing)
    • Unit - Pause (Triggering unit)
    • Unit - Make (Triggering unit) Invulnerable
    • Unit - Make (Triggering unit) face Weak Warlock 0041 <gen> over 0.25 seconds
Why the "Conditions" doesn't have a condition? It goes straight to the actions.
 
There are other actions and conditions above the cinematic. It's just that the GUI is going to be applied to all the quests, and I'm trying to keep my post size down as small as possible, cause large triggers tend to throw people off :P and I'm still a tad shy :(

Here's the entire trigger though, not that it's relevant. This is just the starting quest
  • Quest 0 Prologue Part 1
    • Events
      • Unit - A unit enters Wizard start of game <gen>
      • Unit - A unit enters Wizard start of game Copy <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Trigger - Turn off (This trigger)
      • Special Effect - Destroy SpecialEffect_ULTIMATE_VARIABL[0]
      • Quest - Create a Required quest titled Protect Borealis! with the description Help the town guard..., using icon path ReplaceableTextures\CommandButtons\BTNAmbush.blp
      • For each (Integer A) from 0 to 9, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 10, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                • Then - Actions
                  • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing)
                  • Unit - Pause (Triggering unit)
                  • Unit - Make (Triggering unit) Invulnerable
                  • Unit - Make (Triggering unit) face Weak Warlock 0041 <gen> over 0.25 seconds
                  • Unit - Make Weak Warlock 0041 <gen> face (Triggering unit) over 0.25 seconds
                  • Quest - Display to (All players) the Quest Update message: ((Name of (Owner of (Triggering unit))) + has accepted the team quest: |cff32cd32Protect Borealis|r. See Quest Log for objectives.)
                  • -------- next --------
                  • Cinematic - Turn cinematic mode On for (Player group((Owner of (Triggering unit))))
                  • Cinematic - Turn on letterbox mode (hide interface) for (Player group((Owner of (Triggering unit)))): fade out over 1.00 seconds
                  • Cinematic - Disable user control for (Player group((Owner of (Triggering unit))))
                  • Cinematic - Turn subtitle display override On
                  • -------- next --------
                  • Camera - Apply Quest 0 Camera <gen> for (Owner of (Triggering unit)) over 0.00 seconds
                  • Cinematic - Send transmission to (Player group((Owner of (Triggering unit)))) from Weak Warlock 0041 <gen> named Weak Warlock:: Play No sound and display The town is under a.... Modify duration: Add 5.00 seconds and Don't wait
                  • Wait 5.00 seconds
                  • -------- next --------
                  • Cinematic - Turn off letterbox mode (show interface) for (Player group((Owner of (Triggering unit)))): fade in over 1.00 seconds
                  • Cinematic - Enable user control for (Player group((Owner of (Triggering unit))))
                  • Cinematic - Turn cinematic mode Off for (Player group((Owner of (Triggering unit))))
                  • Cinematic - Turn subtitle display override Off
                  • -------- next --------
                  • Unit - Unpause (Triggering unit)
                  • Unit - Make (Triggering unit) Vulnerable
                  • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), true)) else do (Do nothing)
                • Else - Actions
 
  • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing
Move this to the IntegerA loop, it doesn't have to be under the IntegerB loop.

Wait 5.00 seconds inside a loop means that it will wait for: (example if we had 1 to 10 integer, it would wait 10 times * 5 seconds.)
 
@Mallaboro: Can't you just use:
  • Camera - Lock camera target for (Player((Integer A))) to (Triggering unit), offset by (0.00, 0.00) using Default rotation
To snap back to the triggering unit?

Just tried this now. Unfortunetly it doesn't turn the functions given by the camera system back on.

  • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing
Move this to the IntegerA loop, it doesn't have to be under the IntegerB loop.

Wait 5.00 seconds inside a loop means that it will wait for: (example if we had 1 to 10 integer, it would wait 10 times * 5 seconds.)

Since the values for integer A are 0-9, it seems to cause a critical error.
 
  • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing
Move this to the IntegerA loop, it doesn't have to be under the IntegerB loop.

Wait 5.00 seconds inside a loop means that it will wait for: (example if we had 1 to 10 integer, it would wait 10 times * 5 seconds.)
Ah, I understand now. I made another "for integer A" at the bottom and placed

  • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), true))
in it, and it worked.

I assumed they were still connected since A links to B which links to the trigger, but I guess it doesn't work that way (although now I don't understand why there are both A and B), anyway, here's the final thing, if anyone can simplify it in any way I'd be greatful, although I'm not asking. I'm happy with what it now is. :)

  • For each (Integer A) from 0 to 9, do (Actions)
    • Loop - Actions
      • For each (Integer B) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
            • Then - Actions
              • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing)
              • Unit - Pause (Triggering unit)
              • Unit - Make (Triggering unit) Invulnerable
              • Unit - Make (Triggering unit) face Weak Warlock 0041 <gen> over 0.25 seconds
              • Unit - Make Weak Warlock 0041 <gen> face (Triggering unit) over 0.25 seconds
              • Quest - Display to (All players) the Quest Update message: ((Name of (Owner of (Triggering unit))) + has accepted the team quest: |cff32cd32Protect Borealis|r. See Quest Log for objectives.)
              • -------- next --------
              • Cinematic - Turn cinematic mode On for (Player group((Owner of (Triggering unit))))
              • Cinematic - Turn on letterbox mode (hide interface) for (Player group((Owner of (Triggering unit)))): fade out over 1.00 seconds
              • Cinematic - Disable user control for (Player group((Owner of (Triggering unit))))
              • Cinematic - Turn subtitle display override On
              • -------- next --------
              • Camera - Apply Quest 0 Camera <gen> for (Owner of (Triggering unit)) over 0.00 seconds
              • Cinematic - Send transmission to (Player group((Owner of (Triggering unit)))) from Weak Warlock 0041 <gen> named Weak Warlock:: Play No sound and display The town is under a.... Modify duration: Add 5.00 seconds and Don't wait
              • Wait 5.00 seconds
              • -------- next --------
              • Cinematic - Turn off letterbox mode (show interface) for (Player group((Owner of (Triggering unit)))): fade in over 1.00 seconds
              • Cinematic - Enable user control for (Player group((Owner of (Triggering unit))))
              • Cinematic - Turn cinematic mode Off for (Player group((Owner of (Triggering unit))))
              • Cinematic - Turn subtitle display override Off
              • -------- next --------
              • Unit - Unpause (Triggering unit)
              • Unit - Make (Triggering unit) Vulnerable
              • For each (Integer A) from 0 to 9, do (Actions)
                • Loop - Actions
                  • If ((Owner of (Triggering unit)) Equal to Player 1 (Red)) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), true)) else do (Do nothing)
            • Else - Actions
Thanks as always, Pharaoh. :P You have to stop helping me, I feel bad, you've done so much for me.
 
Last edited:
I'm suddenly having doubts that
  • call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())
is't what I was after :(
The first time I use the gui, it works fine, but every time after it doesnt work. The whole "GetForLoopIndexA())" is makes me think it's effecting all players, when I need it to only effect the owner of the triggering unit. I think it should be something like "GetOwningPlayer", just a theory. I still don't know much about Jass, so my judgement is next-to-none.
 
Here you go:
  • Actions
    • For each (Integer A) from 0 to 9, do (Actions)
      • Loop - Actions
        • Custom script: call BJDebugMsg(I2S(GetConvertedPlayerId(Player(GetForLoopIndexA()))))
The problem was that it would return #'s 2-11. In JASS, Player Id's are 0-11 for Player's 1-12, so this will return it properly from 1-10.

Just use 0-9 instead of 1-10 for the loop. This trigger is just a test trigger.

Ex:
  • For each (Integer A) from 0 to 9, do (Actions)
    • Loop - Actions
      • If ((Owner of (Triggering unit)) Equal to (Player((Integer A))) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing)
I might've missed a parenthesis or two.

It works when I use 0-9, and it doesn't with 1-10.
 
This is the trigger for when you return to the npc after you've done the quest

  • Actions
    • Special Effect - Destroy SpecialEffect_ULTIMATE_VARIABL[0]
    • Special Effect - Create a special effect attached to the overhead of Paladin Mcarthy 0086 <gen> using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
    • Set SpecialEffect_ULTIMATE_VARIABL[1] = (Last created special effect)
    • Quest - Mark (Last created quest) as Completed
    • Unit - Kill Fire 0124 <gen>
    • Unit - Kill Fire 0125 <gen>
    • Unit - Kill Fire 0113 <gen>
    • Unit - Kill Fire 0127 <gen>
    • Unit - Kill Fire 0126 <gen>
    • Destructible - Kill Barricade 0343 <gen>
    • Destructible - Kill Barricade 0346 <gen>
    • Destructible - Kill Barricade 0340 <gen>
    • Destructible - Kill Barricade 0341 <gen>
    • Quest - Display to (All players) the Quest Update message: ((Name of (Owner of (Triggering unit))) + has completed the team quest: |cff32cd32Protect Borealis|r. See Quest Log for reward and details.)
    • Quest - Change the description of (Last created quest) to Quest completed! R...
    • Trigger - Turn off (This trigger)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
      • Then - Actions
        • -------- DISABLE HERO CAM --------
        • For each (Integer A) from 0 to 9, do (Actions)
          • Loop - Actions
            • For each (Integer B) from 1 to 10, do (Actions)
              • Loop - Actions
                • If ((Owner of (Triggering unit)) Equal to (Player((Integer B)))) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), false)) else do (Do nothing)
        • -------- UNIT ACTIVITIES --------
        • Unit - Pause (Triggering unit)
        • Unit - Make (Triggering unit) Invulnerable
        • Unit - Make (Triggering unit) face Weak Warlock 0041 <gen> over 0.25 seconds
        • Unit - Make Weak Warlock 0041 <gen> face (Triggering unit) over 0.25 seconds
        • -------- next --------
        • Cinematic - Turn cinematic mode On for (Player group((Owner of (Triggering unit))))
        • Cinematic - Turn on letterbox mode (hide interface) for (Player group((Owner of (Triggering unit)))): fade out over 0.00 seconds
        • Cinematic - Disable user control for (Player group((Owner of (Triggering unit))))
        • Cinematic - Turn subtitle display override On
        • -------- next --------
        • Cinematic - Send transmission to (Player group((Owner of (Triggering unit)))) from Weak Warlock 0041 <gen> named Weak Warlock:: Play No sound and display Thank you friend, t.... Modify duration: Add 6.00 seconds and Wait
        • Camera - Apply Quest 0 Camera <gen> for (Owner of (Triggering unit)) over 0.00 seconds
        • -------- next --------
        • Cinematic - Turn off letterbox mode (show interface) for (Player group((Owner of (Triggering unit)))): fade in over 0.00 seconds
        • Camera - Reset camera for (Owner of (Triggering unit)) to standard game-view over 1.00 seconds
        • Cinematic - Enable user control for (Player group((Owner of (Triggering unit))))
        • Cinematic - Turn cinematic mode Off for (Player group((Owner of (Triggering unit))))
        • Cinematic - Turn subtitle display override Off
        • -------- next --------
        • Unit - Unpause (Triggering unit)
        • Unit - Make (Triggering unit) Vulnerable
        • -------- ENABLE HERO CAM --------
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • HeroCamOnOff[(Player number of (Owner of (Triggering unit)))] Equal to 0
          • Then - Actions
          • Else - Actions
            • For each (Integer A) from 0 to 9, do (Actions)
              • Loop - Actions
                • For each (Integer B) from 1 to 10, do (Actions)
                  • Loop - Actions
                    • If ((Owner of (Triggering unit)) Equal to (Player((Integer B)))) then do (Custom script: call CameraOn(GetConvertedPlayerId(Player(GetForLoopIndexA())), true)) else do (Do nothing)
        • -------- APPLY KARMA --------
      • Else - Actions
    • Trigger - Turn on Quest 1 PRIMARY Part 1 <gen>
Basically what's supposed to happen is when you enter the region, it turns off the owner of the triggering units hero camera, and then turns on the cinematic camera.
What's happening though, is the herocam isn't turning off.
 
Never mind, I think
  • Camera - Reset camera for (Owner of (Triggering unit)) to standard game-view over 1.00 seconds
is making it conflict.

Thanks as always. Here's hoping I'm right.

[edit] Yup. It works flawlessly now. :3
 
Status
Not open for further replies.
Back
Top