[trigger=1]Chat box Initialization
Events
Map initialization
Conditions
Actions
-------- Run this Initialization on your map initialization --------
-------- Chat Box System Requires Unit Indexer --------
-------- -------------------------------------- --------
-------- Modifiable --------
-------- Set Up --------
Set cBox_DummyType = ChatDummy
Set cBox_maxChatRows = 8
Set cBox_lineSpace = 100.00
Set cBox_NormalSize = 10.00
Set cBox_animSpeed = 5.00
Set cBox_soundEffect = cBox_ChatSoundEffect <gen>
Set cBox_chatStartLocation = (Center of Start Pixel <gen>)
Set cBox_isInstant = False
-------- -------------------------------------- --------
-------- Initialize system variables and constants --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
cBox_isInstant Equal to True
Then - Actions
Set cBox_InitialVelocity = cBox_lineSpace
Else - Actions
Set cBox_InitialVelocity = (5.00 x cBox_animSpeed)
Set cBox_MaxDistance = (cBox_lineSpace x (Real(cBox_maxChatRows)))
Set cBox_MaxDistance = (cBox_MaxDistance + cBox_lineSpace)
Set cBox_currentQueueInteger = 1
Set cBox_maxQueueInteger = 0
Hashtable - Create a hashtable
Set cBox_Hash = (Last created hashtable)
-------- -------------------------------------- --------
-------- Initialize event --------
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
Trigger - Add to Chat Event <gen> the event (Player - (Player((Integer A))) types a chat message containing <Empty String> as A substring)
-------- -------------------------------------- --------
-------- Delete line below --------
-------- Testing Purposes --------
-------- Initialize Player Camera --------
For each (Integer A) from 1 to 12, do (Actions)
Loop - Actions
Camera - Set (Player((Integer A)))'s camera Angle of attack to 270.00 over 2.00 seconds
Camera - Set (Player((Integer A)))'s camera Rotation to 90.00 over 2.00 seconds
Camera - Set (Player((Integer A)))'s camera Distance to target to 2560.00 over 2.00 seconds
Camera - Set (Player((Integer A)))'s camera Field of view to 90.00 over 0.00 seconds
Camera - Pan camera for (Player((Integer A))) to (Center of Camera center <gen>) over 0.00 seconds
Visibility - Disable fog of war
Visibility - Disable black mask
-------- Initialize Player Color --------
Set Ccode_P[1] = RedColorCode
Set Ccode_P[2] = BlueColorCode
-------- -------------------------------------- --------
[/trigger]
[trigger=2]Chat Event
Events
Conditions
Actions
Unit - Create 1 cBox_DummyType for (Triggering player) at (Center of Start Pixel <gen>) facing 90.00 degrees
Set Key = (Custom value of (Last created unit))
Set cBox_scrolledDistance[Key] = 0.00
Set cBox_TargetDistance[Key] = cBox_lineSpace
Set cBox_Velocity[Key] = cBox_InitialVelocity
Set cBox_currentDistance[Key] = 0.00
Set cBox_Size[Key] = (cBox_NormalSize x 1.50)
Set cBox_Transparancy[Key] = 0.00
Set cBox_String[Key] = (((Name of (Triggering player)) + : ) + (Entered chat string))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Length of cBox_String[Key]) Greater than or equal to 32
Then - Actions
-------- -------------------------------------- --------
-------- When string reaches 32, floating text will appear weird --------
Game - Display to (All players) the text: Over limit!
-------- Overloaded string will be seperated into single floating text each --------
-------- -------------------------------------- --------
-------- String overload system under construction --------
For each (Integer A) from 0 to (Length of (Entered chat string)), do (Actions)
Loop - Actions
Set cBox_String[Key] = (Substring((Entered chat string), (Integer A), (Integer A)))
-------- -------------------------------------- --------
Else - Actions
Floating Text - Create floating text that reads cBox_String[Key] above (Last created unit) with Z offset 0.00, using font size cBox_Size[Key], color (100.00%, 100.00%, 100.00%), and 0.00% transparency
Floating Text - Change (Last created floating text): Disable permanence
Set cBox_floatingText[Key] = (Last created floating text)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(cBox_ScrollGroup is empty) Equal to True
Then - Actions
-------- If scroll group is empty (not scrolling) --------
-------- Then we instantiate the floating text normally --------
-------- Play sound on chat --------
Sound - Play cBox_soundEffect
-------- -------------------------------------- --------
-------- Scroll Inactive text upward --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(cBox_InactiveGroup is empty) Equal to False
Then - Actions
Unit Group - Pick every unit in cBox_InactiveGroup and do (Actions)
Loop - Actions
Set cBox_TempUnit2 = (Picked unit)
Set Key = (Custom value of cBox_TempUnit2)
Set cBox_scrolledDistance[Key] = 0.00
Set cBox_Velocity[Key] = cBox_InitialVelocity
Set cBox_TargetDistance[Key] = cBox_lineSpace
Unit Group - Remove cBox_TempUnit2 from cBox_InactiveGroup
Unit Group - Add cBox_TempUnit2 to cBox_ScrollGroup
Trigger - Turn on Chat Scroller <gen>
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(cBox_ScrollGroup is empty) Equal to False
Then - Actions
Unit Group - Pick every unit in cBox_ScrollGroup and do (Actions)
Loop - Actions
Set cBox_TempUnit2 = (Picked unit)
Set Key = (Custom value of cBox_TempUnit2)
Set cBox_scrolledDistance[Key] = 0.00
Set cBox_Velocity[Key] = cBox_InitialVelocity
Set cBox_TargetDistance[Key] = cBox_lineSpace
Trigger - Turn on Chat Scroller <gen>
Else - Actions
-------- -------------------------------------- --------
Unit Group - Add (Last created unit) to cBox_ScrollGroup
Trigger - Turn on Chat Scroller <gen>
-------- -------------------------------------- --------
Else - Actions
-------- If scroll group is not empty (scrolling) --------
-------- Then we instantiate the floating text in queued list --------
-------- To avoid clamping of text --------
-------- -------------------------------------- --------
Set cBox_maxQueueInteger = (cBox_maxQueueInteger + 1)
Hashtable - Save Handle Of(Last created unit) as (Key QueuedChat) of cBox_maxQueueInteger in cBox_Hash
Floating Text - Hide cBox_floatingText[Key] for (All players)
-------- -------------------------------------- --------
[/trigger]
[trigger=3]Queue Manager
Events
Conditions
cBox_currentQueueInteger Less than or equal to cBox_maxQueueInteger
cBox_maxQueueInteger Greater than 0
Actions
-------- -------------------------------------- --------
-------- Play sound on chat --------
Sound - Play cBox_soundEffect
-------- -------------------------------------- --------
-------- Scroll Inactive text upward --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(cBox_InactiveGroup is empty) Equal to False
Then - Actions
Unit Group - Pick every unit in cBox_InactiveGroup and do (Actions)
Loop - Actions
Set cBox_TempUnit2 = (Picked unit)
Set Key = (Custom value of cBox_TempUnit2)
Set cBox_scrolledDistance[Key] = 0.00
Set cBox_Velocity[Key] = cBox_InitialVelocity
Set cBox_TargetDistance[Key] = cBox_lineSpace
Unit Group - Remove cBox_TempUnit2 from cBox_InactiveGroup
Unit Group - Add cBox_TempUnit2 to cBox_ScrollGroup
Trigger - Turn on Chat Scroller <gen>
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(cBox_ScrollGroup is empty) Equal to False
Then - Actions
Unit Group - Pick every unit in cBox_ScrollGroup and do (Actions)
Loop - Actions
Set cBox_TempUnit2 = (Picked unit)
Set Key = (Custom value of cBox_TempUnit2)
Set cBox_scrolledDistance[Key] = 0.00
Set cBox_Velocity[Key] = cBox_InitialVelocity
Set cBox_TargetDistance[Key] = cBox_lineSpace
Trigger - Turn on Chat Scroller <gen>
Else - Actions
-------- -------------------------------------- --------
-------- Run Queued list in order --------
Set cBox_TempUnit3 = (Load (Key QueuedChat) of cBox_currentQueueInteger in cBox_Hash)
Set Key = (Custom value of cBox_TempUnit3)
Special Effect - Create a special effect attached to the overhead of cBox_TempUnit3 using Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
Floating Text - Show cBox_floatingText[Key] for (All players)
Set cBox_currentQueueInteger = (cBox_currentQueueInteger + 1)
Trigger - Turn off (This trigger)
Unit Group - Add cBox_TempUnit3 to cBox_ScrollGroup
Trigger - Turn on Chat Scroller <gen>
-------- -------------------------------------- --------
[/trigger]
[trigger=4]
Chat Scroller
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
-------- -------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(cBox_ScrollGroup is empty) Equal to False
Then - Actions
Unit Group - Pick every unit in cBox_ScrollGroup and do (Actions)
Loop - Actions
-------- -------------------------------------- --------
Set cBox_TempUnit = (Picked unit)
Set Key = (Custom value of cBox_TempUnit)
-------- -------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
cBox_scrolledDistance[Key] Less than cBox_TargetDistance[Key]
Then - Actions
-------- -------------------------------------- --------
-------- Decrease chat box size to normal size --------
-------- For animation --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
cBox_Size[Key] Greater than cBox_NormalSize
Then - Actions
Set cBox_Size[Key] = (cBox_Size[Key] - (cBox_NormalSize / 20.00))
Else - Actions
-------- -------------------------------------- --------
-------- If velocity exceeds chat distance, set velocity to remaining distance. --------
-------- This is so that the line spacing is perfectly alligned. --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(cBox_scrolledDistance[Key] + cBox_Velocity[Key]) Greater than cBox_TargetDistance[Key]
Then - Actions
Set cBox_Velocity[Key] = (cBox_TargetDistance[Key] - cBox_scrolledDistance[Key])
Else - Actions
-------- -------------------------------------- --------
-------- Decrease velocity --------
-------- For animation --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
cBox_Velocity[Key] Greater than 1.00
Then - Actions
Set cBox_Velocity[Key] = (cBox_Velocity[Key] - (cBox_InitialVelocity / 50.00))
Else - Actions
Set cBox_Velocity[Key] = 1.00
-------- -------------------------------------- --------
-------- Accumulate current distance --------
Set cBox_currentDistance[Key] = (cBox_currentDistance[Key] + cBox_Velocity[Key])
-------- -------------------------------------- --------
-------- Move unit location --------
Set cBox_TempPoint = (Position of cBox_TempUnit)
Set cBox_TempPoint2 = (cBox_TempPoint offset by cBox_Velocity[Key] towards 90.00 degrees)
Set cBox_X = (X of cBox_TempPoint2)
Set cBox_Y = (Y of cBox_TempPoint2)
Custom script: call SetUnitX(udg_cBox_TempUnit, udg_cBox_X)
Custom script: call SetUnitY(udg_cBox_TempUnit, udg_cBox_Y)
-------- -------------------------------------- --------
-------- Accumulate scrolled distance --------
Set cBox_scrolledDistance[Key] = (cBox_scrolledDistance[Key] + cBox_Velocity[Key])
-------- -------------------------------------- --------
-------- If it reach the target distance --------
-------- Stop moving --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
cBox_scrolledDistance[Key] Greater than or equal to cBox_TargetDistance[Key]
Then - Actions
Set cBox_Velocity[Key] = 0.00
Else - Actions
-------- -------------------------------------- --------
-------- Update floating text location --------
Floating Text - Change the position of cBox_floatingText[Key] to cBox_TempUnit with Z offset 0.00
Floating Text - Change text of cBox_floatingText[Key] to cBox_String[Key] using font size cBox_Size[Key]
-------- -------------------------------------- --------
-------- If floating text exceed floating line limit, remove floating text --------
-------- with dissapearing animation --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
cBox_currentDistance[Key] Greater than or equal to (cBox_MaxDistance - (cBox_lineSpace x 2.00))
Then - Actions
Set cBox_Transparancy[Key] = ((((cBox_lineSpace x 2.00) - (cBox_MaxDistance - cBox_currentDistance[Key])) / (cBox_lineSpace x 2.00)) x 100.00)
Floating Text - Change the color of cBox_floatingText[Key] to (100.00%, 100.00%, 100.00%) with cBox_Transparancy[Key]% transparency
Animation - Change cBox_TempUnit's vertex coloring to (100.00%, 100.00%, 100.00%) with cBox_Transparancy[Key]% transparency
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
cBox_Transparancy[Key] Greater than or equal to 100.00
Then - Actions
Floating Text - Destroy cBox_floatingText[Key]
Unit Group - Remove cBox_TempUnit from cBox_ScrollGroup
Unit Group - Remove cBox_TempUnit from cBox_InactiveGroup
Unit - Remove cBox_TempUnit from the game
Else - Actions
Else - Actions
-------- -------------------------------------- --------
-------- Remove leaks --------
Custom script: call RemoveLocation(udg_cBox_TempPoint)
Custom script: call RemoveLocation(udg_cBox_TempPoint2)
-------- -------------------------------------- --------
Else - Actions
-------- -------------------------------------- --------
-------- If chat unit has stopped moving --------
-------- Register unit as inactive --------
Unit Group - Add cBox_TempUnit to cBox_InactiveGroup
Unit Group - Remove cBox_TempUnit from cBox_ScrollGroup
-------- -------------------------------------- --------
Else - Actions
-------- -------------------------------------- --------
-------- If there is no longer moving chat animations --------
-------- Turn off this trigger --------
Trigger - Turn off (This trigger)
-------- -------------------------------------- --------
-------- Run queue list in order as the chat animation ends --------
Trigger - Run Queue Manager <gen> (checking conditions)
-------- -------------------------------------- --------
[/trigger]