/// <summary> /// </summary> /// <param name="entity"> /// </param> /// <returns> /// </returns> public bool CheckRequirement(IInstancedEntity entity) { if (this.theCheckFunc == null) { try { this.theCheckFunc = RequirementLambdaCreator.Create(this); return(this.theCheckFunc(entity)); } catch (Exception) { LogUtil.Debug("Could not create lambda for a requirement."); LogUtil.Debug("Values:"); LogUtil.Debug("Target: " + ((ItemTarget)this.Target)); LogUtil.Debug( "StatId: " + (this.Statnumber + " (" + StatNamesDefaults.GetStatName(this.Statnumber)) + ")"); LogUtil.Debug("Operator: " + ((Operator)this.Operator)); LogUtil.Debug("Value: " + this.Value); LogUtil.Debug("ChildOperator:" + ((Operator)this.ChildOperator)); return(false); } } return(this.theCheckFunc(entity)); }
/// <summary> /// </summary> /// <param name="fileName"> /// </param> public static void WriteStatsList(string fileName) { TextWriter tw = new StreamWriter(fileName); WriteHeader1(tw, "CellAO Stats List"); WriteHorizonalLine(tw); Stats stats = new Stats(new Identity() { Instance = 1, Type = IdentityType.CanbeAffected }); foreach (Stat stat in stats.All) { string statName = StatNamesDefaults.GetStatName(stat.StatId); uint statDefaultValue = stat.BaseValue; bool dontWriteToSql = stat.DoNotDontWriteToSql; bool announceToPlayfield = stat.AnnounceToPlayfield; string className = stat.GetType().FullName; tw.WriteLine("**" + statName + " [" + stat.StatId + "]**"); tw.WriteLine(); tw.WriteLine("**Class type:** " + className); tw.WriteLine(); tw.WriteLine("**Default value:** " + statDefaultValue); tw.WriteLine(); tw.WriteLine("**Tags:** "); if (!dontWriteToSql) { WriteCode(tw, "Save in Database"); } if (!dontWriteToSql && announceToPlayfield) { tw.Write(", "); } if (announceToPlayfield) { WriteCode(tw, "Announce to Playfield"); } tw.WriteLine(); WriteHorizonalLine(tw); tw.WriteLine(); } WriteFooter(tw); tw.Close(); }
/// <summary> /// </summary> /// <param name="entity"> /// </param> /// <returns> /// </returns> public bool CheckRequirement(IInstancedEntity entity) { if (this.theCheckFunc == null) { try { this.theCheckFunc = RequirementLambdaCreator.Create(this); //return this.theCheckFunc(entity); } catch (Exception) { LogUtil.Debug(DebugInfoDetail.GameFunctions, "Could not create lambda for a requirement."); LogUtil.Debug(DebugInfoDetail.GameFunctions, "Values:"); LogUtil.Debug(DebugInfoDetail.GameFunctions, "Target: " + (this.Target)); LogUtil.Debug( DebugInfoDetail.GameFunctions, "StatId: " + (this.Statnumber + " (" + StatNamesDefaults.GetStatName(this.Statnumber)) + ")"); LogUtil.Debug(DebugInfoDetail.GameFunctions, "Operator: " + (this.Operator)); LogUtil.Debug(DebugInfoDetail.GameFunctions, "Value: " + this.Value); LogUtil.Debug(DebugInfoDetail.GameFunctions, "ChildOperator:" + (this.ChildOperator)); return(false); } } LogUtil.Debug(DebugInfoDetail.GameFunctions, "Values:"); LogUtil.Debug(DebugInfoDetail.GameFunctions, "Target: " + (this.Target)); LogUtil.Debug( DebugInfoDetail.GameFunctions, "StatId: " + (this.Statnumber + " (" + StatNamesDefaults.GetStatName(this.Statnumber)) + ")"); LogUtil.Debug(DebugInfoDetail.GameFunctions, "Operator: " + (this.Operator)); LogUtil.Debug(DebugInfoDetail.GameFunctions, "Value: " + this.Value + " <-> " + entity.Stats[this.Statnumber].Value.ToString()); LogUtil.Debug(DebugInfoDetail.GameFunctions, "ChildOperator:" + (this.ChildOperator)); LogUtil.Debug(DebugInfoDetail.GameFunctions, "Result: " + this.theCheckFunc(entity)); return(this.theCheckFunc(entity)); }
/// <summary> /// </summary> /// <param name="character"> /// </param> /// <param name="target"> /// </param> /// <param name="args"> /// </param> public override void ExecuteCommand(ICharacter character, Identity target, string[] args) { // Fallback to self if no target is selected if (target.Instance == 0) { target = character.Identity; } if (target.Type != IdentityType.CanbeAffected) { character.Playfield.Publish( ChatTextMessageHandler.Default.CreateIM(character, "Target must be player/monster/NPC")); return; } Dynel targetDynel = (Dynel)character.Playfield.FindByIdentity(target); if (targetDynel != null) { Character targetCharacter = (Character)targetDynel; // May be obsolete in the future, let it stay in comment yet // ch.CalculateSkills(); // Check for numbers too, not only for names int statId; if (!int.TryParse(args[1], out statId)) { try { statId = StatNamesDefaults.GetStatNumber(args[1]); } catch (Exception) { statId = 1234567890; } } if (statId == 1234567890) { character.Playfield.Publish( ChatTextMessageHandler.Default.CreateIM(character, "Unknown Stat name " + args[1])); return; } uint statValue; int effectiveValue; int trickle; int mod; int perc; try { statValue = targetCharacter.Stats[statId].BaseValue; effectiveValue = targetCharacter.Stats[statId].Value; trickle = targetCharacter.Stats[statId].Trickle; mod = targetCharacter.Stats[statId].Modifier; perc = targetCharacter.Stats[statId].PercentageModifier; } catch (StatDoesNotExistException) { character.Playfield.Publish( ChatTextMessageHandler.Default.CreateIM(character, "Unknown Stat Id " + statId)); return; } string response = "Character " + targetCharacter.Name + " (" + targetCharacter.Identity.Instance + "): Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = " + statValue; if (statValue != targetCharacter.Stats[statId].Value) { response += "\r\nEffective value Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = " + effectiveValue; } response += "\r\nTrickle: " + trickle + " Modificator: " + mod + " Percentage: " + perc; character.Playfield.Publish(ChatTextMessageHandler.Default.CreateIM(character, response)); } else { // Shouldnt be happen again (fallback to self) character.Playfield.Publish( ChatTextMessageHandler.Default.CreateIM(character, "Unable to find target.")); } }
/// <summary> /// </summary> /// <param name="character"> /// </param> /// <param name="target"> /// </param> /// <param name="args"> /// </param> public override void ExecuteCommand(ICharacter character, Identity target, string[] args) { // Fallback to self if no target is selected if (target.Instance == 0) { target.Type = character.Client.Character.Identity.Type; target.Instance = character.Client.Character.Identity.Instance; } int statId = 1234567890; if (!int.TryParse(args[1], out statId)) { try { statId = StatNamesDefaults.GetStatNumber(args[1].ToLower()); } catch (Exception) { } } if (statId == 1234567890) { character.Playfield.Publish(ChatText.CreateIM(character, "Unknown Stat name " + args[1])); return; } uint statNewValue = 1234567890; try { statNewValue = (uint)int.Parse(args[2]); } catch { try { // For values >= 2^31 statNewValue = uint.Parse(args[2]); } catch (FormatException) { } catch (OverflowException) { } } IInstancedEntity tempch = character.Playfield.FindByIdentity(target); uint statOldValue; try { statOldValue = tempch.Stats[statId].BaseValue; tempch.Stats[statId].Value = (int)statNewValue; } catch { character.Playfield.Publish(ChatText.CreateIM(character, "Unknown StatId " + statId)); return; } string name = string.Empty; if (tempch is INamedEntity) { name = ((INamedEntity)tempch).Name + " "; } string response = "Dynel " + name + "(" + target.Type + ":" + target.Instance + "): Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") ="; response += " Old: " + statOldValue; response += " New: " + statNewValue; character.Playfield.Publish(ChatText.CreateIM(character, response)); }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="target"> /// </param> /// <param name="args"> /// </param> public override void ExecuteCommand(Client client, Identity target, string[] args) { // Fallback to self if no target is selected bool fallback = false; if (target.Instance == 0) { target = client.Character.Identity; fallback = true; } int statId = 0; try { statId = StatNamesDefaults.GetStatNumber(args[1]); } catch (Exception) { client.SendChatText("Unknown Stat name " + args[1]); return; } uint statNewValue = 1234567890; try { statNewValue = uint.Parse(args[2]); } catch { try { // For values >= 2^31 statNewValue = uint.Parse(args[2]); } catch (FormatException) { } catch (OverflowException) { } } IStats tempch = client.Playfield.FindByIdentity(target); if (tempch == null) { client.SendChatText("Target vanished? This should NOT be reached"); } uint statOldValue; try { statOldValue = tempch.Stats[statId].BaseValue; var IM = new IMExecuteFunction( new Functions { Target = Constants.ItemtargetSelectedtarget, FunctionType = Constants.FunctiontypeSet, Requirements = new List <Requirements>(), Arguments = new FunctionArguments { Values = new List <object> { statId, (int)statNewValue } }, TickCount = 1, TickInterval = 1, dolocalstats = true }, ((INamedEntity)tempch).Identity); if (fallback) { IM.Function.Target = Constants.ItemtargetSelf; } if (tempch.CheckRequirements(IM.Function, true)) { ((IInstancedEntity)tempch).Playfield.Publish(IM); } } catch { client.SendChatText("Unknown StatId " + statId); return; } INamedEntity namedEntity = tempch as INamedEntity; string response; if (namedEntity != null) { response = "Character " + namedEntity.Name + " (" + target.Instance + "): Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") ="; } else { response = "Dynel (" + ((IInstancedEntity)tempch).Identity.Instance + "): Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") ="; } response += " Old: " + statOldValue; response += " New: " + statNewValue; client.SendChatText(response); }
/// <summary> /// </summary> /// <param name="client"> /// </param> /// <param name="target"> /// </param> /// <param name="args"> /// </param> public override void ExecuteCommand(Client client, Identity target, string[] args) { // Fallback to self if no target is selected if (target.Instance == 0) { target = client.Character.Identity; } if (target.Type != IdentityType.CanbeAffected) { client.SendChatText("Target must be player/monster/NPC"); return; } IInstancedEntity targetDynel = client.Playfield.FindByIdentity(target); if (targetDynel != null) { Dynel targetCharacter = (Dynel)targetDynel; // May be obsolete in the future, let it stay in comment yet // ch.CalculateSkills(); int statId; try { statId = StatNamesDefaults.GetStatNumber(args[1]); } catch (Exception) { client.SendChatText("Unknown Stat name " + args[1]); return; } uint statValue; int effectiveValue; int trickle; int mod; int perc; try { statValue = targetCharacter.Stats[statId].BaseValue; effectiveValue = targetCharacter.Stats[statId].Value; trickle = targetCharacter.Stats[statId].Trickle; mod = targetCharacter.Stats[statId].Modifier; perc = targetCharacter.Stats[statId].PercentageModifier; } catch (StatDoesNotExistException) { client.SendChatText("Unknown Stat Id " + statId); return; } string response = string.Empty; INamedEntity namedDynel = targetCharacter as INamedEntity; if (namedDynel != null) { response = "Character " + namedDynel.Name + " (" + targetCharacter.Identity.Instance + "): Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = " + statValue; } else { response = "Dynel " + targetCharacter.Identity.Instance + "Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = " + statValue; } client.SendChatText(response); if (statValue != targetCharacter.Stats[args[1]].Value) { response = "Effective value Stat " + StatNamesDefaults.GetStatName(statId) + " (" + statId + ") = " + effectiveValue; client.SendChatText(response); } response = "Trickle: " + trickle + " Modificator: " + mod + " Percentage: " + perc; client.SendChatText(response); } else { // Shouldnt be happen again (fallback to self) client.SendChatText("Unable to find target."); } }