package script.player; import script.*; import script.base_class.*; import script.combat_engine.*; import java.util.Arrays; import java.util.Hashtable; import java.util.Vector; import script.base_script; import script.library.badge; import script.library.buff; import script.library.callable; import script.library.factions; import script.library.group; import script.library.instance; import script.library.locations; import script.library.prose; import script.library.skill; import script.library.static_item; import script.library.sui; import script.library.trial; import script.library.utils; public class player_instance extends script.base_script { public player_instance() { } public int OnHearSpeech(obj_id self, obj_id speaker, String text) throws InterruptedException { if (!isGod(self)) { return SCRIPT_CONTINUE; } String[] parse = split(text, ' '); if (parse.length < 2) { return SCRIPT_CONTINUE; } if (parse[0].equals("instanceRequest") && speaker == self) { if (parse.length == 3) { instance.requestInstanceMovement(self, parse[1], parse[2]); } else if (parse.length == 4) { instance.requestInstanceMovement(self, parse[1], utils.stringToInt(parse[2]), parse[3]); } else { instance.requestInstanceMovement(self, parse[1]); } } if (parse[0].equals("closeInstance") && speaker == self) { instance.closeOwnedInstance(self, parse[1]); } if (parse[0].equals("exitInstance") && speaker == self) { instance.requestExitPlayer(parse[1], self); } return SCRIPT_CONTINUE; } public int OnUnsticking(obj_id self) throws InterruptedException { obj_id instanceController = instance.getAreaInstanceController(self); if (hasScript(self, "npe.trigger_journal") && hasObjVar(self, "npe")) { location myLoc = getLocation(self); if (myLoc.area.equals("dungeon1")) { String room = getCellName(myLoc.cell); if (room.equals("cave_entrance")) { warpPlayer(self, "dungeon1", 0.0f, 0.0f, 0.0f, myLoc.cell, 7.10f, 9.5f, 6.5f); return SCRIPT_OVERRIDE; } } } if (isIdValid(instanceController)) { String instanceName = instance.getInstanceName(instanceController); instance.requestExitPlayer(instanceName, self); return SCRIPT_CONTINUE; } return SCRIPT_CONTINUE; } public int OnDuelRequest(obj_id self, obj_id actor, obj_id target) throws InterruptedException { if (instance.isInInstanceArea(actor) || instance.isInInstanceArea(target)) { sendConsoleMessage(actor, "Dueling is not permitted here"); sendConsoleMessage(target, "Dueling is not permitted here"); return SCRIPT_OVERRIDE; } return SCRIPT_CONTINUE; } public int OnLogin(obj_id self) throws InterruptedException { String area_name = locations.getBuildoutAreaName(self); int area_row = locations.getBuildoutAreaRow(self); obj_id planet = getPlanetByName(getLocation(self).area); String instance_controller = ""+area_name+"_"+area_row; obj_id areaInstanceController = utils.hasScriptVar(planet, instance_controller) ? utils.getObjIdScriptVar(planet, instance_controller) : null; if (!instance.isInInstanceArea(self)) { return SCRIPT_CONTINUE; } if (!isIdValid(areaInstanceController)) { doLogging("OnLogin", "Could not locate instance controller"); return SCRIPT_CONTINUE; } dictionary dict = new dictionary(); dict.put("player", self); messageTo(areaInstanceController, "validatePlayer", dict, 1.0f, false); return SCRIPT_CONTINUE; } public int OnClusterWideDataResponse(obj_id self, String manage_name, String name, int request_id, String[] element_name_list, dictionary[] data, int lock_key) throws InterruptedException { CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+")recieved trigger"); int requestType = instance.getInstanceRequestType(self); CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+")'s requestType is "+ requestType); int team = instance.getInstanceRequestTeam(self); CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+")'s team is "+ team); if (requestType == instance.REQUEST_MOVETO && team != instance.REQUEST_INVALID) { CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+")'s requestType was "+instance.REQUEST_MOVETO+" and team was not "+instance.REQUEST_INVALID); if (data == null || data.length == 0 || !manage_name.startsWith("instance_manager")) { CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+")'s dictionary 'data' was null, or manage name didnt start with 'instance_manager'. Releasing lock and dieing here."); CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+")'s manage_name was "+manage_name+" and instance name was "+name+"."); doLogging("Insufficient Data. Manage name = "+manage_name +", instance name = "+name); releaseClusterWideDataLock(manage_name, lock_key); instance.setRequestResolved(self); return SCRIPT_CONTINUE; } int emptyInstance = -1; String instance_name = ""; CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-about to start looping thru player "+self+"("+getPlayerName(self)+")'s dictionary 'data' passed from the trigger."); for (int i=0; i -1) { CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-we had an empty instance ("+data[emptyInstance]+") for player "+self+"("+getPlayerName(self)+")."); dictionary newDict = data[emptyInstance]; CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-calling movePlayerToInstance("+self+", "+newDict.getObjId("instance_id")+", "+newDict.getString("instance_name")+", "+newDict.getObjId("owner")+", true, "+team+") for player "+self+"("+getPlayerName(self)+")."); instance.movePlayerToInstance(self, newDict.getObjId("instance_id"), newDict.getString("instance_name"), newDict.getObjId("owner"), true, team); newDict.put("owner", self); newDict.put("team", team); String strName = newDict.getString("instance_name"); obj_id objName = newDict.getObjId("instance_id"); name = strName+"_"+objName; String groupList = ""+self; CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+")'s new groupList is "+ groupList); if (team == 1) { CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+") assigning new list to group1"); newDict.put("groupOne", groupList); } if (team == 2) { CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+") assigning new list to group2"); newDict.put("groupTwo", groupList); } CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-calling replaceClusterWideData("+manage_name+", "+name+", "+newDict+", true, "+lock_key+") for player "+self+"("+getPlayerName(self)+")."); replaceClusterWideData(manage_name, name, newDict, true, lock_key); releaseClusterWideDataLock(manage_name, lock_key); instance.setRequestResolved(self); return SCRIPT_CONTINUE; } else { sendSystemMessage(self, new string_id("instance", "all_full")); } } if (requestType == instance.REQUEST_CLOSE) { CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+")'s requestType was "+instance.REQUEST_CLOSE+"."); if (data == null || data.length == 0 || !manage_name.startsWith("instance_manager")) { CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-player "+self+"("+getPlayerName(self)+")'s dictionary 'data' was null, or manage name didnt start with 'instance_manager'. Releasing lock and dieing here."); doLogging("Insufficient Data. Manage name = "+manage_name +", instance name = "+name); releaseClusterWideDataLock(manage_name, lock_key); instance.setRequestResolved(self); return SCRIPT_CONTINUE; } CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "OnClusterWideDataResponse-about to start looping thru player "+self+"("+getPlayerName(self)+")'s dictionary 'data' passed from the trigger."); for (int i=0; i 0) { addSUIDataItem(pid, sui.LISTBOX_DATASOURCE, ""+ idx); setSUIProperty(pid, sui.LISTBOX_DATASOURCE + "."+ idx, sui.PROP_TEXT, "Group Members In Range"); idx++; for (int i=0; i 0) { for (int i = 0; i < members.length; i++) { testAbortScript(); if (!isIdValid(members[i]) || !exists(members[i])) { continue; } if (!isPlayer(members[i]) || members[i] == self) { continue; } concatenatedAtrocity += getUnflaggedInstancesString(members[i]); concatenatedAtrocity += "\n"; } } } return concatenatedAtrocity; } public String getUnflaggedInstancesString(obj_id player) throws InterruptedException { String[] instanceList = new String[dataTableGetNumRows(instance.INSTANCE_DATATABLE)]; int numNotFlagged = 0; String unflaggedInstancesString = getString(new string_id("instance", "gold")); unflaggedInstancesString += getFirstName(player) + ": "; String instancesString = ""; String preambleString = ""; for (int i = 0; i < instanceList.length; i++) { testAbortScript(); String thisInstance = dataTableGetString(instance.INSTANCE_DATATABLE, i, "key_required"); if (thisInstance.equals("none")) { continue; } if (!hasObjVar(player, "instance_player_protected_data." + thisInstance)) { if (numNotFlagged > 0) { instancesString += ", "; } instancesString += getString(new string_id("instance", thisInstance)); numNotFlagged++; } } if (numNotFlagged == 0) { preambleString += getString(new string_id ("instance", "flagging_all_flags")); } else { preambleString += getString(new string_id("instance", "flagging_not_flagged_for")); } unflaggedInstancesString += preambleString + instancesString; return unflaggedInstancesString; } public String getRaidId(String time, String instance, String owner) throws InterruptedException { String subTime = time.substring(time.length() -3, time.length()); String subInstance = instance.substring(instance.length() - 3, instance.length()); String subOwner = owner.substring(owner.length() -3,owner.length()); return subTime + subInstance + subOwner; } public String getPassedId(Vector listId, String instance_name) throws InterruptedException { if (listId == null || listId.size() == 0) { return ""; } for (int i=0; i= trial.HEROIC_TOKENS.length) { sendSystemMessageTestingOnly(self, "DEBUG: handleAwardtoken sent with out of range tokenIndex."); return SCRIPT_CONTINUE; } obj_id inventory = utils.getInventoryContainer(self); obj_id token = static_item.createNewItemFunction(trial.HEROIC_TOKENS[tokenIndex], inventory, count); prose_package pp = new prose_package(); if (count > 1) { pp = prose.setStringId(pp, new string_id("set_bonus", "recieve_heroic_token_multi")); } else { pp = prose.setStringId(pp, new string_id("set_bonus", "recieve_heroic_token")); } pp = prose.setDI(pp, count); pp = prose.setTT(pp, new string_id("static_item_n", trial.HEROIC_TOKENS[tokenIndex])); sendSystemMessageProse(self, pp); if (tokenIndex == 5 && count == 9) { badge.grantBadge(self, "champion_of_hoth"); obj_id[] rewards = new obj_id[1]; rewards[0] = static_item.createNewItemFunction("item_hoth_flawless_painting", inventory); showLootBox(self, rewards); setObjVar(self, "hoth.flawless_reward", 1); } return SCRIPT_CONTINUE; } public int instanceFailureMessage(obj_id self, dictionary params) throws InterruptedException { if (params == null || params.isEmpty()) { CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "instanceFailureMessage-has a null params exiting handler."); return SCRIPT_CONTINUE; } int reason = params.getInt("fail_reason"); CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "instanceFailureMessage-params.fail_reason was "+ reason + "."); switch(reason) { case instance.FAIL_INSTANCE_FULL: sendSystemMessage(self, new string_id("instance", "fail_instance_full")); break; case instance.FAIL_NOT_MEMBER: sendSystemMessage(self, new string_id("instance", "fail_not_member")); break; case instance.INSTANCE_TIMEOUT: sendSystemMessage(self, new string_id("instance", "instance_time_out")); break; case instance.FAIL_INVALID_LOCKOUT: sendSystemMessage(self, new string_id("instance", "fail_invalid_lockout")); break; case instance.FAIL_INSTANCE_CLOSED: sendSystemMessageTestingOnly(self, "The instance you are attempting to enter is currently inactive"); break; case instance.FAIL_INSTANCE_FEW_PLAYERS: sendSystemMessage(self, new string_id("instance", "fail_under_player_limit")); break; case instance.FAIL_WARN_TOO_FEW: int limit = params.getInt("player_low_limit"); prose_package pp = new prose_package(); pp = prose.setStringId(pp, new string_id("instance", "fail_under_player_limit_warning")); pp = prose.setDI(pp, limit); sendSystemMessageProse(self, pp); break; default: CustomerServiceLog(instance.INSTANCE_DEBUG_LOG, "instanceFailureMessage-switch statement reached the default case this means no system message to player and we died."); break; } return SCRIPT_CONTINUE; } public int requestInstance(obj_id self, obj_id target, String params, float defaultTime) throws InterruptedException { obj_id enterObject = getFirstObjectWithObjVar(getLocation(trial.getTop(self)), 1000.0f, "instance_name"); if (!isIdValid(enterObject)) { sendSystemMessageTestingOnly(self, "No object in range"); return SCRIPT_CONTINUE; } String instance_name = getStringObjVar(enterObject, "instance_name"); instance.requestInstanceMovement(self, instance_name); return SCRIPT_CONTINUE; } public int delayInstanceRequest(obj_id self, dictionary params) throws InterruptedException { String instance_name = params.getString("instance_name"); instance.requestInstanceMovement(self, instance_name); return SCRIPT_CONTINUE; } public int clearInstanceScriptVar(obj_id self, dictionary params) throws InterruptedException { utils.removeScriptVarTree(self, "instance"); return SCRIPT_CONTINUE; } }