Implemented npc_dialog step
This commit is contained in:
parent
55e1001b43
commit
1cda0fca3d
15
auto_quest/actions/actions.iss
Normal file
15
auto_quest/actions/actions.iss
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#ifndef _mr_auto_quest_actions_
|
||||||
|
#define _mr_auto_quest_actions_
|
||||||
|
|
||||||
|
#include "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/actions/npc_dialog_action.iss"
|
||||||
|
|
||||||
|
function RunAction(string actionType, jsonvalue params)
|
||||||
|
{
|
||||||
|
echo "RunAction: ${actionType}, ${params}"
|
||||||
|
if ${actionType.Equal["npc_dialog"]}
|
||||||
|
{
|
||||||
|
call npc_dialog_action params
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
10
auto_quest/actions/npc_dialog_action.iss
Normal file
10
auto_quest/actions/npc_dialog_action.iss
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#includeoptional "${LavishScript.HomeDirectory}/Scripts/mr/utilities/NpcHelpers.iss"
|
||||||
|
|
||||||
|
function npc_dialog_action(jsonvalueref params)
|
||||||
|
{
|
||||||
|
variable NpcHelpers npcHelpers
|
||||||
|
|
||||||
|
echo "npc_dialog_action::params ${params.AsJSON~}"
|
||||||
|
|
||||||
|
call npcHelpers.GetQuestFromNpc "${params.Get["npc_name"]}" "${params.Get["dialog_options"]}"
|
||||||
|
}
|
||||||
100
auto_quest/property_editors/npc_dialog_properties.iss
Normal file
100
auto_quest/property_editors/npc_dialog_properties.iss
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
objectdef NPCDialogPropertiesController
|
||||||
|
{
|
||||||
|
variable string CurrentDialogOptions
|
||||||
|
variable string CurrentNPCName
|
||||||
|
variable jsonvalue ui ="{}"
|
||||||
|
variable string StepType = "npc_dialog"
|
||||||
|
|
||||||
|
member:jsonvalueref GetUI()
|
||||||
|
{
|
||||||
|
return ui
|
||||||
|
}
|
||||||
|
|
||||||
|
member:jsonvalueref GetDialogOptions()
|
||||||
|
{
|
||||||
|
variable jsonvalue dialogOptions
|
||||||
|
|
||||||
|
dialogOptions:SetValue[$$>"{
|
||||||
|
"type": "${This.StepType}",
|
||||||
|
"params": {
|
||||||
|
"npc_name": ${This.CurrentNPCName.AsJSON~},
|
||||||
|
"dialog_options": ${This.CurrentDialogOptions.AsJSON~}
|
||||||
|
}
|
||||||
|
}"<$$]
|
||||||
|
|
||||||
|
return dialogOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
member:jsonvalueref GetDisplayForProperties(jsonvalueref step)
|
||||||
|
{
|
||||||
|
variable jsonvalue stepItem
|
||||||
|
variable string options
|
||||||
|
variable string npcName
|
||||||
|
|
||||||
|
options:Set["${step.Get["params","dialog_options"]}"]
|
||||||
|
npcName:Set["${step.Get["params","npc_name"]}"]
|
||||||
|
|
||||||
|
stepItem:SetValue[$$>"{
|
||||||
|
"type": "stackpanel",
|
||||||
|
"orientation": "vertical",
|
||||||
|
"horizontalAlignment": "left",
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "textblock",
|
||||||
|
"horizontalAlignment": "stretch",
|
||||||
|
"font": {
|
||||||
|
"bold": true,
|
||||||
|
"heightFactor": 1.1
|
||||||
|
},
|
||||||
|
"text": "NPC Dialog"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stackpanel",
|
||||||
|
"orientation": "horizontal",
|
||||||
|
"horizontalAlignment": "stretch",
|
||||||
|
"padding": [5, 0, 0, 0],
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "textblock",
|
||||||
|
"text": "NPC Name:",
|
||||||
|
"margin": [0, 0, 5, 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "textblock",
|
||||||
|
"text": ${npcName.AsJSON~}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stackpanel",
|
||||||
|
"orientation": "horizontal",
|
||||||
|
"horizontalAlignment": "stretch",
|
||||||
|
"padding": [5, 0, 0, 0],
|
||||||
|
"children": [
|
||||||
|
{
|
||||||
|
"type": "textblock",
|
||||||
|
"text": "Options:",
|
||||||
|
"margin": [0, 0, 5, 0]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "textblock",
|
||||||
|
"text": ${options.AsJSON~}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}"<$$]
|
||||||
|
|
||||||
|
return stepItem
|
||||||
|
}
|
||||||
|
|
||||||
|
method Initialize()
|
||||||
|
{
|
||||||
|
ui:ParseFile["${Script.CurrentDirectory}/property_editors/npc_dialog_properties.json"]
|
||||||
|
}
|
||||||
|
|
||||||
|
method OnSetNPCNameButtonClick()
|
||||||
|
{
|
||||||
|
This.CurrentNPCName:Set["${Me.Target.Name}"]
|
||||||
|
}
|
||||||
|
}
|
||||||
21
auto_quest/property_editors/property_editors.iss
Normal file
21
auto_quest/property_editors/property_editors.iss
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#ifndef _mr_property_editors_
|
||||||
|
#define _mr_property_editors_
|
||||||
|
|
||||||
|
#includeoptional "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/property_editors/npc_dialog_properties.iss"
|
||||||
|
|
||||||
|
variable(global) NPCDialogPropertiesController MRNPCDialogPropertiesController
|
||||||
|
|
||||||
|
objectdef PropertyEditors
|
||||||
|
{
|
||||||
|
static method GetPropertyEditor( string stepType )
|
||||||
|
{
|
||||||
|
switch ( stepType )
|
||||||
|
{
|
||||||
|
case MRNPCDialogPropertiesController.StepType:
|
||||||
|
return MRNPCDialogPropertiesController;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,104 +1,7 @@
|
|||||||
objectdef NPCDialogPropertiesController
|
|
||||||
{
|
|
||||||
variable string CurrentDialogOptions
|
|
||||||
variable string CurrentNPCName
|
|
||||||
variable jsonvalue ui ="{}"
|
|
||||||
variable string StepType = "npc_dialog"
|
|
||||||
|
|
||||||
member:jsonvalueref GetUI()
|
|
||||||
{
|
|
||||||
return ui
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref GetDialogOptions()
|
#include "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/property_editors/property_editors.iss"
|
||||||
{
|
#include "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/actions/actions.iss"
|
||||||
variable jsonvalue dialogOptions
|
|
||||||
|
|
||||||
dialogOptions:SetValue[$$>"{
|
|
||||||
"type": "${This.StepType}",
|
|
||||||
"params": {
|
|
||||||
"npc_name": ${This.CurrentNPCName.AsJSON~},
|
|
||||||
"dialog_options": ${This.CurrentDialogOptions.AsJSON~}
|
|
||||||
}
|
|
||||||
}"<$$]
|
|
||||||
|
|
||||||
return dialogOptions
|
|
||||||
}
|
|
||||||
|
|
||||||
member:jsonvalueref GetDisplayForProperties(jsonvalueref step)
|
|
||||||
{
|
|
||||||
variable jsonvalue stepItem
|
|
||||||
variable string options
|
|
||||||
variable string npcName
|
|
||||||
|
|
||||||
options:Set["${step.Get["params","dialog_options"]}"]
|
|
||||||
npcName:Set["${step.Get["params","npc_name"]}"]
|
|
||||||
|
|
||||||
stepItem:SetValue[$$>"{
|
|
||||||
"type": "stackpanel",
|
|
||||||
"orientation": "vertical",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"horizontalAlignment": "stretch",
|
|
||||||
"font": {
|
|
||||||
"bold": true,
|
|
||||||
"heightFactor": 1.1
|
|
||||||
},
|
|
||||||
"text": "NPC Dialog"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "stackpanel",
|
|
||||||
"orientation": "horizontal",
|
|
||||||
"horizontalAlignment": "stretch",
|
|
||||||
"padding": [5, 0, 0, 0],
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"text": "NPC Name:",
|
|
||||||
"margin": [0, 0, 5, 0]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"text": ${npcName.AsJSON~}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "stackpanel",
|
|
||||||
"orientation": "horizontal",
|
|
||||||
"horizontalAlignment": "stretch",
|
|
||||||
"padding": [5, 0, 0, 0],
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"text": "Options:",
|
|
||||||
"margin": [0, 0, 5, 0]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "textblock",
|
|
||||||
"text": ${options.AsJSON~}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}"<$$]
|
|
||||||
|
|
||||||
return stepItem
|
|
||||||
}
|
|
||||||
|
|
||||||
method Initialize()
|
|
||||||
{
|
|
||||||
ui:ParseFile["npc_dialog_ui.json"]
|
|
||||||
}
|
|
||||||
|
|
||||||
method OnSetNPCNameButtonClick()
|
|
||||||
{
|
|
||||||
This.CurrentNPCName:Set["${Me.Target.Name}"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
variable(global) NPCDialogPropertiesController MRNPCDialogPropertiesController
|
|
||||||
|
|
||||||
objectdef QuestWriterController
|
objectdef QuestWriterController
|
||||||
{
|
{
|
||||||
@ -130,10 +33,40 @@ objectdef QuestWriterController
|
|||||||
{
|
{
|
||||||
variable jsonvalue listItems = "[]"
|
variable jsonvalue listItems = "[]"
|
||||||
variable jsonvalue stepItem
|
variable jsonvalue stepItem
|
||||||
|
variable jsonvalue listItem
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
listItems:Add["${This.FormatPropertiesForDisplay["${stepIterator.Value.AsJSON~}"].AsJSON~}"]
|
stepItem:SetValue["${This.FormatPropertiesForDisplay["${stepIterator.Value.AsJSON~}"].AsJSON~}"]
|
||||||
|
stepItem:Set["_dock", "\"left\""]
|
||||||
|
stepItem:Set["widthFactor", "0.8"]
|
||||||
|
|
||||||
|
|
||||||
|
listItem:SetValue[$$>"{
|
||||||
|
"type": "dockpanel",
|
||||||
|
"widthFactor": .18,
|
||||||
|
"children": [
|
||||||
|
${stepItem.AsJSON~},
|
||||||
|
{
|
||||||
|
"type": "button",
|
||||||
|
"content": "Test",
|
||||||
|
"_dock": "right",
|
||||||
|
"verticalAlignment": "center",
|
||||||
|
|
||||||
|
"_step": ${stepIterator.Value.AsJSON~}
|
||||||
|
"eventHandlers": {
|
||||||
|
"onRelease": {
|
||||||
|
"type": "method",
|
||||||
|
"object": "MRQuestWriterController",
|
||||||
|
"method": "OnTestStepButtonClick",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}"<$$]
|
||||||
|
|
||||||
|
listItems:Add["${listItem.AsJSON~}"]
|
||||||
|
|
||||||
}
|
}
|
||||||
while ${stepIterator:Next(exists)}
|
while ${stepIterator:Next(exists)}
|
||||||
}
|
}
|
||||||
@ -162,6 +95,15 @@ objectdef QuestWriterController
|
|||||||
LGUI2.Element["mr.quest_writer.properties_panel"]:AddChild[MRNPCDialogPropertiesController.GetUI]
|
LGUI2.Element["mr.quest_writer.properties_panel"]:AddChild[MRNPCDialogPropertiesController.GetUI]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
method OnTestStepButtonClick()
|
||||||
|
{
|
||||||
|
variable jsonvalue step
|
||||||
|
step:SetValue["${Context.Source.Metadata.Get["step"].AsJSON~}"]
|
||||||
|
echo "${step.AsJSON~}"
|
||||||
|
QueueCommand call RunAction ${step.Get["type"]} "${step.Get["params"].AsJSON~}"
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
method OnAddStepButtonClick()
|
method OnAddStepButtonClick()
|
||||||
{
|
{
|
||||||
This.QuestSteps:Add["${This.CurrentStepProperties.GetDialogOptions.AsJSON~}"]
|
This.QuestSteps:Add["${This.CurrentStepProperties.GetDialogOptions.AsJSON~}"]
|
||||||
@ -176,6 +118,7 @@ function main()
|
|||||||
{
|
{
|
||||||
while 1
|
while 1
|
||||||
{
|
{
|
||||||
|
ExecuteQueued
|
||||||
wait 1
|
wait 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,9 +32,64 @@
|
|||||||
"height": 16
|
"height": 16
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"listbox.contentContainer": {
|
||||||
|
"jsonTemplate": "scrollviewer",
|
||||||
|
"type": "scrollviewer",
|
||||||
|
"acceptsMouseFocus": false,
|
||||||
|
"contentContainer": {
|
||||||
|
"type": "border",
|
||||||
|
"horizontalContentAlignment": "stretch",
|
||||||
|
"verticalContentAlignment": "stretch"
|
||||||
|
}
|
||||||
|
},
|
||||||
"listbox.contentContainerFitWidth": {
|
"listbox.contentContainerFitWidth": {
|
||||||
"jsonTemplate": "listbox.contentContainer",
|
"jsonTemplate": "listbox.contentContainer",
|
||||||
"horizontalScroll": "fit"
|
"horizontalScroll": "fit"
|
||||||
|
},
|
||||||
|
"listbox.content": {
|
||||||
|
"type": "stackpanel",
|
||||||
|
"uniform": true,
|
||||||
|
"backgroundBrush": "listbox.backgroundBrush"
|
||||||
|
},
|
||||||
|
"listbox": {
|
||||||
|
"defaultItemViewTemplate": "listboxitem",
|
||||||
|
"acceptsKeyboardFocus": true,
|
||||||
|
"padding": [ 1, 1, 1, 1 ],
|
||||||
|
"borderThickness": 1,
|
||||||
|
"borderBrush": "listbox.borderBrush",
|
||||||
|
"contentContainer": {
|
||||||
|
"jsonTemplate": "listbox.contentContainer"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"jsonTemplate": "listbox.content"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"itemview": {
|
||||||
|
"type": "itemview",
|
||||||
|
"acceptsKeyboardFocus": false,
|
||||||
|
"contentContainer": {
|
||||||
|
"type": "border",
|
||||||
|
"horizontalContentAlignment": "stretch",
|
||||||
|
"verticalContentAlignment": "stretch"
|
||||||
|
},
|
||||||
|
"padding": [ 2, 2, 2, 2 ],
|
||||||
|
"margin": [ 1, 1, 1, 1 ],
|
||||||
|
"backgroundBrush": "itemview.backgroundBrush",
|
||||||
|
"eventHandlers": {
|
||||||
|
"onMouseButtonMove": {
|
||||||
|
"type": "forward",
|
||||||
|
"elementType": "itemlist",
|
||||||
|
"event": "onItemMouseButtonMove"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"styles": {
|
||||||
|
"onSelected": {
|
||||||
|
"backgroundBrush": "itemview.selectedBackgroundBrush"
|
||||||
|
},
|
||||||
|
"onDeselected": {
|
||||||
|
"backgroundBrush": "itemview.backgroundBrush"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -169,6 +224,7 @@
|
|||||||
{
|
{
|
||||||
"type": "stackpanel",
|
"type": "stackpanel",
|
||||||
"heightFactor": 1,
|
"heightFactor": 1,
|
||||||
|
"widthFactor": 1,
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"type": "textblock",
|
"type": "textblock",
|
||||||
@ -181,6 +237,9 @@
|
|||||||
"name": "mr.quest_writer.quest_steps",
|
"name": "mr.quest_writer.quest_steps",
|
||||||
"heightFactor": 1,
|
"heightFactor": 1,
|
||||||
"widthFactor": 1,
|
"widthFactor": 1,
|
||||||
|
"-contentContainer":{
|
||||||
|
"jsonTemplate":"listbox.contentContainerFitWidth"
|
||||||
|
},
|
||||||
"itemsBinding": {
|
"itemsBinding": {
|
||||||
"pullFormat": "${MRQuestWriterController.GetQuestStepsForDisplay}",
|
"pullFormat": "${MRQuestWriterController.GetQuestStepsForDisplay}",
|
||||||
"autoPull": false,
|
"autoPull": false,
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
#ifndef _mr_npc_helpers_
|
||||||
|
#define _mr_npc_helpers_
|
||||||
objectdef QuestHelpers
|
objectdef QuestHelpers
|
||||||
{
|
{
|
||||||
member:bool IsQuestPending()
|
member:bool IsQuestPending()
|
||||||
@ -13,23 +15,35 @@ objectdef QuestHelpers
|
|||||||
objectdef NpcHelpers
|
objectdef NpcHelpers
|
||||||
{
|
{
|
||||||
variable QuestHelpers QuestHelper
|
variable QuestHelpers QuestHelper
|
||||||
function GetQuestFromNpc(... params)
|
function GetQuestFromNpc(string npcName, string choices)
|
||||||
{
|
{
|
||||||
if ${params.Size} < 1
|
echo "NpcHelpers::GetQuestFromNpc[\"${npcName}\", \"${choices}\"]"
|
||||||
|
if ${npcName.Length} < 1
|
||||||
{
|
{
|
||||||
echo "Usage: GetQuestFromNpc <NPC Name> [...Dialog Choices(optional)]"
|
echo "Usage: GetQuestFromNpc <NPC Name> [comma separted string of dialog choices(optional)]"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
variable string npcName = ${params[1]};
|
|
||||||
Actor[Query, Name =- "${npcName}"]:DoubleClick
|
Actor[Query, Name =- "${npcName}"]:DoubleClick
|
||||||
if ${params.Size} > 1
|
wait 5
|
||||||
|
|
||||||
|
variable int numChoices = 0
|
||||||
|
if ${choices.Length} > 0
|
||||||
|
{
|
||||||
|
numChoices:Set[${choices.Count[","]}]
|
||||||
|
numChoices:Inc
|
||||||
|
}
|
||||||
|
|
||||||
|
if ${numChoices} > 0
|
||||||
{
|
{
|
||||||
variable int idx
|
variable int idx
|
||||||
for (idx:Set[2]; ${idx} <= ${params.Size}; idx:Inc)
|
for (idx:Set[1]; ${idx} <= ${numChoices}; idx:Inc)
|
||||||
{
|
{
|
||||||
variable string choice = ${params[i]};
|
variable string choice
|
||||||
EQ2UIPage[ProxyActor,Conversation].Child[composite,replies].Child[button,choice]:LeftClick
|
choice:Set[${choices.Token[${idx}, ","]}]
|
||||||
|
echo "choice: ${choice}"
|
||||||
|
EQ2UIPage[ProxyActor,Conversation].Child[composite,replies]:SpewProperties
|
||||||
|
EQ2UIPage[ProxyActor,Conversation].Child[composite,replies].Child[${choice}]:LeftClick
|
||||||
wait 5
|
wait 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,6 +52,7 @@ objectdef NpcHelpers
|
|||||||
variable int dialogOptionsTaken = 0;
|
variable int dialogOptionsTaken = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
echo "Clicking dialog option 1 for loop #${dialogOptionsTaken}"
|
||||||
dialogOptionsTaken:Inc
|
dialogOptionsTaken:Inc
|
||||||
EQ2UIPage[ProxyActor,Conversation].Child[composite,replies].Child[button,1]:LeftClick
|
EQ2UIPage[ProxyActor,Conversation].Child[composite,replies].Child[button,1]:LeftClick
|
||||||
wait 5
|
wait 5
|
||||||
@ -59,27 +74,4 @@ objectdef NpcHelpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
atom atexit()
|
|
||||||
{
|
|
||||||
echo "Exiting..."
|
|
||||||
}
|
|
||||||
|
|
||||||
function main()
|
|
||||||
{
|
|
||||||
; variable NpcHelpers NpcHelper
|
|
||||||
; variable NavHelpers NavHelper
|
|
||||||
; echo "Starting test"
|
|
||||||
|
|
||||||
; /*
|
|
||||||
; 910.060730,12.070809,239.235611
|
|
||||||
; 913.628540,10.217931,170.337494
|
|
||||||
; 907.632385,10.002500,152.857849
|
|
||||||
; 897.398376,10.180861,146.060623
|
|
||||||
; */
|
|
||||||
; ; wait 5
|
|
||||||
; ; call NpcHelper.GetQuestFromNpc "Germa"
|
|
||||||
; call NavHelper.FollowPath()
|
|
||||||
; return
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user