• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • Create a faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

Conversation Improvements.

Status
Not open for further replies.

Chaosy

Tutorial Reviewer
Level 41
Joined
Jun 9, 2011
Messages
13,248
I have been working on a MPI version of the Conversation System uploaded back in the day. Sadly it only worked in single player so I thought I would give it a try.

To be completely honest this is the most weird method I've ever used to create a system.

The system WORKS but I want to fix flaws, maybe opinions on how to make it easier to use, etc.

edit: I am working on selecting units right now, no need to point out that out ^^


  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set CS_hash = (Last created hashtable)
      • Custom script: endfunction
      • Custom script: scope ConversationScope initializer myUniqueInit
      • Custom script: function UpdateText takes player p returns nothing
      • Custom script: set udg_CS_player = p
      • Set CS_id = (Player number of CS_player)
      • Set CS_merge[CS_id] = <Empty String>
      • For each (Integer A) from 1 to CS_total_messages[CS_id], do (Actions)
        • Loop - Actions
          • Set CS_messages[(Integer A)] = (Load (10 + (Integer A)) of CS_id from CS_hash)
          • Custom script: set udg_CS_msg = udg_CS_messages[bj_forLoopAIndex] + "\n"
          • Set CS_current_option = (Load 2 of CS_id from CS_hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CS_current_option Equal to (Integer A)
            • Then - Actions
              • Set CS_msg = (|c007d7d7d + (CS_msg + |r))
            • Else - Actions
          • Set CS_merge[CS_id] = (CS_merge[CS_id] + CS_msg)
      • Custom script: endfunction
      • Custom script: function SaveOptions takes player p returns nothing
      • Custom script: set udg_CS_id = GetPlayerId(p) + 1
      • Custom script: call SaveInteger(udg_CS_hash, udg_CS_id, 2, 1)
      • For each (Integer CS_save_int) from 1 to CS_total_messages[CS_id], do (Actions)
        • Loop - Actions
          • Hashtable - Save CS_messages[CS_save_int] as (10 + CS_save_int) of CS_id in CS_hash
      • Custom script: call UpdateText(p)
      • Custom script: endfunction
      • Custom script: function KeyUp takes nothing returns nothing
      • Set CS_current_option = (Load 2 of (Player number of (Triggering player)) from CS_hash)
      • Set CS_current_option = (CS_current_option - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CS_current_option Less than 1
        • Then - Actions
          • Set CS_current_option = CS_total_messages[(Player number of (Triggering player))]
        • Else - Actions
      • Hashtable - Save CS_current_option as 2 of (Player number of (Triggering player)) in CS_hash
      • Custom script: call UpdateText(GetTriggerPlayer())
      • Custom script: endfunction
      • Custom script: function KeyDown takes nothing returns nothing
      • Set CS_current_option = (Load 2 of (Player number of (Triggering player)) from CS_hash)
      • Set CS_current_option = (CS_current_option + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CS_current_option Greater than CS_total_messages[(Player number of (Triggering player))]
        • Then - Actions
          • Set CS_current_option = 1
        • Else - Actions
      • Hashtable - Save CS_current_option as 2 of (Player number of (Triggering player)) in CS_hash
      • Custom script: call UpdateText(GetTriggerPlayer())
      • Custom script: endfunction
      • Custom script: private function myUniqueInit takes nothing returns nothing
      • Custom script: set udg_CS_temp_trigger = CreateTrigger()
      • Custom script: call TriggerAddAction(udg_CS_temp_trigger, function KeyDown)
      • Trigger - Add to CS_temp_trigger the event (Player - Player 1 (Red) Presses the Down Arrow key)
      • Custom script: set udg_CS_temp_trigger = CreateTrigger()
      • Trigger - Add to CS_temp_trigger the event (Player - Player 1 (Red) Presses the Up Arrow key)
      • Custom script: call TriggerAddAction(udg_CS_temp_trigger, function KeyUp)
      • Custom script: endfunction
      • Custom script: endscope
      • Custom script: function whatever takes nothing returns nothing
  • Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in CS_ReplyGroup and do (Actions)
        • Loop - Actions
          • Custom script: local real r = LoadReal(udg_CS_hash, GetPlayerId(GetEnumPlayer()), 1) + 0.03
          • Custom script: call SaveReal(udg_CS_hash, GetPlayerId(GetEnumPlayer()), 1, r)
          • Custom script: if r > 2 then
          • Custom script: call FlushChildHashtable( udg_CS_hash, GetPlayerId(GetEnumPlayer()))
          • Player Group - Remove (Picked player) from CS_ReplyGroup
          • Custom script: endif
      • For each (Integer B) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer B))) is in CS_ReplyGroup) Equal to False
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CS_merge[(Integer B)] Not equal to <Empty String>
                • Then - Actions
                  • Cinematic - Send transmission to (Player group((Player((Integer B))))) from a Player 1 (Red) No unit-type named Player at (Position of Mountain King 0001 <gen>): Play No sound and display CS_merge[(Integer B)]. Modify duration: Set to 0.00 seconds and Wait
                • Else - Actions
            • Else - Actions

  • Create Base Dialogue
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • -------- ------------ --------
      • Set CS_messages[1] = Hello.
      • Set CS_messages[2] = I got a present for you.
      • Set CS_messages[3] = How do I get past the bridge?
      • Set CS_messages[4] = See you!
      • Player Group - Pick every player in Player Group - Player 1 (Red) and do (Actions)
        • Loop - Actions
          • Cinematic - Turn cinematic mode On for (Player group((Picked player)))
          • Cinematic - Enable user control for (Player group((Picked player)))
          • Camera - Apply Camera 001 <gen> for (Picked player) over 0.00 seconds
          • Camera - Lock camera target for (Picked player) to Mountain King 0001 <gen>, offset by (0.00, 0.00) using Default rotation
          • Set CS_total_messages[(Player number of (Picked player))] = 4
          • Custom script: call SaveOptions(GetEnumPlayer())
      • Trigger - Turn on Loop <gen>
  • Replies
    • Events
      • Player - Player 1 (Red) Presses the Right Arrow key
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CS_messages[CS_current_option] Equal to Hello.
        • Then - Actions
          • Cinematic - Send transmission to (All players) from Archmage 0002 <gen> named sad: Play No sound and display My greetings.. Modify duration: Set to 2.00 seconds and Don't wait
          • Player Group - Add (Triggering player) to CS_ReplyGroup
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CS_messages[CS_current_option] Equal to How do I get past the bridge?
        • Then - Actions
          • Cinematic - Send transmission to (All players) from Archmage 0002 <gen> named sad: Play No sound and display Impossible.. Modify duration: Set to 2.00 seconds and Don't wait
          • Player Group - Add (Triggering player) to CS_ReplyGroup
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CS_messages[CS_current_option] Equal to See you!
        • Then - Actions
          • Cinematic - Turn cinematic mode Off for (Player group((Triggering player)))
          • Set CS_total_messages[(Player number of (Triggering player))] = 0
          • Custom script: call SaveOptions(GetTriggerPlayer())
          • Camera - Reset camera for (Triggering player) to standard game-view over 2.00 seconds
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CS_messages[CS_current_option] Equal to Nevermind.
        • Then - Actions
          • Set CS_messages[1] = Hello.
          • Set CS_messages[2] = I got a present for you.
          • Set CS_messages[3] = How do I get past the bridge?
          • Set CS_messages[4] = See you!
          • Custom script: call SaveOptions(GetTriggerPlayer())
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • CS_messages[CS_current_option] Equal to Give him a teddybear.
              • CS_messages[CS_current_option] Equal to Give him a wizard hat.
              • CS_messages[CS_current_option] Equal to Give him a love letter.
        • Then - Actions
          • Cinematic - Send transmission to (All players) from Archmage 0002 <gen> named sad: Play No sound and display Thank you!. Modify duration: Set to 2.00 seconds and Don't wait
          • Player Group - Add (Triggering player) to CS_ReplyGroup
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CS_messages[CS_current_option] Equal to I got a present for you.
        • Then - Actions
          • Cinematic - Send transmission to (All players) from Archmage 0002 <gen> named sad: Play No sound and display What is it?. Modify duration: Set to 2.00 seconds and Don't wait
          • Player Group - Add (Triggering player) to CS_ReplyGroup
          • Set CS_messages[1] = Give him a teddybear.
          • Set CS_messages[2] = Give him a wizard hat.
          • Set CS_messages[3] = Give him a love letter.
          • Set CS_messages[4] = Nevermind.
          • Custom script: call SaveOptions(GetTriggerPlayer())
        • Else - Actions


 

Attachments

  • Conversation System.w3x
    17.6 KB · Views: 37
Last edited:
Nice implementation. I didn't look at the code, but it looks easy relatively easy for a GUI user to use just based on the demo triggers.

You should give your variables specific names though. Come up with a system name (e.g. Conversation System), prefix it (e.g. CS_), and use PascalCase (e.g. CS_Messages[CS_CurrentOption]). Also, instead of messages[current_option], you should have a global variable dedicated to that value. That way, the user would just have to use a single variable (e.g. CS_CurrentMessage) rather than going through the variable and finding the appropriate index.
 

Chaosy

Tutorial Reviewer
Level 41
Joined
Jun 9, 2011
Messages
13,248
Oh yeah, I always change variable names last second, I will update that.. soon..

So you want me to create a variable that point towards something I already have a variable for? I am not exactly against the idea because array are ugly. However I fear that the spells mods wont be happy.

edit: names changed.
 
Last edited:
Status
Not open for further replies.
Top