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

Advanced NPC Chat System [ANCS] Version 1.2a

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: FRENGERS
Advanced NPC Chat System [ANCS] Version 1.2a

Hello! I was bored and decided to make a system. As I could see and find there was no good system out here in this section with this kind of feature, so I decided to create it!

In my opinion it went out good; however, improvements can be made, with your help! Please give me feedback so I may improve this system to become even better, because I know many people would like to have a system like this in their map(s)! Thank you.

system_monitor.png
System Information
This system allow you to create a conversation/chat with any unit placed in your map (can even be used with unit you create in the game with the right setup). Simply you use an ability, as I call in the test map "Talk" on a target unit and the conversation/chat starts.

Depending on how you setup the NPC it will appear different options (a maximum of 5) for you to select and each option will result in a different answer or event. For each option you are able to add an external trigger that will run whenever a player choose this specific "connected" option to the external trigger (in the test map you will kill the Knight if you pick option Nr. 3).

Note: This system has some parts that is made with JASS, however it's very user friendly, else it's fully GUI. Also, it's a 100% MPI!
Tip: If you want a black interface while you have a conversation take a look click here!

apps_system_update_software.png
Triggers
Triggers are inside the hidden-tags below (triggers below are for version 1.1a and the code have been optimized and improved since version 1.2a).



JASS:
function ANCS_SaveData takes unit u, string ta1, string ta2, string ta3, string ta4, string ta5, string to1, string to2, string to3, string to4, string to5, integer mo, trigger trg1, trigger trg2, trigger trg3, trigger trg4, trigger trg5 returns nothing

   set udg_ANCS_NPC_ID = udg_ANCS_NPC_ID + 1

   set udg_ANCS_NPC_Unit[udg_ANCS_NPC_ID] = u

   set udg_ANCS_NPC_TalkAnswer1[udg_ANCS_NPC_ID] = ta1
   set udg_ANCS_NPC_TalkAnswer2[udg_ANCS_NPC_ID] = ta2
   set udg_ANCS_NPC_TalkAnswer3[udg_ANCS_NPC_ID] = ta3
   set udg_ANCS_NPC_TalkAnswer4[udg_ANCS_NPC_ID] = ta4
   set udg_ANCS_NPC_TalkAnswer5[udg_ANCS_NPC_ID] = ta5
   set udg_ANCS_NPC_TalkOption1[udg_ANCS_NPC_ID] = to1
   set udg_ANCS_NPC_TalkOption2[udg_ANCS_NPC_ID] = to2
   set udg_ANCS_NPC_TalkOption3[udg_ANCS_NPC_ID] = to3
   set udg_ANCS_NPC_TalkOption4[udg_ANCS_NPC_ID] = to4
   set udg_ANCS_NPC_TalkOption5[udg_ANCS_NPC_ID] = to5
   set udg_ANCS_NPC_MaxOptions[udg_ANCS_NPC_ID] = mo

   set udg_ANCS_NPC_ExternalTrigger1[udg_ANCS_NPC_ID] = trg1
   set udg_ANCS_NPC_ExternalTrigger2[udg_ANCS_NPC_ID] = trg2
   set udg_ANCS_NPC_ExternalTrigger3[udg_ANCS_NPC_ID] = trg3
   set udg_ANCS_NPC_ExternalTrigger4[udg_ANCS_NPC_ID] = trg4
   set udg_ANCS_NPC_ExternalTrigger5[udg_ANCS_NPC_ID] = trg5
endfunction

function ANCS_GetCurrentOption takes integer c, integer cOption returns string
   if (c == cOption) then
      return udg_ANCS_System_SelectColor + udg_ANCS_System_SelectIndicator
   else
      return udg_ANCS_System_NormalColor
   endif
endfunction

function ANCS_GetOptionString takes integer uID, integer cOption returns string
   local string tmp = ""

   set tmp = tmp + ANCS_GetCurrentOption(1, cOption) + udg_ANCS_NPC_TalkOption1[uID] + "|r|n"
   set tmp = tmp + ANCS_GetCurrentOption(2, cOption) + udg_ANCS_NPC_TalkOption2[uID] + "|r|n"
   set tmp = tmp + ANCS_GetCurrentOption(3, cOption) + udg_ANCS_NPC_TalkOption3[uID] + "|r|n"
   set tmp = tmp + ANCS_GetCurrentOption(4, cOption) + udg_ANCS_NPC_TalkOption4[uID] + "|r|n"
   set tmp = tmp + ANCS_GetCurrentOption(5, cOption) + udg_ANCS_NPC_TalkOption5[uID] + "|r"

      return tmp
   set tmp = null
endfunction

function ANCS_GetAnswerString takes integer uID, integer cOption returns string
   if (cOption == 1) then
      return udg_ANCS_NPC_TalkAnswer1[uID]
   elseif (cOption == 2) then
      return udg_ANCS_NPC_TalkAnswer2[uID]
   elseif (cOption == 3) then      
      return udg_ANCS_NPC_TalkAnswer3[uID]
   elseif (cOption == 4) then
      return udg_ANCS_NPC_TalkAnswer4[uID]
   elseif (cOption == 5) then
      return udg_ANCS_NPC_TalkAnswer5[uID]
   endif
endfunction

function ANCS_GetAnswerTrigger takes integer uID, integer cOption returns trigger
   if (cOption == 1) then
      return udg_ANCS_NPC_ExternalTrigger1[uID]
   elseif (cOption == 2) then
      return udg_ANCS_NPC_ExternalTrigger2[uID]
   elseif (cOption == 3) then      
      return udg_ANCS_NPC_ExternalTrigger3[uID]
   elseif (cOption == 4) then
      return udg_ANCS_NPC_ExternalTrigger4[uID]
   elseif (cOption == 5) then
      return udg_ANCS_NPC_ExternalTrigger5[uID]
   endif
endfunction



  • ANCS System Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- ---------------------------------------------- --------
      • -------- You can remove this variable action below (ANCS_Integer) after you have pasted the system into your map; it's only here so it will be copied correctly. --------
      • Set ANCS_Integer = 0
      • -------- ---------------------------------------------- --------
      • -------- Set the variable below to your "Talk" ability; the ability that will be used in order to talk to an unit. --------
      • Set ANCS_TalkAbility = Talk
      • -------- ---------------------------------------------- --------
      • -------- Set the variable below to a color-code. The variable below is for the normal options (options that are not selected by the player). --------
      • Set ANCS_System_NormalColor = |cffffffff
      • -------- ---------------------------------------------- --------
      • -------- Set the variable below to a color-code. The variable below is for the selected options (the options that are selected by the player). --------
      • Set ANCS_System_SelectColor = |cff80FF00
      • -------- ---------------------------------------------- --------
      • -------- Set the variable below to something that could represent a "select"-indicator. This isn't a must, leave it empty if you don't want to use this. --------
      • Set ANCS_System_SelectIndicator = >
      • -------- ---------------------------------------------- --------
      • -------- Set the variable below to the amount of time you want an answer message to be displayed. --------
      • Set ANCS_System_MsgTime = 2.50
      • -------- ---------------------------------------------- --------
      • -------- Set the variable below to something that will appear when you can't talk to a specific unit in the game. Leave this empty if an error message shouldn't appear. --------
      • Set ANCS_System_CantTalkMsg = You can't talk with this unit.
      • -------- ---------------------------------------------- --------
      • -------- Do not change this below. --------
      • For each (Integer ANCS_Integer) from 1 to 12, do (Actions)
        • Loop - Actions
          • Trigger - Add to ANCS ToggleUp <gen> the event (Player - (Player(ANCS_Integer)) Presses the Up Arrow key)
          • Trigger - Add to ANCS ToggleDown <gen> the event (Player - (Player(ANCS_Integer)) Presses the Down Arrow key)
          • Trigger - Add to ANCS ToggleRight Select <gen> the event (Player - (Player(ANCS_Integer)) Presses the Right Arrow key)
          • Trigger - Add to ANCS ToggleCancel <gen> the event (Player - (Player(ANCS_Integer)) skips a cinematic sequence)
      • -------- ---------------------------------------------- --------
      • -------- Change the trigger below to the Initialization trigger you use! Do you use the GUI, leave! Do you use the JASS, change! --------
      • Trigger - Run ANCS NPC Initialization GUI <gen> (ignoring conditions)




  • ANCS NPC Initialization GUI
    • Events
    • Conditions
    • Actions
      • -------- Local Variable Initialization - DO NOT CHANGE THOSE --------
      • Custom script: local string array ta
      • Custom script: local string array to
      • Custom script: local trigger array trg
      • Custom script: local integer mo
      • -------- ---------------------------------------------- --------
      • -------- ---------------------------------------------- --------
      • -------- Here is the setup for the Footman unit on the map. --------
      • Set u = Footman 0000 <gen>
      • Custom script: set to[1] = "Hello, who are you?"
      • Custom script: set ta[1] = "Hello, I am a Footman."
      • Custom script: set trg[1] = null
      • Custom script: set to[2] = "Hello, why are you here?"
      • Custom script: set ta[2] = "Hello, I am here so you may test this system."
      • Custom script: set trg[2] = null
      • Custom script: set to[3] = "Goodbye Footman."
      • Custom script: set ta[3] = "Goodbye."
      • Custom script: set trg[3] = null
      • Custom script: set mo = 3
      • Custom script: call ANCS_SaveData (udg_u, ta[1], ta[2], ta[3], ta[4], ta[5], to[1], to[2], to[3], to[4], to[5], mo, trg[1], trg[2], trg[3], trg[4], trg[5])
      • -------- ---------------------------------------------- --------
      • -------- Here is the setup for the Knight unit on the map. --------
      • Set u = Knight 0003 <gen>
      • Custom script: set to[1] = "OPTION 1"
      • Custom script: set ta[1] = "ANSWER 1"
      • Custom script: set trg[1] = null
      • Custom script: set to[2] = "OPTION 2"
      • Custom script: set ta[2] = "ANSWER 2"
      • Custom script: set trg[2] = null
      • Custom script: set to[3] = "Select this option to kill the Knight with the External Trigger!"
      • Custom script: set ta[3] = "Ouch, it did work!"
      • Custom script: set trg[3] = gg_trg_ANCS_External_Test_Trigger_KNIGHT_Option_3
      • Custom script: set to[4] = "OPTION 4"
      • Custom script: set ta[4] = "ANSWER 4"
      • Custom script: set trg[4] = null
      • Custom script: set to[5] = "OPTION 5"
      • Custom script: set ta[5] = "ANSWER 5"
      • Custom script: set trg[5] = null
      • Custom script: set mo = 5
      • Custom script: call ANCS_SaveData (udg_u, ta[1], ta[2], ta[3], ta[4], ta[5], to[1], to[2], to[3], to[4], to[5], mo, trg[1], trg[2], trg[3], trg[4], trg[5])



JASS:
function Trig_ANCS_NPC_Initialization_JASS_Actions takes nothing returns nothing
    // Local Variable Initialization - DO NOT CHANGE THOSE
    local string array ta
    local string array to
    local trigger array trg
    local integer mo
    // ----------------------------------------------
    // ----------------------------------------------
    // Here is the setup for the Footman unit on the map.
    set udg_u = gg_unit_hfoo_0000
    set to[1] = "Hello, who are you?"
    set ta[1] = "Hello, I am a Footman."
    set trg[1] = null
    set to[2] = "Hello, why are you here?"
    set ta[2] = "Hello, I am here so you may test this system."
    set trg[2] = null
    set to[3] = "Goodbye Footman."
    set ta[3] = "Goodbye."
    set trg[3] = null
    set mo = 3
    call ANCS_SaveData (udg_u, ta[1], ta[2], ta[3], ta[4], ta[5], to[1], to[2], to[3], to[4], to[5], mo, trg[1], trg[2], trg[3], trg[4], trg[5])
    // ----------------------------------------------
    // Here is the setup for the Knight unit on the map.
    set udg_u = gg_unit_hkni_0003
    set to[1] = "OPTION 1"
    set ta[1] = "ANSWER 1"
    set trg[1] = null
    set to[2] = "OPTION 2"
    set ta[2] = "ANSWER 2"
    set trg[2] = null
    set to[3] = "Select this option to kill the Knight with the External Trigger!"
    set ta[3] = "Ouch, it did work!"
    set trg[3] = gg_trg_ANCS_External_Test_Trigger_KNIGHT_Option_3
    set to[4] = "OPTION 4"
    set ta[4] = "ANSWER 4"
    set trg[4] = null
    set to[5] = "OPTION 5"
    set ta[5] = "ANSWER 5"
    set trg[5] = null
    set mo = 5
    call ANCS_SaveData (udg_u, ta[1], ta[2], ta[3], ta[4], ta[5], to[1], to[2], to[3], to[4], to[5], mo, trg[1], trg[2], trg[3], trg[4], trg[5])
endfunction

//===========================================================================
function InitTrig_ANCS_NPC_Initialization_JASS takes nothing returns nothing
    set gg_trg_ANCS_NPC_Initialization_JASS = CreateTrigger(  )
    call TriggerAddAction( gg_trg_ANCS_NPC_Initialization_JASS, function Trig_ANCS_NPC_Initialization_JASS_Actions )
endfunction




  • ANCS TalkToNPC
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to ANCS_TalkAbility
    • Actions
      • Set ANCS_PlayerGroup = (Player group((Owner of (Triggering unit))))
      • -------- ---------- --------
      • For each (Integer ANCS_Integer) from 1 to ANCS_NPC_ID, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target unit of ability being cast) Equal to ANCS_NPC_Unit[ANCS_Integer]
            • Then - Actions
              • Set ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))] = ANCS_Integer
            • Else - Actions
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))] Greater than 0
        • Then - Actions
          • Cinematic - Turn cinematic mode On for ANCS_PlayerGroup
          • Cinematic - Enable user control for ANCS_PlayerGroup
          • Camera - Lock camera target for (Owner of (Triggering unit)) to ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]], offset by (0.00, 0.00) using Default rotation
          • -------- ---------- --------
          • Set ANCS_Player_Talking[(Player number of (Owner of (Triggering unit)))] = True
          • Set ANCS_Player_CurrentOption[(Player number of (Owner of (Triggering unit)))] = 1
          • -------- ---------- --------
          • Custom script: set udg_ANCS_String = ANCS_GetOptionString(udg_ANCS_Player_NPCID[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))], udg_ANCS_Player_CurrentOption[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
          • -------- ---------- --------
          • Cinematic - Send transmission to ANCS_PlayerGroup from ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]] named (Name of ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]]): Play No sound and display ANCS_String. Modify duration: Add 1000.00 seconds and Don't wait
        • Else - Actions
          • Game - Display to (All players) for 5.00 seconds the text: ANCS_System_CantTalkMsg
      • -------- ---------- --------
      • Custom script: set udg_ANCS_String = ""
      • Custom script: call DestroyForce(udg_ANCS_PlayerGroup)



  • ANCS ToggleUp
    • Events
    • Conditions
      • ANCS_Player_Talking[(Player number of (Triggering player))] Equal to True
    • Actions
      • Set ANCS_PlayerGroup = (Player group((Triggering player)))
      • -------- ---------- --------
      • Set ANCS_Player_CurrentOption[(Player number of (Triggering player))] = (ANCS_Player_CurrentOption[(Player number of (Triggering player))] - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_CurrentOption[(Player number of (Triggering player))] Less than or equal to 0
        • Then - Actions
          • Set ANCS_Player_CurrentOption[(Player number of (Triggering player))] = ANCS_NPC_MaxOptions[ANCS_Player_NPCID[(Player number of (Triggering player))]]
        • Else - Actions
      • -------- ---------- --------
      • Custom script: set udg_ANCS_String = ANCS_GetOptionString(udg_ANCS_Player_NPCID[GetConvertedPlayerId(GetTriggerPlayer())], udg_ANCS_Player_CurrentOption[GetConvertedPlayerId(GetTriggerPlayer())])
      • Cinematic - Send transmission to ANCS_PlayerGroup from ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]] named (Name of ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]]): Play No sound and display ANCS_String. Modify duration: Add 1000.00 seconds and Don't wait
      • -------- ---------- --------
      • Custom script: set udg_ANCS_String = ""
      • Custom script: call DestroyForce(udg_ANCS_PlayerGroup)



  • ANCS ToggleDown
    • Events
    • Conditions
      • ANCS_Player_Talking[(Player number of (Triggering player))] Equal to True
    • Actions
      • Set ANCS_PlayerGroup = (Player group((Triggering player)))
      • -------- ---------- --------
      • Set ANCS_Player_CurrentOption[(Player number of (Triggering player))] = (ANCS_Player_CurrentOption[(Player number of (Triggering player))] + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_CurrentOption[(Player number of (Triggering player))] Greater than ANCS_NPC_MaxOptions[ANCS_Player_NPCID[(Player number of (Triggering player))]]
        • Then - Actions
          • Set ANCS_Player_CurrentOption[(Player number of (Triggering player))] = 1
        • Else - Actions
      • -------- ---------- --------
      • Custom script: set udg_ANCS_String = ANCS_GetOptionString(udg_ANCS_Player_NPCID[GetConvertedPlayerId(GetTriggerPlayer())], udg_ANCS_Player_CurrentOption[GetConvertedPlayerId(GetTriggerPlayer())])
      • Cinematic - Send transmission to ANCS_PlayerGroup from ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]] named (Name of ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]]): Play No sound and display ANCS_String. Modify duration: Add 1000.00 seconds and Don't wait
      • -------- ---------- --------
      • Custom script: set udg_ANCS_String = ""
      • Custom script: call DestroyForce(udg_ANCS_PlayerGroup)



  • ANCS ToggleRight Select
    • Events
    • Conditions
      • ANCS_Player_Talking[(Player number of (Triggering player))] Equal to True
    • Actions
      • Custom script: local string str = ANCS_GetAnswerString(udg_ANCS_Player_NPCID[GetConvertedPlayerId(GetTriggerPlayer())], udg_ANCS_Player_CurrentOption[GetConvertedPlayerId(GetTriggerPlayer())])
      • Custom script: local trigger trg = ANCS_GetAnswerTrigger(udg_ANCS_Player_NPCID[GetConvertedPlayerId(GetTriggerPlayer())], udg_ANCS_Player_CurrentOption[GetConvertedPlayerId(GetTriggerPlayer())])
      • Set ANCS_PlayerGroup = (Player group((Triggering player)))
      • -------- ---------- --------
      • Set ANCS_System_RecentPlayerID = (Player number of (Triggering player))
      • -------- ---------- --------
      • Cinematic - Turn cinematic mode Off for ANCS_PlayerGroup
      • Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
      • -------- ---------- --------
      • Custom script: call DisplayTimedTextToForce( udg_ANCS_PlayerGroup, udg_ANCS_System_MsgTime, ( "|cffffcc00" + ( GetUnitName(udg_ANCS_NPC_Unit[udg_ANCS_Player_NPCID[GetConvertedPlayerId(GetTriggerPlayer())]]) + ( ":|r " + str ) ) ) )
      • Custom script: call ConditionalTriggerExecute(trg)
      • -------- ---------- --------
      • Set ANCS_Player_CurrentOption[(Player number of (Triggering player))] = 0
      • Set ANCS_Player_NPCID[(Player number of (Triggering player))] = 0
      • Set ANCS_Player_Talking[(Player number of (Triggering player))] = False
      • -------- ---------- --------
      • Custom script: call DestroyForce(udg_ANCS_PlayerGroup)



  • ANCS ToggleCancel
    • Events
    • Conditions
      • ANCS_Player_Talking[(Player number of (Triggering player))] Equal to True
    • Actions
      • Set ANCS_PlayerGroup = (Player group((Triggering player)))
      • Cinematic - Turn cinematic mode Off for ANCS_PlayerGroup
      • Camera - Reset camera for (Triggering player) to standard game-view over 0.00 seconds
      • -------- ---------- --------
      • Set ANCS_Player_CurrentOption[(Player number of (Triggering player))] = 0
      • Set ANCS_Player_NPCID[(Player number of (Triggering player))] = 0
      • Set ANCS_Player_Talking[(Player number of (Triggering player))] = False
      • -------- ---------- --------
      • Custom script: call DestroyForce(udg_ANCS_PlayerGroup)



  • ANCS External Test Trigger KNIGHT Option 3
    • Events
    • Conditions
    • Actions
      • Unit - Kill ANCS_NPC_Unit[ANCS_Player_NPCID[ANCS_System_RecentPlayerID]]




x_mime_changelog.png
Changelog
VERSION 1.2a
- Optimized the code even more:
> Map Header-script optimized.
> Renamed the variable 'tmp' to 's' in function ANCS_GetOptionString; saves some space.
> Renamed the variable 'cOption' to 'cO' in all functions; saves some space.
> Added a new function; ANCS_ResetPlayer(integer, force). This reduced the GUI code in two triggers: ANCS_ToggleRight_Select
and ANCS_ToggleCancel

- Fixed an issue with 'ANCS_System_CantTalkMsg'; it was displayed to all players.
- Map size reduced by 0.2kB (better than nothing, right?)

VERSION 1.1a
- Added a variable that allow an user to set a time for how long an answer shall be displayed.
- Replaced "Cinematic - Send transmission" with "Game - Display to (All players)"; because transmission changed the player unit portrait and hide HP/MP bars.
- Optimized the system code A LOT (more than 2kB!)
- Fixed an issue with the system; was able to talk to non-talk unit(s).

VERSION 1.0a
- Release.



------------------------------------

Thank you for testing. Any feedback is welcome!


Keywords:
conversation, chat, advanced, system, NPC, npc, flood, the_flood, nusica, talk, arrowkey, select, option, trigger, event, condition, fun, simple, gui,
Contents

ANCS - Version 1.2a (Map)

Reviews
12th Dec 2015 IcemanBo: Too long as NeedsFix. Rejected. 07:04, 17th Aug 2012 Magtheridon96: Well, this is a lot better than the previous version. If this were completely JASS, it would've been nicer to have a Conversation struct that...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long as NeedsFix. Rejected.

07:04, 17th Aug 2012
Magtheridon96:

Well, this is a lot better than the previous version.

  • If this were completely JASS, it would've been nicer to have a Conversation struct that has a list of Answer/Option groups, and you could register answer/option pairs to those groups, but this is a GUI system, and thus needs to be easy for beginners to use, and yours is, so my current rant is pointless :p
  • You should store things like (Triggering unit), (Owner of (Triggering unit)) or whatever into variables instead of repeating them over and over again. (JASS is a slow interpreted language)

Otherwise, good job.
If you don't want to use hashtables, it's not a major problem, but it would increase performance, and shorten your code just a bit.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Also, it's a 100% MUI!
How can it be MUI when a Player can only interact with it one at a time ?
This system is MPI.
It cannot be MUI because that's the system's purpose lol.
So you might change that description a bit.

On the system, after you have chosen which option you want, the potrait stay stuck at "chat animation", meaning that you can't see HP/MP values at the potrait of each unit.
You may wanna fix that.
 
Level 5
Joined
Aug 16, 2010
Messages
97
How can it be MUI when a Player can only interact with it one at a time ?
This system is MPI.
It cannot be MUI because that's the system's purpose lol.
So you might change that description a bit.

On the system, after you have chosen which option you want, the potrait stay stuck at "chat animation", meaning that you can't see HP/MP values at the potrait of each unit.
You may wanna fix that.

Maybe 3 heroes of 3 different players can talk simultaneously and that's both MUI and MPI?
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Maybe 3 heroes of 3 different players can talk simultaneously and that's both MUI and MPI?
I'm lazy to explain what is MUI and what is MPI, but this system is MPI, because only 1 unit per player is allowed to initiate this system at a time, you understand ?

MUI
Many units at once (regardless of Player)

MPI
1 unit per player

And the fact this system is MPI, does not make it bad, because that's what this system purpose, to handle 1 unit per player (1 conversation per Player).

Imagine, you can't have 3 Footmans talking to 3 different units and have 3 chat windows at a time for a single Player, do you ?

You can only have a max of 1 chat windows per player at a time, that's why it is MPI, not MUI.

Also;
and that's both MUI and MPI?
A trigger cannot be both MUI and MPI, they must be either one.
 
Level 19
Joined
Aug 16, 2007
Messages
881
@FRENGERS,
Haha, thank you.

@defskull & @Dr.Killer
The system is MPI I was tired at the moment I wrote it and didn't notice I wrote MUI instead of MPI. Thank you for notice that.

defskull said:
On the system, after you have chosen which option you want, the potrait stay stuck at "chat animation", meaning that you can't see HP/MP values at the potrait of each unit.
You may wanna fix that.
Fixed in the next version, thanks.


Edit: I've updated this system to version 1.1a. You are able to read the changelog in the main post.

Magtheridon96; I won't use hashtables; however, I've optimised the code a lot(!) in this version, below is an example:


  • ANCS TalkToNPC
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to ANCS_TalkAbility
    • Actions
      • Set ANCS_PlayerGroup = (Player group((Owner of (Triggering unit))))
      • -------- ---------- --------
      • For each (Integer ANCS_Integer) from 1 to ANCS_NPC_ID, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target unit of ability being cast) Equal to ANCS_NPC_Unit[ANCS_Integer]
            • Then - Actions
              • Set ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))] = ANCS_Integer
            • Else - Actions
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))] Greater than 0
        • Then - Actions
          • Cinematic - Turn cinematic mode On for ANCS_PlayerGroup
          • Cinematic - Enable user control for ANCS_PlayerGroup
          • Camera - Lock camera target for (Owner of (Triggering unit)) to ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]], offset by (0.00, 0.00) using Default rotation
          • -------- ---------- --------
          • Set ANCS_Player_Talking[(Player number of (Owner of (Triggering unit)))] = True
          • Set ANCS_Player_CurrentOption[(Player number of (Owner of (Triggering unit)))] = 1
          • -------- ---------- --------
          • Custom script: set udg_ANCS_String = udg_ANCS_String + (udg_ANCS_System_SelectColor + udg_ANCS_System_SelectIndicator)
          • Set ANCS_String = (ANCS_String + ANCS_NPC_TalkOption1[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]])
          • Custom script: set udg_ANCS_String = udg_ANCS_String + "|r|n"
          • Set ANCS_String = (ANCS_String + ANCS_NPC_TalkOption2[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]])
          • Custom script: set udg_ANCS_String = udg_ANCS_String + "|r|n"
          • Set ANCS_String = (ANCS_String + ANCS_NPC_TalkOption3[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]])
          • Custom script: set udg_ANCS_String = udg_ANCS_String + "|r|n"
          • Set ANCS_String = (ANCS_String + ANCS_NPC_TalkOption4[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]])
          • Custom script: set udg_ANCS_String = udg_ANCS_String + "|r|n"
          • Set ANCS_String = (ANCS_String + ANCS_NPC_TalkOption5[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]])
          • Custom script: set udg_ANCS_String = udg_ANCS_String + "|r"
          • -------- ---------- --------
          • Cinematic - Send transmission to ANCS_PlayerGroup from ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]] named (Name of ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]]): Play No sound and display ANCS_String. Modify duration: Add 1000.00 seconds and Don't wait
        • Else - Actions
          • Game - Display to (All players) for 5.00 seconds the text: ANCS_System_CantTalkMsg
      • -------- ---------- --------
      • Custom script: set udg_ANCS_String = ""
      • Custom script: call DestroyForce(udg_ANCS_PlayerGroup)
  • ANCS TalkToNPC
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to ANCS_TalkAbility
    • Actions
      • Set ANCS_PlayerGroup = (Player group((Owner of (Triggering unit))))
      • -------- ---------- --------
      • For each (Integer ANCS_Integer) from 1 to ANCS_NPC_ID, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target unit of ability being cast) Equal to ANCS_NPC_Unit[ANCS_Integer]
            • Then - Actions
              • Set ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))] = ANCS_Integer
            • Else - Actions
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))] Greater than 0
        • Then - Actions
          • Cinematic - Turn cinematic mode On for ANCS_PlayerGroup
          • Cinematic - Enable user control for ANCS_PlayerGroup
          • Camera - Lock camera target for (Owner of (Triggering unit)) to ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]], offset by (0.00, 0.00) using Default rotation
          • -------- ---------- --------
          • Set ANCS_Player_Talking[(Player number of (Owner of (Triggering unit)))] = True
          • Set ANCS_Player_CurrentOption[(Player number of (Owner of (Triggering unit)))] = 1
          • -------- ---------- --------
          • Custom script: set udg_ANCS_String = ANCS_GetOptionString(udg_ANCS_Player_NPCID[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))], udg_ANCS_Player_CurrentOption[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
          • -------- ---------- --------
          • Cinematic - Send transmission to ANCS_PlayerGroup from ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]] named (Name of ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]]): Play No sound and display ANCS_String. Modify duration: Add 1000.00 seconds and Don't wait
        • Else - Actions
          • Game - Display to (All players) for 5.00 seconds the text: ANCS_System_CantTalkMsg
      • -------- ---------- --------
      • Custom script: set udg_ANCS_String = ""
      • Custom script: call DestroyForce(udg_ANCS_PlayerGroup)


Super proof:
  • ANCS ToggleUp
    • Events
    • Conditions
      • ANCS_Player_Talking[(Player number of (Triggering player))] Equal to True
    • Actions
      • Set ANCS_PlayerGroup = (Player group((Triggering player)))
      • -------- ---------- --------
      • Set ANCS_Player_CurrentOption[(Player number of (Triggering player))] = (ANCS_Player_CurrentOption[(Player number of (Triggering player))] - 1)
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_CurrentOption[(Player number of (Triggering player))] Less than or equal to 0
        • Then - Actions
          • Set ANCS_Player_CurrentOption[(Player number of (Triggering player))] = ANCS_NPC_MaxOptions[ANCS_Player_NPCID[(Player number of (Triggering player))]]
        • Else - Actions
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_CurrentOption[(Player number of (Triggering player))] Equal to 1
        • Then - Actions
          • Custom script: set udg_ANCS_String = udg_ANCS_String + (udg_ANCS_System_SelectColor + udg_ANCS_System_SelectIndicator)
        • Else - Actions
      • Set ANCS_String = (ANCS_String + ANCS_NPC_TalkOption1[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]])
      • Custom script: set udg_ANCS_String = udg_ANCS_String + "|r|n"
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_CurrentOption[(Player number of (Triggering player))] Equal to 2
        • Then - Actions
          • Custom script: set udg_ANCS_String = udg_ANCS_String + (udg_ANCS_System_SelectColor + udg_ANCS_System_SelectIndicator)
        • Else - Actions
      • Set ANCS_String = (ANCS_String + ANCS_NPC_TalkOption2[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]])
      • Custom script: set udg_ANCS_String = udg_ANCS_String + "|r|n"
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_CurrentOption[(Player number of (Triggering player))] Equal to 3
        • Then - Actions
          • Custom script: set udg_ANCS_String = udg_ANCS_String + (udg_ANCS_System_SelectColor + udg_ANCS_System_SelectIndicator)
        • Else - Actions
      • Set ANCS_String = (ANCS_String + ANCS_NPC_TalkOption3[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]])
      • Custom script: set udg_ANCS_String = udg_ANCS_String + "|r|n"
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_CurrentOption[(Player number of (Triggering player))] Equal to 4
        • Then - Actions
          • Custom script: set udg_ANCS_String = udg_ANCS_String + (udg_ANCS_System_SelectColor + udg_ANCS_System_SelectIndicator)
        • Else - Actions
      • Set ANCS_String = (ANCS_String + ANCS_NPC_TalkOption4[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]])
      • Custom script: set udg_ANCS_String = udg_ANCS_String + "|r|n"
      • -------- ---------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_CurrentOption[(Player number of (Triggering player))] Equal to 5
        • Then - Actions
          • Custom script: set udg_ANCS_String = udg_ANCS_String + (udg_ANCS_System_SelectColor + udg_ANCS_System_SelectIndicator)
        • Else - Actions
      • Set ANCS_String = (ANCS_String + ANCS_NPC_TalkOption5[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]])
      • Custom script: set udg_ANCS_String = udg_ANCS_String + "|r"
      • -------- ---------- --------
      • Cinematic - Send transmission to ANCS_PlayerGroup from ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]] named (Name of ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]]): Play No sound and display ANCS_String. Modify duration: Add 1000.00 seconds and Don't wait
      • -------- ---------- --------
      • Custom script: set udg_ANCS_String = ""
      • Custom script: call DestroyForce(udg_ANCS_PlayerGroup)
  • ANCS ToggleUp
    • Events
    • Conditions
      • ANCS_Player_Talking[(Player number of (Triggering player))] Equal to True
    • Actions
      • Set ANCS_PlayerGroup = (Player group((Triggering player)))
      • -------- ---------- --------
      • Set ANCS_Player_CurrentOption[(Player number of (Triggering player))] = (ANCS_Player_CurrentOption[(Player number of (Triggering player))] - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ANCS_Player_CurrentOption[(Player number of (Triggering player))] Less than or equal to 0
        • Then - Actions
          • Set ANCS_Player_CurrentOption[(Player number of (Triggering player))] = ANCS_NPC_MaxOptions[ANCS_Player_NPCID[(Player number of (Triggering player))]]
        • Else - Actions
      • -------- ---------- --------
      • Custom script: set udg_ANCS_String = ANCS_GetOptionString(udg_ANCS_Player_NPCID[GetConvertedPlayerId(GetTriggerPlayer())], udg_ANCS_Player_CurrentOption[GetConvertedPlayerId(GetTriggerPlayer())])
      • Cinematic - Send transmission to ANCS_PlayerGroup from ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]] named (Name of ANCS_NPC_Unit[ANCS_Player_NPCID[(Player number of (Owner of (Triggering unit)))]]): Play No sound and display ANCS_String. Modify duration: Add 1000.00 seconds and Don't wait
      • -------- ---------- --------
      • Custom script: set udg_ANCS_String = ""
      • Custom script: call DestroyForce(udg_ANCS_PlayerGroup)
 
Last edited:
Level 19
Joined
Aug 16, 2007
Messages
881
Version 1.2a

Sorry for the delay; but I've now updated this system to version 1.2a.

I would like to post the differences here; but the 'JASS'-tags doesn't work it seems; they put all code in one line. So you have to trust me it's optimized! :)


x_mime_changelog.png
Changelog

VERSION 1.2a
- Optimized the code even more:
> Map Header-script optimized.
> Renamed the variable 'tmp' to 's' in function ANCS_GetOptionString; saves some space.
> Renamed the variable 'cOption' to 'cO' in all functions; saves some space.
> Added a new function; ANCS_ResetPlayer(integer, force). This reduced the GUI code in two triggers: ANCS_ToggleRight_Select
and ANCS_ToggleCancel

- Fixed an issue with 'ANCS_System_CantTalkMsg'; it was displayed to all players.
- Map size reduced by 0.2kB (better than nothing, right?)

 
Top