- Joined
- Jul 14, 2011
- Messages
- 3,213
Hi! The_Witcher made this code for me, since i know nothing about JASS.
In my map, NPC sells "Talk", when "Talk" is sold, the dialog starts. The thing is that after the coversation ends, the Player can't "Talk" again to the same NPC.
Somewhere in this vJASS code there's a function to disable the "Talk" selling or something like that, I need someone to check it and tell me how to disable the "Disabling" of "Talk" after having "Talked" xD
One of the triggers that use it
In my map, NPC sells "Talk", when "Talk" is sold, the dialog starts. The thing is that after the coversation ends, the Player can't "Talk" again to the same NPC.
Somewhere in this vJASS code there's a function to disable the "Talk" selling or something like that, I need someone to check it and tell me how to disable the "Disabling" of "Talk" after having "Talked" xD
JASS:
library DialogSystem initializer onInit
//function AddLineToDialog takes string text, unit fromUnit, player toPlayer returns nothing
//function StartPlayerDialog takes player toPlayer returns nothing
globals
private string array texts[12][50]
private unit array partner[12][50]
private integer array count
private integer array pointer
private boolean array talking
private multiboard array DialogBoard
endglobals
function AddLineToDialog takes string text, unit fromUnit, player toPlayer returns nothing
local integer id = GetPlayerId(toPlayer)
set texts[id][count[id]] = text
set partner[id][count[id]] = fromUnit
set count[id] = count[id] + 1
endfunction
function StartPlayerDialog takes player toPlayer returns nothing
local multiboarditem mbitem
local integer id = GetPlayerId(toPlayer)
local integer i = 0
set pointer[id] = 0
set talking[id] = true
loop
exitwhen i >= count[id]
call PauseUnit(partner[id][i], true)
set i = i + 1
endloop
set mbitem = MultiboardGetItem(DialogBoard[id], 0, 0)
call MultiboardSetItemValue(mbitem, "|cffffd700" + GetUnitName(partner[id][0]) + "|r:")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[id], 1, 0)
call MultiboardSetItemValue(mbitem, "|cffffd700" + GetUnitName(partner[id][1]) + "|r:")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[id], 1, 1)
call MultiboardSetItemValue(mbitem, "")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[id], 0, 1)
call MultiboardSetItemValue(mbitem, texts[id][0])
call MultiboardReleaseItem(mbitem)
call AddIndicator(partner[id][0], 255, 255, 255, 255)
if GetLocalPlayer() == toPlayer then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 1500, 1.0)
call MultiboardMinimize( DialogBoard[id], false)
call ClearSelection()
endif
endfunction
private function EscPress takes nothing returns boolean
local integer id = GetPlayerId(GetTriggerPlayer())
local multiboarditem mbitem
local integer i = 0
if talking[id] then
set pointer[id] = pointer[id] + 1
if pointer[id] < count[id] then
set mbitem = MultiboardGetItem(DialogBoard[id], 0, 0)
call MultiboardSetItemValue(mbitem, "|cffffd700" + GetUnitName(partner[id][pointer[id] - 1]) + "|r:")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[id], 1, 0)
call MultiboardSetItemValue(mbitem, "|cffffd700" + GetUnitName(partner[id][pointer[id]]) + "|r:")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[id], 0, 1)
call MultiboardSetItemValue(mbitem, texts[id][pointer[id] - 1])
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[id], 1, 1)
call MultiboardSetItemValue(mbitem, texts[id][pointer[id]])
call MultiboardReleaseItem(mbitem)
call AddIndicator(partner[id][pointer[id]], 255, 255, 255, 255)
else
loop
exitwhen i >= count[id]
call PauseUnit(partner[id][i], false)
set i = i + 1
endloop
set talking[id] = false
set count[id] = 0
if GetLocalPlayer() == GetTriggerPlayer() then
call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 2250, 1.0)
call MultiboardMinimize( DialogBoard[id], true)
endif
endif
endif
return false
endfunction
private function Start takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
local multiboarditem mbitem
call DestroyTimer(GetExpiredTimer())
loop
exitwhen i >= 12
set count[i] = 0
set talking[i] = false
call TriggerRegisterPlayerEvent(t, Player(i), EVENT_PLAYER_END_CINEMATIC)
set DialogBoard[i] = CreateMultiboard()
call MultiboardSetRowCount(DialogBoard[i], 2)
call MultiboardSetColumnCount(DialogBoard[i], 2)
call MultiboardSetTitleText(DialogBoard[i], "Game Dialogs")
set mbitem = MultiboardGetItem(DialogBoard[i], 0, 0)
call MultiboardSetItemWidth(mbitem, 0.06)
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[i], 1, 0)
call MultiboardSetItemWidth(mbitem, 0.06)
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[i], 0, 1)
call MultiboardSetItemWidth(mbitem, 0.64)
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[i], 1, 1)
call MultiboardSetItemWidth(mbitem, 0.64)
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[i], 0, 0)
call MultiboardSetItemIcon(mbitem, "ReplaceableTextures\\CommandButtons\\BTN_CMD_Talk.blp")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[i], 1, 0)
call MultiboardSetItemIcon(mbitem, "ReplaceableTextures\\CommandButtons\\BTN_CMD_Talk.blp")
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[i], 0, 1)
call MultiboardSetItemStyle(mbitem, true, false)
call MultiboardReleaseItem(mbitem)
set mbitem = MultiboardGetItem(DialogBoard[i], 1, 1)
call MultiboardSetItemStyle(mbitem, true, false)
call MultiboardReleaseItem(mbitem)
if GetLocalPlayer() == Player(i) then
call MultiboardDisplay(DialogBoard[i], true)
endif
set i = i + 1
endloop
call TriggerAddCondition(t, Condition(function EscPress))
endfunction
private function onInit takes nothing returns nothing
call TimerStart(CreateTimer(),0.01,false,function Start)
endfunction
endlibrary
One of the triggers that use it
-
Roger 1 Dialog System
-
Events
- Unit - A unit Sells an item (from shop)
-
Conditions
- (Selling unit) Equal to Roger 0000 <gen>
- (Item-type of (Sold Item)) Equal to Talk
- ((Buying unit) is A Hero) Equal to True
-
Actions
- Unit - Make (Selling unit) face (Buying unit) over 0.00 seconds
- Unit - Make (Buying unit) face (Selling unit) over 0.00 seconds
- Custom script: call AddLineToDialog( "Hi! |cffffd700Roger|r! How's it going?", GetBuyingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "Hi! Gsu'h told me to explain you some stuff.", GetSellingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "As you already know, you have to press [Esc] to continue with the conversation...", GetSellingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "During this time, though you are paused, you are vulnerable to damage", GetSellingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "Also, forget about just killing everything. This game involves more than that.", GetSellingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "Be aware of the night, wich is dark enough to need some light source, like a torch...", GetSellingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "Notice that most units don't show the Green Health Bar, and Items aren't that obvious to detect", GetSellingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "As an example, those torchs over there can be picked. Try doing it after we finish talking", GetSellingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "You should also check your |cffffd700Main Skills|r, you can now find in your command panel.", GetSellingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "These will be neccesary for quests, fights, and finding secrets", GetSellingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "Now go explore. Good luck! Hope you the best of |cffffd700Elomvah|r blessings ;)", GetSellingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call AddLineToDialog( "Okay thanks!", GetBuyingUnit(), GetOwningPlayer(GetBuyingUnit()))
- Custom script: call StartPlayerDialog(GetOwningPlayer(GetBuyingUnit()))
- Unit - Add Main skills to (Buying unit)
-
Events
Last edited: