function ANCS_SaveData takes unit u, string a1, string a2, string a3, string a4, string a5, string o1, string o2, string o3, string o4, string o5, integer mo, trigger tr1, trigger tr2, trigger tr3, trigger tr4, trigger tr5 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] = a1
set udg_ANCS_NPC_TalkAnswer2[udg_ANCS_NPC_ID] = a2
set udg_ANCS_NPC_TalkAnswer3[udg_ANCS_NPC_ID] = a3
set udg_ANCS_NPC_TalkAnswer4[udg_ANCS_NPC_ID] = a4
set udg_ANCS_NPC_TalkAnswer5[udg_ANCS_NPC_ID] = a5
set udg_ANCS_NPC_TalkOption1[udg_ANCS_NPC_ID] = o1
set udg_ANCS_NPC_TalkOption2[udg_ANCS_NPC_ID] = o2
set udg_ANCS_NPC_TalkOption3[udg_ANCS_NPC_ID] = o3
set udg_ANCS_NPC_TalkOption4[udg_ANCS_NPC_ID] = o4
set udg_ANCS_NPC_TalkOption5[udg_ANCS_NPC_ID] = o5
set udg_ANCS_NPC_ExternalTrigger1[udg_ANCS_NPC_ID] = tr1
set udg_ANCS_NPC_ExternalTrigger2[udg_ANCS_NPC_ID] = tr2
set udg_ANCS_NPC_ExternalTrigger3[udg_ANCS_NPC_ID] = tr3
set udg_ANCS_NPC_ExternalTrigger4[udg_ANCS_NPC_ID] = tr4
set udg_ANCS_NPC_ExternalTrigger5[udg_ANCS_NPC_ID] = tr5
set udg_ANCS_NPC_MaxOptions[udg_ANCS_NPC_ID] = mo
endfunction
function ANCS_GetCurrentOption takes integer c, integer cO returns string
if (c == cO) then
return udg_ANCS_System_SelectColor + udg_ANCS_System_SelectIndicator
endif
return udg_ANCS_System_NormalColor
endfunction
function ANCS_GetOptionString takes integer uID, integer cO returns string
local string s = ""
set s = s + ANCS_GetCurrentOption(1, cO) + udg_ANCS_NPC_TalkOption1[uID] + "|r|n"
set s = s + ANCS_GetCurrentOption(2, cO) + udg_ANCS_NPC_TalkOption2[uID] + "|r|n"
set s = s + ANCS_GetCurrentOption(3, cO) + udg_ANCS_NPC_TalkOption3[uID] + "|r|n"
set s = s + ANCS_GetCurrentOption(4, cO) + udg_ANCS_NPC_TalkOption4[uID] + "|r|n"
set s = s + ANCS_GetCurrentOption(5, cO) + udg_ANCS_NPC_TalkOption5[uID] + "|r"
return s
endfunction
function ANCS_GetAnswerString takes integer uID, integer cO returns string
if (cO == 1) then
return udg_ANCS_NPC_TalkAnswer1[uID]
elseif (cO == 2) then
return udg_ANCS_NPC_TalkAnswer2[uID]
elseif (cO == 3) then
return udg_ANCS_NPC_TalkAnswer3[uID]
elseif (cO == 4) then
return udg_ANCS_NPC_TalkAnswer4[uID]
endif
return udg_ANCS_NPC_TalkAnswer5[uID]
endfunction
function ANCS_GetAnswerTrigger takes integer uID, integer cO returns trigger
if (cO == 1) then
return udg_ANCS_NPC_ExternalTrigger1[uID]
elseif (cO == 2) then
return udg_ANCS_NPC_ExternalTrigger2[uID]
elseif (cO == 3) then
return udg_ANCS_NPC_ExternalTrigger3[uID]
elseif (cO == 4) then
return udg_ANCS_NPC_ExternalTrigger4[uID]
endif
return udg_ANCS_NPC_ExternalTrigger5[uID]
endfunction
function ANCS_ResetPlayer takes integer i, force f returns nothing
call CinematicModeBJ( false, f )
call ResetToGameCameraForPlayer( ConvertedPlayer(i), 0 )
set udg_ANCS_Player_CurrentOption[i] = 0
set udg_ANCS_Player_NPCID[i] = 0
set udg_ANCS_Player_Talking[i] = false
call DestroyForce(f)
endfunction
Name | Type | is_array | initial_value |
ANCS_Integer | integer | No | |
ANCS_NPC_ExternalTrigger1 | trigger | Yes | |
ANCS_NPC_ExternalTrigger2 | trigger | Yes | |
ANCS_NPC_ExternalTrigger3 | trigger | Yes | |
ANCS_NPC_ExternalTrigger4 | trigger | Yes | |
ANCS_NPC_ExternalTrigger5 | trigger | Yes | |
ANCS_NPC_ID | integer | No | |
ANCS_NPC_MaxOptions | integer | Yes | |
ANCS_NPC_TalkAnswer1 | string | Yes | |
ANCS_NPC_TalkAnswer2 | string | Yes | |
ANCS_NPC_TalkAnswer3 | string | Yes | |
ANCS_NPC_TalkAnswer4 | string | Yes | |
ANCS_NPC_TalkAnswer5 | string | Yes | |
ANCS_NPC_TalkOption1 | string | Yes | |
ANCS_NPC_TalkOption2 | string | Yes | |
ANCS_NPC_TalkOption3 | string | Yes | |
ANCS_NPC_TalkOption4 | string | Yes | |
ANCS_NPC_TalkOption5 | string | Yes | |
ANCS_NPC_Unit | unit | Yes | |
ANCS_Player_CurrentOption | integer | Yes | |
ANCS_Player_NPCID | integer | Yes | |
ANCS_Player_Talking | boolean | Yes | |
ANCS_PlayerGroup | force | No | |
ANCS_String | string | No | |
ANCS_System_CantTalkMsg | string | No | |
ANCS_System_MsgTime | real | No | |
ANCS_System_NormalColor | string | No | |
ANCS_System_RecentPlayerID | integer | No | |
ANCS_System_SelectColor | string | No | |
ANCS_System_SelectIndicator | string | No | |
ANCS_TalkAbility | abilcode | No | |
u | unit | No |
ADVANCED NPC CHAT SYSTEM - [ANCS] - Version 1.2a
Created by Flood @http://hiveworkshop.com
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.
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.
System Information
------------------
First of all, it is MPI; every player(s) in the map can use it at the same time without any errors/issues.
This system allow you to setup an advanced chat with "NPC" units in your map.
You are able to give a NPC up to five (5) different questions/sentences ("said" by you) and up to five (5) different answers/sentences for those questions/sentences,
told by the NPC.
In example:
1. How are you? < Asked by you.
NPC will then answer: I am fine.
2. Who are you? < Asked by you.
NPC will then answer: I am xxxx.
You are also able to add external triggers to each sentence, that will run whenever they are selected by the player for that specific NPC. In example you may want the NPC
to give your hero an item whenever you choose a specific option, it's easily done!
How do I setup this System?
---------------------------
You don't have to change anything in those triggers:
ANCS TalkToNPC
ANCS ToggleUp
ANCS ToggleDown
ANCS ToggleRight Select
ANCS ToggleCancel
ANCS External Test Trigger KNIGHT Option 3 (Test Trigger; not required).
You are able to change something in those triggers:
You are able to setup the core of the system in the [ ANCS System Initialization ] trigger (change colors and more).
You are able to setup the NPC's of the system in the [ ANCS NPC Initialization GUI/JASS] trigger; how you do this, continue read below
(I recommend use the JASS-one (less lagg) and I recommend you to delete the trigger you do not use to save space).
In order to setup a NPC go to the [ ANCS NPC Initialization ] trigger, in this trigger you will see many LOCAL variables, don't touch those. In order to save map-space
I've shortened the names of those variables into silly "shortcuts". I'll explain them:
[X=Number]
* u = NPCUnit - Set this to the NPC that shall have the options, answers & triggers below.
* toX = TalkOptionX - This is the option (question/sentence) you want the NPC to have.
* taX = TalkAnswerX - This is the X answer for the option X.
* mo = MaxOptions - This is the maximum options your NPC will have. Leave un-used options blank/empty.
* trgX - (External)TriggerX - This is the external trigger that will run when you select option X, leave as "null" if no trigger shall execute.
When you have setup all those variables above you simply put
call ANCS_SaveData (udg_u, ta1, ta2, ta3, ta4, ta5, to1, to2, to3, to4, to5, mo, trg1, trg2, trg3, trg4, trg5)
below in order to save the Data.
WARNING: If you use external triggers make sure you use the variable: udg_ANCS_System_RecentPlayerID (Integer). This variable will store the most recent player who have
used an option with the chat-system. So you are NOT able to use any WAIT-actions if you use this system as a MPI. Single Player is fine!
- Check the ANCS External Test Trigger KNIGHT Option 3 trigger.
How do I import this System?
---------------------------
STEP 1:
First of all, the most important. Look at your top-left on the screen (map header). There you will see a map-icon with the text "ANCS.w3x", click there and some code will appear for you.
Copy and paste this code to the same place, but in YOUR map.
STEP 2:
Open the main window (the window with the terrain) and go to [ File ] (top-left) in the menu. Select [ Preferences ] and make sure you check the:
"Automatically create unknown variables while pasting trigger data"! If it's already checked, leave it checked.
STEP 3:
When you have done this you simply copy and paste this system folder: [ Advanced NPC Chat System [ANCS] Copy this folder when import ] and paste it in your map!
STEP 4 (optional):
Do also copy the "Talk"-ability in the Object Editor; else you're done.
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