• 🏆 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] Making special effect(s) visible only for certain player

Status
Not open for further replies.
Level 10
Joined
Nov 24, 2010
Messages
546
Hello everyone,

I'm trying to make MPI Quest and I need to make special effects overhead of quest givers.
Basicly, I create "!" overhead effect in map int and save it into variable, and let's say Player 1 accept quest, every player but Player 1 will still see "!" and when Player 1 complete quest objective only Player 1 will see "?" overhead of quest giver and when Player 1 finishes quest special effect dissapear for him. And I need this working for every player.

Please note that I'm beginner so don't use strange expressions that I won't understand to.

Thanks
 
Level 10
Joined
Nov 24, 2010
Messages
546
Thanks for quick response, anyway I totally don't understand anything of this, the way you accept quest is "buying" item from quest giver. Here is an example-

  • TestSet
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Special Effect - Create a special effect attached to the overhead of Village Guardian 0011 <gen> using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
      • Set TestEffect[1] = (Last created special effect)
  • TestQ
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to TestQuest
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TestQuestAccepted[(Player number of (Owner of (Triggering unit)))] Not equal to True
        • Then - Actions
          • Set TestQuestAccepted[(Player number of (Owner of (Triggering unit)))] = True
          • -------- Here I need to destroy special effect for Owner of triggering unit and create effect visible for owner of triggering unit only--------
        • Else - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) for 5.00 seconds the text: BlaBla
          • Skip remaining actions
So I need to destroy TestEffect[1] for Owner of Triggering unit.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
I think this will do it:
  • Actions
    • Player Group - Pick every player in (All players) and do (Actions)
      • Loop - Actions
        • Custom script: if GetLocalPlayer() == GetEnumPlayer() then
        • Set s = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
        • Custom script: else
        • Set s = <Empty String>
        • Custom script: endif
        • Special Effect - Create a special effect attached to the overhead of unit using s
        • Set efar[(Player number of (Picked player))] = (Last created special effect)
 
Level 10
Joined
Nov 24, 2010
Messages
546
This is what I have now but somehow nothing happens with special effects

  • TestQ
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to TestQuest
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TestQuestAccepted[(Player number of (Owner of (Triggering unit)))] Not equal to True
        • Then - Actions
          • Set TestQuestAccepted[(Player number of (Owner of (Triggering unit)))] = True
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Custom script: if GetLocalPlayer() == GetEnumPlayer() then
              • Set TestString = floating questionmark_v2.mdx
              • Custom script: else
              • Set TestString = <Empty String>
              • Special Effect - Create a special effect attached to the overhead of Village Guardian 0011 <gen> using TestString
              • Set TestEffect2[(Player number of (Picked player))] = (Last created special effect)
              • Custom script: endif
          • -------- Here I need to destroy special effect for Owner of triggering unit --------
        • Else - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) for 5.00 seconds the text: BlaBla
          • Skip remaining actions
 
Level 10
Joined
Nov 24, 2010
Messages
546
Yes sorry, my mistake, creating special effect part works now.
How can I destroy special effect that I have created in map int for Owner of triggering unit in quest take effect part?



And here is Quest finish part, where I have to destroy special effect that I have created in quest take part

  • TestQFinish
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to TestQuest
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TestQuestAccepted[(Player number of (Owner of (Triggering unit)))] Equal to True
          • TestQuestObjectCompleted[(Player number of (Owner of (Triggering unit)))] Equal to True
        • Then - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: BlaBla quest comple...
          • -------- Here I have to destroy special effect I created in take quest part --------
        • Else - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: BlaBla
 
Level 10
Joined
Nov 24, 2010
Messages
546
Allright so part with taking and finishing quest works, when I take quest special effect that I wanted to appear appeared and after completing objective and finishing quest that special effect dissapeared, anyway, I have one more problem.

This is way I set special effect to each quest giver on map and I need this special effect to be destroyed after accepting quest
  • TestSet
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Special Effect - Create a special effect attached to the overhead of Village Guardian 0011 <gen> using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
      • Set TestEffect[1] = (Last created special effect)
And I can't destroy this effect for certain player after accepting quest.
 
Level 10
Joined
Nov 24, 2010
Messages
546
Everything works perfectly in single player, here is my code, please tell me if there is anything to improve (ignore massages, they are only for testing there)
This is just simple quest I created for testing - Kill 1 unit


Starting effect:

  • Starting Quest Effects
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Special Effect - Create a special effect attached to the overhead of Blacksmith Jonathan 0003 <gen> using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
      • Set MakingItBeterStartEff[1] = (Last created special effect)
"Buy" Quest item part:

  • MakingItBetterTake
    • Events
      • Unit - A unit Acquires an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to MakkingItBetter
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MakingItBetterAccepted[(Player number of (Owner of (Triggering unit)))] Not equal to True
          • MakingItBetterFinished[(Player number of (Owner of (Triggering unit)))] Not equal to True
        • Then - Actions
          • Set MakingItBetterAccepted[(Player number of (Owner of (Triggering unit)))] = True
          • Player Group - Pick every player in (All players) and do (Actions)
            • Loop - Actions
              • Custom script: if GetLocalPlayer() == GetEnumPlayer() then
              • Set MakingItBetterString[1] = Objects\RandomObject\RandomObject.mdl
              • Custom script: else
              • Set MakingItBetterString[1] = <Empty String>
              • Custom script: endif
              • Special Effect - Create a special effect attached to the overhead of Blacksmith Jonathan 0003 <gen> using MakingItBetterString[1]
              • Special Effect - Destroy MakingItBeterStartEff[1]
              • Set MakingItBetterEffect[(Player number of (Picked player))] = (Last created special effect)
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 6.00 seconds the text: Q taken
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MakingItBetterObjectiveComp[(Player number of (Owner of (Triggering unit)))] Not equal to True
              • MakingItBetterAccepted[(Player number of (Owner of (Triggering unit)))] Equal to True
              • MakingItBetterFinished[(Player number of (Owner of (Triggering unit)))] Not equal to True
            • Then - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 6.00 seconds the text: You are allready on...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MakingItBetterObjectiveComp[(Player number of (Owner of (Triggering unit)))] Equal to True
              • MakingItBetterAccepted[(Player number of (Owner of (Triggering unit)))] Equal to True
              • MakingItBetterFinished[(Player number of (Owner of (Triggering unit)))] Not equal to True
            • Then - Actions
              • Game - Display to (Player group((Owner of (Triggering unit)))) for 6.00 seconds the text: Quest Making it Bet...
              • Set MakingItBetterFinished[(Player number of (Owner of (Triggering unit)))] = True
              • Player Group - Pick every player in (All players) and do (Actions)
                • Loop - Actions
                  • Custom script: if GetLocalPlayer() == GetEnumPlayer() then
                  • Set MakingItBetterString[1] = floating questionmark_v2.mdx
                  • Custom script: else
                  • Set MakingItBetterString[1] = <Empty String>
                  • Custom script: endif
                  • Special Effect - Destroy MakingItBetterEffect[(Player number of (Picked player))]
            • Else - Actions

Kill quest unit:

  • MakingItBetterKill
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Giant Winter Wolf (melee)
    • Actions
      • Unit Group - Pick every unit in (Units within 900.00 of (Position of (Triggering unit))) and do (Actions)
        • Loop - Actions
          • Set MakingItBetterI = (Player number of (Owner of (Picked unit)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • MakingItBetterAccepted[MakingItBetterI] Equal to True
              • MakingItBetterObjectiveComp[(Player number of (Owner of (Picked unit)))] Not equal to True
            • Then - Actions
              • Set MakingItBetterObjectiveComp[MakingItBetterI] = True
              • Game - Display to (Player group((Owner of (Picked unit)))) the text: aaa
              • Player Group - Pick every player in (All players) and do (Actions)
                • Loop - Actions
                  • Custom script: if GetLocalPlayer() == GetEnumPlayer() then
                  • Set MakingItBetterString[2] = floating questionmark_v2.mdl
                  • Custom script: else
                  • Set MakingItBetterString[2] = <Empty String>
                  • Custom script: endif
                  • Special Effect - Destroy MakingItBetterEffect[(Player number of (Picked player))]
                  • Special Effect - Create a special effect attached to the overhead of Blacksmith Jonathan 0003 <gen> using MakingItBetterString[2]
                  • Set MakingItBetterEffect[(Player number of (Picked player))] = (Last created special effect)
            • Else - Actions
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Loop through players in this trigger, and create the effects with GetLocalPlayer. Use player number of picked player
  • Starting Quest Effects
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Special Effect - Create a special effect attached to the overhead of Blacksmith Jonathan 0003 <gen> using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
      • Set MakingItBeterStartEff[1] = (Last created special effect)
Read about leaks: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
 
Level 10
Joined
Nov 24, 2010
Messages
546
Did you mean something like this?

  • Starting Quest Effects
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Custom script: if GetLocalPlayer() == GetEnumPlayer() then
          • Set MakingItBetterString[(Player number of (Picked player))] = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
          • Custom script: else
          • Set MakingItBetterString[(Player number of (Picked player))] = <Empty String>
          • Custom script: endif
          • Special Effect - Create a special effect attached to the overhead of Blacksmith Jonathan 0003 <gen> using MakingItBetterString[(Player number of (Picked player))]
          • Set MakingItBetterEffect[(Player number of (Picked player))] = (Last created special effect)
EDIT:

This doesn't work, I have tested it in multiplayer and all players see same special effect, doesn't metter who have/don't have accepted quest.
 
Last edited:
Level 23
Joined
Apr 16, 2012
Messages
4,041
of course all see this, because all players are picked
GetLocalPlayer returns different players depending on which mashine you run it, so if the code was executed on player 1's computer, it will run, since you have GetEnumPlayer it will run for each player and the else block never runs
You should make some condition for it
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
when you do GetLocalPlayer function call, it returns different players for different mashines it runs on, so basically if I did if GetLocalPlayer() == Player(0) then ... endif, then everything within then and endif keyword would run only on Player 1's(red) computer
Your code runes for all players because you set string to something for every player because you run it as a loop, the GetEnumPlayer() will run 12 times so sooner or later all players will have the value set to that
Also, when you do stuff locally you dont need to use arrays because it will change on computer not for the whole game, so:
JASS:
local integer i = 0
if GetLocalPlayer() == Player(0) then
    set i = 6
endif
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 60, I2S(i))

Should print 6 for player 1(red) but 0 for everyone else(I didnt test it works that way even if it doesnt print the right numbers)
 
Status
Not open for further replies.
Top