include library.badge; include library.factions; include library.jedi; include library.loot; include library.money; include library.prose; include library.static_item; include library.utils; include library.weapons; include library.xp; include library.gcw; // --------------------------------------------------------------------- const int CHRONICLE_HOLOCRON_VERSION = 0; const int CHRONICLE_CREATION_XP_BASE = 99; const int CHRONICLE_SHARED_XP_BASE = 4; const int CHRONICLES_QUESTOR_GOLD_TOKEN_CHANCE = 5; const int CHRONICLES_CHRONICLER_GOLD_TOKEN_CHANCE = 5; const float CHRONICLE_SILVER_TOKENS_FOR_CHRONICLER_MOD = 0.42f; const float CHRONICLE_SILVER_TOKENS_FOR_QUESTOR_MOD = 1.2f; const boolean TEXT_FILTER_DISABLED = false; const string PGC_QUEST_RECIPE_TEMPLATE = "object/player_quest/pgc_quest_recipe.iff"; const string PGC_QUEST_HOLOCRON_TEMPLATE = "object/player_quest/pgc_quest_holocron.iff"; const string PGC_QUEST_SHARED_TEMPLATE = "object/player_quest/pgc_quest_holocron_shared.iff"; const string PGC_QUEST_CONTROL_DEVICE_TEMPLATE = "object/intangible/saga_system/sage_intangible_holocron.iff"; const string PGC_QUEST_HOLOCRON_SCRIPT ="quest.task.pgc.quest_holocron"; const int PGC_QUEST_MAX_NUM_QUESTS = 4; // max num active pgc quests const int PGC_QUEST_MAX_NUM_TASKS = 12; const int PGC_QUEST_MAX_NUM_TASKS_PER_PHASE = 4; const int PGC_NUM_REWARD_PARSE_SLOTS = 5; const int PGC_MAX_NUM_PLAYER_REWARDS = 4; const int PQ_TASK_ACTIVE = 0; // Shows the task in the quest helper and journal. const int PQ_TASK_CURRENT = 1; // Does nothing currently. const int PQ_TASK_COMPLETE = 2; // Removes waypoint and task from task helper. const int PQ_TASK_FAILED = 3; // Does nothing currently. const int PQ_TASK_INACTIVE = 4; // Hides the task in the quest helper and quest journal. const string CATEGORY_NAME_RELIC_DATA = "relic_data"; const int CATERGORY_RELIC_DATA_LEVEL_INDEX = 1; const int CATERGORY_RELIC_DATA_GROUP_INDEX = 2; const int CATERGORY_RELIC_DATA_KASHYYYK_INDEX = 3; const int CATERGORY_RELIC_DATA_MUSTAFAR_INDEX = 4; const int COMM_TASK_COMPLETION_DELAY = 6; const int COMPLETED_HOLOCRON_HUE = 6; const int BOOSTER_PACK_SIZE = 5; const int STARTER_PACK_SIZE = 12; // --------------------------------------------------------------------- const string SAGA_DESTROY_MULTIPLE = "saga_relic_destroy_multiple"; const string SAGA_DESTROY_MULTIPLE_LOOT = "saga_relic_destroy_multiple_loot"; const string SAGA_PERFORM = "saga_relic_perform"; const string SAGA_CRAFT_ITEM = "saga_relic_craft_item"; const string SAGA_COMM_MESSAGE = "saga_relic_comm_message"; const string SAGA_GOTO_LOCATION = "saga_relic_goto_location"; const string SAGA_RETRIEVE_ITEM = "saga_relic_retrieve_item"; const string SAGA_PVP_OBJECTIVE = "saga_relic_pvp_objective"; const string[] CREDIT_FOR_KILL_TASKS = { SAGA_DESTROY_MULTIPLE, SAGA_DESTROY_MULTIPLE_LOOT }; const string[] ALL_PGC_COLLECTION_TASK_NAMES = { SAGA_DESTROY_MULTIPLE, SAGA_DESTROY_MULTIPLE_LOOT, SAGA_PERFORM, SAGA_CRAFT_ITEM, SAGA_COMM_MESSAGE, SAGA_GOTO_LOCATION, SAGA_RETRIEVE_ITEM, SAGA_PVP_OBJECTIVE }; const string PGC_CASH_ITEM_TEMPLATE = "object/tangible/saga_system/pgc_loot_cash.iff"; const string PGC_RELIC_SLOT_GOTO_GENERIC_LOC = "relic_goto_global_generic"; const string PGC_RELIC_OBJ_GOTO_GENERIC_LOC = "saga_relic_goto_global_generic"; // --------------------------------------------------------------------- const int PGC_CHRONICLE_BASE_FRAGEMENT_CHANCE = 18; const int PGC_CHRONICLE_BASE_CRAFTING_LOOT_CHANCE = 14; const int PGC_CHRONICLE_BASE_PVP_LOOT_CHANCE = 14; const string PGC_CHRONICLES_XP_TYPE = "chronicles"; const string PGC_CHRONICLES_STARTING_SKILL = "class_chronicles_novice"; const string PGC_CHRONICLES_COPPER_TOKEN = "item_pgc_token_01"; const string PGC_CHRONICLES_SILVER_TOKEN = "item_pgc_token_02"; const string PGC_CHRONICLES_GOLD_TOKEN = "item_pgc_token_03"; const string PGC_CHRONICLES_RELIC_FRAGMENT = "item_pgc_relic_fragment"; const string PGC_CHRONICLES_BOOSTER_PACK = "item_pgc_booster_pack"; const string PGC_CHRONICLES_STARTER_KIT = "item_pgc_starter_kit"; const string PGC_SKILLMOD_MAX_TASKS = "chronicles_max_tasks"; const string PGC_SKILLMOD_RELIC_QUALITY = "chronicles_relic_quality"; const string PGC_SKILLMOD_MAX_SHARED_QUESTS = "chronicles_max_quest_shared"; const string PGC_SKILLMOD_RELIC_MASTERY = "chronicles_relic_mastery"; // --------------------------------------------------------------------- const string PCG_QUEST_CREATOR_ID_OBJVAR = "chronicles.quest_creator_id"; const string PCG_QUEST_CREATOR_NAME_OBJVAR = "chronicles.quest_creator_name"; const string PCG_QUEST_CREATOR_STATIONID_OBJVAR = "chronicles.quest_creator_station_id"; const string PCG_QUEST_VERSION_OBJVAR = "chronicles.version"; const string PCG_QUEST_CUR_QUEST_PHASE_OBJVAR = "chronicles.quest_phase"; const string PCG_QUEST_COMPLETE_OBJVAR = "chronicles.quest_complete"; const string PCG_QUEST_WAS_RATED_OBJVAR = "chronicles.quest_was_rated"; const string PCG_QUEST_SHARED_HOLOCRON_OBJVAR = "chronicles.quest_is_shared_version"; const string PCG_QUEST_CAN_SHARE_OBJVAR = "chronicles.quest_can_be_shared"; const string PCG_QUEST_CAN_SHARE_MAX_OBJVAR = "chronicles.quest_can_be_shared_max"; const string PCG_QUEST_HOLOCRON_SHARED_WITH_LIST = "sharing.sharedWithList"; const string PCG_QUEST_LEVEL_OBJVAR = "chronicles.quest_level"; const string PCG_QUEST_NUM_TASKS_OBJVAR = "chronicles.num_tasks"; const string PCG_QUEST_DIFFICULTY_OBJVAR = "chronicles.quest_difficulty"; const string PCG_QUEST_NEED_KASHYYYK_OBJVAR = "chronicles.quest_requires_kashyyyk"; const string PCG_QUEST_NEED_MUSTAFAR_OBJVAR = "chronicles.quest_requires_mustafar"; const string PCG_QUEST_INVOLVES_PVP_OBJVAR = "chronicles.quest_involves_pvp"; const string PCG_QUEST_INVOLVES_CRAFT_OBJVAR = "chronicles.quest_involves_crafting"; const string PCG_QUEST_INVOLVES_ENTERTAIN_OBJVAR = "chronicles.quest_involves_entertaining"; const string PCG_QUEST_INVOLVES_COMBAT_OBJVAR = "chronicles.quest_involves_combat"; const string PCG_QUEST_WEIGHT_OBJVAR = "chronicles.quest_weight"; const string PCG_QUEST_TASK_TYPE_DIVERSITY = "chronicles.quest_task_type_diversity"; const string PCG_QUEST_RELIC_DIVERSITY = "chronicles.quest_relic_diversity"; const string PCG_QUEST_CREATOR_AT_MAX_LEVEL_OBJVAR = "chronicles.creator_at_max_level"; const string PCG_QUEST_ACTIVATED_TIME = "chronicles.questActivatedTime"; const string PCG_QUEST_COMPLETED_TIME = "chronicles.questCompletedTime"; const string PGC_GRANTED_ROADMAP_REWARDS_OBJVAR = "chroniclesRewards.grantedRoadmapRewards"; const string PGC_RELIC_SLOT_DATA_OBJVAR = "chronicles.slotName"; // --------------------------------------------------------------------- // Pgc Rating Data Indexes const int PGC_STORED_CHRONICLE_XP_INDEX = 0; const int PGC_STORED_CHRONICLE_SILVER_TOKENS_INDEX = 1; const int PGC_STORED_CHRONICLE_GOLD_TOKENS_INDEX = 2; // ALL = all quests // MID = quest weight greater than or equal to 15.0 and less than 30.0 // HIGH = quest weight 30.0 and higer const int PGC_NUM_QUESTS_CREATED_ALL_INDEX = 3; const int PGC_NUM_QUESTS_CREATED_MID_QUALITY_INDEX = 4; const int PGC_NUM_QUESTS_CREATED_HIGH_QUALITY_INDEX = 5; const int PGC_NUM_YOUR_QUESTS_OTHERS_COMPLETED_ALL_INDEX = 6; const int PGC_NUM_YOUR_QUESTS_OTHERS_COMPLETED_MID_QUALITY_INDEX = 7; const int PGC_NUM_YOUR_QUESTS_OTHERS_COMPLETED_HIGH_QUALITY_INDEX = 8; const int PGC_NUM_QUESTS_YOU_COMPLETED_ALL_INDEX = 9; const int PGC_NUM_QUESTS_YOU_COMPLETED_MID_QUALITY_INDEX = 10; const int PGC_NUM_QUESTS_YOU_COMPLETED_HIGH_QUALITY_INDEX = 11; const float PGC_MIN_MID_QUALITY_QUEST_WEIGHT = 15.0f; const float PGC_MIN_HIGH_QUALITY_QUEST_WEIGHT = 30.0f; // --------------------------------------------------------------------- boolean activateQuestHolocron(obj_id questHolocron, obj_id player) { obj_id datapad = utils.getPlayerDatapad(player); if( isIdValid(datapad) ) { obj_id questControlDevice = createObject(PGC_QUEST_CONTROL_DEVICE_TEMPLATE, datapad, ""); if ( isIdValid(questControlDevice) ) { putInOverloaded(questHolocron, questControlDevice); messageTo(questHolocron, "handleQuestHolocronActivated", null, 1, false); return true; } } return false; } // --------------------------------------------------------------------- boolean clearQuestHolocron(obj_id questControlDevice, obj_id player) { obj_id questHolocron = getQuestHolocronFromQCD(questControlDevice); if ( isIdValid(questHolocron) ) { obj_id playerInventory = utils.getInventoryContainer(player); if ( isIdValid(playerInventory) ) { resetQuestHolocron(questHolocron, player); sendDirtyObjectMenuNotification(questHolocron); putInOverloaded(questHolocron, playerInventory); return true; } } return false; } // --------------------------------------------------------------------- boolean isPgcQuestObject(obj_id object) { int gameObjectType = getGameObjectType(object); if ( gameObjectType == GOT_chronicles_quest_holocron || gameObjectType == GOT_chronicles_quest_holocron_recipe ) { return true; } return false; } // --------------------------------------------------------------------- boolean isPgcRelicObject(obj_id object) { int gameObjectType = getGameObjectType(object); if ( gameObjectType == GOT_chronicles_relic ) { return true; } return false; } // --------------------------------------------------------------------- boolean isSharedPlayerQuestObject(obj_id questHolocron) { return hasObjVar(questHolocron, PCG_QUEST_SHARED_HOLOCRON_OBJVAR); } // --------------------------------------------------------------------- obj_id getQuestHolocronFromQCD(obj_id questControlDevice) { obj_id[] questItems = getContents(questControlDevice); if ( questItems != null && questItems.length > 0 ) { for ( int i = 0; i < questItems.length; i++ ) { obj_id questItem = questItems[i]; if ( isPgcQuestObject(questItem) ) { return questItem; } } } return obj_id.NULL_ID; } // --------------------------------------------------------------------- boolean canSharePgcQuest(obj_id questHolocron) { if ( isPlayerQuestRecipe(questHolocron) ) { return false; } if ( isSharedPlayerQuestObject(questHolocron) ) { return false; } if ( !hasObjVar(questHolocron, pgc_quests.PCG_QUEST_CAN_SHARE_OBJVAR) ) { return false; } return true; } dictionary recreateSharedTaskDictionary(obj_id questHolocron) { dictionary webster = recreateQuestTaskDictionary(questHolocron); webster.put("isShared", true); return webster; } dictionary recreateQuestTaskDictionary(obj_id questHolocron) { dictionary webster = new dictionary(); webster.put("questName", getPlayerQuestTitle(questHolocron)); webster.put("questDescription", getPlayerQuestDescription(questHolocron)); webster.put("recipe", false); webster.put("rewards", "0~0~0~0~0"); webster.put("oldRecipe", obj_id.NULL_ID); webster.put("totalTasks", getIntObjVar(questHolocron, pgc_quests.PCG_QUEST_NUM_TASKS_OBJVAR)); for ( int i = 0; i < pgc_quests.PGC_QUEST_MAX_NUM_TASKS; i++ ) { string phaseString = pgc_quests.getPhaseObjVarString(i); if ( hasObjVar(questHolocron, phaseString) ) { for ( int j = 0; j < pgc_quests.PGC_QUEST_MAX_NUM_TASKS_PER_PHASE; j++) { string taskString = pgc_quests.getTaskObjVarString(j); string baseObjVar = pgc_quests.getPgcBaseObjVar(phaseString, taskString); if ( hasObjVar(questHolocron, baseObjVar) ) { string relicName = pgc_quests.getRelicName(questHolocron, phaseString, taskString); string taskTitle = pgc_quests.getTaskName(questHolocron, phaseString, taskString); string taskDescription = pgc_quests.getTaskDescription(questHolocron, phaseString, taskString); string relicType = pgc_quests.getTaskType(questHolocron, phaseString, taskString); string[] relicData = getCollectionSlotCategoryInfo(relicName); string taskData = ""; if ( relicType.equals(pgc_quests.SAGA_DESTROY_MULTIPLE) ) { int count = pgc_quests.getIntPgcTaskData(questHolocron, baseObjVar, "count", relicData); taskData += "5~"+relicName+"~"+taskTitle+"~"+taskDescription+"~unneededDummyData~"+count; } else if ( relicType.equals(pgc_quests.SAGA_DESTROY_MULTIPLE_LOOT) ) { int count = pgc_quests.getIntPgcTaskData(questHolocron, baseObjVar, "count", relicData); string message = pgc_quests.getStringPgcTaskData(questHolocron, baseObjVar, "message", relicData); int dropRate = pgc_quests.getIntPgcTaskData(questHolocron, baseObjVar, "drop_rate", relicData); taskData += "7~"+relicName+"~"+taskTitle+"~"+taskDescription+"~unneededDummyData~"+count+"~"+message+"~"+dropRate; } else if ( relicType.equals(pgc_quests.SAGA_PERFORM) ) { taskData += "6~"+relicName+"~"+taskTitle+"~"+taskDescription+"~unneededDummyData~unneededDummyData~unneededDummyData"; } else if ( relicType.equals(pgc_quests.SAGA_CRAFT_ITEM) ) { int count = pgc_quests.getIntPgcTaskData(questHolocron, baseObjVar, "count", relicData); taskData += "5~"+relicName+"~"+taskTitle+"~"+taskDescription+"~unneededDummyData~"+count; } else if ( relicType.equals(pgc_quests.SAGA_COMM_MESSAGE) ) { string message = pgc_quests.getStringPgcTaskData(questHolocron, baseObjVar, "message", relicData); taskData += "5~"+relicName+"~"+taskTitle+"~"+taskDescription+"~unneededDummyData~"+message; } else if ( relicType.equals(pgc_quests.SAGA_GOTO_LOCATION) ) { dictionary waypointData = getWaypointObjVarTaskData(questHolocron, baseObjVar, "waypoint"); if ( waypointData == null || waypointData.isEmpty() ) { waypointData = getWaypointRelicData("waypoint", relicData); } string waypointDataString = ""; if ( waypointData == null || waypointData.isEmpty() ) { waypointDataString += "0:0:0:tatooine:Unknown"; } else { location waypointLoc = waypointData.getLocation("waypointLoc"); string waypointName = waypointData.getString("waypointName"); waypointDataString += waypointLoc.x+":"+waypointLoc.y+":"+waypointLoc.z+":"+waypointLoc.area+":"+waypointName; } taskData += "4~"+relicName+"~"+taskTitle+"~"+taskDescription+"~"+waypointDataString; } else if ( relicType.equals(pgc_quests.SAGA_RETRIEVE_ITEM) ) { int count = pgc_quests.getIntPgcTaskData(questHolocron, baseObjVar, "count", relicData); taskData += "5~"+relicName+"~"+taskTitle+"~"+taskDescription+"~unneededDummyData~"+count; } else if ( relicType.equals(pgc_quests.SAGA_PVP_OBJECTIVE) ) { int count = pgc_quests.getIntPgcTaskData(questHolocron, baseObjVar, "count", relicData); taskData += "5~"+relicName+"~"+taskTitle+"~"+taskDescription+"~"+count+"~unneededDummyData"; } webster.put(""+i, taskData); } else { break; } } } else { break; } } return webster; } // --------------------------------------------------------------------- boolean handleChroniclesRelicCosts(obj_id player, dictionary taskDictionary) { int numTasks = taskDictionary.getInt("totalTasks"); int maxTasksSkillMod = pgc_quests.getMaxChronicleQuestTasks(player); if ( numTasks > maxTasksSkillMod ) { numTasks = maxTasksSkillMod; } dictionary relicNames = getRelicCount(taskDictionary, numTasks); if ( relicNames == null || relicNames.isEmpty() ) { return false; } if ( !canCoverAllChroniclesRelicCosts(player, relicNames, numTasks) ) { return false; } else { java.util.Enumeration keys = relicNames.keys(); while ( keys.hasMoreElements() ) { string relicName = (string)(keys.nextElement()); int relicCount = relicNames.getInt(relicName); modifyCollectionSlotValue(player, relicName, relicCount*(-1)); } } return true; } boolean canCoverAllChroniclesRelicCosts(obj_id player, dictionary relicNames, int numTasks) { boolean result = true; java.util.Enumeration keys = relicNames.keys(); while ( keys.hasMoreElements() ) { string relicName = (string)(keys.nextElement()); int relicCount = relicNames.getInt(relicName); long relicSlotValue = getCollectionSlotValue(player, relicName); if ( relicSlotValue < relicCount + 1 ) { result = false; } } return result; } dictionary getRelicCount(dictionary taskDictionary, int numTasks) { dictionary relicNames = new dictionary(); for ( int i = 0; i < numTasks; i++ ) { string taskName = "" + i; string taskData = taskDictionary.getString(taskName); string[] parse = split(taskData, '~'); string relicName = parse[1]; int relicNameCount = 0; if ( relicNames.containsKey(relicName) ) { relicNameCount = relicNames.getInt(relicName); } relicNames.put(relicName, relicNameCount + 1); } return relicNames; } // --------------------------------------------------------------------- string getQuestName(obj_id questHolocron) { return getPlayerQuestTitle(questHolocron); } // --------------------------------------------------------------------- string getQuestDescription(obj_id questHolocron) { return getPlayerQuestDescription(questHolocron); } // --------------------------------------------------------------------- string getTaskName(obj_id questHolocron, int phaseNum, int taskNum) { string phaseString = getPhaseObjVarString(phaseNum); string taskString = getTaskObjVarString(taskNum); int taskIndex = getIntObjVarTaskData(questHolocron, getPgcBaseObjVar(phaseString, taskString), "task_index"); return getPlayerQuestTaskTitle(questHolocron, taskIndex); } // --------------------------------------------------------------------- string getTaskName(obj_id questHolocron, string phaseString, string taskString) { int taskIndex = getIntObjVarTaskData(questHolocron, getPgcBaseObjVar(phaseString, taskString), "task_index"); return getPlayerQuestTaskTitle(questHolocron, taskIndex); } // --------------------------------------------------------------------- string getTaskDescription(obj_id questHolocron, int phaseNum, int taskNum) { string phaseString = getPhaseObjVarString(phaseNum); string taskString = getTaskObjVarString(taskNum); int taskIndex = getIntObjVarTaskData(questHolocron, getPgcBaseObjVar(phaseString, taskString), "task_index"); return getPlayerQuestTaskDescription(questHolocron, taskIndex); } // --------------------------------------------------------------------- string getTaskDescription(obj_id questHolocron, string phaseString, string taskString) { int taskIndex = getIntObjVarTaskData(questHolocron, getPgcBaseObjVar(phaseString, taskString), "task_index"); return getPlayerQuestTaskDescription(questHolocron, taskIndex); } // --------------------------------------------------------------------- string getTaskType(obj_id questHolocron, int phaseNum, int taskNum) { string phaseString = getPhaseObjVarString(phaseNum); string taskString = getTaskObjVarString(taskNum); return getStringObjVarTaskData(questHolocron, getPgcBaseObjVar(phaseString, taskString), "task_type"); } // --------------------------------------------------------------------- string getTaskType(obj_id questHolocron, string phaseString, string taskString) { return getStringObjVarTaskData(questHolocron, getPgcBaseObjVar(phaseString, taskString), "task_type"); } // --------------------------------------------------------------------- string getRelicName(obj_id questHolocron, string phaseString, string taskString) { return getStringObjVarTaskData(questHolocron, getPgcBaseObjVar(phaseString, taskString), "task_relic"); } // --------------------------------------------------------------------- string useFilteredQuestText(string text) { if ( TEXT_FILTER_DISABLED ) { return text; } return filterText(text); } // --------------------------------------------------------------------- int getMaxChronicleQuestTasks(obj_id player) { int maxTasksSkillmod = getEnhancedSkillStatisticModifierUncapped(player, pgc_quests.PGC_SKILLMOD_MAX_TASKS); if ( maxTasksSkillmod < 1 ) { maxTasksSkillmod = 1; } if ( maxTasksSkillmod > PGC_QUEST_MAX_NUM_TASKS ) { maxTasksSkillmod = PGC_QUEST_MAX_NUM_TASKS; } return maxTasksSkillmod; } // --------------------------------------------------------------------- boolean passedQuestHolocronProfanityCheck(obj_id player, obj_id questHolocron, string text) { // Server Profanity Filter disabled /* string[] RESERVED_RULES_TO_IGNORE = new string[] { "name_declined_number", "name_declined_syntax", "name_declined_fictionally_reserved", "name_declined_reserved" }; if ( isNameReserved(text, RESERVED_RULES_TO_IGNORE) && !isGod(player) ) { setObjVar(questHolocron, "pcg.failedProfanityFilter", true); destroyObject(questHolocron); sendSystemMessage(player, new string_id ("saga_system","holocron_failed_profanity_check")); return false; } */ return true; } // --------------------------------------------------------------------- int getTaskLevel(string[] relicData) { int level = 1; if ( relicData != null && relicData.length > 0 ) { for ( int i = 0; i < relicData.length; i++ ) { string relicCategory = relicData[i]; if ( relicCategory.startsWith(CATEGORY_NAME_RELIC_DATA) ) { string[] parse = split(relicCategory, ':'); level = utils.stringToInt(parse[CATERGORY_RELIC_DATA_LEVEL_INDEX]); } } } return level; } // --------------------------------------------------------------------- string getTaskGroupSetting(string[] relicData) { string groupSetting = "solo"; if ( relicData != null && relicData.length > 0 ) { for ( int i = 0; i < relicData.length; i++ ) { string relicCategory = relicData[i]; if ( relicCategory.startsWith(CATEGORY_NAME_RELIC_DATA) ) { string[] parse = split(relicCategory, ':'); int data = utils.stringToInt(parse[CATERGORY_RELIC_DATA_GROUP_INDEX]); if ( data >= 1 ) { groupSetting = "group"; } } } } return groupSetting; } // --------------------------------------------------------------------- int getTaskDifficultySetting(string[] relicData) { // 0 = normal // 1 = elite // 2 = boss int difficultySetting = 0; if ( relicData != null && relicData.length > 0 ) { for ( int i = 0; i < relicData.length; i++ ) { string relicCategory = relicData[i]; if ( relicCategory.startsWith(CATEGORY_NAME_RELIC_DATA) ) { string[] parse = split(relicCategory, ':'); int data = utils.stringToInt(parse[CATERGORY_RELIC_DATA_GROUP_INDEX]); if ( data > -1 ) { difficultySetting = data; } } } } return difficultySetting; } // --------------------------------------------------------------------- boolean getTaskKashyyykSetting(string[] relicData) { boolean requiresKashyyyk = false; if ( relicData != null && relicData.length > 0 ) { for ( int i = 0; i < relicData.length; i++ ) { string relicCategory = relicData[i]; if ( relicCategory.startsWith(CATEGORY_NAME_RELIC_DATA) ) { string[] parse = split(relicCategory, ':'); int data = utils.stringToInt(parse[CATERGORY_RELIC_DATA_KASHYYYK_INDEX]); if ( data == 1 ) { requiresKashyyyk = true; } } } } return requiresKashyyyk; } // --------------------------------------------------------------------- boolean getTaskMustafarSetting(string[] relicData) { boolean requiresMustafar = false; if ( relicData != null && relicData.length > 0 ) { for ( int i = 0; i < relicData.length; i++ ) { string relicCategory = relicData[i]; if ( relicCategory.startsWith(CATEGORY_NAME_RELIC_DATA) ) { string[] parse = split(relicCategory, ':'); int data = utils.stringToInt(parse[CATERGORY_RELIC_DATA_MUSTAFAR_INDEX]); if ( data == 1 ) { requiresMustafar = true; } } } } return requiresMustafar; } // --------------------------------------------------------------------- obj_id getQuestPlayer(obj_id questHolocron) { return utils.getContainingPlayer(questHolocron); } // --------------------------------------------------------------------- int getNumActiveQuests(obj_id player) { obj_id[] activeHolocrons = getActivateQuestHolocrons(player); if ( activeHolocrons == null || activeHolocrons.length < 1 ) { return 0; } return activeHolocrons.length; } // --------------------------------------------------------------------- boolean hasMaxActivatedQuests(obj_id player) { return getNumActiveQuests(player) >= PGC_QUEST_MAX_NUM_QUESTS; } // --------------------------------------------------------------------- obj_id[] getActivateQuestHolocrons(obj_id player) { resizeable obj_id[] dynamicQuestHolocronList = new obj_id[]; obj_id datapad = utils.getPlayerDatapad(player); if( isIdValid(datapad) ) { obj_id[] dataItems = getContents(datapad); if(dataItems != null && dataItems.length > 0 ) { for(int i = 0; i < dataItems.length; i++) { obj_id dataItem = dataItems[i]; if( isIdValid(dataItem) && getTemplateName(dataItem).equals(PGC_QUEST_CONTROL_DEVICE_TEMPLATE) ) { obj_id[] questObjects = getContents(dataItem); for ( int j=0; j < questObjects.length; j++ ) { obj_id questObject = questObjects[j]; if( isIdValid(questObject) ) { if ( isPgcQuestObject(questObject) ) { utils.addElement(dynamicQuestHolocronList, questObject); } } } } } } } if ( dynamicQuestHolocronList != null && dynamicQuestHolocronList.length > 0 ) { return utils.toStaticObjIdArray(dynamicQuestHolocronList); } return null; } // --------------------------------------------------------------------- string getTaskObjVarString(int taskNum) { string taskString = "task_0" + taskNum; if ( taskNum >=10 ) { taskString = "task_" + taskNum; } return taskString; } // --------------------------------------------------------------------- string getPgcBaseObjVar(string phaseString, string taskString) { return phaseString + "." + taskString; } // --------------------------------------------------------------------- boolean phaseHasActiveTaskOfType(obj_id questHolocron, string taskType, string phaseString) { for ( int i = 0; i < PGC_QUEST_MAX_NUM_TASKS_PER_PHASE; i++) { string taskString = getTaskObjVarString(i); string baseObjVar = getPgcBaseObjVar(phaseString, taskString); if ( hasObjVar(questHolocron, baseObjVar) ) { string phaseTaskCompleteObjVar = baseObjVar + ".task_complete"; if ( !hasObjVar(questHolocron, phaseTaskCompleteObjVar) ) { if ( getActiveTaskTaskType(questHolocron, phaseString, taskString).equals(taskType) ) { return true; } } } else { break; } } return false; } // --------------------------------------------------------------------- boolean phaseHasActiveTask(obj_id questHolocron, string phaseString) { for ( int i = 0; i < PGC_QUEST_MAX_NUM_TASKS_PER_PHASE; i++) { string taskString = getTaskObjVarString(i); string baseObjVar = getPgcBaseObjVar(phaseString, taskString); if ( hasObjVar(questHolocron, baseObjVar) ) { if ( !hasObjVar(questHolocron, baseObjVar + ".task_complete") ) { return true; } } else { break; } } return false; } // --------------------------------------------------------------------- string getActiveTaskTaskType(obj_id questHolocron, string phaseString, string taskString) { string taskType = ""; string phaseTaskTypeObjVar = getPgcBaseObjVar(phaseString, taskString) + ".task_type"; if ( hasObjVar(questHolocron, phaseTaskTypeObjVar) ) { taskType = getStringObjVar(questHolocron, phaseTaskTypeObjVar); } return taskType; } // --------------------------------------------------------------------- int incrementTaskCounter(obj_id questHolocron, string baseObjVar) { int currentCount = 1; string currentCountObjVar = baseObjVar + "." + "current_count"; if ( hasObjVar(questHolocron, currentCountObjVar) ) { currentCount = getIntObjVar(questHolocron, currentCountObjVar) + 1; } int taskIndex = getIntObjVarTaskData(questHolocron, baseObjVar, "task_index"); setPlayerQuestTaskCounter(questHolocron, taskIndex, currentCount); setObjVar(questHolocron, currentCountObjVar, currentCount); return currentCount; } // --------------------------------------------------------------------- boolean isTaskComplete(obj_id questHolocron, string phaseString, string taskString) { string baseObjVar = getPgcBaseObjVar(phaseString, taskString); return hasObjVar(questHolocron, baseObjVar+".task_complete"); } // --------------------------------------------------------------------- int getActivePhaseNum(obj_id questHolocron) { int phaseNum = 0; if ( hasObjVar(questHolocron, pgc_quests.PCG_QUEST_CUR_QUEST_PHASE_OBJVAR) ) { phaseNum = getIntObjVar(questHolocron, pgc_quests.PCG_QUEST_CUR_QUEST_PHASE_OBJVAR); } return phaseNum; } // --------------------------------------------------------------------- string getPhaseObjVarString(int phaseNum) { string phaseString = "phase_0"+phaseNum; if ( phaseNum >= 10 ) { phaseString = "phase_"+phaseNum; } return phaseString; } // --------------------------------------------------------------------- string getActivePhaseObjVarString(obj_id questHolocron) { int phaseNum = getActivePhaseNum(questHolocron); string phaseString = getPhaseObjVarString(phaseNum); return phaseString; } // --------------------------------------------------------------------- void setTaskComplete(obj_id questHolocron, string phaseString, string taskString) { string completedTaskBaseObjVar = getPgcBaseObjVar(phaseString, taskString); setObjVar(questHolocron, completedTaskBaseObjVar+".task_complete", true); removePlayerQuestWaypoint(questHolocron, completedTaskBaseObjVar); int completedTaskIndex = getIntObjVarTaskData(questHolocron, completedTaskBaseObjVar, "task_index"); setPlayerQuestTaskStatus(questHolocron, completedTaskIndex, PQ_TASK_COMPLETE); if ( !phaseHasActiveTask(questHolocron, phaseString) ) { // Activate the next phase of the quest int phaseNum = incrementActivePhaseNum(questHolocron); if ( phaseNum > 0 ) { string newPhaseString = getPhaseObjVarString(phaseNum); for ( int i = 0; i < PGC_QUEST_MAX_NUM_TASKS_PER_PHASE; i++) { string activatedTaskString = getTaskObjVarString(i); string activatedTaskBaseObjVar = getPgcBaseObjVar(newPhaseString, activatedTaskString); if ( hasObjVar(questHolocron, activatedTaskBaseObjVar) ) { // activate each task in the new quest phase int activatedTaskIndex = getIntObjVarTaskData(questHolocron, activatedTaskBaseObjVar, "task_index"); setPlayerQuestTaskStatus(questHolocron, activatedTaskIndex, PQ_TASK_ACTIVE); handleTaskActived(questHolocron, phaseNum, i); } else { break; } } } } return; } // --------------------------------------------------------------------- void removePlayerQuestWaypoint(obj_id questHolocron, string baseObjVar) { string activeWaypointObjVar = baseObjVar + ".waypointActive"; if ( hasObjVar(questHolocron, activeWaypointObjVar) ) { obj_id waypoint = getObjIdObjVar(questHolocron, activeWaypointObjVar); obj_id player = getQuestPlayer(questHolocron); if ( isIdValid(waypoint) && isIdValid(player) ) { destroyWaypointInDatapad(waypoint, player); removeObjVar(questHolocron, activeWaypointObjVar); } } } // --------------------------------------------------------------------- void activatePlayerQuestWaypointFromHolocron(obj_id questHolocron, string baseObjVar) { string activeWaypointObjVar = baseObjVar + ".waypointActive"; if ( hasObjVar(questHolocron, activeWaypointObjVar) ) { obj_id waypoint = getObjIdObjVar(questHolocron, activeWaypointObjVar); obj_id player = getQuestPlayer(questHolocron); activatePlayerQuestWaypoint(player, waypoint); } } // --------------------------------------------------------------------- void activatePlayerQuestWaypoint(obj_id player, obj_id waypoint) { if ( isIdValid(waypoint) && isIdValid(player) ) { location waypointLoc = getWaypointLocation(waypoint); string waypointPlanet = waypointLoc.area; location playerLoc = getLocation(player); string playerPlanet = playerLoc.area; if ( playerPlanet.equals(waypointPlanet) ) { setWaypointActive(waypoint, true); } } } // --------------------------------------------------------------------- int incrementActivePhaseNum(obj_id questHolocron) { int phaseNum = getActivePhaseNum(questHolocron) + 1; if ( hasObjVar(questHolocron, getPhaseObjVarString(phaseNum)) ) { setObjVar(questHolocron, pgc_quests.PCG_QUEST_CUR_QUEST_PHASE_OBJVAR, phaseNum); } else { setQuestComplete(questHolocron); phaseNum = -1; } return phaseNum; } // --------------------------------------------------------------------- void checkForPhaseComplete(obj_id questHolocron, string phaseString) { if ( !phaseHasActiveTask(questHolocron, phaseString) ) { int phaseNum = incrementActivePhaseNum(questHolocron); if ( phaseNum > 0 ) { handlePhaseActived(questHolocron, phaseNum); return; } } return; } // --------------------------------------------------------------------- void handlePhaseActived(obj_id questHolocron, int phaseNum) { string phaseString = getPhaseObjVarString(phaseNum); for ( int i = 0; i < PGC_QUEST_MAX_NUM_TASKS_PER_PHASE; i++) { string taskString = getTaskObjVarString(i); string baseObjVar = getPgcBaseObjVar(phaseString, taskString); if ( hasObjVar(questHolocron, baseObjVar) ) { handleTaskActived(questHolocron, phaseNum, i); } else { break; } } return; } // --------------------------------------------------------------------- void handleTaskActived(obj_id questHolocron, int phaseNum, int taskNum) { string phaseString = getPhaseObjVarString(phaseNum); string taskString = getTaskObjVarString(taskNum); obj_id player = getQuestPlayer(questHolocron); if ( isIdValid(player) ) { string taskName = getTaskName(questHolocron, phaseString, taskString); if ( taskName.length() <= 0 ) { taskName = phaseString + " - " + taskString; } // Activating the task //sendSystemMessage(player, "Task Activated: "+taskName, ""); string_id taskActivatedMsg = new string_id ("saga_system","holocron_task_activated"); prose_package pp_title = prose.getPackage(taskActivatedMsg, player, player); prose.setTO(pp_title, taskName); sendSystemMessageProse(player, pp_title); string_id taskDescMsg = new string_id ("saga_system","holocron_task_active_desc"); prose_package pp_desc = prose.getPackage(taskDescMsg, player, player); prose.setTO(pp_desc, getTaskDescription(questHolocron, phaseString, taskString)); sendSystemMessageProse(player, pp_desc); string baseObjVar = getPgcBaseObjVar(phaseString, taskString); string relicName = getRelicName(questHolocron, phaseString, taskString); string[] relicData = getCollectionSlotCategoryInfo(relicName); dictionary waypointData = getWaypointObjVarTaskData(questHolocron, baseObjVar, "waypoint"); if ( waypointData == null || waypointData.isEmpty() ) { waypointData = getWaypointRelicData("waypoint", relicData); } location waypointLoc = null; string waypointName = ""; if ( waypointData != null && !waypointData.isEmpty() ) { waypointLoc = waypointData.getLocation("waypointLoc"); waypointName = waypointData.getString("waypointName"); } if ( waypointLoc != null && waypointName.length() > 0 ) { obj_id waypoint = createWaypointInDatapad(player, waypointLoc); setWaypointName(waypoint, waypointName); activatePlayerQuestWaypoint(player, waypoint); setObjVar(questHolocron, baseObjVar + ".waypointActive", waypoint); } string taskType = getTaskType(questHolocron, phaseString, taskString); if ( taskType != null && taskType.length() > 0 ) { if ( taskType.equals(SAGA_COMM_MESSAGE) ) { handleCommMessageTaskActivated(questHolocron, phaseString, taskString); } else if ( taskType.equals(SAGA_GOTO_LOCATION) ) { if ( waypointLoc != null ) { handleGoToLocationTaskActivated(questHolocron, phaseString, taskString, waypointLoc); } } } } return; } // --------------------------------------------------------------------- float getDestroyTaskWeight(int taskLevel, int taskDifficulty, int taskCounterMax) { float weight = 1.0f; // levelMod = 1 - 5 int levelMod = taskLevel/20 + 2; if ( levelMod > 5 ) { levelMod = 5; } int counterMod = 0; if ( taskDifficulty == 2 ) { counterMod = 2; } else if ( taskCounterMax > 4 && taskCounterMax <= 10 ) { counterMod = 1; } else if ( taskCounterMax > 10 ) { counterMod = 2; } //taskDifficulty = 0(normal), 1(elite), or 2(boss) int difficultyMod = counterMod + taskDifficulty + 1; weight = (float)(levelMod + difficultyMod)/2; // 1 - 5 //obj_id player = getSelf(); //sendSystemMessage(player, "levelMod = "+levelMod+" counterMod = "+counterMod+" difficultyMod = "+difficultyMod+" weight = "+weight, ""); return weight; } float getDestroyLootTaskWeight(int taskLevel, int taskDifficulty, int taskCounterMax, int dropRate) { float weight = 1.0f; // levelMod = 1 - 5 int levelMod = taskLevel/20 + 2; if ( levelMod > 5 ) { levelMod = 5; } float dropRateFraction = dropRate/100; int percentageBasedTaskCounter = (int)(taskCounterMax / dropRateFraction); int counterMod = 0; if ( taskDifficulty == 2 ) { counterMod = 2; } else if ( percentageBasedTaskCounter > 4 && percentageBasedTaskCounter <= 10 ) { counterMod = 1; } else if ( percentageBasedTaskCounter > 10 ) { counterMod = 2; } //taskDifficulty = 0(normal), 1(elite), or 2(boss) int difficultyMod = counterMod + taskDifficulty + 1; weight = (float)(levelMod + difficultyMod)/2; // 1 - 5 //obj_id player = getSelf(); //sendSystemMessage(player, "levelMod = "+levelMod+" counterMod = "+counterMod+" difficultyMod = "+difficultyMod+" weight = "+weight, ""); return weight; } float getPerformTaskWeight(int taskLevel) { float weight = 1.0f; // levelMod = 1 - 5 int levelMod = taskLevel/20 + 2; if ( levelMod > 5 ) { levelMod = 5; } weight = levelMod; return weight; } float getCraftingTaskWeight(int taskLevel, int taskCounterMax) { float weight = 1.0f; // levelMod = 1 - 5 int levelMod = taskLevel/20 + 2; if ( levelMod > 5 ) { levelMod = 5; } int counterMod = 0; if ( taskCounterMax > 3 && taskCounterMax <= 6 ) { counterMod = 1; } else if ( taskCounterMax > 6 && taskCounterMax <= 10 ) { counterMod = 3; } else if ( taskCounterMax > 10 ) { counterMod = 5; } weight = (float)(levelMod + counterMod)/2; return weight; } float getCommTaskWeight(int taskLevel) { float weight = 0.0f; return weight; } float getGoToTaskWeight(int taskLevel) { float weight = 0.5f; return weight; } float getRetrieveTaskWeight(int taskLevel, int taskCounterMax) { float weight = 1.0f; // levelMod = 1 - 5 int levelMod = taskLevel/20 + 2; if ( levelMod > 5 ) { levelMod = 5; } int counterMod = 0; if ( taskCounterMax > 4 && taskCounterMax <= 10 ) { counterMod = 1; } else if ( taskCounterMax > 10 ) { counterMod = 3; } weight = (float)(levelMod + counterMod)/2; return weight; } float getPvpTaskWeight(int taskLevel, int taskCounterMax) { float weight = 1.0f; // levelMod = 1 - 5 int levelMod = taskLevel/20 + 2; if ( levelMod > 5 ) { levelMod = 5; } int counterMod = 0; if ( taskCounterMax > 4 && taskCounterMax <= 10 ) { counterMod = 1; } else if ( taskCounterMax > 10 ) { counterMod = 3; } weight = (float)(levelMod + counterMod)/2; return weight; } float calculateQuestWeight(float[] taskWeightArray) { int numTasks = taskWeightArray.length; Arrays.sort(taskWeightArray); int offset = 0; if ( numTasks > 3 && numTasks <=7 ) offset = 1; else if ( numTasks > 7 ) offset = 2; float questWeight = 0.0f; for ( int i = offset; i < taskWeightArray.length; i++ ) { questWeight += taskWeightArray[i]; } questWeight = questWeight; return questWeight; } // --------------------------------------------------------------------- float calculateTaskTypeDiversity(dictionary taskTypes, int numTasks) { float questTaskTypeDiversity = 0; float numDifferentTaskTypes = taskTypes.size(); if ( numTasks > 0 ) questTaskTypeDiversity = numDifferentTaskTypes / numTasks; return questTaskTypeDiversity; } float calculateRelicDiversity(dictionary relicNames, int numTasks) { float questRelicDiversity = 0; float numDifferentRelics = relicNames.size(); int offset = 0; if ( numTasks > 3 && numTasks <=7 ) offset = 1; else if ( numTasks > 7 ) offset = 2; int numDiversityTasks = numTasks - offset; if ( numDiversityTasks > 0 ) questRelicDiversity = numDifferentRelics / numDiversityTasks; if ( questRelicDiversity > 1 ) questRelicDiversity = 1; return questRelicDiversity; } // --------------------------------------------------------------------- int calculateHolocronCreationChroniclesXp(float questWeight, float questRelicDiversity, float questTaskTypeDiversity) { if ( questWeight < 1.0f ) { questWeight = 1.0f; } // scale the questWeight by the relic diversity (0 to 1) int xp = (int)(CHRONICLE_CREATION_XP_BASE * questWeight * questRelicDiversity); // add bonus of up to 1% based on task type diversity xp += xp * questTaskTypeDiversity * 0.01; return xp; } // --------------------------------------------------------------------- int calculateHolocronQuestCompletedChroniclesXp(obj_id questHolocron, int rating) { float questWeight = getFloatObjVar(questHolocron, pgc_quests.PCG_QUEST_WEIGHT_OBJVAR); float questRelicDiversity = getFloatObjVar(questHolocron, pgc_quests.PCG_QUEST_RELIC_DIVERSITY); float questTaskTypeDiversity = getFloatObjVar(questHolocron, pgc_quests.PCG_QUEST_TASK_TYPE_DIVERSITY); if ( questWeight < 1.0f ) { questWeight = 1.0f; } // scale the questWeight by the relic diversity (0 to 1) int xp = (int)(CHRONICLE_SHARED_XP_BASE * questWeight * questRelicDiversity); // add bonus of up to 1% based on task type diversity xp += xp * questTaskTypeDiversity * 0.01; // add bonus of up to xp += xp * (rating/2.5) *0.03; return xp; } // --------------------------------------------------------------------- int grantChronicleXp(obj_id player, int xpAmount) { string[] chronicleSkills = skill_template.getSkillTemplateSkillsByTemplateName(pgc_quests.PGC_CHRONICLES_XP_TYPE); if ( chronicleSkills != null && chronicleSkills.length > 0 ) { string finalChronicleSkill = chronicleSkills[chronicleSkills.length - 1]; if ( hasSkill(player, finalChronicleSkill) ) { return 0; } xpAmount = getConfigModifiedChroniclesXPAmount(xpAmount); xpAmount = xp.grant(player, PGC_CHRONICLES_XP_TYPE, xpAmount); showPgcXpGrantedMessage(player, PGC_CHRONICLES_XP_TYPE, xpAmount); messageTo(player, "handleCheckForGainedChroniclesLevelDelay", null, 1, false); } return xpAmount; } int getConfigModifiedChroniclesXPAmount(int xpAmount) { string configMod_string = getConfigSetting("GameServer", "chroniclesXpModifier"); if ( configMod_string != null && configMod_string.length() > 0 ) { float configMod = utils.stringToFloat(configMod_string); if ( configMod > 0 ) { xpAmount *= configMod; } } return xpAmount; } void checkForGainedChroniclesLevel(obj_id player) { string[] chronicleSkills = skill_template.getSkillTemplateSkillsByTemplateName(pgc_quests.PGC_CHRONICLES_XP_TYPE); if ( chronicleSkills != null && chronicleSkills.length > 0 ) { string currentChronicleSkill = chronicleSkills[0]; string nextChronicleSkill = ""; int nextChronicleSkillIndex = -1; for ( int i = 0; i < chronicleSkills.length; i++ ) { if ( hasSkill(player, chronicleSkills[i]) ) { currentChronicleSkill = chronicleSkills[i]; } else { nextChronicleSkill = chronicleSkills[i]; nextChronicleSkillIndex = i; break; } } boolean hasRequiredSkills = skill.hasRequiredSkillsForSkillPurchase(player, nextChronicleSkill); boolean hasRequiredXp = skill.hasRequiredXpForSkillPurchase(player, nextChronicleSkill); reportChronicleXPRequiredForNextSkill(player, nextChronicleSkill); if( hasRequiredSkills && hasRequiredXp ) { if ( nextChronicleSkill.length() > 0 ) { grantSkill(player, nextChronicleSkill); showFlyText(player, new string_id("cbt_spam", "level_up_chronicles"), 2.5f, colors.GOLDENROD); playClientEffectObj(player, "clienteffect/level_granted_chronicles.cef", player, null); string_id skillGainMsg = new string_id ("saga_system","chronicles_skill_gained"); prose_package pp_title = prose.getPackage(skillGainMsg, player, player); prose.setTO(pp_title, new string_id ("skl_n", nextChronicleSkill)); sendSystemMessageProse(player, pp_title); grantChroniclesRoadmapItem(player, nextChronicleSkill, nextChronicleSkillIndex); // CS Log pgc_quests.logProgression(player, obj_id.NULL_ID, "Chronicles Profession Level Up! Skill granted: "+nextChronicleSkill); } } } return; } void reportChronicleXPRequiredForNextSkill(obj_id player, string skillName) { if ( isGod(player) && questGetDebugging() ) { dictionary xpReqs = getSkillPrerequisiteExperience(skillName); if ( xpReqs != null && !xpReqs.isEmpty() ) { java.util.Enumeration e = xpReqs.keys(); while ( e.hasMoreElements() ) { string xpType = (string)(e.nextElement()); int xpCost = xpReqs.getInt(xpType); int curXP = getExperiencePoints(player, xpType); sendSystemMessage(player, "[God Mode] For xpType = "+xpType+", player has "+curXP+" of "+xpCost, ""); } } } return; } boolean grantChroniclesRoadmapItem(obj_id player, string skillName, int skillIndex) { boolean success = false; string[] chronicleSkills = skill_template.getSkillTemplateSkillsByTemplateName(pgc_quests.PGC_CHRONICLES_XP_TYPE); if ( chronicleSkills != null && chronicleSkills.length > 0 ) { // initialize the array of granted rewards int[] getGrantedRewardsArray = new int[chronicleSkills.length]; for ( int q = 0; q < chronicleSkills.length; q++ ) { getGrantedRewardsArray[q] = -1; } // if they have the objvar with a pre-existing array, use that if ( hasObjVar(player, PGC_GRANTED_ROADMAP_REWARDS_OBJVAR) ) { getGrantedRewardsArray = getIntArrayObjVar(player, PGC_GRANTED_ROADMAP_REWARDS_OBJVAR); } int alreadyHasReward = getGrantedRewardsArray[skillIndex]; if ( alreadyHasReward <= -1 ) { string skillTemplate = "chronicles"; string itemGrant = skill_template.getRoadmapItem(player, skillTemplate, skillName); if ( itemGrant == null || itemGrant.equals("") ) { getGrantedRewardsArray[skillIndex] = 0; setObjVar(player, PGC_GRANTED_ROADMAP_REWARDS_OBJVAR, getGrantedRewardsArray); return false; } string[] items = split(itemGrant, ','); if ( items == null || items.length == 0 ) return false; resizeable obj_id[] allNewObjectsResizable = new obj_id[0]; for ( int i = 0; i < items.length; i++ ) { obj_id newItem = null; if ( items[i].endsWith(".iff") ) { newItem = createObjectInInventoryAllowOverload(items[i], player); } else { newItem = static_item.createNewItemFunction(items[i], player); } if ( !isIdValid(newItem) ) { LOG("roadmap", "ERROR - Could not create roadmap item ("+items[i]+")"); } else { utils.addElement(allNewObjectsResizable, newItem); // CS Log string newItemName = ""; if ( static_item.isStaticItem(newItem) ) { newItemName = getStaticItemName(newItem); } else { newItemName = getTemplateName(newItem); } pgc_quests.logProgression(player, obj_id.NULL_ID, "Chronicles Roadmap Reward Granted! Item granted to "+player+": "+newItem+" ("+newItemName+")."); } } if ( allNewObjectsResizable != null && allNewObjectsResizable.length > 0 ) { getGrantedRewardsArray[skillIndex] = getCalendarTime(); string_id itemDesc = utils.unpackString(skill_template.getRoadmapItemDesc(skillTemplate, skillName)); prose_package pp = prose.getPackage(new string_id("base_player", "skill_template_item_reward"), itemDesc); sendSystemMessageProse(player, pp); obj_id[] allNewObjects = allNewObjectsResizable; showLootBox(player, allNewObjects); success = true; } } else { if ( isGod(player) ) { sendSystemMessage(player, "[God Mode]: Already received this reward.", ""); } } setObjVar(player, PGC_GRANTED_ROADMAP_REWARDS_OBJVAR, getGrantedRewardsArray); } return success; } // --------------------------------------------------------------------- void setQuestComplete(obj_id questHolocron) { obj_id questControlDevice = getContainedBy(questHolocron); if ( isIdValid(questControlDevice) && getTemplateName(questControlDevice).equals(PGC_QUEST_CONTROL_DEVICE_TEMPLATE) ) { obj_id player = getQuestPlayer(questHolocron); if( isIdValid(player) ) { if ( clearQuestHolocron(questControlDevice, player) ) { if ( isPlayerQuestRecipe(questHolocron) ) { resetQuestHolocron(questHolocron, player); } else { setObjVar(questHolocron, PCG_QUEST_COMPLETE_OBJVAR, player); setOwner(questHolocron, player); int chroniclerStationId = getIntObjVar(questHolocron, pgc_quests.PCG_QUEST_CREATOR_STATIONID_OBJVAR); if ( chroniclerStationId == getPlayerStationId(player) ) { setObjVar(questHolocron, pgc_quests.PCG_QUEST_WAS_RATED_OBJVAR, -1); sendDirtyObjectMenuNotification(questHolocron); } else { showQuestRatingUI(questHolocron, player); } //hue.setColor(questHolocron, 1, pgc_quests.COMPLETED_HOLOCRON_HUE); string name = getAssignedName(questHolocron); setName(questHolocron, "[Completed] "+name); pgc_quests.grantPgcNonChroniclesQuestXp(player, questHolocron); int tokenCount = pgc_quests.getNumQuestCompleteQuestorRewardTokens(player, questHolocron); obj_id token = pgc_quests.grantSilverChroniclesRewardTokens(player, tokenCount); float questWeight = getFloatObjVar(questHolocron, pgc_quests.PCG_QUEST_WEIGHT_OBJVAR); // CS Log logReward(player, questHolocron, "Silver Tokens awared ("+tokenCount+") for completing a quest of weight="+questWeight); // Storing quest completion data for quests completed by the player pgcAdjustRatingData(player, getName(player), pgc_quests.PGC_NUM_QUESTS_YOU_COMPLETED_ALL_INDEX, 1); if ( questWeight >= pgc_quests.PGC_MIN_MID_QUALITY_QUEST_WEIGHT && questWeight < pgc_quests.PGC_MIN_HIGH_QUALITY_QUEST_WEIGHT ) { pgcAdjustRatingData(player, getName(player), pgc_quests.PGC_NUM_QUESTS_YOU_COMPLETED_MID_QUALITY_INDEX, 1); } else if ( questWeight >= pgc_quests.PGC_MIN_HIGH_QUALITY_QUEST_WEIGHT ) { pgcAdjustRatingData(player, getName(player), pgc_quests.PGC_NUM_QUESTS_YOU_COMPLETED_HIGH_QUALITY_INDEX, 1); } // for any quest over mid-quality, give a chance to win a gold token // as long as you aren't running your own quest if ( questWeight >= pgc_quests.PGC_MIN_MID_QUALITY_QUEST_WEIGHT && !isCompletingYourOwnChronicleQuest(player, questHolocron) ) { int goldTokenChance = CHRONICLES_QUESTOR_GOLD_TOKEN_CHANCE; string configChance_string = getConfigSetting("GameServer", "chroniclesQuestorGoldTokenChanceOverride"); if ( configChance_string != null && configChance_string.length() > 0 ) { int configChance = utils.stringToInt(configChance_string); if ( configChance > 0 ) { goldTokenChance = configChance; } } int goldTokenRoll = rand(1, 100); if ( goldTokenRoll <= goldTokenChance ) { grantGoldChroniclesRewardTokens(player, 1); showFlyText(player, new string_id("saga_system", "bonus_gold_token"), 2.0f, colors.GOLDENROD); // CS Log logReward(player, questHolocron, "Gold Token awared for completing a quest of weight="+questWeight); } } } play2dNonLoopingSound(player, groundquests.MUSIC_QUEST_COMPLETED); string questName = getQuestName(questHolocron); string_id message = new string_id ("saga_system","holocron_quest_complete"); prose_package pp = prose.getPackage(message, player, player); prose.setTO(pp, questName); sendSystemMessageProse(player, pp); // CS Log int currentTime = getCalendarTime(); setObjVar(questHolocron, pgc_quests.PCG_QUEST_COMPLETED_TIME, currentTime); string timeToCompleteQuest = utils.formatTimeVerbose(currentTime - getIntObjVar(questHolocron, pgc_quests.PCG_QUEST_ACTIVATED_TIME)); pgc_quests.logQuest(player, questHolocron, "Quest completed after "+timeToCompleteQuest+"."); destroyObject(questControlDevice); } } } } void grantPgcNonChroniclesQuestXp(obj_id player, obj_id questHolocron) { int questLevel = getIntObjVar(questHolocron, pgc_quests.PCG_QUEST_LEVEL_OBJVAR); obj_id questCreatorObjId = getObjIdObjVar(questHolocron, PCG_QUEST_CREATOR_ID_OBJVAR); int questCreatorStationId = getIntObjVar(questHolocron, PCG_QUEST_CREATOR_STATIONID_OBJVAR); float questWeight = getFloatObjVar(questHolocron, PCG_QUEST_WEIGHT_OBJVAR); pgc_quests.grantPgcNonChroniclesQuestXp(player, questLevel, questWeight, questCreatorObjId, questCreatorStationId); return; } void grantPgcNonChroniclesQuestXp(obj_id player, int questLevel, float questWeight, obj_id questCreatorObjId, int questCreatorStationId) { float xpWeight = questWeight * 0.5f; if ( xpWeight < 5.0f ) { xpWeight = 5.0f; } else if ( xpWeight > 25.0f ) { xpWeight = 25.0f; } int xpAmount = (int)(groundquests.getQuestExperienceReward(player, questLevel, 1, 0) * xpWeight); int playerStationId = getPlayerStationId(player); if ( playerStationId == questCreatorStationId ) { xpAmount *= 0.5; } string template = getSkillTemplate(player); string xpType = xp.QUEST_COMBAT; if(template.startsWith("trader")) { xpAmount = xp.grantCraftingQuestXp(player, xpAmount); xpType = xp.QUEST_CRAFTING; } else if(template.startsWith("entertainer")) { xpAmount = xp.grantSocialStyleXp(player, xp.QUEST_SOCIAL, xpAmount); xpType = xp.QUEST_SOCIAL; } else { xpAmount = xp.grantCombatStyleXp(player, xp.QUEST_COMBAT, xpAmount); xpType = xp.QUEST_COMBAT; } xp.displayXpFlyText(player, player, xpAmount);//xp flies off your own head! //showPgcXpGrantedMessage(player, xpType, xpAmount); return; } void showPgcXpGrantedMessage(obj_id player, string xpType, int xpAmount) { float grpMod = 1f; if(utils.hasScriptVar(player, "combat.xp.groupBonus")) { grpMod = utils.getFloatScriptVar(player, "combat.xp.groupBonus"); } float inspMod = xp.getInspirationBuffXpModifier(player, xpType); prose_package pp = xp.getXpProsePackage(xpType, xpAmount, grpMod, inspMod); if( pp != null ) { sendQuestSystemMessage(player, pp); } return; } int getNumQuestCompleteChroniclerRewardTokens(obj_id questHolocron) { obj_id questCreatorObjId = getObjIdObjVar(questHolocron, PCG_QUEST_CREATOR_ID_OBJVAR); int questCreatorStationId = getIntObjVar(questHolocron, PCG_QUEST_CREATOR_STATIONID_OBJVAR); float questWeight = getFloatObjVar(questHolocron, PCG_QUEST_WEIGHT_OBJVAR); float relicTypeDiversity = getFloatObjVar(questHolocron, PCG_QUEST_RELIC_DIVERSITY); int count = 1; count = (int) ((float) (count + (questWeight * relicTypeDiversity)) * CHRONICLE_SILVER_TOKENS_FOR_CHRONICLER_MOD); string tokenNumMod_string = getConfigSetting("GameServer", "chroniclesChroniclerSilverTokenNumModifier"); if ( tokenNumMod_string != null && tokenNumMod_string.length() > 0 ) { float tokenNumMod = utils.stringToFloat(tokenNumMod_string); if ( tokenNumMod > 0 ) { count *= tokenNumMod; } } return count; } int getNumQuestCompleteQuestorRewardTokens(obj_id player, obj_id questHolocron) { if ( isCompletingYourOwnChronicleQuest(player, questHolocron) ) { return 0; } float questWeight = getFloatObjVar(questHolocron, PCG_QUEST_WEIGHT_OBJVAR); float relicTypeDiversity = getFloatObjVar(questHolocron, PCG_QUEST_RELIC_DIVERSITY); int count = 1; count = (int) ((float) (count + (questWeight * relicTypeDiversity)) * CHRONICLE_SILVER_TOKENS_FOR_QUESTOR_MOD); string tokenNumMod_string = getConfigSetting("GameServer", "chroniclesQuestorSilverTokenNumModifier"); if ( tokenNumMod_string != null && tokenNumMod_string.length() > 0 ) { float tokenNumMod = utils.stringToFloat(tokenNumMod_string); if ( tokenNumMod > 0 ) { count *= tokenNumMod; } } return count; } obj_id grantSilverChroniclesRewardTokens(obj_id player, int count) { return grantChroniclesRewardTokens(player, count, PGC_CHRONICLES_SILVER_TOKEN); } obj_id grantGoldChroniclesRewardTokens(obj_id player, int count) { return grantChroniclesRewardTokens(player, count, PGC_CHRONICLES_GOLD_TOKEN); } obj_id grantChroniclesRewardTokens(obj_id player, int count, string tokenType) { obj_id token = obj_id.NULL_ID; if ( count > 0 ) { obj_id inventory = utils.getInventoryContainer(player); // static_item.createNewItemFunction only allows a count of 500 or less, // so we have to make tokens in blocks of 500 or less. They will autostack. for ( int i = count; i > 0; i = i - 500 ) { int tempCount = 500; if ( i < 500 ) { tempCount = i; } token = static_item.createNewItemFunction(tokenType, inventory, tempCount); } pgc_quests.sendPlacedInInventorySystemMessage(player, token, count); } return token; } boolean isCompletingYourOwnChronicleQuest(obj_id player, obj_id questHolocron) { int questCreatorStationId = getIntObjVar(questHolocron, PCG_QUEST_CREATOR_STATIONID_OBJVAR); int playerStationId = getPlayerStationId(player); if ( playerStationId == questCreatorStationId ) { return true; } return false; } // --------------------------------------------------------------------- void sendPlacedInInventorySystemMessage(obj_id player, obj_id objectPlaced, int count) { if ( isValidId(objectPlaced) ) { string_id name = getNameStringId(objectPlaced); prose_package pp = prose.getPackage(new string_id("saga_system", "placed_in_inventory_count"), player, player); prose.setTO(pp, name); prose.setDI(pp, count); sendSystemMessageProse(player, pp); } } // --------------------------------------------------------------------- void sendPlacedInInventorySystemMessage(obj_id player, obj_id objectPlaced) { if ( isValidId(objectPlaced) ) { prose_package pp = null; string_id name = getNameStringId(objectPlaced); pp = prose.getPackage(new string_id("saga_system", "placed_in_inventory"), name); sendQuestSystemMessage(player, pp); } } // --------------------------------------------------------------------- void showQuestRatingUI(obj_id questHolocron, obj_id player) { string questName = getQuestName(questHolocron); openRatingWindow(player, "Chronicle Rating", "Please rate this quest: "+questName); utils.setScriptVar(player, "chronicles.rating_a_holocron", questHolocron); return; } // --------------------------------------------------------------------- float getCurrentPgcRating(int ratingTotal, int ratingCount) { return getCurrentPgcRating( (float)ratingTotal, (float)ratingCount); } // --------------------------------------------------------------------- float getCurrentPgcRating(float ratingTotal, float ratingCount) { float tempNumber = (ratingTotal/ratingCount) * 10; int result = (int)Math.round(tempNumber); float finalValue = (float)result/10; return finalValue; } // --------------------------------------------------------------------- void showChroniclerRatingTable(obj_id player, string name, obj_id[] chroniclers) { if ( chroniclers != null && chroniclers.length > 0 ) { string [][] data = new string[chroniclers.length][4]; for ( int i = 0; i < chroniclers.length; i++ ) { obj_id chroniclerId = chroniclers[i]; string chroniclerName = pgcGetChroniclerName(chroniclerId); if ( chroniclerName == null || chroniclerName.length() <= 0 ) { chroniclerName = name; } data[i][0] = chroniclerName; int[] chroniclerRating = pgcGetRating(chroniclerId); if ( chroniclerRating != null && chroniclerRating.length > 0 ) { int ratingTotal = chroniclerRating[PGC_INFO_INDEX_TOTAL_RATING_VALUE]; int ratingCount = chroniclerRating[PGC_INFO_INDEX_TOTAL_RATING_COUNT]; int lastRatedTime = chroniclerRating[PGC_INFO_INDEX_MOST_RECENT_RATING_TIME]; if ( ratingTotal > 0 ) { data[i][1] = "" + pgc_quests.getCurrentPgcRating(ratingTotal, ratingCount); data[i][2] = "" + ratingCount; data[i][3] = utils.formatTimeVerbose(getCalendarTime() - lastRatedTime); } else { data[i][1] = "" + 0.0; data[i][2] = "" + 0; data[i][3] = "Not Yet Rated"; } } else { data[i][1] = "" + 0.0; data[i][2] = "" + 0; data[i][3] = "Not Yet Rated"; } } string title = name + " Chronicle Ratings"; string [] colTitles = {"Chronicler Name", "Rating", "Number of Times Rated", "Time Since Last Rating"}; string [] colTypes = {"text", "float", "integer", "text"}; int id = sui.table(player, player, sui.OK_CANCEL, title, "tableHandler", null, colTitles, colTypes, data, true, false); } else { sendSystemMessage(player, new string_id ("saga_system","pgc_rating_chronicler_not_found")); } return; } boolean isEligiblePgcReward(obj_id rewardItem) { if ( !canTrade(rewardItem) ) { return false; } if ( hasScript(rewardItem, "item.special.nomove") ) { return false; } obj_id biolink = getBioLink(rewardItem); if ( isIdValid(biolink) && biolink != utils.OBJ_ID_BIO_LINK_PENDING ) { return false; } if ( static_item.isStaticItem (rewardItem) ) { if ( static_item.isUniqueStaticItem(rewardItem) ) { return false; } } if ( utils.isContainer(rewardItem) ) { obj_id[] itemContents = getContents(rewardItem); if ( itemContents != null && itemContents.length > 0 ) { return false; } } if ( jedi.isCrystalTuned(rewardItem) ) { return false; } return true; } // --------------------------------------------------------------------- void setQuestAbandoned(obj_id questControlDevice, obj_id player) { string questName = "Unknown"; string timeToCompleteQuest = "Unknown"; obj_id questHolocron = getQuestHolocronFromQCD(questControlDevice); if ( isIdValid(questHolocron) ) { questName = pgc_quests.getQuestName(questHolocron); int currentTime = getCalendarTime(); timeToCompleteQuest = utils.formatTimeVerbose(currentTime - getIntObjVar(questHolocron, pgc_quests.PCG_QUEST_ACTIVATED_TIME)); removeObjVar(questHolocron, pgc_quests.PCG_QUEST_ACTIVATED_TIME); } if ( clearQuestHolocron(questControlDevice, player) ) { string_id message = new string_id ("saga_system","qcd_quest_abandoned"); prose_package pp = prose.getPackage(message, player, player); prose.setTO(pp, questName); sendSystemMessageProse(player, pp); // CS Log pgc_quests.logQuest(player, questHolocron, "Quest Abandoned after "+timeToCompleteQuest+" time active."); destroyObject(questControlDevice); } return; } // --------------------------------------------------------------------- void initializeQuestTasksStatus(obj_id questHolocron, int numTasks) { for ( int q = 0; q < numTasks; q++ ) { int status = pgc_quests.PQ_TASK_INACTIVE; if ( q == 0 ) { status = pgc_quests.PQ_TASK_ACTIVE; } setPlayerQuestTaskStatus(questHolocron, q, status); } } // --------------------------------------------------------------------- void resetQuestHolocron(obj_id questHolocron, obj_id player) { if ( hasObjVar(questHolocron, PCG_QUEST_COMPLETE_OBJVAR) ) { // if the quest has been completed, do nothing. return; } for ( int i = 0; i < PGC_QUEST_MAX_NUM_TASKS; i++ ) { string phaseString = getPhaseObjVarString(i); if ( hasObjVar(questHolocron, phaseString) ) { for ( int j = 0; j < PGC_QUEST_MAX_NUM_TASKS_PER_PHASE; j++) { string taskString = getTaskObjVarString(j); string baseObjVar = getPgcBaseObjVar(phaseString, taskString); if ( hasObjVar(questHolocron, baseObjVar) ) { int taskIndex = getIntObjVarTaskData(questHolocron, baseObjVar, "task_index"); if ( hasObjVar(questHolocron, baseObjVar + ".task_complete") ) { removeObjVar(questHolocron, baseObjVar + ".task_complete"); } if ( hasObjVar(questHolocron, baseObjVar + ".current_count") ) { removeObjVar(questHolocron, baseObjVar + ".current_count"); setPlayerQuestTaskCounter(questHolocron, taskIndex, 0); } setPlayerQuestTaskStatus(questHolocron, taskIndex, pgc_quests.PQ_TASK_COMPLETE); removePlayerQuestWaypoint(questHolocron, baseObjVar); } else { break; } } } else { break; } } setObjVar(questHolocron, pgc_quests.PCG_QUEST_CUR_QUEST_PHASE_OBJVAR, 0); messageTo(questHolocron, "handleQuestHolocronInitializeTaskStatus", null, 1, false); return; } // --------------------------------------------------------------------- // --------------------------------------------------------------------- void addRelicToQuestBuilder(obj_id player, obj_id relic, boolean addEntireStack) { if( !utils.isNestedWithin(relic, player) ) { return; } string relicData = getStringObjVar(relic, pgc_quests.PGC_RELIC_SLOT_DATA_OBJVAR); string[] splitSlotNames = split(relicData, ':'); string slotName = splitSlotNames[1]; string collectionName = splitSlotNames[0]; string staticItemName = getStaticItemName(relic); if ( !canUseRelic(player, relic, slotName, collectionName, true) ) { sendSystemMessage(player, new string_id("saga_system", "relic_consume_fail_lower_level")); return; } //Check to make sure they havent completed the collection yet. if( !hasCompletedCollection(player, collectionName) ) { //check to see if they already have this slot completed if( !hasCompletedCollectionSlot(player, slotName) && !slotName.equals("") ) { int targetCount = 1; int actualCount = 0; long relicSlotValue = getCollectionSlotValue(player, slotName); int stackCount = getCount(relic); if ( addEntireStack && stackCount > 0) { targetCount = stackCount; } if ( relicSlotValue <= 0 ) { targetCount += 1; } for ( int i = 1; i <= targetCount; i++ ) { if( modifyCollectionSlotValue(player, slotName, 1) ) { if ( relicSlotValue <= 0 && i == 1 ) { } else { decrementCount(relic); actualCount += 1; } if ( hasCompletedCollectionSlot(player, slotName) ) { sendSystemMessage(player, new string_id("saga_system", "relic_count_added_to_max")); break; } } else { //tell the player we failed sendSystemMessage(player, new string_id("saga_system", "relic_report_consume_item_fail")); // CS Log pgc_quests.logRelic(player, obj_id.NULL_ID, "Chronicle Relic "+staticItemName+"(slot: "+slotName+") had bad data and was unable to be add to their relic collection ("+collectionName+")."); return; } } prose_package pp = prose.getPackage(new string_id("saga_system", "relic_consume_success"), relic, relic); prose.setTO(pp, new string_id("collection_n", slotName)); prose.setDI(pp, actualCount); sendSystemMessageProse(player, pp); // CS Log pgc_quests.logRelic(player, obj_id.NULL_ID, "Player added Chronicle Relic "+staticItemName+"(slot: "+slotName+" x "+actualCount+") to their relic collection ("+collectionName+")."); } else { //tell the player They have already finished all collections for this item sendSystemMessage(player, new string_id("saga_system", "relic_count_at_max")); // CS Log pgc_quests.logRelic(player, obj_id.NULL_ID, "Player attempted to add "+staticItemName+"(slot: "+slotName+") to their relic collection ("+collectionName+"), but that relic is already at max amount."); } } else { //tell the player They have already finished the collection sendSystemMessage(player, new string_id("saga_system", "relic_count_at_max")); // CS Log pgc_quests.logRelic(player, obj_id.NULL_ID, "Player attempted to add "+staticItemName+"(slot: "+slotName+") to their relic collection, but they have already maxed out every single available relic of this type, "+collectionName+"."); } return; } boolean canUseRelic(obj_id player, obj_id relic, string slotName, string collectionName, boolean isVerbose) { int relicQualitySkillmod = getEnhancedSkillStatisticModifierUncapped(player, pgc_quests.PGC_SKILLMOD_RELIC_QUALITY); string staticItemName = getStaticItemName(relic); dictionary row = dataTableGetRow(storyteller.STORYTELLER_DATATABLE, staticItemName); int relic_tier = row.getInt("relic_tier"); if ( relic_tier > relicQualitySkillmod ) { if ( isVerbose ) { if ( !isGod(player) ) { // CS Log pgc_quests.logRelic(player, obj_id.NULL_ID, "Player attempted to add "+staticItemName+"(slot: "+slotName+") to their relic collection ("+collectionName+"), but they were not high enough level (player tier = "+relicQualitySkillmod+"; relic tier = "+relic_tier+")."); return false; } else { sendSystemMessage(player, "[GOD_MODE] Bypassing relic quality check, which you failed...", ""); } } } return true; } // --------------------------------------------------------------------- // --------------------------------------------------------------------- string getStringPgcTaskData(obj_id questHolocron, string baseObjVar, string category, string[] relicData) { string taskData = getStringObjVarTaskData(questHolocron, baseObjVar, category); if ( taskData.length() < 1 ) { taskData = getStringRelicData(category, relicData); } return taskData; } string getStringObjVarTaskData(obj_id questHolocron, string baseObjVar, string category) { string taskData = ""; string dataObjVar = baseObjVar + "." + category; if ( hasObjVar(questHolocron, dataObjVar) ) { taskData = getStringObjVar(questHolocron, dataObjVar); } return taskData; } string getStringRelicData(string category, string[] relicData) { return parseRelicData(category, relicData); } // --------------------------------------------------------------------- int getIntPgcTaskData(obj_id questHolocron, string baseObjVar, string category, string[] relicData) { int taskData = getIntObjVarTaskData(questHolocron, baseObjVar, category); if ( taskData < 0 ) { taskData = getIntRelicData(category, relicData); } return taskData; } int getIntObjVarTaskData(obj_id questHolocron, string baseObjVar, string category) { int taskData = -1; string dataObjVar = baseObjVar + "." + category; if ( hasObjVar(questHolocron, dataObjVar) ) { taskData = getIntObjVar(questHolocron, dataObjVar); } return taskData; } int getIntRelicData(string category, string[] relicData) { return utils.stringToInt(parseRelicData(category, relicData)); } // --------------------------------------------------------------------- dictionary getWaypointObjVarTaskData(obj_id questHolocron, string baseObjVar, string category) { string waypointLocObjVar = baseObjVar + "." + category; if ( hasObjVar(questHolocron, waypointLocObjVar) ) { dictionary waypointData = new dictionary(); location waypointLoc = getLocationObjVar(questHolocron, waypointLocObjVar); string waypointName = "Unknown"; string waypointNameObjVar = baseObjVar + "." + "waypointName"; if ( hasObjVar(questHolocron, waypointNameObjVar) ) { waypointName = getStringObjVar(questHolocron, waypointNameObjVar); } if ( waypointLoc != null ) { waypointData.put("waypointLoc", waypointLoc); waypointData.put("waypointName", waypointName); return waypointData; } } return null; } dictionary getWaypointRelicData(string category, string[] relicData) { if ( relicData != null && relicData.length > 0 ) { for ( int i = 0; i < relicData.length; i++ ) { string relicCategory = relicData[i]; if ( relicCategory.startsWith(category) ) { string[] parse = split(relicCategory, ':'); string baseData = parse[1]; if ( baseData != null && baseData.length() > 0 ) { string[] waypointParse = split(baseData, ','); if ( waypointParse.length == 6 ) { string planet = waypointParse[0]; float x = utils.stringToFloat(waypointParse[1]); float y = utils.stringToFloat(waypointParse[2]); float z = utils.stringToFloat(waypointParse[3]); string cellName = waypointParse[4]; string waypointName = waypointParse[5]; dictionary waypointData = new dictionary(); location waypointLoc = new location(x, y, z, planet); waypointData.put("waypointLoc", waypointLoc); waypointData.put("waypointName", waypointName); return waypointData; } } } } } return null; } // --------------------------------------------------------------------- obj_id getObjIdRelicData(string category, string[] relicData) { return utils.stringToObjId(parseRelicData(category, relicData)); } // --------------------------------------------------------------------- string_id getStringIdRelicData(string category, string[] relicData) { string stringData = parseRelicData(category, relicData); string[] parse = split(stringData, ','); return new string_id(parse[0], parse[1]); } // --------------------------------------------------------------------- string parseRelicData(string category, string[] relicData) { string data = ""; if ( relicData != null && relicData.length > 0 ) { for ( int i = 0; i < relicData.length; i++ ) { string relicCategory = relicData[i]; if ( relicCategory.startsWith(category) ) { string[] parse = split(relicCategory, ':'); data = parse[1]; if ( parse.length > 2 ) { data += ","+parse[2]; } break; } } } return data; } // --------------------------------------------------------------------- // --------------------------------------------------------------------- void checkForKillTaskCredit(obj_id questHolocron, string taskType, string phaseString, string taskString, dictionary params) { obj_id player = getQuestPlayer(questHolocron); if( !isIdValid(player) ) return; string killedCreatureType = params.getString("creatureName"); string killedCreatureSocialGroup = params.getString("socialGroup"); location creatureLoc = params.getLocation("location"); float distance = getDistance(player, creatureLoc); if (distance == -1.0f || distance > xp.MAX_DISTANCE) return; string baseObjVar = getPgcBaseObjVar(phaseString, taskString); string relicName = getRelicName(questHolocron, phaseString, taskString); string[] relicData = getCollectionSlotCategoryInfo(relicName); string targetCreatureNamesList = getStringPgcTaskData(questHolocron, baseObjVar, "creature_name", relicData); string targetSocialGroupList = getStringPgcTaskData(questHolocron, baseObjVar, "social_group", relicData); int targetCount = getIntPgcTaskData(questHolocron, baseObjVar, "count", relicData); boolean creatureAcceptable = false; if( targetCreatureNamesList != null && killedCreatureType != null ) { string[] targetCreatureNamesArray = split(targetCreatureNamesList, ','); if ( targetCreatureNamesArray != null && targetCreatureNamesArray.length > 0 ) { for ( int i = 0; i < targetCreatureNamesArray.length; i++ ) { string targetCreatureName = targetCreatureNamesArray[i]; if ( killedCreatureType.equals(targetCreatureName) ) { creatureAcceptable = true; } } } } if( targetSocialGroupList != null && killedCreatureSocialGroup != null ) { string[] socialGroupsNamesArray = split(targetSocialGroupList, ','); if ( socialGroupsNamesArray != null && socialGroupsNamesArray.length > 0 ) { for ( int i = 0; i < socialGroupsNamesArray.length; i++ ) { string targetSocialGroup = socialGroupsNamesArray[i]; if ( killedCreatureSocialGroup.equals(targetSocialGroup) ) { creatureAcceptable = true; } } } } if ( creatureAcceptable ) { if ( taskType.equals(SAGA_DESTROY_MULTIPLE) ) { handleDestroyMultipleKill(questHolocron, phaseString, taskString, targetCount); } else if ( taskType.equals(SAGA_DESTROY_MULTIPLE_LOOT) ) { handleDestroyMultipleLootKill(questHolocron, phaseString, taskString, targetCount, relicData); } } return; } // --------------------------------------------------------------------- void handleDestroyMultipleKill(obj_id questHolocron, string phaseString, string taskString, int targetCount) { string baseObjVar = getPgcBaseObjVar(phaseString, taskString); int currentCount = incrementTaskCounter(questHolocron, baseObjVar); obj_id player = getQuestPlayer(questHolocron); if( isIdValid(player) ) { sendSystemMessage(player, getQuestName(questHolocron) + ": Target killed! "+ currentCount+"/"+targetCount, ""); play2dNonLoopingSound(player, groundquests.MUSIC_QUEST_INCREMENT_COUNTER); } if ( currentCount >= targetCount ) { setTaskComplete(questHolocron, phaseString, taskString); } return; } // --------------------------------------------------------------------- void handleDestroyMultipleLootKill(obj_id questHolocron, string phaseString, string taskString, int targetCount, string[] relicData) { obj_id player = getQuestPlayer(questHolocron); if( isIdValid(player) ) { string baseObjVar = getPgcBaseObjVar(phaseString, taskString); int dropRate = getIntPgcTaskData(questHolocron, baseObjVar, "drop_rate", relicData); int roll = rand (1, 100); if(roll <= dropRate ) { string message_string = getStringObjVarTaskData(questHolocron, baseObjVar, "message"); if ( message_string != null && message_string.length() > 0 ) { sendSystemMessage(player, message_string, ""); } else { string_id message_sid = getStringIdRelicData("message", relicData); sendSystemMessage(player, message_sid); } int currentCount = incrementTaskCounter(questHolocron, baseObjVar); play2dNonLoopingSound(player, groundquests.MUSIC_QUEST_INCREMENT_COUNTER); if ( currentCount >= targetCount ) { setTaskComplete(questHolocron, phaseString, taskString); } } else { sendSystemMessage(player, getQuestName(questHolocron) + ": Nothing Found.", ""); } } return; } // --------------------------------------------------------------------- void handlePvpPlayerKillCredit(obj_id questHolocron, string taskType, string phaseString, string taskString, dictionary params) { obj_id player = getQuestPlayer(questHolocron); if( !isIdValid(player) ) return; int killedPlayerRank = params.getInt("victimRank"); string baseObjVar = getPgcBaseObjVar(phaseString, taskString); string relicName = getRelicName(questHolocron, phaseString, taskString); string[] relicData = getCollectionSlotCategoryInfo(relicName); int targetRank = getIntPgcTaskData(questHolocron, baseObjVar, "rank_value", relicData); if ( killedPlayerRank >= targetRank ) { int targetCount = getIntPgcTaskData(questHolocron, baseObjVar, "count", relicData); int currentCount = incrementTaskCounter(questHolocron, baseObjVar); sendSystemMessage(player, getQuestName(questHolocron) + ": PvP Target defeated! "+ currentCount+"/"+targetCount, ""); play2dNonLoopingSound(player, groundquests.MUSIC_QUEST_INCREMENT_COUNTER); if ( currentCount >= targetCount ) { setTaskComplete(questHolocron, phaseString, taskString); } } return; } // --------------------------------------------------------------------- void handleCommMessageTaskActivated(obj_id questHolocron, string phaseString, string taskString) { obj_id player = getQuestPlayer(questHolocron); if ( isIdValid(player) ) { string baseObjVar = getPgcBaseObjVar(phaseString, taskString); string relicName = getRelicName(questHolocron, phaseString, taskString); string[] relicData = getCollectionSlotCategoryInfo(relicName); string message_string = getStringObjVarTaskData(questHolocron, baseObjVar, "message"); prose_package pp = new prose_package (); if ( message_string != null && message_string.length() > 0 ) { string_id message_base = new string_id ("saga_system","holocron_string_message"); pp = prose.getPackage(message_base, player, player); prose.setTO(pp, message_string); } else { pp.stringId = getStringIdRelicData("message", relicData); } string voiceOver = getStringRelicData("voice_over", relicData); if ( voiceOver != null && voiceOver.length() > 0 ) { play2dNonLoopingSound(player, voiceOver); } string appearance = getStringPgcTaskData(questHolocron, baseObjVar, "appearance", relicData); if ( appearance.equals("message_box") ) { showChroniclesMessageBox(player, questHolocron, pp, phaseString, taskString); } else { commPlayerQuest(questHolocron, player, pp, appearance); dictionary webster = new dictionary(); webster.put("phaseString", phaseString); webster.put("taskString", taskString); messageTo(questHolocron, "handleCommMessageTaskCompletion", webster, COMM_TASK_COMPLETION_DELAY, false); } //setTaskComplete(questHolocron, phaseString, taskString); } return; } void showChroniclesMessageBox(obj_id player, obj_id questHolocron, prose_package pp, string phaseString, string taskString) { string messageBoxTitle = getTaskName(questHolocron, phaseString, taskString); string messageBoxText = ""; prose.setTT(pp, getName(player)); messageBoxText ="\0" + packOutOfBandProsePackage(null, pp); int messageBoxSizeWidth = 384; int messageBoxSizeHeight = 256; int messageBoxLocationX = 320; int messageBoxLocationY = 256; int pageId = sui.createSUIPage(sui.SUI_MSGBOX, questHolocron, player, "ChroniclesMessageBoxCompleted"); //do not save the position and size settings for this window sui.setAutosaveProperty(pageId, false); //size sui.setSizeProperty(pageId, messageBoxSizeWidth, messageBoxSizeHeight); //location sui.setLocationProperty(pageId, messageBoxLocationX, messageBoxLocationY); setSUIProperty(pageId, sui.MSGBOX_TITLE, sui.PROP_TEXT, messageBoxTitle); setSUIProperty(pageId, sui.MSGBOX_PROMPT, sui.PROP_TEXT, messageBoxText); sui.msgboxButtonSetup(pageId, sui.OK_ONLY); sui.showSUIPage(pageId); utils.setScriptVar(questHolocron, getPhaseStringVarName(pageId, "message_box"), phaseString); utils.setScriptVar(questHolocron, getTaskStringVarName(pageId, "message_box"), taskString); return; } string getPhaseStringVarName(int pageId, string taskType) { return taskType + ".phaseString." + pageId; } string getTaskStringVarName(int pageId, string taskType) { return taskType + ".taskString." + pageId; } // --------------------------------------------------------------------- void handleGoToLocationTaskActivated(obj_id questHolocron, string phaseString, string taskString, location targetLoc) { obj_id player = getQuestPlayer(questHolocron); if ( isIdValid(player) ) { string baseObjVar = getPgcBaseObjVar(phaseString, taskString); string relicName = getRelicName(questHolocron, phaseString, taskString); string[] relicData = getCollectionSlotCategoryInfo(relicName); int radius = getIntPgcTaskData(questHolocron, baseObjVar, "radius", relicData); dictionary webster = new dictionary(); webster.put("targetLoc", targetLoc); webster.put("radius", radius); webster.put("locationTargetName", relicName); messageTo(player, "playerQuestSetLocationTarget", webster, 1, false); } return; } // --------------------------------------------------------------------- /** @brief Chronicles log * * Generate a chronicles specific customer service log * * @param player The object id of the player. If null then no player information will be put in the log. * @param questHolcron The object id of the quest holocron. If null then no quest information will be put in the log. * @param category The name of the category of the log. This will become the filename. * @param text The text output to the log. This is application specific. */ void log(obj_id player, obj_id questHolocron, string category, string text) { if (category.length() > 0 && text.length() > 0) { string playerInfo = ""; if (isIdValid(player)) playerInfo = "player=(" + player + "," + getName(player) + "," + getPlayerStationId(player) + ") "; string questInfo = "" ; if (isIdValid(questHolocron)) { obj_id chroniclerId = getObjIdObjVar(questHolocron, PCG_QUEST_CREATOR_ID_OBJVAR); string chroniclerName = getStringObjVar(questHolocron, PCG_QUEST_CREATOR_NAME_OBJVAR); string questName = getPlayerQuestTitle(questHolocron); string holocronType = "Chronicles Holocron"; if ( isPlayerQuestRecipe(questHolocron) ) holocronType = "Chronicles Draft"; if ( isSharedPlayerQuestObject(questHolocron) ) holocronType = "Shared Chronicles Holocron"; questInfo = holocronType+" quest=(" + questHolocron + "," + chroniclerId + "," + chroniclerName + "," + questName + ") "; } CustomerServiceLog(category, playerInfo + questInfo + text); } } // --------------------------------------------------------------------- /** @brief Chronicles Progression log * * Use this to log information on progression like chronicles xp, skills earned, etc. * * @param player The object id of the player. If null then no player information will be put in the log. * @param questHolcron The object id of the quest holocron. If null then no quest information will be put in the log. * @param text The text output to the log. This is application specific. */ void logProgression(obj_id player, obj_id questHolocron, string text) { log(player, questHolocron, "chronicles_progression", text); } // --------------------------------------------------------------------- /** @brief Chronicles Reward log * * Use this to log information on rewards like fragments or tokens received. * * @param player The object id of the player. If null then no player information will be put in the log. * @param questHolcron The object id of the quest holocron. If null then no quest information will be put in the log. * @param text The text output to the log. This is application specific. */ void logReward(obj_id player, obj_id questHolocron, string text) { log(player, questHolocron, "chronicles_reward", text); } // --------------------------------------------------------------------- /** @brief Chronicles Quest log * * Use this to log information on quest status, completion, abandonment, sharing, creation, etc. * * @param player The object id of the player. If null then no player information will be put in the log. * @param questHolcron The object id of the quest holocron. If null then no quest information will be put in the log. * @param text The text output to the log. This is application specific. */ void logQuest(obj_id player, obj_id questHolocron, string text) { log(player, questHolocron, "chronicles_quest", text); } // --------------------------------------------------------------------- /** @brief Chronicles Relic log * * Use this to log information on relics like boosters, deconstruction, reconstruction, etc. * * @param player The object id of the player. If null then no player information will be put in the log. * @param questHolcron The object id of the quest holocron. If null then no quest information will be put in the log. * @param text The text output to the log. This is application specific. */ void logRelic(obj_id player, obj_id questHolocron, string text) { log(player, questHolocron, "chronicles_relic", text); } // --------------------------------------------------------------------- /** @brief Chronicles Rating log * * Use this to log information on rating stats like rejected, ratings, etc. * * @param player The object id of the player. If null then no player information will be put in the log. * @param questHolcron The object id of the quest holocron. If null then no quest information will be put in the log. * @param text The text output to the log. This is application specific. */ void logRating(obj_id player, obj_id questHolocron, string text) { log(player, questHolocron, "chronicles_rating", text); } // ---------------------------------------------------------------------