include library.badge; include library.buff; include library.callable; include library.factions; include library.group; include library.instance; include library.locations; include library.prose; include library.skill; include library.static_item; include library.sui; include library.trial; include library.utils; trigger OnHearSpeech(obj_id speaker, string text) { 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; } trigger OnUnsticking() { 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; } trigger OnDuelRequest(obj_id actor, obj_id target) { 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; } trigger OnLogin() { 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; } trigger OnClusterWideDataResponse(string manage_name, string name, int request_id, string[] element_name_list, dictionary[] data, int lock_key) { 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++) { if (!isIdValid(members[i]) || !exists(members[i])) { continue; } if (!isPlayer(members[i]) || members[i] == self) { continue; } concatenatedAtrocity += getUnflaggedInstancesString(members[i]); concatenatedAtrocity += "\n"; } } } return concatenatedAtrocity; } // Compare player objvars against instance datatable and return a single line comma seperated list. string getUnflaggedInstancesString(obj_id player) { string[] instanceList = new string[dataTableGetNumRows(instance.INSTANCE_DATATABLE)]; int numNotFlagged = 0; string unflaggedInstancesString = getString(new string_id("instance", "gold")); unflaggedInstancesString += getFirstName(player) + ": "; string instancesString = ""; // List of unflagged instances. May be empty. string preambleString = ""; // 'Not flagged for:' or 'Flagged for All' for(int i = 0; i < instanceList.length; i++) { 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 += ", "; //omgunlocalizedcommalol } 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; } string getRaidId(string time, string instance, string owner) { 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; } string getPassedId(resizeable string[] listId, string instance_name) { if (listId == null || listId.length == 0) { return ""; } for (int i=0;i 1) { count = (int)((float)count * (float)multiplier); // Precision lost. } if(tokenIndex < 0 || tokenIndex >= 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); //determine if they get the echo base champion badge if(tokenIndex == 5 && count == 9) { badge.grantBadge(self, "champion_of_hoth"); obj_id[] rewards = new obj_id[1]; //grant the flawless painting reward. rewards[0] = static_item.createNewItemFunction("item_hoth_flawless_painting", inventory); showLootBox(self, rewards); setObjVar(self, "hoth.flawless_reward", 1); } return SCRIPT_CONTINUE; } messageHandler instanceFailureMessage() { 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; } commandHandler requestInstance() { 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; } messageHandler delayInstanceRequest() { string instance_name = params.getString("instance_name"); instance.requestInstanceMovement(self, instance_name); return SCRIPT_CONTINUE; } //right now this is just used to clear the scriptvar stamped on the pilot //when attempting to enter the star destroyer instance. //It can be used more in the future to remove any scriptvar that starts with "instance." messageHandler clearInstanceScriptVar() { utils.removeScriptVarTree(self, "instance"); return SCRIPT_CONTINUE; }