• 🏆 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] GetLocalPlayer problem

Status
Not open for further replies.
Level 14
Joined
Aug 30, 2004
Messages
909
I want to order a player's unit to open their spellbook ability, but only that unit. For some reason there are bugs with this that make other players lose their abilities (as if their selected unit has opened a spellbook).

I decided to use the GetLocalPlayer() custom script, which I don't really understand. It is now disconnecting players and crashes the game in single player. These are the triggers that cause it.

Trigger #1: this occurs when a player selects the unit with the spellbook ability

  • Selection Event Rebel
    • Events
    • Conditions
      • (Unit-type of (Triggering unit)) Not equal to Rebel Command Control
    • Actions
      • Set tempPlayer = (Triggering player)
      • Set tempInteger = (Player number of tempPlayer)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • defaultSelection[tempInteger] Not equal to (Triggering unit)
          • (defaultSelection[tempInteger] is alive) Equal to True
          • Or - Any (Conditions) are true
            • Conditions
              • (defaultSelection[tempInteger] is A Hero) Equal to False
              • ((Triggering unit) is in FlareShuttles) Equal to True
        • Then - Actions
          • Selection - Clear selection for tempPlayer
          • Selection - Select defaultSelection[tempInteger] for tempPlayer
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Triggering unit) is A Hero) Equal to False
              • ((Triggering unit) is Mechanical) Equal to False
            • Then - Actions
  • [B] Set zUnit = (Triggering unit)
    • Set MBint = tempInteger
    • Trigger - Run zPress Trigger <gen> (ignoring conditions)[/B]
    • Else - Actions
      • Skip remaining actions
I've bolded the important parts. As far as I know, this sets zUnit to the unit that has the spellbook ability. It then sets MBint = the player number of the player, and calls the next trigger. I think this section is fine, as it worked in the past. The crash didn't appear until I changed this next trigger:

  • zPress Trigger
    • Events
    • Conditions
    • Actions
      • Set MBint = (MBint - 1)
      • Custom script: if GetLocalPlayer() == Player(udg_MBint) then
      • Custom script: call IssueImmediateOrderById (udg_zUnit, 852608)
      • Custom script: endif
What I thought this trigger would do is set MBint to the player number in JASS (apparently player 1 is player 0, etc.). Then I was hoping it would only issue the order to the player who owned zUnit. Instead, it appears to disconnect online players and caused a crash on my side.

Is there a tutorial for GetLocalPlayer()? Does anyone see what's wrong with this? I used this custom script in other areas and it worked, but I don't really understand it.
 
Level 14
Joined
Aug 30, 2004
Messages
909
Excellent, thanks for the link to that tutorial. I do think the problem was the ordering, because I've used it to make and min/max multiboards without desyncs.

What do I need it for?

It's hard to explain because I don't really understand it. The way Battle for Tatooine works is that you're controlling a ship with a spell book ability. You spend the whole time flying inside this spellbook, never seeing the annoying "move" "hold position" etc. commands. In order to do this, every time you select your ship I order it to execute an order that opens the spellbook.

For some reason, this seems to mess with other players who are not in spellbooks; for example a player walking around with their hero. I found this bizarre work around 3 years ago:

  • zPress Trigger Copy
    • Events
    • Conditions
    • Actions
      • Custom script: call IssueImmediateOrderById (udg_zUnit, 852608)
      • Player Group - Pick every player in Imperials and do (Actions)
        • Loop - Actions
          • Set zInteger = (Player number of (Picked player))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • defaultSelection[zInteger] Not equal to Fliers[zInteger]
              • (Imperial Command Control 0107 <gen> is selected by (Picked player)) Equal to False
            • Then - Actions
              • Unit - Add dummy Spellbook to defaultSelection[zInteger]
              • Unit - Remove dummy Spellbook from defaultSelection[zInteger]
            • Else - Actions
      • Player Group - Pick every player in Rebels and do (Actions)
        • Loop - Actions
          • Set zInteger = (Player number of (Picked player))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • defaultSelection[zInteger] Not equal to Fliers[zInteger]
              • (Rebel Command Control 0108 <gen> is selected by (Picked player)) Equal to False
            • Then - Actions
              • Unit - Add dummy Spellbook to defaultSelection[zInteger]
              • Unit - Remove dummy Spellbook from defaultSelection[zInteger]
            • Else - Actions
I just add and remove a dummy spellbook to the units and it avoids the bug. I'm not 100% confident of what I've said here...it was years ago and was the worst bug I ever had. I might have had a post about it...

I DID! Here it is:

http://www.hiveworkshop.com/forums/triggers-scripts-269/spellbook-bug-identified-201588/

Someone suggested testing GetLocalPlayer but warned it might desync. Apparently it does.

The work around is okay, but I think it causes a minor bug of sometimes kicking people out of purchasing menus. That's why I tried GetLocalPlayer.
 
Status
Not open for further replies.
Top