Added run path action & wired up test button
This commit is contained in:
parent
e065094616
commit
fde5095f11
@ -2,6 +2,7 @@
|
||||
#define _mr_auto_quest_actions_
|
||||
|
||||
#include "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/actions/npc_dialog_action.iss"
|
||||
#include "${LavishScript.HomeDirectory}/Scripts/mr/auto_quest/actions/run_path_action.iss"
|
||||
|
||||
function RunAction(string actionType, jsonvalue params)
|
||||
{
|
||||
@ -9,6 +10,10 @@ function RunAction(string actionType, jsonvalue params)
|
||||
{
|
||||
call npc_dialog_action params
|
||||
}
|
||||
if ${actionType.Equal["run_path"]}
|
||||
{
|
||||
call run_path_action params
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
33
auto_quest/actions/run_path_action.iss
Normal file
33
auto_quest/actions/run_path_action.iss
Normal file
@ -0,0 +1,33 @@
|
||||
#includeoptional "${LavishScript.HomeDirectory}/Scripts/mr/common/api.iss"
|
||||
|
||||
variable(global) MRBotApi MRApi
|
||||
|
||||
function run_path_action(jsonvalueref params)
|
||||
{
|
||||
variable jsoniterator pathIterator
|
||||
params.Get["path"]:GetIterator[pathIterator]
|
||||
|
||||
if !${MRApi(exists)}
|
||||
{
|
||||
echo "MRApi not available"
|
||||
|
||||
}
|
||||
|
||||
if !${MRNav(exists)}
|
||||
{
|
||||
echo "MRNav not available"
|
||||
}
|
||||
|
||||
if ${pathIterator:First(exists)}
|
||||
{
|
||||
variable point3f nextLocation
|
||||
do
|
||||
{
|
||||
nextLocation:Set[${pathIterator.Value.Get[x]},${pathIterator.Value.Get[y]},${pathIterator.Value.Get[z]}]
|
||||
call MRApi.MoveTo "${Me.Name}" "${nextLocation}" 1
|
||||
call MRApi.WaitForMoveTo "${Me.Name}" "${nextLocation}" 1
|
||||
|
||||
}
|
||||
while ${pathIterator:Next(exists)}
|
||||
}
|
||||
}
|
||||
@ -100,6 +100,8 @@ objectdef QuestWriterController
|
||||
{
|
||||
variable jsonvalue step
|
||||
step:SetValue["${Context.Source.Metadata.Get["step"].AsJSON~}"]
|
||||
|
||||
echo "Testing step ${step.Get["params"].AsJSON~}"
|
||||
QueueCommand call RunAction ${step.Get["type"]} "${step.Get["params"].AsJSON~}"
|
||||
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ objectdef RelayApi
|
||||
|
||||
variable point3f location
|
||||
location:Set[${Context.Get["parameters", "location", "X"]}, ${Context.Get["parameters", "location", "Y"]}, ${Context.Get["parameters", "location", "Z"]}]
|
||||
MRApi:MoveTo["${Context.Get["parameters","ForWho"]}", "${location}", ${Context.Get["parameters", "minDistance"]}]
|
||||
;MRApi:MoveTo["${Context.Get["parameters","ForWho"]}", "${location}", ${Context.Get["parameters", "minDistance"]}]
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,12 +1,15 @@
|
||||
#ifndef _mr_api_
|
||||
#define _mr_api_
|
||||
objectdef MRApi
|
||||
objectdef MRBotApi
|
||||
{
|
||||
static member:bool IsForMe(string forWhoTarget)
|
||||
variable string test = "test MRAPI";
|
||||
member:bool IsForMe(string forWhoTarget)
|
||||
{
|
||||
variable string target = ${forWhoTarget};
|
||||
variable string prefix = ${forWhoTarget.Token[1, ":"]};
|
||||
variable bool negate = FALSE;
|
||||
variable string target = ${forWhoTarget}
|
||||
variable string prefix = ${forWhoTarget.Token[1, ":"]}
|
||||
variable bool negate = FALSE
|
||||
|
||||
echo "IsForMe ${forWhoTarget} ${prefix} ${target}"
|
||||
|
||||
|
||||
if ${target.Count[":"]} > 0
|
||||
@ -62,19 +65,28 @@ objectdef MRApi
|
||||
return ${negate}
|
||||
}
|
||||
|
||||
static method MoveTo(string forWho, point3f location, float minDistance = 0)
|
||||
function MoveTo(string forWho, point3f location, float minDistance = 0)
|
||||
{
|
||||
echo "Moving to ${location}"
|
||||
if ${MRApi.IsForMe[${forWho}]}
|
||||
if ${This.IsForMe["${forWho}"]}
|
||||
{
|
||||
MRNav:MoveTo["${location}"]
|
||||
}
|
||||
else
|
||||
{
|
||||
echo "NotForMe"
|
||||
echo "${forWho} NotForMe"
|
||||
}
|
||||
}
|
||||
|
||||
function WaitForMoveTo(string forWho, point3f location, float minDistance = 0)
|
||||
{
|
||||
echo "Waiting for move to ${location}"
|
||||
while ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${location.X},${location.Y},${location.Z}]} > ${minDistance}
|
||||
{
|
||||
echo "waiting for path to complete ${Math.Distance[${Me.X},${Me.Y},${Me.Z},${location.X},${location.Y},${location.Z}]}"
|
||||
wait 5
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user