• 🏆 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!

Specific player - filter and units

Status
Not open for further replies.
Level 7
Joined
Nov 19, 2015
Messages
283
Can someone tell me how to apply a filter for only a specific player.


Also if it is possible to make a certain unit unviewable for certain players (not using invisibility). I have an illusion ability that I want only the targeted player to be able to see but not others. The illusion won't do anything but just for special effects. (eg. make copies of my hero that only one player can see).
 
Level 37
Joined
Jul 22, 2015
Messages
3,485
You make a post in Triggers & Scripts if you need help with code/triggers you have already started. If you need help getting started with one, you should post in World Editor Help Zone.

Anywho, here's how you would do it (I think):
  • Custom script: set udg_playerVariable = GetLocalPlayer()
  • Set stringVariable = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (playerVariable is player) Equal to False
    • Then - Actions
      • Set stringVariable = <Empty String>
    • Else - Actions
  • Special Effect - Create a special effect attached to the origin of unit using stringVariable
 
Level 7
Joined
Nov 19, 2015
Messages
283
Sorry, my bad, I got confused of where to put it.

Thank you. Could you please tell me how I can apply this to a unit.
Is everything that player see is under the custom script?
If so, is there an end?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
To run a piece of code only for one player, you filter out the players that you don't want to see it:
(Don't copy triggers yet.)
  • Custom script: set udg_TempPlayer = GetLocalPlayer()
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • TempPlayer Equal to Player 1 (Red)
    • Then - Actions
      • -------- runs for selected players --------
    • Else - Actions
      • -------- do nothing -------- (is a comment)
First, you set the "TempPlayer" variable to the local player.
So every player who is playing now has a different value in that variable.
If the value is equal to "Player 1 (Red)" (which only happens for player 1), then the "Then" block runs.
For all other players, the "Else" block runs but you ussually dont use it.

In any case, there are some restrictions to what you can do for one player only.
You cannot for example create/remove units, destructables, items, locations, groups, texttags, etc, etc, etc... you cannot create/remove anything at all.
You can also not change any gameplay related things, like adding an ability to a unit, changing a unit's location, damaging a unit, etc.

In your case, you want to hide a unit for all players except one or two.
In that case, you create the unit before the If/Then/Else block and hide it inside the If/Then/Else block:
  • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees (Leaks location, I know.)
  • Set TempUnit = (Last created unit)
  • Custom script: set udg_TempPlayer = GetLocalPlayer()
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • TempPlayer Equal to Player 1 (Red)
    • Then - Actions
      • -------- runs for selected players --------
    • Else - Actions
      • -------- do nothing --------
      • Unit - Hide TempUnit
      • Animation - Change TempUnit's vertex coloring to (100.00%, 100.00%, 100.00%) with 100.00% transparency
Now there are two ways to hide a unit,
1, Hide the unit.
2, Make the unit invisible (color wise).

I am not quite sure if option 1 is allowed locally, so you may just use the animation action and remove the unit - hide action from the trigger.

Ofcourse, you check if "TempPlayer" is equal to the owner or the target.
There is one slight problem... you want to store 3 players:
1, The owner of the unit.
2, The targeted player.
3, The local player.
Instead of making 3 "TempPlayer", "TempPlayer1", "TempPlayer2" variables, we change our "TempPlayer" variable to an array.
Now you have 8191 "TempPlayer[<number>]" variables all in one.
So "TempPlayer[0]" is the owner.
"TempPlayer[1]" is the target.
And "TempPlayer[2]" is the local player.
(Ofcourse we also do this for the unit variable.)
  • Actions
    • Set TempPlayer[0] = Player 1 (Red)
    • Set TempPlayer[1] = Player 2 (Blue)
    • -------- - --------
    • Unit - Create 1 Footman for TempPlayer[0] at (Center of (Playable map area)) facing Default building facing degrees (Still leaks, I still know.)
    • Set TempUnit[0] = (Last created unit)
    • -------- - --------
    • Custom script: set udg_TempPlayer[2] = GetLocalPlayer()
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Or - Any (Conditions) are true
          • Conditions
            • TempPlayer[2] Equal to TempPlayer[0]
            • TempPlayer[2] Equal to TempPlayer[1]
      • Then - Actions
        • -------- runs for selected players --------
        • -------- unit is already visible --------
      • Else - Actions
        • -------- do nothing --------
        • Unit - Hide TempUnit[0] <<< So dont use this
        • Animation - Change TempUnit[0]'s vertex coloring to (100.00%, 100.00%, 100.00%) with 100.00% transparency
 
Level 7
Joined
Nov 19, 2015
Messages
283
I still don't get what GetLocalPlayer() even means but your examples are really helpful. I can pretty much do what I want with the examples you gave me.

I will try test this out soon but its kinda hard since I need another computer.
 
Status
Not open for further replies.
Top