Disabling 'chatter' for 6 seconds?

Danis[h]

New Member
Reaction score
19
So basically I want my non-important units to speak idle gossip through floating text tags when you right-click them and stand near them, but I only want it to be possible for them to 'chatter' once every 6th seconds (since that's the duration of the floating text) so the text tags wont overlap..

Also, I think I've been able to make it so that it will only display for the player who clicks the unit, however I'm not sure if it will work?

Trigger:
  • Show Chatter
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • ((Owner of (Target unit of issued order)) Equal to Player 10 (Light Blue)) and ((Target unit of issued order) Not equal to (Random unit from ImportantUnits))
      • (Issued order) Equal to (Order(smart))
    • Actions
      • Custom script: local string Message = ""
      • Set Point = (Position of (Ordered unit))
      • Set Point2 = (Position of (Target unit of issued order))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between Point and Point2) Less than or equal to 200.00
        • Then - Actions
          • Set Die[0] = (Random integer number between 1 and 6)
          • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetOrderedUnit()) then
          • Custom script: set Message = udg_AravilleChatter[udg_Die[0]]
          • Custom script: endif
          • Custom script: call CreateTextTagLocBJ( Message, udg_Point2, 0, 10, 100, 100, 100, 0 )
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 6.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
          • Custom script: set Message = null
        • Else - Actions
          • Do nothing
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: call RemoveLocation(udg_Point2)


edit

In case you were wondering about the string im referring to in the trigger 'AravilleChatter' then here it is set up.
Trigger:
  • Araville Chatter Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set AravilleChatter[1] = Lovely Weather
      • Set AravilleChatter[2] = There's nothing like a good bit of fresh air, don't you think?
      • Set AravilleChatter[3] = Welcome, stranger!
      • Set AravilleChatter[4] = You're not from around here, are you?
      • Set AravilleChatter[5] = Stop Bothering Me
      • Set AravilleChatter[6] = We don't want no trouble here. Araville is a nice town
 

WastedSavior

A day without sunshine is like, well, night.
Reaction score
217
You could set the custom value of the unit to 1, then wait 6 seconds and set it back to 0.

Then add an "if" to check if it is 1 or 0?

As for the displaying to the triggering player, floating text initially displays to everyone, but you can


Code:
Floating Text - Hide (Last created floating text) for (All players)
Floating Text - Show (Last created floating text) for (Player group((Triggering player)))
 

Danis[h]

New Member
Reaction score
19
You could set the custom value of the unit to 1, then wait 6 seconds and set it back to 0.

Then add an "if" to check if it is 1 or 0?

As for the displaying to the triggering player, floating text initially displays to everyone, but you can


Code:
Floating Text - Hide (Last created floating text) for (All players)
Floating Text - Show (Last created floating text) for (Player group((Triggering player)))

I've tested it on b.net and the floating text only displays to the player clicking because to everyone else it's just an empty string.

Although, I can't use unit custom value for a couple of reasons.

1. Custom value of units is already being used by my respawn trigger to respawn npc's and monsters at their initial locations (where they started out)

2. It's supposed to be able to be used by two players at the same time.

e.g. Player 1 clicks it and is shown some message, then 2.5 seconds later player 2 clicks and is also displayed a message. However neither player 1 nor player 2 can click that unit again within the next 6 seconds from the time of the click.
 

WastedSavior

A day without sunshine is like, well, night.
Reaction score
217
I've tested it on b.net and the floating text only displays to the player clicking because to everyone else it's just an empty string.
I would suggest using my method, messing with local player is unnecessary and could have undesired affects.

Although, I can't use unit custom value for a couple of reasons.

1. Custom value of units is already being used by my respawn trigger to respawn npc's and monsters at their initial locations (where they started out)

2. It's supposed to be able to be used by two players at the same time.

e.g. Player 1 clicks it and is shown some message, then 2.5 seconds later player 2 clicks and is also displayed a message. However neither player 1 nor player 2 can click that unit again within the next 6 seconds from the time of the click.

Hmm, I will have to think about that.

I assume all of your units are accounted for by the respawn trigger? (1/2/3/4/5/etc) each one is given a number as a custom value?
 

Danis[h]

New Member
Reaction score
19
I would suggest using my method, messing with local player is unnecessary and could have undesired affects.



Hmm, I will have to think about that.

I assume all of your units are accounted for by the respawn trigger? (1/2/3/4/5/etc) each one is given a number as a custom value?

yes. Every unit on the map (except heroes) are being picked in a unit group loop and assigned their custom values and corresponding points.
Like this
 

WastedSavior

A day without sunshine is like, well, night.
Reaction score
217
So is it possible to create an array boolean for each player?

and each unit clicked, corresponds to it's number in the array

It sets it to true for that player for 6 seconds, which prevents that player from clicking it again, but allows other players to do so?
 

Danis[h]

New Member
Reaction score
19
So is it possible to create an array boolean for each player?

and each unit clicked, corresponds to it's number in the array

It sets it to true for that player for 6 seconds, which prevents that player from clicking it again, but allows other players to do so?

Inspired by this, i used a UnitGroup Array. Simply enough. If the unit is in the player's currently spoken to unitgroup then the trigger wont run.

This is what I ended out with.. I'm a bit worried whether it could cause problems with leaks ect on battle.net.
Trigger:
  • Show Chatter1
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • ((Owner of (Target unit of issued order)) Equal to Player 10 (Light Blue)) and ((Target unit of issued order) Not equal to (Random unit from ImportantUnits))
      • (Issued order) Equal to (Order(smart))
      • (Target unit of issued order) Not equal to (Random unit from ChatterQuarenteen[(Player number of (Owner of (Ordered unit)))])
    • Actions
      • Custom script: local unit Chatterbox = GetOrderTargetUnit()
      • Custom script: local unit OrderUnit = GetOrderedUnit()
      • Custom script: local string Message = ""
      • Set Point = (Position of (Ordered unit))
      • Set Point2 = (Position of (Target unit of issued order))
      • If ((Target unit of issued order) Not equal to (Random unit from ChatterQuarenteen[(Player number of (Owner of (Ordered unit)))])) then do (Unit Group - Add (Target unit of issued order) to ChatterQuarenteen[(Player number of (Owner of (Ordered unit)))]) else do (Do nothing)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between Point and Point2) Less than or equal to 200.00
        • Then - Actions
          • Set Die[0] = (Random integer number between 1 and 6)
          • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetOrderedUnit()) then
          • Custom script: set Message = udg_AravilleChatter[udg_Die[0]]
          • Custom script: endif
          • Custom script: call CreateTextTagLocBJ( Message, udg_Point2, 0, 10, 100, 100, 100, 0 )
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 6.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
          • Custom script: set Message = null
        • Else - Actions
          • Do nothing
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: call RemoveLocation(udg_Point2)
      • Wait 6.00 seconds
      • Custom script: call GroupRemoveUnitSimple( Chatterbox, udg_ChatterQuarenteen[GetConvertedPlayerId(GetOwningPlayer(OrderUnit))] )
      • Custom script: set Chatterbox = null
      • Custom script: set OrderUnit = null


So I guess the remaining question is: Would it mess up on b.net?

Also there is the issue that a random unit from unit group might return false if there's more than one unit in the unit group. any way of changing this?
 

WilliamPa

Active Member
Reaction score
51
I tell you a simple way, which has no chance to mess up(unless u mess it up), turn off the trigger, and after the 6s wait turn it back on.

Code:
Trigger - Turn On
Trigger - Turn Off
 

elmstfreddie

The Finglonger
Reaction score
203
I tell you a simple way, which has no chance to mess up(unless u mess it up), turn off the trigger, and after the 6s wait turn it back on.

Code:
Trigger - Turn On
Trigger - Turn Off

He's using GetLocalPlayer(); turning off the trigger would turn it off for everyone, and I believe it'd cause a desync if he GetLocalPlayer()ed that too.. worth a try I suppose, though.
 

Danis[h]

New Member
Reaction score
19
He's using GetLocalPlayer(); turning off the trigger would turn it off for everyone, and I believe it'd cause a desync if he GetLocalPlayer()ed that too.. worth a try I suppose, though.

this is correct. I cannot simply turn off the trigger since I want it to work for every player, and they may not click a unit at the same time, but they might click one each within a timeframe of 6 seconds.
 

WastedSavior

A day without sunshine is like, well, night.
Reaction score
217
Code:
(Target unit of issued order) Not equal to (Random unit from ChatterQuarenteen[(Player number of (Owner of (Ordered unit)))])


Change this condition to the boolean "Unit - Unit in Unit Group"

Code:
((Target unit of issued order) is in Chatterquarantine) Equal to False
 

Danis[h]

New Member
Reaction score
19
Code:
(Target unit of issued order) Not equal to (Random unit from ChatterQuarenteen[(Player number of (Owner of (Ordered unit)))])


Change this condition to the boolean "Unit - Unit in Unit Group"

Code:
((Target unit of issued order) is in Chatterquarantine) Equal to False

I feel like I've totally missed the obvious here, thanks! Now it works as intended.. Now the trigger looks like this.
Trigger:
  • Show Chatter1
    • Events
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • ((Owner of (Target unit of issued order)) Equal to Player 10 (Light Blue)) and ((Target unit of issued order) Not equal to (Random unit from ImportantUnits))
      • (Issued order) Equal to (Order(smart))
      • ((Target unit of issued order) is in ChatterQuarenteen[(Player number of (Owner of (Ordered unit)))]) Equal to False
    • Actions
      • Custom script: local unit Chatterbox = GetOrderTargetUnit()
      • Custom script: local unit OrderUnit = GetOrderedUnit()
      • Custom script: local string Message = ""
      • Set Point = (Position of (Ordered unit))
      • Set Point2 = (Position of (Target unit of issued order))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Distance between Point and Point2) Less than or equal to 200.00
        • Then - Actions
          • Unit Group - Add (Target unit of issued order) to ChatterQuarenteen[(Player number of (Owner of (Ordered unit)))]
          • Set Die[0] = (Random integer number between 1 and 6)
          • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetOrderedUnit()) then
          • Custom script: set Message = udg_AravilleChatter[udg_Die[0]]
          • Custom script: endif
          • Custom script: call CreateTextTagLocBJ( Message, udg_Point2, 0, 10, 100, 100, 100, 0 )
          • Floating Text - Change (Last created floating text): Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 6.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 4.00 seconds
          • Custom script: set Message = null
        • Else - Actions
          • Do nothing
      • Custom script: call RemoveLocation(udg_Point)
      • Custom script: call RemoveLocation(udg_Point2)
      • Wait 6.00 seconds
      • Custom script: call GroupRemoveUnitSimple( Chatterbox, udg_ChatterQuarenteen[GetConvertedPlayerId(GetOwningPlayer(OrderUnit))] )
      • Custom script: set Chatterbox = null
      • Custom script: set OrderUnit = null


The only question remaining is whether the GetLocalPlayer could cause any problems? So far it hasn't caused any issues on Battle.net when I've tested it. However it might if it runs multiple times or something?
 

WastedSavior

A day without sunshine is like, well, night.
Reaction score
217
If your concerned about local player, do it the normal way.

Code:
Custom script: if GetLocalPlayer() == GetOwningPlayer(GetOrderedUnit()) then
Custom script: set Message = udg_AravilleChatter[udg_Die[0]]
Custom script: endif
Custom script: call CreateTextTagLocBJ( Message, udg_Point2, 0, 10, 100, 100, 100, 0 )

I'd suggest deleting all this, it is absolutely unnecessary.

Create your floating text normally and then add these two lines after
Code:
Floating Text - Hide (Last created floating text) for (All players)
Floating Text - Show (Last created floating text) for (Player group((Triggering player)))

Code:
Do nothing
// Is also unnecessary
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top