private void OnPreconditionEval(Object p_sender, EventArgs p_args) { PreconditionEvaluateArgs preconditionEvaluateArgs = p_args as PreconditionEvaluateArgs; if (preconditionEvaluateArgs == null) { return; } if (preconditionEvaluateArgs.Passed || preconditionEvaluateArgs.Cancelled) { return; } String text = String.Empty; Boolean flag = false; Int32 num = 0; PartyCheckPrecondition partyCheckPrecondition = p_sender as PartyCheckPrecondition; if (partyCheckPrecondition != null && partyCheckPrecondition.Decision == EPreconditionDecision.NONE && partyCheckPrecondition.RequiredTokenID > 0) { flag = true; num = partyCheckPrecondition.RequiredTokenID; } Boolean flag2 = false; Boolean flag3 = false; Boolean flag4 = false; Position position = LegacyLogic.Instance.WorldManager.Party.Position; GridSlot slot = LegacyLogic.Instance.MapLoader.Grid.GetSlot(position); IEnumerable <InteractiveObject> interactiveObjectIterator = slot.GetInteractiveObjectIterator(); foreach (InteractiveObject interactiveObject in interactiveObjectIterator) { if (interactiveObject is Door || interactiveObject is Container || interactiveObject is Lever) { if (interactiveObject != m_lastInteractiveObject) { if (interactiveObject is Door) { Door door = (Door)interactiveObject; if (flag && m_lastInteractiveObject == door) { flag3 = true; break; } if (door.State == EInteractiveObjectState.DOOR_OPEN || !door.Enabled) { flag3 = true; break; } foreach (SpawnCommand spawnCommand in interactiveObject.Commands) { if (spawnCommand.Precondition != "NONE" && !spawnCommand.Precondition.Contains("SECRET_CHALLENGE") && !spawnCommand.Precondition.Contains("PLAIN")) { String[] array = spawnCommand.Precondition.Split(new Char[] { ',' }); if (array[4] == String.Empty) { Int32 num2 = 0; if (array[5] != String.Empty && Int32.TryParse(array[5], out num2) && num2 > 0 && num2 != num) { flag4 = true; break; } if (flag && (m_lastInteractiveObject == null || m_lastInteractiveObject != door)) { m_lastInteractiveObject = door; } flag2 = true; break; } } } text = LocaManager.GetText("DOOR_KEY_FAIL_TEXT"); } else if (interactiveObject is Container) { if (interactiveObject.State == EInteractiveObjectState.CONTAINER_OPENED) { flag3 = true; break; } foreach (SpawnCommand spawnCommand2 in interactiveObject.Commands) { if (spawnCommand2.Type == EInteraction.OPEN_CONTAINER && spawnCommand2.Precondition != "NONE" && partyCheckPrecondition.RequiredTokenID > 0) { String[] array2 = spawnCommand2.Precondition.Split(new Char[] { ',' }); if (array2[4] == String.Empty) { Int32 num3 = 0; if (array2[5] != String.Empty && Int32.TryParse(array2[5], out num3) && num3 > 0 && num3 != num) { flag4 = true; break; } } text = LocaManager.GetText("CHEST_KEY_FAIL_TEXT"); flag3 = false; flag2 = true; flag4 = false; m_lastInteractiveObject = interactiveObject; break; } } if (!String.IsNullOrEmpty(text) || flag4) { break; } } else if (interactiveObject is Lever) { if (interactiveObject.State == EInteractiveObjectState.LEVER_DOWN) { flag3 = true; break; } foreach (SpawnCommand spawnCommand3 in interactiveObject.Commands) { if ((spawnCommand3.Type == EInteraction.LEVER_DOWN || spawnCommand3.Type == EInteraction.LEVER_UP) && spawnCommand3.Precondition != "NONE" && partyCheckPrecondition.RequiredTokenID > 0) { String[] array3 = spawnCommand3.Precondition.Split(new Char[] { ',' }); if (array3[4] == String.Empty) { Int32 num4 = 0; if (array3[5] != String.Empty && Int32.TryParse(array3[5], out num4) && num4 > 0 && num4 != num) { flag4 = true; break; } } text = LocaManager.GetText("LEVER_GEAR_FAIL_TEXT"); flag3 = false; flag2 = true; flag4 = false; m_lastInteractiveObject = interactiveObject; break; } } if (!String.IsNullOrEmpty(text) || flag4) { break; } } } } } if (flag3) { return; } if (!flag2) { return; } if (flag4) { return; } if (String.IsNullOrEmpty(text)) { return; } if (m_lastInteractiveObject != null) { LegacyLogic.Instance.EventManager.RegisterEvent(EEventType.MOVE_ENTITY, new EventHandler(OnMoveEntity)); InputManager.RegisterHotkeyEvent(EHotkeyType.INTERACT, new EventHandler <HotkeyEventArgs>(OnInteractHotkeyPressed)); } GameMessage item = new GameMessage(text); m_importantMessages.Enqueue(item); }
protected internal static BasePrecondition ParsePrecondition(String p_precondition) { if (p_precondition == "NONE" || p_precondition == String.Empty) { return(null); } String[] array = p_precondition.Split(new Char[] { ',' }); if (array[0] == "NONE") { return(null); } BasePrecondition basePrecondition = null; String maintext = String.Empty; String successText = String.Empty; String failText = String.Empty; String text = String.Empty; EPotionTarget attribute = EPotionTarget.NONE; Int32 requiredValue = 0; EPreconditionDecision epreconditionDecision = (EPreconditionDecision)Enum.Parse(typeof(EPreconditionDecision), array[1]); maintext = array[2]; if (epreconditionDecision == EPreconditionDecision.TEXT_INPUT && array.Length > 5) { text = array[5]; } if (epreconditionDecision == EPreconditionDecision.WHO_WILL && array.Length > 5) { attribute = (EPotionTarget)Enum.Parse(typeof(EPotionTarget), array[5]); requiredValue = Convert.ToInt32(array[6]); } if (array[0] == "PLAIN") { basePrecondition = new PlainPrecondition(); } else { successText = array[3]; failText = array[4]; } if (array[0] == "SELECT_CHARACTER") { basePrecondition = new SelectCharacterPrecondition(); } if (array[0] == "TEST") { if (array.Length != 7) { throw new FormatException(String.Concat(new Object[] { "Could not parse precondition params ", p_precondition, " because it contains ", array.Length, " arguments instead of ", 7 })); } basePrecondition = new TestPrecondition { Attribute = attribute, RequiredValue = requiredValue, SuccessText = successText, FailText = failText }; } if (array[0] == "CHALLENGE") { if (array.Length != 8 && array.Length != 7) { throw new FormatException(String.Concat(new Object[] { "Could not parse precondition params ", p_precondition, " because it contains ", array.Length, " arguments instead of ", 8 })); } if (array.Length == 8) { basePrecondition = new ChallengePrecondition { Attribute = attribute, RequiredValue = requiredValue, SuccessText = successText, FailText = failText, Damage = Convert.ToInt32(array[7]) }; } else { basePrecondition = new ChallengePrecondition { Attribute = attribute, RequiredValue = requiredValue, SuccessText = successText, FailText = failText, Damage = 0 }; } } if (array[0] == "SECRET_CHALLENGE") { if (array.Length != 8) { throw new FormatException(String.Concat(new Object[] { "Could not parse precondition params ", p_precondition, " because it contains ", array.Length, " arguments instead of ", 8 })); } basePrecondition = new SecretChallengePrecondition { Attribute = attribute, RequiredValue = requiredValue, SuccessText = successText, FailText = failText, Damage = Convert.ToInt32(array[7]) }; } if (array[0] == "DISARM_TRAP") { if (array.Length != 7) { throw new FormatException(String.Concat(new Object[] { "Could not parse precondition params ", p_precondition, " because it contains ", array.Length, " arguments instead of ", 7 })); } basePrecondition = new DisarmTrapPrecondition { Attribute = attribute, RequiredValue = requiredValue, SuccessText = successText, FailText = failText }; } if (array[0] == "INPUT") { if (array.Length != 6) { throw new FormatException(String.Concat(new Object[] { "Could not parse precondition params ", p_precondition, " because it contains ", array.Length, " arguments instead of ", 6 })); } basePrecondition = new InputPrecondition { WantedInput = text, SuccessText = successText, FailText = failText }; } if (array[0] == "UNLOCK_KEY") { if (array.Length != 6) { throw new FormatException(String.Concat(new Object[] { "Could not parse precondition params ", p_precondition, " because it contains ", array.Length, " arguments instead of ", 6 })); } Int32 wantedPrivilege = 0; if (text != String.Empty) { wantedPrivilege = Int32.Parse(text, CultureInfo.InvariantCulture.NumberFormat); } basePrecondition = new UnlockKeyPrecondition { WantedPrivilege = wantedPrivilege, SuccessText = successText, FailText = failText }; } if (array[0] == "PARTY_CHECK") { if (array.Length != 13 && array.Length != 10 && array.Length != 9 && array.Length != 8) { throw new FormatException(String.Concat(new Object[] { "Could not parse precondition params ", p_precondition, " because it contains ", array.Length, " arguments instead of ", 13 })); } if (array.Length > 5) { basePrecondition = new PartyCheckPrecondition { SuccessText = successText, FailText = failText, RequiredTokenID = Convert.ToInt32(array[5]), RequiredBlessingID = Convert.ToInt32(array[6]), RequiredActiveQuestStepID = Convert.ToInt32(array[7]) }; if (array.Length > 8) { ((PartyCheckPrecondition)basePrecondition).RequiredFinishedQuestStepID = Convert.ToInt32(array[8]); } if (array.Length > 9) { ((PartyCheckPrecondition)basePrecondition).RequiredHirelingID = Convert.ToInt32(array[9]); } if (array.Length > 12) { ((PartyCheckPrecondition)basePrecondition).RequiredInactiveQuestStepID = Convert.ToInt32(array[10]); ((PartyCheckPrecondition)basePrecondition).WithoutHirelingID = Convert.ToInt32(array[11]); ((PartyCheckPrecondition)basePrecondition).WithoutTokenID = Convert.ToInt32(array[12]); } } else { basePrecondition = new PartyCheckPrecondition { SuccessText = successText, FailText = failText }; } } basePrecondition.Decision = epreconditionDecision; basePrecondition.Maintext = maintext; return(basePrecondition); }