public void DrawLines(ARGB argb, System.Collections.Generic.IEnumerable <Box> points, double width = 1) { var brush = GetBrush(argb); var first = true; var previous = Box.Empty; foreach (var point in points) { if (first) { previous = point; first = false; continue; } var line = Create <Line>(); line.X1 = previous.X; line.Y1 = previous.Y; line.X2 = point.X; line.Y2 = point.Y; line.StrokeThickness = width; line.Stroke = brush; previous = point; } }
public void DrawLines(ARGB argb, System.Collections.Generic.IEnumerable <Box> points, double width = 1) { var brush = new SolidColorBrush(argb.ToColor()); var first = true; var previous = Box.Empty; foreach (var point in points) { if (first) { previous = point; first = false; continue; } var line = new Line() { X1 = previous.X, Y1 = previous.Y, X2 = point.X, Y2 = point.Y, StrokeThickness = width, Stroke = brush }; _canvas.Children.Add(line); previous = point; } }
public void DrawString(string s, Font font, ARGB argb, Box bounds) { _context.Font = font.Name + " " + font.Size + "px"; _context.StrokeStyle = argb.ToColor(); _context.GlobalAlpha = argb.A / 255.0f; _context.StrokeText(s, (int)bounds.X, (int)bounds.Y); }
public void Color_read() { // FileStream cfs = new FileStream("Assets/Files/result.txt", FileMode.Open, FileAccess.Read); // FileStream cfs = new FileStream("Application.persistentDataPath"+"/" + "result.txt", FileMode.Open, FileAccess.Read); TextAsset cfs = (TextAsset)Resources.Load("TextAsset/result", typeof(TextAsset)) as TextAsset; // 파일을 열기위해 파일 스트림 객체 생성 StringReader csr = new StringReader(cfs.text); // 스트림 리더 생성 string c_str;// 한줄읽기 c_str = csr.ReadLine(); // color = new Color(); while ((c_str = csr.ReadLine()) != null) { ARGB color = new ARGB(); string[] c_temp = c_str.Split(' '); name = c_temp[0]; name = name.Replace('_', ' '); color.A = int.Parse(c_temp[1]); color.R = int.Parse(c_temp[2]); color.G = int.Parse(c_temp[3]); color.B = int.Parse(c_temp[4]); dic.Add(name, color); Debug.Log(name + " : " + color.A + ", " + color.R + ", " + color.G + ", " + color.B); } csr.Dispose(); }
public static bool LikeColor(ARGB left, ARGB right, byte offset = 10, bool discardAlpha = false) { var absA = Math.Abs(left.alpha - right.alpha); var result = LikeColor((RGB)left, (RGB)right, offset); return(discardAlpha ? result : result && (absA <= offset)); }
// root file header // 64 bytes public static void ReadMOHD(Stream WMOrootstream) { wmoData.Info.nTextures = ReadLong(WMOrootstream); // number of textures used wmoData.Info.nGroups = ReadLong(WMOrootstream); // number of groups wmoData.Info.nPortals = ReadLong(WMOrootstream); // number of portals wmoData.Info.nLights = ReadLong(WMOrootstream); // number of lights //Blizzard seems to add one to the MOLT entry count when there are MOLP chunks in the groups (and maybe for MOLS too?) int nDoodadNames = ReadLong(WMOrootstream); // number of doodad names int nDoodadDefs = ReadLong(WMOrootstream); // number of doodad definitions int nDoodadSets = ReadLong(WMOrootstream); // number of doodad sets ARGB ambColor = ReadARGB(WMOrootstream); // Color settings for base (ambient) color. See the flag at /*03Ch*/. // ARGB wmoData.Info.wmoID = ReadLong(WMOrootstream); // < uint32_t, &WMOAreaTableRec::m_WMOID> ID located in DBC BoundingBox bounding_box = ReadBoundingBox(WMOrootstream); // in the alpha, this bounding box was computed upon loading // <Flags> 2 bytes byte[] arrayOfBytes = new byte[2]; WMOrootstream.Read(arrayOfBytes, 0, 2); BitArray flags = new BitArray(arrayOfBytes); bool flag_attenuate_vertices_based_on_distance_to_portal = flags[0]; bool flag_skip_base_color = flags[1]; // do not add base (ambient) color (of MOHD) to MOCVs. apparently does more, e.g. required for multiple MOCVs bool flag_use_liquid_type_dbc_id = flags[2]; // use real liquid type ID from DBCs instead of local one. See MLIQ for further reference. bool flag_lighten_interiors = flags[3]; // makes iterior groups much brighter, effects MOCV rendering. Used e.g.in Stormwind for having shiny bright interiors, bool Flag_Lod = flags[4]; // ≥ Legion (20740) // 11 bits unused flags // unused as of Legion (20994) // </Flags> int numLod = ReadShort(WMOrootstream); // ≥ Legion (21108) includes base lod (→ numLod = 3 means '.wmo', 'lod0.wmo' and 'lod1.wmo') }
public void Clear(ARGB argb) { _context.FillStyle = argb.ToColor(); _context.GlobalAlpha = argb.A / 255.0f; _context.ClearRect(0, 0, _canvas.Width, _canvas.Height); _context.FillRect(0, 0, _canvas.Width, _canvas.Height); }
public IseSprite(IRenderSprite sprite) { Sprite = sprite; ARGB col = ARGB.Random; col.Alpha = 100; TagColor = col; }
public void DrawEllipse(ARGB argb, Box bounds, double width = 1) { _context.StrokeStyle = argb.ToColor(); _context.GlobalAlpha = argb.A / 255.0f; _context.BeginPath(); _context.Arc(bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2, bounds.Width / 2, 0, 2 * Math.PI); _context.Stroke(); }
public override void Read(PacketReader r) { EffectType = (EffectType)r.ReadByte(); TargetId = r.ReadInt32(); PosA = (Location) new Location().Read(r); PosB = (Location) new Location().Read(r); Color = ARGB.Read(r); }
protected override void Read(NReader rdr) { EffectType = (EffectType)rdr.ReadByte(); TargetId = rdr.ReadInt32(); PosA = Position.Read(rdr); PosB = Position.Read(rdr); Color = ARGB.Read(rdr); }
public void FillEllipse(ARGB argb, Box bounds) { _context.BeginPath(); _context.FillStyle = argb.ToColor(); _context.GlobalAlpha = argb.A / 255.0f; _context.Arc(bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2, bounds.Width / 2, 0, 2 * Math.PI); _context.Fill(); }
protected override void Read(Client psr, NReader rdr) { EffectType = (EffectType)rdr.ReadByte(); TargetObjectId = rdr.ReadInt32(); PosA = Position.Read(psr, rdr); PosB = Position.Read(psr, rdr); Color = ARGB.Read(psr, rdr); }
public void ToFromColor(Color color) { ARGB argb = color; Assert.Equal(color.ToArgb(), argb.Value); Color backAgain = argb; Assert.Equal(color.ToArgb(), backAgain.ToArgb()); }
protected override void Read(NReader rdr) { EffectType = (EffectType)rdr.ReadByte(); TargetObjectId = rdr.ReadInt32(); Pos1 = Position.Read(rdr); Pos2 = Position.Read(rdr); Color = ARGB.Read(rdr); Duration = rdr.ReadInt32(); }
public virtual Result Noise(NoiseRequest request) { if (request == default) { throw new ArgumentNullException(nameof(request)); } var avg = 0.0f; var min = float.MaxValue; var max = float.MinValue; var index = 0; var result = new ARGB[request.Width * request.Height]; var noise = new float[request.Width * request.Height]; for (var y = request.Height / -2; y < request.Height / 2; y++) { for (var x = request.Width / -2; x < request.Width / 2; x++) { var value = request.Is3D ? request.Noise.Get(request.Warp.Get(new XYZ(x, y, request.Z))) : request.Noise.Get(request.Warp.Get(new XY(x, y))); avg += value; max = Math.Max(max, value); min = Math.Min(min, value); noise[index++] = value; } } avg /= index - 1; var scale = 255.0f / (max - min); for (var i = 0; i < noise.Length; i++) { var value = Math.Round(Math.Clamp((noise[i] - min) * scale, 0, 255)); if (request.IsInverted) { value = 255 - value; } result[i] = new ARGB(255, value, value, value); } return(new Result() { Image = result, Statistics = new Statistics() { Average = avg, Minimum = min, Maximum = max } }); }
public void DrawLine(ARGB argb, Box p1, Box p2, double width = 1) { var line = new Line() { X1 = p1.X, Y1 = p1.Y, X2 = p2.X, Y2 = p2.Y, StrokeThickness = width, Stroke = new SolidColorBrush(argb.ToColor()) }; _canvas.Children.Add(line); }
public void DrawLine(ARGB argb, double x1, double y1, double x2, double y2, double width = 1) { var line = new Line() { X1 = x1, Y1 = y1, X2 = x2, Y2 = y2, StrokeThickness = width, Stroke = new SolidColorBrush(argb.ToColor()) }; _canvas.Children.Add(line); }
public Aoe(double radius, bool players, int minDamage, int maxDamage, bool noDef, uint color) { this.radius = (float)radius; this.players = players; this.minDamage = minDamage; this.maxDamage = maxDamage; this.noDef = noDef; this.color = new ARGB(color); }
private bool Create(ActivateEffect eff) { if (Stars >= 10 || Client.Account.Admin) { ushort objType; if (!Manager.GameData.IdToObjectType.TryGetValue(eff.Id, out objType) || !Manager.GameData.Portals.ContainsKey(objType)) { SendHelp("Dungeon not implemented yet."); return(true); } Entity entity = Resolve(Manager, objType); World w = Manager.GetWorld(Owner.Id); //can't use Owner here, as it goes out of scope int TimeoutTime = Manager.GameData.Portals[objType].TimeoutTime; string DungName = Manager.GameData.Portals[objType].DungeonName; ARGB c = new ARGB(0x00FF00); entity?.Move(X, Y); w?.EnterWorld(entity); w.BroadcastPacket(new NOTIFICATION { Color = c, Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"Opened by " + Name + "\"}}", ObjectId = Client.Player.Id }, null); w.BroadcastPacket(new TEXT { BubbleTime = 0, Stars = -1, Name = "", Text = DungName + " opened by " + Name, NameColor = 0x123456, TextColor = 0x123456 }, null); w?.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w?.LeaveWorld(entity); } catch (Exception ex) { log.ErrorFormat("Couldn't despawn portal.\n{0}", ex); } })); return(false); } else { SendInfo("You need at least 10 stars to use Keys! Complete class quests to earn additional stars."); return(true); } }
public void Clear(ARGB argb) { if (argb.Equals(_background)) { return; } _background = argb; _canvas.Background = GetBrush(_background); }
/// <summary> /// Clears the backbuffer with the specified color. /// </summary> /// <param name="backColor">the color to clear the background with.</param> public void Clear(ARGB backColor) { if (!Window.IsValid) { throw new InvalidOperationException("Not initialized!"); } glfw3.MakeContextCurrent(Window); gl2.ClearColor(backColor.RedFloat, backColor.GreenFloat, backColor.BlueFloat, backColor.AlphaFloat); gl2.Clear(GL._COLOR_BUFFER_BIT | GL._DEPTH_BUFFER_BIT); }
protected override void Read(NReader rdr) { Position = Position.Read(rdr); Radius = rdr.ReadSingle(); Damage = rdr.ReadUInt16(); Effects = (ConditionEffectIndex)rdr.ReadByte(); EffectDuration = rdr.ReadSingle(); OriginType = rdr.ReadInt16(); Color = ARGB.Read(rdr); }
public void DrawLine(ARGB argb, Box p1, Box p2, double width = 1) { _context.StrokeStyle = argb.ToColor(); _context.LineWidth = width; _context.GlobalAlpha = Math.Min(1.0f, Math.Max(0.0f, argb.A / 255.0f)); _context.BeginPath(); _context.MoveTo(p1.X, p1.Y); _context.LineTo(p2.X, p2.Y); _context.Stroke(); }
private static ARGB ReadARGB(Stream stream) { ARGB argbColor = new ARGB(); argbColor.A = (byte)stream.ReadByte(); argbColor.R = (byte)stream.ReadByte(); argbColor.G = (byte)stream.ReadByte(); argbColor.B = (byte)stream.ReadByte(); return(argbColor); }
public static ARGB ReadARGB(this BinaryReader reader) { ARGB argbColor = new ARGB(); argbColor.A = reader.ReadByte(); argbColor.R = reader.ReadByte(); argbColor.G = reader.ReadByte(); argbColor.B = reader.ReadByte(); return(argbColor); }
public void DrawLine(ARGB argb, double x1, double y1, double x2, double y2, double width = 1) { var line = Create <Line>(); line.X1 = x1; line.Y1 = y1; line.X2 = x2; line.Y2 = y2; line.StrokeThickness = width; line.Stroke = GetBrush(argb); }
static Brush GetBrush(ARGB argb) { Brush brush; if (!_brushLookup.TryGetValue(argb, out brush)) { _brushLookup[argb] = brush = new SolidColorBrush(argb.ToColor()); } return(brush); }
/// <summary> /// Reads a 4-byte RGBA value from the data stream. /// </summary> /// <returns>The argument.</returns> /// <param name="binaryReader">binaryReader.</param> public static ARGB ReadARGB(this BinaryReader binaryReader) { byte a = binaryReader.ReadByte(); byte r = binaryReader.ReadByte(); byte g = binaryReader.ReadByte(); byte b = binaryReader.ReadByte(); ARGB argb = new ARGB(b, g, r, a); return(argb); }
/// <summary> /// Reads a 4-byte RGBA value from the data stream. /// </summary> /// <returns>The argument.</returns> /// <param name="binaryReader">The reader.</param> public static ARGB ReadARGB(this BinaryReader binaryReader) { var a = binaryReader.ReadByte(); var r = binaryReader.ReadByte(); var g = binaryReader.ReadByte(); var b = binaryReader.ReadByte(); var argb = new ARGB(b, g, r, a); return(argb); }
/// <summary> /// Load color picture, you can select file by mouse and will return a ARGB arrays /// </summary> /// <returns></returns> public static ARGB[,] LoadColorImg() { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "Openfile (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All Files (*.*)|*.*"; if (openFile.ShowDialog() == DialogResult.OK) { image = new Bitmap(openFile.FileName); FastBitmap image1 = new FastBitmap(image); Color cc = new Color(); int xres, yres, i, j; xres = image.Width; yres = image.Height; ARGB[,] argb = new ARGB[xres, yres]; for (i = 0; i <= xres - 1; i++) for (j = 0; j <= yres - 1; j++) { argb[i, j] = new ARGB(0, 0, 0); } for (i = 0; i <= xres - 1; i++) for (j = 0; j <= yres - 1; j++) { cc = image1.GetPixel(i, j); argb[i, j].R = cc.R; argb[i, j].G = cc.G; argb[i, j].B = cc.B; } return argb; } return null; }
/// <summary> /// Converts an ARGB color to a HSV color. /// </summary> /// <param name="argb">ARGB color to convert</param> /// <returns>HSV color equivalent</returns> public static HSV RGBtoHSV(ARGB argb) { double h, s; var r = (double)argb.Red / 255; var g = (double)argb.Green / 255; var b = (double)argb.Blue / 255; var min = Math.Min(Math.Min(r, g), b); var max = Math.Max(Math.Max(r, g), b); var v = max; var delta = max - min; if (Equals(max, 0.0d) || Equals(delta, 0.0d)) { s = 0; h = 0; } else { s = delta / max; if (Equals(r, max)) h = (g - b) / delta; else if (Equals(g, max)) h = 2 + (b - r) / delta; else h = 4 + (r - g) / delta; } h *= 60; if (h < 0) h += 360; return new HSV(argb.Alpha, (int)(h / 360 * 255), (int)(s * 255), (int)(v * 255)); }
public static HSV RGBtoHSV(ARGB argb) { // In this function, R, G, and B values must be scaled // to be between 0 and 1. // HSV.Hue will be a value between 0 and 360, and // HSV.Saturation and value are between 0 and 1. // The code must scale these to be between 0 and 255 for // the purposes of this application. double r = (double) argb.Red/255; double g = (double) argb.Green/255; double b = (double) argb.Blue/255; double h; double s; double v; double min = Math.Min(Math.Min(r, g), b); double max = Math.Max(Math.Max(r, g), b); v = max; double delta = max - min; if (max == 0 || delta == 0) { // R, G, and B must be 0, or all the same. // In this case, S is 0, and H is undefined. // Using H = 0 is as good as any... s = 0; h = 0; } else { s = delta/max; if (r == max) { // Between Yellow and Magenta h = (g - b)/delta; } else if (g == max) { // Between Cyan and Yellow h = 2 + (b - r)/delta; } else { // Between Magenta and Cyan h = 4 + (r - g)/delta; } } // Scale h to be between 0 and 360. // This may require adding 360, if the value // is negative. h *= 60; if (h < 0) { h += 360; } // Scale to the requirements of this // application. All values are between 0 and 255. return new HSV(argb.Alpha, (int) (h/360*255), (int) (s*255), (int) (v*255)); }
public bool Activate(RealmTime time, Item item, UseItemPacket pkt) { bool endMethod = false; Position target = pkt.ItemUsePos; Mp -= item.MpCost; IContainer con = Owner.GetEntity(pkt.SlotObject.ObjectId) as IContainer; if (con == null) return true; if (pkt.SlotObject.SlotId != 255 && pkt.SlotObject.SlotId != 254 && con.Inventory[pkt.SlotObject.SlotId] != item) { Entity.logger.FatalFormat("Cheat engine detected for player {0},\nItem should be {1}, but its {2}.", Name, Inventory[pkt.SlotObject.SlotId].ObjectId, item.ObjectId); foreach (Player player in Owner.Players.Values) if (player.Client.Account.Rank >= 2) player.SendInfo(String.Format("Cheat engine detected for player {0},\nItem should be {1}, but its {2}.", Name, Inventory[pkt.SlotObject.SlotId].ObjectId, item.ObjectId)); Client.Disconnect(); return true; } if (item.IsBackpack) { if (HasBackpack) return true; Client.Character.Backpack = new[] { -1, -1, -1, -1, -1, -1, -1, -1 }; HasBackpack = true; Client.Character.HasBackpack = 1; Manager.Database.DoActionAsync(db => db.SaveBackpacks(Client.Character, Client.Account)); Array.Resize(ref inventory, 20); int[] slotTypes = Utils.FromCommaSepString32( Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes").Value); Array.Resize(ref slotTypes, 20); for (int i = 0; i < slotTypes.Length; i++) if (slotTypes[i] == 0) slotTypes[i] = 10; SlotTypes = slotTypes; return false; } if (item.XpBooster) { if (!XpBoosted) { XpBoostTimeLeft = (float)item.Timer; XpBoosted = item.XpBooster; xpFreeTimer = (float)item.Timer == -1.0 ? false : true; return false; } else { SendInfo("You have already an active XP Booster."); return true; } } if (item.LootDropBooster) { if (!LootDropBoost) { LootDropBoostTimeLeft = (float)item.Timer; lootDropBoostFreeTimer = (float)item.Timer == -1.0 ? false : true; return false; } else { SendInfo("You have already an active Loot Drop Booster."); return true; } } if (item.LootTierBooster) { if (!LootTierBoost) { LootTierBoostTimeLeft = (float)item.Timer; lootTierBoostFreeTimer = (float)item.Timer == -1.0 ? false : true; return false; } else { SendInfo("You have already an active Loot Tier Booster."); return true; } } foreach (ActivateEffect eff in item.ActivateEffects) { switch (eff.Effect) { case ActivateEffects.BulletNova: { ProjectileDesc prjDesc = item.Projectiles[0]; //Assume only one Packet[] batch = new Packet[21]; uint s = Random.CurrentSeed; Random.CurrentSeed = (uint)(s * time.tickTimes); for (int i = 0; i < 20; i++) { Projectile proj = CreateProjectile(prjDesc, item.ObjectType, (int)StatsManager.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), time.tickTimes, target, (float)(i * (Math.PI * 2) / 20)); Owner.EnterWorld(proj); FameCounter.Shoot(proj); batch[i] = new Shoot2Packet() { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = item.ObjectType, StartingPos = target, Angle = proj.Angle, Damage = (short)proj.Damage }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket() { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0xFFFF00AA) }; BroadcastSync(batch, p => this.Dist(p) < 35); } break; case ActivateEffects.Shoot: { ActivateShoot(time, item, target); } break; case ActivateEffects.StatBoostSelf: { int idx = -1; if (eff.Stats == StatsType.MaximumHP) idx = 0; else if (eff.Stats == StatsType.MaximumMP) idx = 1; else if (eff.Stats == StatsType.Attack) idx = 2; else if (eff.Stats == StatsType.Defense) idx = 3; else if (eff.Stats == StatsType.Speed) idx = 4; else if (eff.Stats == StatsType.Vitality) idx = 5; else if (eff.Stats == StatsType.Wisdom) idx = 6; else if (eff.Stats == StatsType.Dexterity) idx = 7; List<Packet> pkts = new List<Packet>(); ActivateBoostStat(this, idx, pkts); int OGstat = oldstat; int bit = idx + 39; int s = eff.Amount; Boost[idx] += s; ApplyConditionEffect(new ConditionEffect { DurationMS = eff.DurationMS, Effect = (ConditionEffectIndex)bit }); UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { Boost[idx] = OGstat; UpdateCount++; })); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Potion, TargetId = Id, Color = new ARGB(0xffffffff) }, null); } break; case ActivateEffects.StatBoostAura: { int idx = -1; if (eff.Stats == StatsType.MaximumHP) idx = 0; if (eff.Stats == StatsType.MaximumMP) idx = 1; if (eff.Stats == StatsType.Attack) idx = 2; if (eff.Stats == StatsType.Defense) idx = 3; if (eff.Stats == StatsType.Speed) idx = 4; if (eff.Stats == StatsType.Vitality) idx = 5; if (eff.Stats == StatsType.Wisdom) idx = 6; if (eff.Stats == StatsType.Dexterity) idx = 7; int bit = idx + 39; var amountSBA = eff.Amount; var durationSBA = eff.DurationMS; var rangeSBA = eff.Range; if (eff.UseWisMod) { amountSBA = (int)UseWisMod(eff.Amount, 0); durationSBA = (int)(UseWisMod(eff.DurationSec) * 1000); rangeSBA = UseWisMod(eff.Range); } this.Aoe(rangeSBA, true, player => { // TODO support for noStack StatBoostAura attribute (paladin total // hp increase / insta heal) ApplyConditionEffect(new ConditionEffect { DurationMS = durationSBA, Effect = (ConditionEffectIndex)bit }); (player as Player).Boost[idx] += amountSBA; player.UpdateCount++; Owner.Timers.Add(new WorldTimer(durationSBA, (world, t) => { (player as Player).Boost[idx] -= amountSBA; player.UpdateCount++; })); }); BroadcastSync(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = rangeSBA } }, p => this.Dist(p) < 25); } break; case ActivateEffects.ConditionEffectSelf: { var durationCES = eff.DurationMS; if (eff.UseWisMod) durationCES = (int)(UseWisMod(eff.DurationSec) * 1000); var color = 0xffffffff; switch (eff.ConditionEffect.Value) { case ConditionEffectIndex.Damaging: color = 0xffff0000; break; case ConditionEffectIndex.Berserk: color = 0x808080; break; } ApplyConditionEffect(new ConditionEffect { Effect = eff.ConditionEffect.Value, DurationMS = durationCES }); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position { X = 2 } }, null); } break; case ActivateEffects.ConditionEffectAura: { var durationCEA = eff.DurationMS; var rangeCEA = eff.Range; if (eff.UseWisMod) { durationCEA = (int)(UseWisMod(eff.DurationSec) * 1000); rangeCEA = UseWisMod(eff.Range); } this.Aoe(rangeCEA, true, player => { player.ApplyConditionEffect(new ConditionEffect { Effect = eff.ConditionEffect.Value, DurationMS = durationCEA }); }); var color = 0xffffffff; switch (eff.ConditionEffect.Value) { case ConditionEffectIndex.Damaging: color = 0xffff0000; break; case ConditionEffectIndex.Berserk: color = 0x808080; break; } BroadcastSync(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position { X = rangeCEA } }, p => this.Dist(p) < 25); } break; case ActivateEffects.Heal: { List<Packet> pkts = new List<Packet>(); ActivateHealHp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.HealNova: { var amountHN = eff.Amount; var rangeHN = eff.Range; if (eff.UseWisMod) { amountHN = (int)UseWisMod(eff.Amount, 0); rangeHN = UseWisMod(eff.Range); } List<Packet> pkts = new List<Packet>(); this.Aoe(rangeHN, true, player => { ActivateHealHp(player as Player, amountHN, pkts); }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = rangeHN } }); BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.Magic: { List<Packet> pkts = new List<Packet>(); ActivateHealMp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.MagicNova: { List<Packet> pkts = new List<Packet>(); this.Aoe(eff.Range / 2, true, player => { ActivateHealMp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = eff.Range } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Teleport: { Move(target.X, target.Y); UpdateCount++; Owner.BroadcastPackets(new Packet[] { new GotoPacket { ObjectId = Id, Position = new Position { X = X, Y = Y } }, new ShowEffectPacket { EffectType = EffectType.Teleport, TargetId = Id, PosA = new Position { X = X, Y = Y }, Color = new ARGB(0xFFFFFFFF) } }, null); } break; case ActivateEffects.VampireBlast: { List<Packet> pkts = new List<Packet>(); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Trail, TargetId = Id, PosA = target, Color = new ARGB(0xFFFF0000) }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Diffuse, Color = new ARGB(0xFFFF0000), TargetId = Id, PosA = target, PosB = new Position { X = target.X + eff.Radius, Y = target.Y } }); int totalDmg = 0; List<Enemy> enemies = new List<Enemy>(); Owner.Aoe(target, eff.Radius, false, enemy => { enemies.Add(enemy as Enemy); totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false); }); List<Player> players = new List<Player>(); this.Aoe(eff.Radius, true, player => { players.Add(player as Player); ActivateHealHp(player as Player, totalDmg, pkts); }); if (enemies.Count > 0) { Random rand = new Random(); for (int i = 0; i < 5; i++) { Enemy a = enemies[rand.Next(0, enemies.Count)]; Player b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position { X = a.X, Y = a.Y }, Color = new ARGB(0xffffffff) }); } } BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.Trap: { BroadcastSync(new ShowEffectPacket { EffectType = EffectType.Throw, Color = new ARGB(0xff9000ff), TargetId = Id, PosA = target }, p => this.Dist(p) < 25); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Trap trap = new Trap( this, eff.Radius, eff.TotalDamage, eff.ConditionEffect ?? ConditionEffectIndex.Slowed, eff.EffectDuration); trap.Move(target.X, target.Y); world.EnterWorld(trap); })); } break; case ActivateEffects.StasisBlast: { List<Packet> pkts = new List<Packet>(); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Concentrate, TargetId = Id, PosA = target, PosB = new Position { X = target.X + 3, Y = target.Y }, Color = new ARGB(0xFF00D0) }); Owner.Aoe(target, 3, false, enemy => { if (IsSpecial(enemy.ObjectType)) return; if (enemy.HasConditionEffect(ConditionEffectIndex.StasisImmune)) { if (!enemy.HasConditionEffect(ConditionEffectIndex.Invincible)) { pkts.Add(new NotificationPacket { ObjectId = enemy.Id, Color = new ARGB(0xff00ff00), Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"Immune\"}}" }); } } else if (!enemy.HasConditionEffect(ConditionEffectIndex.Stasis)) { enemy.ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Stasis, DurationMS = eff.DurationMS }); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { enemy.ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.StasisImmune, DurationMS = 3000 }); })); pkts.Add(new NotificationPacket { ObjectId = enemy.Id, Color = new ARGB(0xffff0000), Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"Stasis\"}}" }); } }); BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.Decoy: { Decoy decoy = new Decoy(Manager, this, eff.DurationMS, StatsManager.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } break; case ActivateEffects.Lightning: { Enemy start = null; double angle = Math.Atan2(target.Y - Y, target.X - X); double diff = Math.PI / 3; Owner.Aoe(target, 6, false, enemy => { if (!(enemy is Enemy)) return; double x = Math.Atan2(enemy.Y - Y, enemy.X - X); if (Math.Abs(angle - x) < diff) { start = enemy as Enemy; diff = Math.Abs(angle - x); } }); if (start == null) break; Enemy current = start; Enemy[] targets = new Enemy[eff.MaxTargets]; for (int i = 0; i < targets.Length; i++) { targets[i] = current; Enemy next = current.GetNearestEntity(8, false, enemy => enemy is Enemy && Array.IndexOf(targets, enemy) == -1 && this.Dist(enemy) <= 6) as Enemy; if (next == null) break; current = next; } List<Packet> pkts = new List<Packet>(); for (int i = 0; i < targets.Length; i++) { if (targets[i] == null) break; if (targets[i].HasConditionEffect(ConditionEffectIndex.Invincible)) continue; Entity prev = i == 0 ? (Entity)this : targets[i - 1]; targets[i].Damage(this, time, eff.TotalDamage, false); if (eff.ConditionEffect != null) targets[i].ApplyConditionEffect(new ConditionEffect { Effect = eff.ConditionEffect.Value, DurationMS = (int)(eff.EffectDuration * 1000) }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Lightning, TargetId = prev.Id, Color = new ARGB(0xffff0088), PosA = new Position { X = targets[i].X, Y = targets[i].Y }, PosB = new Position { X = 350 } }); } BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.PoisonGrenade: { try { BroadcastSync(new ShowEffectPacket { EffectType = EffectType.Throw, Color = new ARGB(0xffddff00), TargetId = Id, PosA = target }, p => this.Dist(p) < 25); Placeholder x = new Placeholder(Manager, 1500); x.Move(target.X, target.Y); Owner.EnterWorld(x); try { Owner.Timers.Add(new WorldTimer(1500, (world, t) => { world.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, Color = new ARGB(0xffddff00), TargetId = x.Id, PosA = new Position { X = eff.Radius } }, null); world.Aoe(target, eff.Radius, false, enemy => PoisonEnemy(enemy as Enemy, eff)); })); } catch (Exception ex) { Entity.logger.ErrorFormat("Poison ShowEffect:\n{0}", ex); } } catch (Exception ex) { Entity.logger.ErrorFormat("Poisons General:\n{0}", ex); } } break; case ActivateEffects.RemoveNegativeConditions: { this.Aoe(eff.Range / 2, true, player => { ApplyConditionEffect(NegativeEffs); }); BroadcastSync(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = eff.Range / 2 } }, p => this.Dist(p) < 25); } break; case ActivateEffects.RemoveNegativeConditionsSelf: { ApplyConditionEffect(NegativeEffs); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = 1 } }, null); } break; case ActivateEffects.IncrementStat: { int idx = -1; if (eff.Stats == StatsType.MaximumHP) idx = 0; else if (eff.Stats == StatsType.MaximumMP) idx = 1; else if (eff.Stats == StatsType.Attack) idx = 2; else if (eff.Stats == StatsType.Defense) idx = 3; else if (eff.Stats == StatsType.Speed) idx = 4; else if (eff.Stats == StatsType.Vitality) idx = 5; else if (eff.Stats == StatsType.Wisdom) idx = 6; else if (eff.Stats == StatsType.Dexterity) idx = 7; Stats[idx] += eff.Amount; int limit = int.Parse( Manager.GameData.ObjectTypeToElement[ObjectType].Element( StatsManager.StatsIndexToName(idx)) .Attribute("max") .Value); if (Stats[idx] > limit) Stats[idx] = limit; UpdateCount++; } break; case ActivateEffects.UnlockPortal: Portal portal = this.GetNearestEntity(5, Manager.GameData.IdToObjectType[eff.LockedName]) as Portal; Packet[] packets = new Packet[3]; packets[0] = new ShowEffectPacket { EffectType = EffectType.AreaBlast, Color = new ARGB(0xFFFFFF), PosA = new Position { X = 5 }, TargetId = Id }; if (portal == null) break; portal.Unlock(eff.DungeonName); packets[1] = new NotificationPacket { Color = new ARGB(0x00FF00), Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"Unlocked by " + Name + "\"}}", ObjectId = Id }; packets[2] = new TextPacket { BubbleTime = 0, Stars = -1, Name = "", Text = eff.DungeonName + " Unlocked by " + Name + "." }; BroadcastSync(packets); break; case ActivateEffects.Create: //this is a portal { ushort objType; if (!Manager.GameData.IdToObjectType.TryGetValue(eff.Id, out objType) || !Manager.GameData.Portals.ContainsKey(objType)) break; // object not found, ignore Entity entity = Resolve(Manager, objType); World w = Manager.GetWorld(Owner.Id); //can't use Owner here, as it goes out of scope int TimeoutTime = Manager.GameData.Portals[objType].TimeoutTime; string DungName = Manager.GameData.Portals[objType].DungeonName; ARGB c = new ARGB(0x00FF00); entity.Move(X, Y); w.EnterWorld(entity); w.BroadcastPacket(new NotificationPacket { Color = c, Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"" + DungName + " opened by " + Client.Account.Name + "\"}}", ObjectId = Client.Player.Id }, null); w.BroadcastPacket(new TextPacket { BubbleTime = 0, Stars = -1, Name = "", Text = DungName + " opened by " + Client.Account.Name }, null); w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w.LeaveWorld(entity); } catch (Exception ex) //couldn't remove portal, Owner became null. Should be fixed with RealmManager implementation { logger.ErrorFormat("Couldn't despawn portal.\n{0}", ex); } })); } break; case ActivateEffects.Dye: { if (item.Texture1 != 0) { Texture1 = item.Texture1; } if (item.Texture2 != 0) { Texture2 = item.Texture2; } SaveToCharacter(); } break; case ActivateEffects.ShurikenAbility: { if (!ninjaShoot) { ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Speedy, DurationMS = -1 }); ninjaFreeTimer = true; ninjaShoot = true; } else { ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Speedy, DurationMS = 0 }); ushort obj; Manager.GameData.IdToObjectType.TryGetValue(item.ObjectId, out obj); if (Mp >= item.MpEndCost) { ActivateShoot(time, item, pkt.ItemUsePos); Mp -= (int)item.MpEndCost; } targetlink = target; ninjaShoot = false; } } break; case ActivateEffects.UnlockSkin: if (!Client.Account.OwnedSkins.Contains(item.ActivateEffects[0].SkinType)) { Manager.Database.DoActionAsync(db => { Client.Account.OwnedSkins.Add(item.ActivateEffects[0].SkinType); MySqlCommand cmd = db.CreateQuery(); cmd.CommandText = "UPDATE accounts SET ownedSkins=@ownedSkins WHERE id=@id"; cmd.Parameters.AddWithValue("@ownedSkins", Utils.GetCommaSepString(Client.Account.OwnedSkins.ToArray())); cmd.Parameters.AddWithValue("@id", AccountId); cmd.ExecuteNonQuery(); SendInfo( "New skin unlocked successfully. Change skins in your Vault, or start a new character to use."); Client.SendPacket(new UnlockedSkinPacket { SkinID = item.ActivateEffects[0].SkinType }); }); endMethod = false; break; } SendInfo("Error.alreadyOwnsSkin"); endMethod = true; break; case ActivateEffects.PermaPet: //Doesnt exist anymore { //psr.Character.Pet = XmlDatas.IdToType[eff.ObjectId]; //GivePet(XmlDatas.IdToType[eff.ObjectId]); //UpdateCount++; } break; case ActivateEffects.Pet: Entity en = Entity.Resolve(Manager, eff.ObjectId); en.Move(X, Y); en.SetPlayerOwner(this); Owner.EnterWorld(en); Owner.Timers.Add(new WorldTimer(30 * 1000, (w, t) => { w.LeaveWorld(en); })); break; case ActivateEffects.CreatePet: if (!Owner.Name.StartsWith("Pet Yard")) { SendInfo("server.use_in_petyard"); return true; } Pet.Create(Manager, this, item); break; case ActivateEffects.MysteryPortal: string[] dungeons = new[] { "Pirate Cave Portal", "Forest Maze Portal", "Spider Den Portal", "Snake Pit Portal", "Glowing Portal", "Forbidden Jungle Portal", "Candyland Portal", "Haunted Cemetery Portal", "Undead Lair Portal", "Davy Jones' Locker Portal", "Manor of the Immortals Portal", "Abyss of Demons Portal", "Lair of Draconis Portal", "Mad Lab Portal", "Ocean Trench Portal", "Tomb of the Ancients Portal", "Beachzone Portal", "The Shatters", "Deadwater Docks", "Woodland Labyrinth", "The Crawling Depths", "Treasure Cave Portal", "Battle Nexus Portal", "Belladonna's Garden Portal", "Lair of Shaitan Portal" }; var descs = Manager.GameData.Portals.Where(_ => dungeons.Contains<string>(_.Value.ObjectId)).Select(_ => _.Value).ToArray(); var portalDesc = descs[Random.Next(0, descs.Count())]; Entity por = Entity.Resolve(Manager, portalDesc.ObjectId); por.Move(this.X, this.Y); Owner.EnterWorld(por); Client.SendPacket(new NotificationPacket { Color = new ARGB(0x00FF00), Text = "{\"key\":\"blank\",\"tokens\":{\"data\":\"" + portalDesc.DungeonName + " opened by " + Client.Account.Name + "\"}}", ObjectId = Client.Player.Id }); Owner.BroadcastPacket(new TextPacket { BubbleTime = 0, Stars = -1, Name = "", Text = portalDesc.ObjectId + " opened by " + Name }, null); Owner.Timers.Add(new WorldTimer(portalDesc.TimeoutTime * 1000, (w, t) => //default portal close time * 1000 { try { w.LeaveWorld(por); } catch (Exception ex) { Entity.logger.ErrorFormat("Couldn't despawn portal.\n{0}", ex); } })); break; case ActivateEffects.GenericActivate: var targetPlayer = eff.Target.Equals("player"); var centerPlayer = eff.Center.Equals("player"); var duration = (eff.UseWisMod) ? (int)(UseWisMod(eff.DurationSec) * 1000) : eff.DurationMS; var range = (eff.UseWisMod) ? UseWisMod(eff.Range) : eff.Range; Owner.Aoe((eff.Center.Equals("mouse")) ? target : new Position { X = X, Y = Y }, range, targetPlayer, entity => { if (IsSpecial(entity.ObjectType)) return; if (!entity.HasConditionEffect(ConditionEffectIndex.Stasis) && !entity.HasConditionEffect(ConditionEffectIndex.Invincible)) { entity.ApplyConditionEffect( new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = duration }); } }); // replaced this last bit with what I had, never noticed any issue with it. // Perhaps I'm wrong? BroadcastSync(new ShowEffectPacket() { EffectType = (EffectType)eff.VisualEffect, TargetId = Id, Color = new ARGB(eff.Color ?? 0xffffffff), PosA = centerPlayer ? new Position { X = range } : target, PosB = new Position(target.X - range, target.Y) }, p => this.DistSqr(p) < 25); /*if (eff.VisualEffect > 0) { Placeholder x = null; if (eff.Center == "mouse") { x = new Placeholder(Manager, 1500); x.Move(pkt.ItemUsePos.X, pkt.ItemUsePos.Y); Owner.EnterWorld(x); } BroadcastSync(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = x?.Id ?? Id, Color = new ARGB(eff.Color ?? 0xffffffff), PosA = new Position {X = eff.VisualEffect/2}, }, p => this.Dist(p) < 25); }*/ break; } } UpdateCount++; return endMethod; }
private static void DrawLine(float x1, float x2, float y1, float y2, float size, ARGB color) { LeagueSharp.Drawing.DrawLine(x1, y1, x1, x2, size, color.ToSystemColor()); }
private void DoSmooth(int row, int col) { ARGB sum = new ARGB(); for (int y = -1; y < 2; y++) { for (int x = -1; x < 2; x++) { ARGB inValue = GetColor(row + y, col + x); sum.A += inValue.A; sum.B += inValue.B; sum.G += inValue.G; sum.R += inValue.R; } } sum.A = sum.A / 9; sum.B = sum.B / 9; sum.G = sum.G / 9; sum.R = sum.R / 9; PutColor(row, col, sum); }
private ARGB GetColor(int row, int col) { ARGB result = new ARGB(); if (row < 0) row = 0; if (col < 0) col = 0; if (row >= _bmpData.Height) row = _bmpData.Height-1; if (col >= _bmpData.Width) col = _bmpData.Width-1; int offset = row * _bmpData.Stride + col * 4; result.B = (int)_rgbData[offset]; result.G = (int)_rgbData[offset + 1]; result.R = (int)_rgbData[offset + 2]; result.A = (int)_rgbData[offset + 3]; return result; }
/// <summary> /// Save color image to files /// </summary> /// <param name="imMatrix">Image matrix needed to be saved</param> /// <param name="fileName">Specify the filename to be save in</param> public static void saveColorImage(ARGB[,] imMatrix, string fileName) { int i, j; ARGB pp; //PGM Picuture; fileName = (fileName + ".bmp"); int w = imMatrix.GetLength(0); int h = imMatrix.GetLength(1); Bitmap box1 = new Bitmap(w,h); // FastBitmap box11 = new FastBitmap(box1); Color cc = new Color(); for (i = 0; i < w; i++) for (j = 0; j < h; j++) { pp = imMatrix[i, j]; // cc = Color.FromArgb(255, 255, 255); cc = Color.FromArgb(pp.R, pp.G, pp.B); box1.SetPixel(i, j, cc); } /* for (i = 0; i < w; i++) for (j = 0; j < h; j++) { cc = box11.GetPixel(i, j); imMatrix[i, j] = cc.R; } */ // box1 = box11.Bitmap; // ShowImg("box1", imMatrix); // System.IO.File.Delete(fileName); box1.Save(fileName); //box11.Release(); }
void Activate(RealmTime time, Item item, Position target) { MP -= item.MpCost; foreach (var eff in item.ActivateEffects) { switch (eff.Effect) { case ActivateEffects.BulletNova: { var prjDesc = item.Projectiles[0]; //Assume only one Packet[] batch = new Packet[21]; uint s = Random.CurrentSeed; Random.CurrentSeed = (uint)(s * time.tickTimes); for (int i = 0; i < 20; i++) { Projectile proj = CreateProjectile(prjDesc, item.ObjectType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), time.tickTimes, target, (float)(i * (Math.PI * 2) / 20)); Owner.EnterWorld(proj); fames.Shoot(proj); batch[i] = new ShootPacket() { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = item.ObjectType, Position = target, Angle = proj.Angle, Damage = (short)proj.Damage }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket() { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0xFFFF00AA) }; Owner.BroadcastPackets(batch, null); } break; case ActivateEffects.Shoot: { ActivateShoot(time, item, target); } break; case ActivateEffects.StatBoostSelf: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } int s = eff.Amount; Boost[idx] += s; UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { Boost[idx] -= s; UpdateCount++; })); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Potion, TargetId = Id, Color = new ARGB(0xffffffff) }, null); } break; case ActivateEffects.StatBoostAura: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } int s = eff.Amount; Behavior.AOE(Owner, this, eff.Range / 2, true, player => { (player as Player).Boost[idx] += s; player.UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { (player as Player).Boost[idx] -= s; player.UpdateCount++; })); }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.ConditionEffectSelf: { ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = 1 } }, null); } break; case ActivateEffects.ConditionEffectAura: { Behavior.AOE(Owner, this, eff.Range / 2, true, player => { player.ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); }); uint color = 0xffffffff; if (eff.ConditionEffect.Value == ConditionEffectIndex.Damaging) color = 0xffff0000; Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.Heal: { List<Packet> pkts = new List<Packet>(); ActivateHealHp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.HealNova: { List<Packet> pkts = new List<Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ActivateHealHp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Magic: { List<Packet> pkts = new List<Packet>(); ActivateHealMp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.MagicNova: { List<Packet> pkts = new List<Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ActivateHealMp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Teleport: { Move(target.X, target.Y); UpdateCount++; Owner.BroadcastPackets(new Packet[] { new GotoPacket() { ObjectId = Id, Position = new Position() { X = X, Y = Y } }, new ShowEffectPacket() { EffectType = EffectType.Teleport, TargetId = Id, PosA = new Position() { X = X, Y = Y }, Color = new ARGB(0xFFFFFFFF) } }, null); } break; case ActivateEffects.VampireBlast: { List<Packet> pkts = new List<Packet>(); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Trail, TargetId = Id, PosA = target, Color = new ARGB(0xFFFF0000) }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Diffuse, Color = new ARGB(0xFFFF0000), TargetId = Id, PosA = target, PosB = new Position() { X = target.X + eff.Radius, Y = target.Y } }); int totalDmg = 0; var enemies = new List<Enemy>(); Behavior.AOE(Owner, target, eff.Radius, false, enemy => { enemies.Add(enemy as Enemy); totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false); }); var players = new List<Player>(); Behavior.AOE(Owner, this, eff.Radius, true, player => { players.Add(player as Player); ActivateHealHp(player as Player, totalDmg, pkts); }); Random rand = new System.Random(); for (int i = 0; i < 5; i++) { Enemy a = enemies[rand.Next(0, enemies.Count)]; Player b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position() { X = a.X, Y = a.Y }, Color = new ARGB(0xffffffff) }); } if (enemies.Count > 0) { Enemy a = enemies[rand.Next(0, enemies.Count)]; Player b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position() { X = a.X, Y = a.Y }, Color = new ARGB(0Xffffffff) }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Trap: { ARGB effColor = new ARGB(0xff9000ff); if (eff.Color != null) effColor = new ARGB((uint)eff.Color); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = effColor, TargetId = Id, PosA = target }, null); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Trap trap = new Trap( this, eff.Radius, eff.TotalDamage, eff.ConditionEffect ?? ConditionEffectIndex.Slowed, eff.EffectDuration); trap.Move(target.X, target.Y); world.EnterWorld(trap); })); } break; case ActivateEffects.StasisBlast: { List<Packet> pkts = new List<Packet>(); ARGB effColor = new ARGB(0xffffffff); if (eff.Color != null) effColor = new ARGB((uint)eff.Color); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Concentrate, TargetId = Id, PosA = target, PosB = new Position() { X = target.X + 3, Y = target.Y }, Color = effColor }); Behavior.AOE(Owner, target, 3, false, enemy => { if (enemy.HasConditionEffect(ConditionEffects.StasisImmune)) { pkts.Add(new NotificationPacket() { ObjectId = enemy.Id, Color = new ARGB(0xff00ff00), Text = "Immune" }); } else if (!enemy.HasConditionEffect(ConditionEffects.Stasis)) { enemy.ApplyConditionEffect( new ConditionEffect() { Effect = ConditionEffectIndex.Stasis, DurationMS = eff.DurationMS }, new ConditionEffect() { Effect = ConditionEffectIndex.Confused, DurationMS = eff.DurationMS } ); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { enemy.ApplyConditionEffect(new ConditionEffect() { Effect = ConditionEffectIndex.StasisImmune, DurationMS = 3000 } ); } )); pkts.Add(new NotificationPacket() { ObjectId = enemy.Id, Color = new ARGB(0xffff0000), Text = "Stasis" }); } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Decoy: { var decoy = new Decoy(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } break; case ActivateEffects.MultiDecoy: { for (var i = 0; i < eff.Amount; i++) { var decoy = Decoy.DecoyRandom(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } } break; case ActivateEffects.Lightning: { Enemy start = null; double angle = Math.Atan2(target.Y - Y, target.X - X); double diff = Math.PI / 3; Behavior.AOE(Owner, target, 6, false, enemy => { if (!(enemy is Enemy)) return; var x = Math.Atan2(enemy.Y - Y, enemy.X - X); if (Math.Abs(angle - x) < diff) { start = enemy as Enemy; diff = Math.Abs(angle - x); } }); if (start == null) break; Enemy current = start; Enemy[] targets = new Enemy[eff.MaxTargets]; for (int i = 0; i < targets.Length; i++) { targets[i] = current; float dist = 8; Enemy next = Behavior.GetNearestEntity(current, ref dist, false, enemy => enemy is Enemy && Array.IndexOf(targets, enemy) == -1 && Behavior.Dist(this, enemy) <= 6) as Enemy; if (next == null) break; else current = next; } List<Packet> pkts = new List<Packet>(); for (int i = 0; i < targets.Length; i++) { if (targets[i] == null) break; Entity prev = i == 0 ? (Entity)this : targets[i - 1]; targets[i].Damage(this, time, eff.TotalDamage, false); if (eff.ConditionEffect != null) targets[i].ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = (int)(eff.EffectDuration * 1000) }); ARGB shotColor = new ARGB(0xffff0088); if (eff.Color != null) shotColor = new ARGB((uint)eff.Color); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Lightning, TargetId = prev.Id, Color = shotColor, PosA = new Position() { X = targets[i].X, Y = targets[i].Y }, PosB = new Position() { X = 350 } }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.PoisonGrenade: { try { Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = new ARGB(0xffddff00), TargetId = Id, PosA = target }, null); Placeholder x = new Placeholder(1500); x.Move(target.X, target.Y); Owner.EnterWorld(x); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { try { Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, Color = new ARGB(0xffddff00), TargetId = x.Id, PosA = new Position() { X = eff.Radius } }, null); } catch { Console.ForegroundColor = ConsoleColor.DarkRed; Console.Out.WriteLine("Crash halted - Nobody likes death..."); Console.ForegroundColor = ConsoleColor.White; } List<Enemy> enemies = new List<Enemy>(); Behavior.AOE(world, target, eff.Radius, false, enemy => PoisonEnemy(enemy as Enemy, eff)); })); } catch { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.Out.WriteLine("Crash halted - Poison grenade??"); Console.ForegroundColor = ConsoleColor.White; } } break; case ActivateEffects.RemoveNegativeConditions: { Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ApplyConditionEffect(NegativeEffs); }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.RemoveNegativeConditionsSelf: { ApplyConditionEffect(NegativeEffs); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = 1 } }, null); } break; case ActivateEffects.IncrementStat: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } Stats[idx] += eff.Amount; int limit = int.Parse(XmlDatas.TypeToElement[ObjectType].Element(StatsManager.StatsIndexToName(idx)).Attribute("max").Value); if (Stats[idx] > limit) Stats[idx] = limit; UpdateCount++; } break; case ActivateEffects.Create: //this is a portal { short objType; if (!XmlDatas.IdToType.TryGetValue(eff.Id, out objType) || !XmlDatas.PortalDescs.ContainsKey(objType)) break;// object not found, ignore var entity = Entity.Resolve(objType); entity.Move(X, Y); int TimeoutTime = XmlDatas.PortalDescs[objType].TimeoutTime; string DungName = XmlDatas.PortalDescs[objType].DungeonName; Owner.EnterWorld(entity); ARGB c; c.A = 0; c.B = 91; c.R = 233; c.G = 176; psr.SendPacket(new NotificationPacket() { Color = c, Text = DungName + " opened by " + psr.Account.Name, ObjectId = psr.Player.Id }); World w = RealmManager.GetWorld(Owner.Id); //can't use Owner here, as it goes out of scope w.BroadcastPacket(new TextPacket() { BubbleTime = 0, Stars = -1, Name = "", Text = DungName + " opened by " + psr.Account.Name }, null); w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w.LeaveWorld(entity); } catch //couldn't remove portal, Owner became null. Should be fixed with RealmManager implementation { Console.WriteLine("Couldn't despawn portal."); } })); } break; case ActivateEffects.Dye: { if (item.Texture1 != 0) { this.Texture1 = item.Texture1; } if (item.Texture2 != 0) { this.Texture2 = item.Texture2; } this.SaveToCharacter(); } break; case ActivateEffects.ShurikenAbility: { World w = RealmManager.GetWorld(Owner.Id); ApplyConditionEffect(new ConditionEffect() { Effect = ConditionEffectIndex.Speedy, DurationMS = eff.DurationMS }); w.Timers.Add(new WorldTimer(eff.DurationMS * 1000, (world, t) => { try { ActivateShoot(time, item, target); } catch (System.Exception ex) { Console.WriteLine("Could not end effect"); } })); } break; case ActivateEffects.TomeDamage: { List<Packet> pkts = new List<Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, false, enemy => { (enemy as Enemy).Damage(this, time, (int)this.statsMgr.GetAttackDamage(eff.TotalDamage, eff.TotalDamage), false, new ConditionEffect[0]); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xFF00FF00), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Mushroom: { World w = RealmManager.GetWorld(Owner.Id); Size = eff.Amount; UpdateCount++; w.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { try { Size = 100; UpdateCount++; } catch { } })); } break; case ActivateEffects.Pet: case ActivateEffects.UnlockPortal: break; } } UpdateCount++; }
/// <summary> /// show the recongnition result /// </summary> /// <summary> /// show the result; /// </summary> /// <param name="num"></param> /// <summary> /// Show color image /// </summary> /// <param name="str">The name for the form</param> /// <param name="imMatrix">Matrix needed to be show</param> public static void ShowImg(string str, ARGB[,] imMatrix) { int i, j, w, h; int rr, gg, bb; Form2 child = new Form2(); probsolve = child; child.Text = str; w = imMatrix.GetLength(0); h = imMatrix.GetLength(1); Bitmap box1 = new Bitmap(w, h); FastBitmap box11 = new FastBitmap(box1); child.Show(); Color cc = new Color(); for (i = 0; i < w; i++) for (j = 0; j < h; j++) { rr = imMatrix[i, j].R; gg = imMatrix[i, j].G; bb = imMatrix[i, j].B; cc = Color.FromArgb(rr, gg, bb); box11.SetPixel(i, j, cc); } child.PictureBox1.Refresh(); box1 = box11.Bitmap; child.PictureBox1.Image = box1; box11.Release(); // Application.Run(child); }
private static void DrawRectangle(float x, float y, float width, float height, ARGB color) { new Render.Rectangle((int)x, (int)y, (int)width, (int)height, new ColorBGRA(color.ToSystemColor().ToArgb())).Add(); }
private static void DrawCircle(float x, float y, float z, float size, ARGB color) { LeagueSharp.Drawing.DrawCircle(new Vector3(x, y, z), size, color.ToSystemColor()); }
private void Activate(RealmTime time, Item item, Position target) { MP -= item.MpCost; foreach (var eff in item.ActivateEffects) { switch (eff.Effect) { case ActivateEffects.BulletNova: { var prjDesc = item.Projectiles[0]; //Assume only one var batch = new Packet[21]; var s = Random.CurrentSeed; Random.CurrentSeed = (uint)(s * time.tickTimes); for (var i = 0; i < 20; i++) { var proj = CreateProjectile(prjDesc, item.ObjectType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), time.tickTimes, target, (float)(i * (Math.PI * 2) / 20)); Owner.EnterWorld(proj); fames.Shoot(proj); batch[i] = new ShootPacket { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = item.ObjectType, Position = target, Angle = proj.Angle, Damage = (short)proj.Damage }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0xFFFF00AA) }; Owner.BroadcastPackets(batch, null); } break; case ActivateEffects.Shoot: { ActivateShoot(time, item, target); } break; case ActivateEffects.StatBoostSelf: { var idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } var pkts = new List<Packet>(); ActivateBoostStat(this, idx, pkts); var OGstat = oldstat; var s = eff.Amount; Boost[idx] += s; UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { Boost[idx] = OGstat; UpdateCount++; })); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Potion, TargetId = Id, Color = new ARGB(0xffffffff) }, null); } break; case ActivateEffects.StatBoostAura: { var idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } var s = eff.Amount; BehaviorBase.AOE(Owner, this, eff.Range, true, player => { (player as Player).Boost[idx] += s; player.UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { (player as Player).Boost[idx] -= s; player.UpdateCount++; })); }); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = eff.Range } }, null); } break; case ActivateEffects.ConditionEffectSelf: { ApplyConditionEffect(new ConditionEffect { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = 1 } }, null); } break; case ActivateEffects.Tag: { //Add Tag to DB using (Database db = new Database()) { var db1 = db.CreateQuery(); db1.CommandText = "SELECT tags FROM accounts WHERE id=@id;"; db1.Parameters.AddWithValue("@id", psr.Account.AccountId); db1.ExecuteScalar(); db1.Parameters.AddWithValue("@tags", item.ObjectId); db1.CommandText = "UPDATE accounts SET tags=@tags"; db1.ExecuteNonQuery(); UpdateCount++; } } break; case ActivateEffects.ConditionEffectAura: { BehaviorBase.AOE(Owner, this, eff.Range, true, player => { player.ApplyConditionEffect(new ConditionEffect { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); }); var color = 0xffffffff; if (eff.ConditionEffect.Value == ConditionEffectIndex.Damaging) color = 0xffff0000; Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position { X = eff.Range } }, null); } break; case ActivateEffects.Heal: { var pkts = new List<Packet>(); ActivateHealHp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.HealNova: { var pkts = new List<Packet>(); BehaviorBase.AOE(Owner, this, eff.Range, true, player => { ActivateHealHp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = eff.Range } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Magic: { var pkts = new List<Packet>(); ActivateHealMp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.MagicNova: { var pkts = new List<Packet>(); BehaviorBase.AOE(Owner, this, eff.Range, true, player => { ActivateHealMp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = eff.Range } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Teleport: { Move(target.X, target.Y); UpdateCount++; Owner.BroadcastPackets(new Packet[] { new GotoPacket { ObjectId = Id, Position = new Position { X = X, Y = Y } }, new ShowEffectPacket { EffectType = EffectType.Teleport, TargetId = Id, PosA = new Position { X = X, Y = Y }, Color = new ARGB(0xFFFFFFFF) } }, null); } break; case ActivateEffects.VampireBlast: { var pkts = new List<Packet>(); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Trail, TargetId = Id, PosA = target, Color = new ARGB(0xFFFF0000) }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Diffuse, Color = new ARGB(0xFFFF0000), TargetId = Id, PosA = target, PosB = new Position { X = target.X + eff.Radius, Y = target.Y } }); var totalDmg = 0; var enemies = new List<Enemy>(); BehaviorBase.AOE(Owner, target, eff.Radius, false, enemy => { enemies.Add(enemy as Enemy); totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false); }); var players = new List<Player>(); BehaviorBase.AOE(Owner, this, eff.Radius, true, player => { players.Add(player as Player); ActivateHealHp(player as Player, totalDmg, pkts); }); var rand = new Random(); for (var i = 0; i < 5; i++) { var a = enemies[rand.Next(0, enemies.Count)]; var b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position { X = a.X, Y = a.Y }, Color = new ARGB(0xffffffff) }); } if (enemies.Count > 0) { var a = enemies[rand.Next(0, enemies.Count)]; var b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position { X = a.X, Y = a.Y }, Color = new ARGB(0Xffffffff) }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Trap: { var effColor = new ARGB(0xff9000ff); if (eff.Color != null) effColor = new ARGB((uint)eff.Color); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Throw, Color = effColor, TargetId = Id, PosA = target }, null); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { var trap = new Trap( this, eff.Radius, eff.TotalDamage, eff.ConditionEffect ?? ConditionEffectIndex.Slowed, eff.EffectDuration); trap.Move(target.X, target.Y); world.EnterWorld(trap); })); } break; case ActivateEffects.StasisBlast: { var pkts = new List<Packet>(); var effColor = new ARGB(0xffffffff); if (eff.Color != null) effColor = new ARGB((uint)eff.Color); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Concentrate, TargetId = Id, PosA = target, PosB = new Position { X = target.X + 3, Y = target.Y }, Color = effColor }); BehaviorBase.AOE(Owner, target, 3, false, enemy => { if (enemy.HasConditionEffect(ConditionEffects.StasisImmune)) { pkts.Add(new NotificationPacket { ObjectId = enemy.Id, Color = new ARGB(0xff00ff00), Text = "Immune" }); } else if (enemy.isPet) { } else if (!enemy.HasConditionEffect(ConditionEffects.Stasis)) { enemy.ApplyConditionEffect( new ConditionEffect { Effect = ConditionEffectIndex.Stasis, DurationMS = eff.DurationMS }, new ConditionEffect { Effect = ConditionEffectIndex.Confused, DurationMS = eff.DurationMS } ); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { enemy.ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.StasisImmune, DurationMS = 3000 } ); } )); pkts.Add(new NotificationPacket { ObjectId = enemy.Id, Color = new ARGB(0xffff0000), Text = "Stasis" }); } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Decoy: { var decoy = new Decoy(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } break; case ActivateEffects.MultiDecoy: { for (var i = 0; i < eff.Amount; i++) { var decoy = Decoy.DecoyRandom(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } } break; case ActivateEffects.Lightning: { Enemy start = null; var angle = Math.Atan2(target.Y - Y, target.X - X); var diff = Math.PI / 3; BehaviorBase.AOE(Owner, target, 6, false, enemy => { if (!(enemy is Enemy)) return; var x = Math.Atan2(enemy.Y - Y, enemy.X - X); if (Math.Abs(angle - x) < diff) { start = enemy as Enemy; diff = Math.Abs(angle - x); } }); if (start == null) break; var current = start; var targets = new Enemy[eff.MaxTargets]; for (var i = 0; i < targets.Length; i++) { targets[i] = current; float dist = 8; var next = BehaviorBase.GetNearestEntity(current, ref dist, false, enemy => enemy is Enemy && Array.IndexOf(targets, enemy) == -1 && BehaviorBase.Dist(this, enemy) <= 6) as Enemy; if (next == null) break; current = next; } var pkts = new List<Packet>(); for (var i = 0; i < targets.Length; i++) { if (targets[i] == null) break; var prev = i == 0 ? (Entity)this : targets[i - 1]; targets[i].Damage(this, time, eff.TotalDamage, false); if (eff.ConditionEffect != null) targets[i].ApplyConditionEffect(new ConditionEffect { Effect = eff.ConditionEffect.Value, DurationMS = (int)(eff.EffectDuration * 1000) }); var shotColor = new ARGB(0xffff0088); if (eff.Color != null) shotColor = new ARGB((uint)eff.Color); pkts.Add(new ShowEffectPacket { EffectType = EffectType.Lightning, TargetId = prev.Id, Color = shotColor, PosA = new Position { X = targets[i].X, Y = targets[i].Y }, PosB = new Position { X = 350 } }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.PoisonGrenade: { try { Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Throw, Color = new ARGB(0xffddff00), TargetId = Id, PosA = target }, null); var x = new Placeholder(1500); x.Move(target.X, target.Y); Owner.EnterWorld(x); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { try { Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, Color = new ARGB(0xffddff00), TargetId = x.Id, PosA = new Position { X = eff.Radius } }, null); } catch { Console.ForegroundColor = ConsoleColor.DarkRed; Console.Out.WriteLine("Crash halted - Nobody likes death..."); Console.ForegroundColor = ConsoleColor.White; } var enemies = new List<Enemy>(); BehaviorBase.AOE(world, target, eff.Radius, false, enemy => PoisonEnemy(enemy as Enemy, eff)); })); } catch { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.Out.WriteLine("Crash halted - Poison grenade??"); Console.ForegroundColor = ConsoleColor.White; } } break; case ActivateEffects.RemoveNegativeConditions: { BehaviorBase.AOE(Owner, this, eff.Range, true, player => { ApplyConditionEffect(NegativeEffs); }); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = eff.Range } }, null); } break; case ActivateEffects.RemoveNegativeConditionsSelf: { ApplyConditionEffect(NegativeEffs); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position { X = 1 } }, null); } break; case ActivateEffects.IncrementStat: { var idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } Stats[idx] += eff.Amount; var limit = int.Parse( XmlDatas.TypeToElement[ObjectType].Element(StatsManager.StatsIndexToName(idx)) .Attribute("max") .Value); if (Stats[idx] > limit) Stats[idx] = limit; UpdateCount++; } break; case ActivateEffects.Create: //this is a portal { short objType; if (!XmlDatas.IdToType.TryGetValue(eff.Id, out objType) || !XmlDatas.PortalDescs.ContainsKey(objType)) break; // object not found, ignore var entity = Resolve(objType); var w = RealmManager.GetWorld(Owner.Id); //can't use Owner here, as it goes out of scope var TimeoutTime = XmlDatas.PortalDescs[objType].TimeoutTime; var DungName = XmlDatas.PortalDescs[objType].DungeonName; ARGB c; c.A = 0; c.B = 91; c.R = 233; c.G = 176; if (eff.Id == "Wine Cellar Portal") //wine cellar incantation { var opened = false; foreach (var i in w.StaticObjects) { if (i.Value.ObjectType == 0x0721) //locked wine cellar portal { opened = true; entity.Move(i.Value.X, i.Value.Y); w.EnterWorld(entity); w.LeaveWorld(i.Value); UpdateCount++; } } if (opened) { psr.SendPacket(new NotificationPacket { Color = c, Text = DungName + " opened by " + psr.Account.Name, ObjectId = psr.Player.Id }); w.BroadcastPacket(new TextPacket { BubbleTime = 0, Stars = -1, Name = "", Text = DungName + " opened by " + psr.Account.Name }, null); w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w.LeaveWorld(entity); } catch //couldn't remove portal, Owner became null. Should be fixed with RealmManager implementation { Console.WriteLine(@"Couldn't despawn portal."); } })); } } else { entity.Move(X, Y); w.EnterWorld(entity); psr.SendPacket(new NotificationPacket { Color = c, Text = DungName + " opened by " + psr.Account.Name, ObjectId = psr.Player.Id }); w.BroadcastPacket(new TextPacket { BubbleTime = 0, Stars = -1, Name = "", Text = DungName + " opened by " + psr.Account.Name }, null); w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w.LeaveWorld(entity); } catch //couldn't remove portal, Owner became null. Should be fixed with RealmManager implementation { Console.WriteLine(@"Couldn't despawn portal."); } })); } } break; case ActivateEffects.Dye: { if (item.Texture1 != 0) { Texture1 = item.Texture1; } if (item.Texture2 != 0) { Texture2 = item.Texture2; } SaveToCharacter(); } break; case ActivateEffects.PartyAOE: { var randomnumber = Random.Next(1, 5); ConditionEffectIndex partyeffect = 0; var color = 0xffffffff; if (randomnumber == 1) { partyeffect = ConditionEffectIndex.Damaging; color = 0xffff0000; } if (randomnumber == 2) { color = 0xff00ff00; partyeffect = ConditionEffectIndex.Speedy; } if (randomnumber == 3) { color = 0xffffd800; partyeffect = ConditionEffectIndex.Berserk; } if (randomnumber == 4) { color = 0xff00ffff; partyeffect = ConditionEffectIndex.Healing; } BehaviorBase.AOE(Owner, this, eff.Range, true, player => { player.ApplyConditionEffect(new ConditionEffect { Effect = partyeffect, DurationMS = eff.DurationMS }); }); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position { X = eff.Range } }, null); } break; case ActivateEffects.ShurikenAbility: { var w = RealmManager.GetWorld(Owner.Id); ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Speedy, DurationMS = eff.DurationMS }); var pt = eff.ObjectId; short obj; XmlDatas.IdToType.TryGetValue(pt, out obj); var substitute = Resolve(obj); substitute.PlayerOwner = this; substitute.isPet = true; w.EnterWorld(substitute); substitute.Move(X, Y); targetlink = target; } break; case ActivateEffects.TomeDamage: { var pkts = new List<Packet>(); BehaviorBase.AOE(Owner, this, eff.Range, false, enemy => { (enemy as Enemy).Damage(this, time, (int)statsMgr.GetAttackDamage(eff.TotalDamage, eff.TotalDamage), false, new ConditionEffect[0]); }); pkts.Add(new ShowEffectPacket { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xFF00FF00), PosA = new Position { X = eff.Range } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Mushroom: { var w = RealmManager.GetWorld(Owner.Id); Size = eff.Amount; UpdateCount++; w.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { try { Size = 100; UpdateCount++; } catch { } })); } break; case ActivateEffects.PearlAbility: { var w = RealmManager.GetWorld(Owner.Id); var pt = eff.ObjectId; short obj; XmlDatas.IdToType.TryGetValue(pt, out obj); var substitute = Resolve(obj); substitute.PlayerOwner = this; substitute.isPet = true; w.EnterWorld(substitute); substitute.Move(X, Y); targetlink = target; var pkts = new List<Packet>(); ActivateHealHp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.PermaPet: { psr.Character.Pet = XmlDatas.IdToType[eff.ObjectId]; GivePet(XmlDatas.IdToType[eff.ObjectId]); UpdateCount++; } break; case ActivateEffects.MiniPot: { Client.Player.Stats[1] = 1; Client.Player.Stats[0] = 1; Client.Player.Stats[6] = 1; Client.Player.Stats[7] = 1; Client.Player.Stats[2] = 1; Client.Player.Stats[3] = 1; Client.Player.Stats[5] = 1; Client.Player.Stats[4] = 1; } break; case ActivateEffects.Backpack: { var bps = 1; foreach (var i in psr.Character.Backpacks) { if (bps < i.Key) bps = i.Key; } psr.Character.Backpacks.Add(bps + 1, new short[] { -1, -1, -1, -1, -1, -1, -1, -1 }); new Database().SaveBackpacks(psr.Character, psr.Account); SendInfo("Added backpack #" + (bps + 1)); } break; case ActivateEffects.Drake: { var w = RealmManager.GetWorld(Owner.Id); var pt = eff.ObjectId; short obj; XmlDatas.IdToType.TryGetValue(pt, out obj); var drake = Resolve(obj); drake.PlayerOwner = this; w.EnterWorld(drake); drake.Move(X, Y); Owner.BroadcastPacket(new ShowEffectPacket { TargetId = Id, Color = new ARGB(0x9195A9), EffectType = EffectType.AreaBlast, PosA = new Position { X = 1 } }, null); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { w.LeaveWorld(drake); })); } break; case ActivateEffects.BuildTower: { var w = RealmManager.GetWorld(Owner.Id); var pt = eff.ObjectId; short obj; XmlDatas.IdToType.TryGetValue(pt, out obj); var tower = Resolve(obj); tower.PlayerOwner = this; tower.isPet = true; w.EnterWorld(tower); tower.Move(X, Y); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { w.LeaveWorld(tower); })); } break; case ActivateEffects.MonsterToss: { var w = RealmManager.GetWorld(Owner.Id); var pt = eff.ObjectId; short obj; XmlDatas.IdToType.TryGetValue(pt, out obj); var monster = Resolve(obj); Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Throw, Color = new ARGB(0x000000), TargetId = Id, PosA = target }, null); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { w.EnterWorld(monster); monster.Move(target.X, target.Y); })); } break; case ActivateEffects.Halo: { var halo = new Halo(this, eff.Range, eff.Amount, eff.DurationMS); halo.Move(X, Y); Owner.EnterWorld(halo); } break; case ActivateEffects.Fame: { CurrentFame = psr.Account.Stats.Fame = new Database().UpdateFame(psr.Account, eff.Amount); } break; case ActivateEffects.SamuraiAbility: { var ydist = target.Y - Y; var xdist = target.X - X; var xwalkable = target.X + xdist / 2; var ywalkable = target.Y + ydist / 2; var tile = Owner.Map[(int)xwalkable, (int)ywalkable]; ObjectDesc desc; if (XmlDatas.TileDescs[tile.TileId].NoWalk) return; if (XmlDatas.ObjectDescs.TryGetValue(tile.ObjType, out desc)) { if (!desc.Static) return; } Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Diffuse, Color = new ARGB(0xFFFF0000), TargetId = Id, PosA = target, PosB = new Position { X = target.X + eff.Radius, Y = target.Y } }, null); BehaviorBase.AOE(Owner, target, eff.Radius, false, enemy => { (enemy as Enemy).Damage(this, time, eff.TotalDamage, false, new ConditionEffect { Effect = ConditionEffectIndex.Bleeding, DurationMS = eff.DurationMS }); }); Move(target.X + xdist / 2, target.Y + ydist / 2); UpdateCount++; Owner.BroadcastPackets(new Packet[] { new GotoPacket { ObjectId = Id, Position = new Position { X = X, Y = Y } }, new ShowEffectPacket { EffectType = EffectType.Teleport, TargetId = Id, PosA = new Position { X = X, Y = Y }, Color = new ARGB(0xFFFFFFFF) } }, null); ApplyConditionEffect(new ConditionEffect { Effect = ConditionEffectIndex.Paralyzed, DurationMS = eff.DurationMS2 }); } break; case ActivateEffects.Summon: { var w = RealmManager.GetWorld(Owner.Id); var pt = eff.ObjectId + " Summon"; short obj; XmlDatas.IdToType.TryGetValue(pt, out obj); var summon = Resolve(obj); summon.PlayerOwner = this; summon.isPet = true; w.EnterWorld(summon); summon.Move(X, Y); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { w.LeaveWorld(summon); })); } break; } } UpdateCount++; }
private void PutColor(int row, int col, ARGB color) { int offset = row * _bmpData.Stride + col * 4; _result[offset] = color.ToByte(color.B); _result[offset + 1] = color.ToByte(color.G); _result[offset + 2] = color.ToByte(color.R); _result[offset + 3] = color.ToByte(color.A); }
private static void DrawPoint(float x, float y, float thickness, ARGB color) { LeagueSharp.Drawing.DrawLine(new Vector2(x, y), new Vector2(x, y), thickness, color.ToSystemColor()); }
private static void DrawText(string text, int size, float x, float y, ARGB color) { LeagueSharp.Drawing.DrawText(x, y, color.ToSystemColor(), text); }