include library.create; include library.locations; include library.quests; include library.utils; trigger OnQuestActivated(int questRow) { LOG("newquests", "random_encounter - OnQuestActivated(+ " + questRow + ")"); // determine if the trigger is related to this particular script // more than one task script may be attached to the player if(quests.isMyQuest(questRow, "quest.task.random_encounter")) { // get the name of the qust from the quests data table String questName = quests.getDataEntry(questRow, "NAME"); int successChanceInt = 0; String objvarname = "quest." + questName + ".parameter"; if(hasObjVar(self, objvarname)) { successChanceInt = getIntObjVar(self, objvarname); } else { String successChance = quests.getDataEntry(questRow, "PARAMETER"); successChanceInt = utils.stringToInt(successChance); } int dieRoll = rand(0, 99); boolean success = true; LOG("newquests", "random_encounter - questName = " + questName + " successChance = " + successChanceInt + " dieRoll = " + dieRoll); if(dieRoll < successChanceInt) { success = quests.doEncounterSpawn(self, questRow); } LOG("newquests", "random_encounter - success = " + success); // complete the task. It is normal for log output to indicate // that the encounter failed to activate, because this call // will deactivate it while in the process of activating it. quests.complete(questName, self, success); } return SCRIPT_CONTINUE; }