The queryEgs native AI script function sends a query message to EGS to get information about a player. The answer is asynchronous, so we have to indicate a group and a user event that will be triggered when the answer comes back to AIS.
()queryEgs(botIndex: s, query: s, queryParam: s, groupThatWillBeTriggered: c, idOfTheUserEvent: f, msgId: s) // queryEgs_ssscfs_
()queryEgs(botIndex: s, query: s, groupThatWillBeTriggered: c, idOfTheUserEvent: f, msgId: s) // queryEgs_sscfs_
The following code sends multiple queries to EGS to get information about a player:
// Send message to EGS
// ($playerEid)getCurrentPlayerEid();
(@groupToNotify)boss_group.context();
()queryEgs("Name", $playerEid, @groupToNotify, 4, "MSG_NAME");
()queryEgs("Hp", $playerEid, @groupToNotify, 4, "msg1");
()queryEgs("MaxHp", $playerEid, @groupToNotify, 4, "msg2");
()queryEgs("RatioHp", $playerEid, @groupToNotify, 4, "msg3");
()queryEgs("Sap", $playerEid, @groupToNotify, 4, "msg4");
()queryEgs("MaxSap", $playerEid, @groupToNotify, 4, "msg5");
()queryEgs("RatioSap", $playerEid, @groupToNotify, 4, "msg6");
()queryEgs("Focus", $playerEid, @groupToNotify, 4, "msg7");
()queryEgs("MaxFocus", $playerEid, @groupToNotify, 4, "msg8");
()queryEgs("RatioFocus", $playerEid, @groupToNotify, 4, "msg9");
()queryEgs("Stamina", $playerEid, @groupToNotify, 4, "msg10");
()queryEgs("MaxStamina", $playerEid, @groupToNotify, 4, "msg11");
()queryEgs("RatioStamina", $playerEid, @groupToNotify, 4, "msg12");
()queryEgs("BestSkillLevel", $playerEid, @groupToNotify, 4, "msg13");
// Answer of the EGS
// The user_event 4 of groupToNotify will be triggered
($msgName)getEventParam(0); // the message name
($ret)getEventParam(1); // the return value
($funName)getEventParam(2); // the name of the function
($playerEid)getEventParam(3); // the id of the player
($param1)getEventParam(4); // empty or item, or sbrick, or botEid
if ($msgName == "MSG_NAME") {
()phrasePushString("literal", $ret);
()phrasePushString("player", $playerEid);
()boss_group.phraseEndNpcMsg(0, "say", "TEST_BOSS_TEST_MSG");
} else {
()phrasePushString("player", $playerEid);
()phrasePushString("literal", $funName);
()phrasePushString("literal", $msgName);
()phrasePushString("integer", $ret);
()boss_group.phraseEndNpcMsg(0, "say", "TEST_BOSS_TEST_EGS_QUERY");
}
// Sending message to EGS
// ($playerEid)getCurrentPlayerEid();
(@groupToNotify)boss_group.context();
()queryEgs("KnowBrick", $playerEid, "bfma01.sbrick", @groupToNotify, 4, "MSG_BRICK");
()queryEgs("IsInInventory", $playerEid, "iccm1bm.sitem", @groupToNotify, 4, "MSG_ITEM");
()queryEgs("Target", $playerEid, $botEid, @groupToNotify, 4, "MSG_TARGET");
// Handling the answer from EGS in a user event
($msgName)getEventParam(0);
($ret)getEventParam(1);
($funName)getEventParam(2);
($playerEid)getEventParam(3);
($param1)getEventParam(4);
if ($msgName == "MSG_ITEM") {
// Handle the answer when checking for an item in inventory or equipment
()phrasePushString("item", $param1);
()phrasePushString("integer", $ret);
()boss_group.phraseEndNpcMsg(0, "say", "TEST_BOSS_TEST_EGS_QUERY_ITEM");
} else if ($msgName == "MSG_BRICK") {
// Handle the answer when checking if the player knows a specific sbrick
()phrasePushString("sbrick", $param1);
()phrasePushString("integer", $ret);
()boss_group.phraseEndNpcMsg(0, "say", "TEST_BOSS_TEST_EGS_QUERY_BRICK");
} else if ($msgName == "MSG_TARGET") {
// Handle the answer when checking if the player is targeting a specific bot
()phrasePushString("bot", $param1);
()phrasePushString("integer", $ret);
()boss_group.phraseEndNpcMsg(0, "say", "TEST_BOSS_TEST_EGS_QUERY_TARGET");
}