// Searching image code //private void btnPicture_Click(object sender, EventArgs e) //{ // OpenFileDialog dig = new OpenFileDialog(); // dig.Filter = "JPG Files(*.jpg)|*.jpg|PNG Files(*.png)|*.png|ALL Files(*.*)|*.*"; // dig.Title = "Select Product Image"; // if (dig.ShowDialog() == DialogResult.OK) // { // string location = dig.FileName.ToString(); // pictureBox1.ImageLocation = location; // } //} private void Registration_Form_Load(object sender, EventArgs e) { DoT.Hide(); cboJob.SelectedIndex = 0; cboQuestion.SelectedIndex = 0; AutoCompleteStringCollection cols = new AutoCompleteStringCollection(); try { con.Open(); SqlCommand cmd = new SqlCommand("select * from tblUsers ", con); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { cols.Add(read["First_Name"].ToString()); cols.Add(read["Last_Name"].ToString()); txtFirst.AutoCompleteCustomSource = cols; txtLast.AutoCompleteCustomSource = cols; } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); con.Close(); } }
// Form loading private void Selling_Form_Load(object sender, System.EventArgs e) { pnInscription.Hide(); rank(Convert.ToInt32(lblRank.Text)); cboCategory.SelectedIndex = 0; txtAlert.Hide(); txtSTotal.Hide(); txt.Hide(); DoT.Hide(); lblRank.Hide(); // table.Columns.Add("SNo", typeof(int)); table.Columns.Add("Category", typeof(string)); table.Columns.Add("Item Name", typeof(string)); table.Columns.Add("Item ID", typeof(string)); table.Columns.Add("Dosage", typeof(string)); table.Columns.Add("Strength", typeof(string)); table.Columns.Add("Selling Qnty", typeof(int)); table.Columns.Add("Qnty Purchase", typeof(int)); table.Columns.Add("Price", typeof(int)); table.Columns.Add("Sub Total", typeof(int)); table.Columns.Add("Items Remains", typeof(int)); DataGridView1.DataSource = table; try { connection.Open(); SqlCommand cmd = new SqlCommand("select * from tblPurchases ", connection); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { cboCategory.Items.Add(read["Category"].ToString()); } connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); connection.Close(); } //autocompletion code AutoCompleteStringCollection col = new AutoCompleteStringCollection(); try { connection.Open(); SqlCommand cmd = new SqlCommand("select * from tblPurchases ", connection); SqlDataReader read = cmd.ExecuteReader(); while (read.Read()) { col.Add(read["Category"].ToString()); cboCategory.AutoCompleteCustomSource = col; } connection.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); connection.Close(); } }
public void ApplyDoT(float damage, float duration) { if (Dots == null) { Dots = new List <DoT>(); } DoT dot = new DoT(); dot.Damage = damage; dot.Duration = duration; Dots.Add(dot); }
// TODO: Improve NPC movement to be more fluid like a player //General Updating public override void Update(long timeMs) { var curMapLink = MapId; base.Update(timeMs); var statuses = Statuses.Values.ToArray(); foreach (var status in statuses) { if (status.Type == StatusTypes.Stun || status.Type == StatusTypes.Sleep) { return; } } //TODO Clear Damage Map if out of combat (target is null and combat timer is to the point that regen has started) if (Target == null && Globals.Timing.Milliseconds > CombatTimer && Globals.Timing.Milliseconds > RegenTimer) { DamageMap.Clear(); } var fleeing = false; if (Base.FleeHealthPercentage > 0) { var fleeHpCutoff = GetMaxVital(Vitals.Health) * ((float)Base.FleeHealthPercentage / 100f); if (GetVital(Vitals.Health) < fleeHpCutoff) { fleeing = true; } } if (MoveTimer < Globals.Timing.Milliseconds) { var targetMap = Guid.Empty; var targetX = 0; var targetY = 0; var targetZ = 0; //Check if there is a target, if so, run their ass down. if (Target != null) { if (!Target.IsDead() && CanAttack(Target, null)) { targetMap = Target.MapId; targetX = Target.X; targetY = Target.Y; targetZ = Target.Z; var targetStatuses = Target.Statuses.Values.ToArray(); foreach (var targetStatus in targetStatuses) { if (targetStatus.Type == StatusTypes.Stealth) { targetMap = Guid.Empty; targetX = 0; targetY = 0; targetZ = 0; } } } else { if (CastTime <= 0) { RemoveTarget(); } } } else //Find a target if able { long dmg = 0; Entity tgt = null; foreach (var pair in DamageMap) { if (pair.Value > dmg) { dmg = pair.Value; tgt = pair.Key; } } if (tgt != null) { AssignTarget(tgt); } else { // Check if attack on sight or have other npc's to target TryFindNewTarget(timeMs); } } if (targetMap != Guid.Empty) { //Check if target map is on one of the surrounding maps, if not then we are not even going to look. if (targetMap != MapId) { if (MapInstance.Get(MapId).SurroundingMaps.Count > 0) { for (var x = 0; x < MapInstance.Get(MapId).SurroundingMaps.Count; x++) { if (MapInstance.Get(MapId).SurroundingMaps[x] == targetMap) { break; } if (x == MapInstance.Get(MapId).SurroundingMaps.Count - 1) { targetMap = Guid.Empty; } } } else { targetMap = Guid.Empty; } } } if (targetMap != Guid.Empty) { if (mPathFinder.GetTarget() != null) { if (targetMap != mPathFinder.GetTarget().TargetMapId || targetX != mPathFinder.GetTarget().TargetX || targetY != mPathFinder.GetTarget().TargetY) { mPathFinder.SetTarget(null); } } if (mPathFinder.GetTarget() == null) { mPathFinder.SetTarget(new PathfinderTarget(targetMap, targetX, targetY, targetZ)); } } if (mPathFinder.GetTarget() != null) { TryCastSpells(); if (!IsOneBlockAway( mPathFinder.GetTarget().TargetMapId, mPathFinder.GetTarget().TargetX, mPathFinder.GetTarget().TargetY, mPathFinder.GetTarget().TargetZ )) { switch (mPathFinder.Update(timeMs)) { case PathfinderResult.Success: var dir = mPathFinder.GetMove(); if (dir > -1) { if (fleeing) { switch (dir) { case 0: dir = 1; break; case 1: dir = 0; break; case 2: dir = 3; break; case 3: dir = 2; break; } } if (CanMove(dir) == -1 || CanMove(dir) == -4) { //check if NPC is snared or stunned statuses = Statuses.Values.ToArray(); foreach (var status in statuses) { if (status.Type == StatusTypes.Stun || status.Type == StatusTypes.Snare || status.Type == StatusTypes.Sleep) { return; } } Move((byte)dir, null); } else { mPathFinder.PathFailed(timeMs); } // Have we reached our destination? If so, clear it. var tloc = mPathFinder.GetTarget(); if (tloc.TargetMapId == MapId && tloc.TargetX == X && tloc.TargetY == Y) { targetMap = Guid.Empty; // Reset our aggro center so we can get "pulled" again. AggroCenterMap = null; AggroCenterX = 0; AggroCenterY = 0; AggroCenterZ = 0; } } break; case PathfinderResult.OutOfRange: RemoveTarget(); targetMap = Guid.Empty; break; case PathfinderResult.NoPathToTarget: TryFindNewTarget(timeMs, Target?.Id ?? Guid.Empty); targetMap = Guid.Empty; break; case PathfinderResult.Failure: targetMap = Guid.Empty; RemoveTarget(); break; case PathfinderResult.Wait: targetMap = Guid.Empty; break; default: throw new ArgumentOutOfRangeException(); } } else { var fleed = false; if (Target != null && fleeing) { var dir = DirToEnemy(Target); switch (dir) { case 0: dir = 1; break; case 1: dir = 0; break; case 2: dir = 3; break; case 3: dir = 2; break; } if (CanMove(dir) == -1 || CanMove(dir) == -4) { //check if NPC is snared or stunned statuses = Statuses.Values.ToArray(); foreach (var status in statuses) { if (status.Type == StatusTypes.Stun || status.Type == StatusTypes.Snare || status.Type == StatusTypes.Sleep) { return; } } Move(dir, null); fleed = true; } } if (!fleed) { if (Target != null) { if (Dir != DirToEnemy(Target) && DirToEnemy(Target) != -1) { ChangeDir(DirToEnemy(Target)); } else { if (Target.IsDisposed) { Target = null; } else { if (CanAttack(Target, null)) { TryAttack(Target); } } } } } } } //Move randomly if (targetMap != Guid.Empty) { return; } if (LastRandomMove >= Globals.Timing.Milliseconds || CastTime > 0) { return; } if (Base.Movement == (int)NpcMovement.StandStill) { LastRandomMove = Globals.Timing.Milliseconds + Randomization.Next(1000, 3000); return; } else if (Base.Movement == (int)NpcMovement.TurnRandomly) { ChangeDir((byte)Randomization.Next(0, 4)); LastRandomMove = Globals.Timing.Milliseconds + Randomization.Next(1000, 3000); return; } var i = Randomization.Next(0, 1); if (i == 0) { i = Randomization.Next(0, 4); if (CanMove(i) == -1) { //check if NPC is snared or stunned statuses = Statuses.Values.ToArray(); foreach (var status in statuses) { if (status.Type == StatusTypes.Stun || status.Type == StatusTypes.Snare || status.Type == StatusTypes.Sleep) { return; } } Move((byte)i, null); } } LastRandomMove = Globals.Timing.Milliseconds + Randomization.Next(1000, 3000); if (fleeing) { LastRandomMove = Globals.Timing.Milliseconds + (long)GetMovementTime(); } } //If we switched maps, lets update the maps if (curMapLink != MapId) { if (curMapLink == Guid.Empty) { MapInstance.Get(curMapLink).RemoveEntity(this); } if (MapId != Guid.Empty) { MapInstance.Get(MapId).AddEntity(this); } } // Check if we've moved out of our range we're allowed to move from after being "aggro'd" by something. // If so, remove target and move back to the origin point. if (Options.Npc.AllowResetRadius && AggroCenterMap != null && GetDistanceTo(AggroCenterMap, AggroCenterX, AggroCenterY) > Options.Npc.ResetRadius) { // Remove our target. RemoveTarget(); // Reset our vitals and statusses when configured. if (Options.Npc.ResetVitalsAndStatusses) { Statuses.Clear(); DoT.Clear(); for (var v = 0; v < (int)Vitals.VitalCount; v++) { RestoreVital((Vitals)v); } } // Try and move back to where we came from before we started chasing something. mPathFinder.SetTarget(new PathfinderTarget(AggroCenterMap.Id, AggroCenterX, AggroCenterY, AggroCenterZ)); } }