public static void Set_Target_HP() { string cp = "0/0"; string hp = "0/0"; string mp = "0/0"; uint target_id = Globals.gamedata.my_char.TargetID; switch (Globals.gamedata.my_char.CurrentTargetType) { case TargetType.SELF: hp = Globals.gamedata.my_char.Cur_HP.ToString() + "/" + Globals.gamedata.my_char.Max_HP.ToString(); mp = Globals.gamedata.my_char.Cur_MP.ToString() + "/" + Globals.gamedata.my_char.Max_MP.ToString(); cp = Globals.gamedata.my_char.Cur_CP.ToString() + "/" + Globals.gamedata.my_char.Max_CP.ToString(); break; case TargetType.MYPET: hp = Globals.gamedata.my_pet.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet.Max_HP.ToString(); mp = Globals.gamedata.my_pet.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet.Max_MP.ToString(); cp = Globals.gamedata.my_pet.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet.Max_CP.ToString(); break; case TargetType.MYPET1: hp = Globals.gamedata.my_pet1.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet1.Max_HP.ToString(); mp = Globals.gamedata.my_pet1.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet1.Max_MP.ToString(); cp = Globals.gamedata.my_pet1.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet1.Max_CP.ToString(); break; case TargetType.MYPET2: hp = Globals.gamedata.my_pet2.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet2.Max_HP.ToString(); mp = Globals.gamedata.my_pet2.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet2.Max_MP.ToString(); cp = Globals.gamedata.my_pet2.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet2.Max_CP.ToString(); break; case TargetType.MYPET3: hp = Globals.gamedata.my_pet3.Cur_HP.ToString() + "/" + Globals.gamedata.my_pet3.Max_HP.ToString(); mp = Globals.gamedata.my_pet3.Cur_MP.ToString() + "/" + Globals.gamedata.my_pet3.Max_MP.ToString(); cp = Globals.gamedata.my_pet3.Cur_CP.ToString() + "/" + Globals.gamedata.my_pet3.Max_CP.ToString(); break; case TargetType.PLAYER: Globals.PlayerLock.EnterReadLock(); try { CharInfo player = Util.GetChar(target_id); if (player != null) { /*if (Globals.gamedata.Chron >= Chronicle.CT2_4 && Globals.gamedata.Official_Server) { /* hp = ("HP: " + player.Cur_HP / 100000).ToString() + "%"; mp = ("MP: " + player.Cur_MP / 100000).ToString() + "%"; cp = ("CP: " + player.Cur_CP / 100000).ToString() + "%"; hp = ("HP: " + (player.Cur_HP / 10000000).ToString("P", System.Globalization.CultureInfo.InvariantCulture)); mp = ("CP: " + (player.Cur_MP / 10000000).ToString("P", System.Globalization.CultureInfo.InvariantCulture)); cp = ("MP: " + (player.Cur_CP / 10000000).ToString("P", System.Globalization.CultureInfo.InvariantCulture)); } else {*/ hp = player.Cur_HP.ToString() + "/" + player.Max_HP.ToString(); mp = player.Cur_MP.ToString() + "/" + player.Max_MP.ToString(); cp = player.Cur_CP.ToString() + "/" + player.Max_CP.ToString(); //} } }//unlock finally { Globals.PlayerLock.ExitReadLock(); } break; case TargetType.NPC: Globals.NPCLock.EnterReadLock(); try { NPCInfo npc = Util.GetNPC(target_id); if (npc != null) { hp = npc.Cur_HP.ToString() + "/" + npc.Max_HP.ToString(); mp = npc.Cur_MP.ToString() + "/" + npc.Max_MP.ToString(); cp = npc.Cur_CP.ToString() + "/" + npc.Max_CP.ToString(); } }//unlock finally { Globals.NPCLock.ExitReadLock(); } break; } Globals.l2net_home.Set_Target_CP(cp); Globals.l2net_home.Set_Target_HP(hp); Globals.l2net_home.Set_Target_MP(mp); //Globals.l2net_home.panel_target.Refresh(); if (Globals.l2net_home.menuItem_cmd_overlay.Checked && Globals.overlaywindow != null) { Globals.overlaywindow.Set_Target_CP(cp); Globals.overlaywindow.Set_Target_HP(hp); Globals.overlaywindow.Set_Target_MP(mp); //L2NET.overlaywindow.Refresh(); } }
static public int Distance(uint id) { //this function will lock based on what we are checking distance to TargetType type = GetType(id); switch (type) { case TargetType.ERROR: case TargetType.NONE: return(System.Int32.MaxValue); case TargetType.SELF: return(0); case TargetType.MYPET: return((int)System.Math.Sqrt( System.Math.Pow(Globals.gamedata.my_pet.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(Globals.gamedata.my_pet.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(Globals.gamedata.my_pet.Z - Globals.gamedata.my_char.Z, 2))); case TargetType.MYPET1: return((int)System.Math.Sqrt( System.Math.Pow(Globals.gamedata.my_pet1.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(Globals.gamedata.my_pet1.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(Globals.gamedata.my_pet1.Z - Globals.gamedata.my_char.Z, 2))); case TargetType.MYPET2: return((int)System.Math.Sqrt( System.Math.Pow(Globals.gamedata.my_pet2.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(Globals.gamedata.my_pet2.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(Globals.gamedata.my_pet2.Z - Globals.gamedata.my_char.Z, 2))); case TargetType.MYPET3: return((int)System.Math.Sqrt( System.Math.Pow(Globals.gamedata.my_pet3.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(Globals.gamedata.my_pet3.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(Globals.gamedata.my_pet3.Z - Globals.gamedata.my_char.Z, 2))); case TargetType.PLAYER: Globals.PlayerLock.EnterReadLock(); try { CharInfo player = GetChar(id); if (player != null) { return((int)System.Math.Sqrt( System.Math.Pow(player.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(player.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(player.Z - Globals.gamedata.my_char.Z, 2))); } } //unlock finally { Globals.PlayerLock.ExitReadLock(); } break; case TargetType.NPC: Globals.NPCLock.EnterReadLock(); try { NPCInfo npc = GetNPC(id); if (npc != null) { return((int)System.Math.Sqrt( System.Math.Pow(npc.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(npc.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(npc.Z - Globals.gamedata.my_char.Z, 2))); } } //unlock finally { Globals.NPCLock.ExitReadLock(); } break; case TargetType.ITEM: Globals.ItemLock.EnterReadLock(); try { ItemInfo item = GetItem(id); if (item != null) { return((int)System.Math.Sqrt( System.Math.Pow(item.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(item.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(item.Z - Globals.gamedata.my_char.Z, 2))); } } //unlock finally { Globals.ItemLock.ExitReadLock(); } break; } return(System.Int32.MaxValue); }
private static void AnimateStuff() { bool found = false; float vx, vy, vz; float vxx; float movespeed; float time; ////////////////////////////////Animate self try { if (Globals.gamedata.my_char.Moving == true) { if (Globals.gamedata.OOG && (DateTime.Now - Globals.gamedata.my_char.lastVerifyTime).Milliseconds > 1000) { //send the verify pos packet ServerPackets.Send_Verify(); } if (Globals.gamedata.my_char.MoveTarget != 0) { found = false; //need to set the dest switch (Globals.gamedata.my_char.MoveTargetType) { case TargetType.ERROR: case TargetType.NONE: //shouldn't get this ever //Globals.l2net_home.Add_OnlyDebug("MoveToPawn MoveTargetType invalid - char: " + Globals.gamedata.my_char.Name + ":" + Globals.gamedata.my_char.ID.ToString() + "--: " + Globals.gamedata.my_char.MoveTarget.ToString()); break; case TargetType.SELF: //shouldn't get this ever... Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_char.X; Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_char.Y; Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_char.Z; found = true; break; case TargetType.MYPET: Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_pet.X; Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_pet.Y; Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_pet.Z; found = true; break; case TargetType.MYPET1: Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_pet1.X; Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_pet1.Y; Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_pet1.Z; found = true; break; case TargetType.MYPET2: Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_pet2.X; Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_pet2.Y; Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_pet2.Z; found = true; break; case TargetType.MYPET3: Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_pet3.X; Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_pet3.Y; Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_pet3.Z; found = true; break; case TargetType.PLAYER: CharInfo player_target = null; Globals.PlayerLock.EnterReadLock(); try { player_target = Util.GetChar(Globals.gamedata.my_char.MoveTarget); } finally { Globals.PlayerLock.ExitReadLock(); } if (player_target != null) { Globals.gamedata.my_char.Dest_X = player_target.X; Globals.gamedata.my_char.Dest_Y = player_target.Y; Globals.gamedata.my_char.Dest_Z = player_target.Z; found = true; } break; case TargetType.NPC: NPCInfo npc_target = null; Globals.NPCLock.EnterReadLock(); try { npc_target = Util.GetNPC(Globals.gamedata.my_char.MoveTarget); } finally { Globals.NPCLock.ExitReadLock(); } if (npc_target != null) { Globals.gamedata.my_char.Dest_X = npc_target.X; Globals.gamedata.my_char.Dest_Y = npc_target.Y; Globals.gamedata.my_char.Dest_Z = npc_target.Z; found = true; } break; case TargetType.ITEM: ItemInfo item_target = null; Globals.ItemLock.EnterReadLock(); try { item_target = Util.GetItem(Globals.gamedata.my_char.MoveTarget); } finally { Globals.ItemLock.ExitReadLock(); } if (item_target != null) { Globals.gamedata.my_char.Dest_X = item_target.X; Globals.gamedata.my_char.Dest_Y = item_target.Y; Globals.gamedata.my_char.Dest_Z = item_target.Z; found = true; } break; } if (!found) { Globals.gamedata.my_char.Dest_X = Globals.gamedata.my_char.X; Globals.gamedata.my_char.Dest_Y = Globals.gamedata.my_char.Y; Globals.gamedata.my_char.Dest_Z = Globals.gamedata.my_char.Z; } } //move me towards my target vx = Globals.gamedata.my_char.Dest_X - Globals.gamedata.my_char.X; vy = Globals.gamedata.my_char.Dest_Y - Globals.gamedata.my_char.Y; vz = Globals.gamedata.my_char.Dest_Z - Globals.gamedata.my_char.Z; //movespeed = ((float)my_char.RunSpeed)*ch.MoveSpeedMult; movespeed = Globals.gamedata.my_char.RunSpeed * Globals.gamedata.my_char.MoveSpeedMult; time = Convert.ToSingle((DateTime.Now - Globals.gamedata.my_char.lastMoveTime).Milliseconds) * Globals.INV_THOUSAND; vxx = Convert.ToSingle(Math.Sqrt(vx * vx + vy * vy + vz * vz)); if (vxx != 0) { vxx = Util.Float_Cap(movespeed * time / vxx); } vx *= vxx; vy *= vxx; vz *= vxx; Globals.gamedata.my_char.X += vx; Globals.gamedata.my_char.Y += vy; Globals.gamedata.my_char.Z += vz; Globals.gamedata.my_char.lastMoveTime = DateTime.Now; if ((Globals.gamedata.my_char.MoveTarget == 0) && (Math.Sqrt(Math.Pow(Globals.gamedata.my_char.X - Globals.gamedata.my_char.Dest_X, 2) + Math.Pow(Globals.gamedata.my_char.Y - Globals.gamedata.my_char.Dest_Y, 2) + Math.Pow(Globals.gamedata.my_char.Z - Globals.gamedata.my_char.Dest_Z, 2)) < Globals.THRESHOLD)) { Globals.gamedata.my_char.Moving = false; } } } catch { Globals.l2net_home.Add_Error("crash: Animate self"); } ///////////////////////Animate Pet if (Globals.gamedata.my_pet.ID != 0) { try { if (Globals.gamedata.my_pet.Moving == true) { if (Globals.gamedata.my_pet.MoveTarget != 0) { found = false; //need to set the dest switch (Globals.gamedata.my_pet.MoveTargetType) { case TargetType.ERROR: case TargetType.NONE: //shouldn't get this ever //Globals.l2net_home.Add_OnlyDebug("MoveToPawn MoveTargetType invalid - pet: " + Globals.gamedata.my_pet.Name + ":" + Globals.gamedata.my_pet.ID.ToString() + "--: " + Globals.gamedata.my_pet.MoveTarget.ToString()); break; case TargetType.SELF: Globals.gamedata.my_pet.Dest_X = Globals.gamedata.my_char.X; Globals.gamedata.my_pet.Dest_Y = Globals.gamedata.my_char.Y; Globals.gamedata.my_pet.Dest_Z = Globals.gamedata.my_char.Z; found = true; break; case TargetType.MYPET: //shouldn't get this ever... Globals.gamedata.my_pet.Dest_X = Globals.gamedata.my_pet.X; Globals.gamedata.my_pet.Dest_Y = Globals.gamedata.my_pet.Y; Globals.gamedata.my_pet.Dest_Z = Globals.gamedata.my_pet.Z; found = true; break; case TargetType.MYPET1: //shouldn't get this ever... Globals.gamedata.my_pet1.Dest_X = Globals.gamedata.my_pet1.X; Globals.gamedata.my_pet1.Dest_Y = Globals.gamedata.my_pet1.Y; Globals.gamedata.my_pet1.Dest_Z = Globals.gamedata.my_pet1.Z; found = true; break; case TargetType.MYPET2: //shouldn't get this ever... Globals.gamedata.my_pet2.Dest_X = Globals.gamedata.my_pet2.X; Globals.gamedata.my_pet2.Dest_Y = Globals.gamedata.my_pet2.Y; Globals.gamedata.my_pet2.Dest_Z = Globals.gamedata.my_pet2.Z; found = true; break; case TargetType.MYPET3: //shouldn't get this ever... Globals.gamedata.my_pet3.Dest_X = Globals.gamedata.my_pet3.X; Globals.gamedata.my_pet3.Dest_Y = Globals.gamedata.my_pet3.Y; Globals.gamedata.my_pet3.Dest_Z = Globals.gamedata.my_pet3.Z; found = true; break; case TargetType.PLAYER: CharInfo player_target = null; Globals.PlayerLock.EnterReadLock(); try { player_target = Util.GetChar(Globals.gamedata.my_pet.MoveTarget); } finally { Globals.PlayerLock.ExitReadLock(); } if (player_target != null) { Globals.gamedata.my_pet.Dest_X = player_target.X; Globals.gamedata.my_pet.Dest_Y = player_target.Y; Globals.gamedata.my_pet.Dest_Z = player_target.Z; found = true; } break; case TargetType.NPC: NPCInfo npc_target = null; Globals.NPCLock.EnterReadLock(); try { npc_target = Util.GetNPC(Globals.gamedata.my_pet.MoveTarget); } finally { Globals.NPCLock.ExitReadLock(); } if (npc_target != null) { Globals.gamedata.my_pet.Dest_X = npc_target.X; Globals.gamedata.my_pet.Dest_Y = npc_target.Y; Globals.gamedata.my_pet.Dest_Z = npc_target.Z; found = true; } break; case TargetType.ITEM: ItemInfo item_target = null; Globals.ItemLock.EnterReadLock(); try { item_target = Util.GetItem(Globals.gamedata.my_pet.MoveTarget); } finally { Globals.ItemLock.ExitReadLock(); } if (item_target != null) { Globals.gamedata.my_pet.Dest_X = item_target.X; Globals.gamedata.my_pet.Dest_Y = item_target.Y; Globals.gamedata.my_pet.Dest_Z = item_target.Z; found = true; } break; } if (!found) { Globals.gamedata.my_pet.Dest_X = Globals.gamedata.my_pet.X; Globals.gamedata.my_pet.Dest_Y = Globals.gamedata.my_pet.Y; Globals.gamedata.my_pet.Dest_Z = Globals.gamedata.my_pet.Z; } } //move me towards my target vx = Globals.gamedata.my_pet.Dest_X - Globals.gamedata.my_pet.X; vy = Globals.gamedata.my_pet.Dest_Y - Globals.gamedata.my_pet.Y; vz = Globals.gamedata.my_pet.Dest_Z - Globals.gamedata.my_pet.Z; //movespeed = ((float)my_char.RunSpeed)*ch.MoveSpeedMult; movespeed = Globals.gamedata.my_pet.RunSpeed * Globals.gamedata.my_pet.MoveSpeedMult; time = Convert.ToSingle((DateTime.Now - Globals.gamedata.my_pet.lastMoveTime).Milliseconds) * Globals.INV_THOUSAND; vxx = Convert.ToSingle(Math.Sqrt(vx * vx + vy * vy + vz * vz)); if (vxx != 0) { vxx = Util.Float_Cap(movespeed * time / vxx); } vx *= vxx; vy *= vxx; vz *= vxx; Globals.gamedata.my_pet.X += vx; Globals.gamedata.my_pet.Y += vy; Globals.gamedata.my_pet.Z += vz; Globals.gamedata.my_pet.lastMoveTime = DateTime.Now; if ((Globals.gamedata.my_pet.MoveTarget == 0) && (Math.Sqrt(Math.Pow(Globals.gamedata.my_pet.X - Globals.gamedata.my_pet.Dest_X, 2) + Math.Pow(Globals.gamedata.my_pet.Y - Globals.gamedata.my_pet.Dest_Y, 2) + Math.Pow(Globals.gamedata.my_pet.Z - Globals.gamedata.my_pet.Dest_Z, 2)) < Globals.THRESHOLD)) { Globals.gamedata.my_pet.Moving = false; } } } catch { Globals.l2net_home.Add_Error("crash: Animate pet"); } } ///////////////////////Animate other chars Globals.PlayerLock.EnterReadLock(); try { foreach (CharInfo player in Globals.gamedata.nearby_chars.Values) { if (player.Moving) { if (player.MoveTarget != 0) { found = false; //need to set the dest switch (player.MoveTargetType) { case TargetType.ERROR: case TargetType.NONE: //shouldn't get this ever... //Globals.l2net_home.Add_OnlyDebug("MoveToPawn MoveTargetType invalid - pc: " + player.Name + ":" + player.ID.ToString() + "--: " + player.MoveTarget.ToString()); break; case TargetType.SELF: player.Dest_X = Globals.gamedata.my_char.X; player.Dest_Y = Globals.gamedata.my_char.Y; player.Dest_Z = Globals.gamedata.my_char.Z; found = true; break; case TargetType.MYPET: player.Dest_X = Globals.gamedata.my_pet.X; player.Dest_Y = Globals.gamedata.my_pet.Y; player.Dest_Z = Globals.gamedata.my_pet.Z; found = true; break; case TargetType.MYPET1: player.Dest_X = Globals.gamedata.my_pet1.X; player.Dest_Y = Globals.gamedata.my_pet1.Y; player.Dest_Z = Globals.gamedata.my_pet1.Z; found = true; break; case TargetType.MYPET2: player.Dest_X = Globals.gamedata.my_pet2.X; player.Dest_Y = Globals.gamedata.my_pet2.Y; player.Dest_Z = Globals.gamedata.my_pet2.Z; found = true; break; case TargetType.MYPET3: player.Dest_X = Globals.gamedata.my_pet3.X; player.Dest_Y = Globals.gamedata.my_pet3.Y; player.Dest_Z = Globals.gamedata.my_pet3.Z; found = true; break; case TargetType.PLAYER: CharInfo player_target = null; //no need to lock... we already have a writer lock player_target = Util.GetChar(Globals.gamedata.my_char.MoveTarget); if (player_target != null) { player.Dest_X = player_target.X; player.Dest_Y = player_target.Y; player.Dest_Z = player_target.Z; found = true; } break; case TargetType.NPC: NPCInfo npc_target = null; Globals.NPCLock.EnterReadLock(); try { npc_target = Util.GetNPC(player.MoveTarget); } finally { Globals.NPCLock.ExitReadLock(); } if (npc_target != null) { player.Dest_X = npc_target.X; player.Dest_Y = npc_target.Y; player.Dest_Z = npc_target.Z; found = true; } break; case TargetType.ITEM: ItemInfo item_target = null; Globals.ItemLock.EnterReadLock(); try { item_target = Util.GetItem(player.MoveTarget); } //unlock finally { Globals.ItemLock.ExitReadLock(); } if (item_target != null) { player.Dest_X = item_target.X; player.Dest_Y = item_target.Y; player.Dest_Z = item_target.Z; found = true; } break; } if (!found) { player.Dest_X = player.X; player.Dest_Y = player.Y; player.Dest_Z = player.Z; } } vx = player.Dest_X - player.X; vy = player.Dest_Y - player.Y; vz = player.Dest_Z - player.Z; if (player.isRunning != 0) { movespeed = player.RunSpeed * player.MoveSpeedMult; } else { movespeed = player.WalkSpeed * player.MoveSpeedMult; } time = Convert.ToSingle((DateTime.Now - player.lastMoveTime).Milliseconds) * Globals.INV_THOUSAND; vxx = Convert.ToSingle(Math.Sqrt(vx * vx + vy * vy + vz * vz)); if (vxx != 0) { vxx = Util.Float_Cap(movespeed * time / vxx); } vx *= vxx; vy *= vxx; vz *= vxx; player.X += Util.Float_Int32(vx); player.Y += Util.Float_Int32(vy); player.Z += Util.Float_Int32(vz); player.lastMoveTime = DateTime.Now; if ((player.MoveTarget == 0) && (Math.Sqrt(Math.Pow(player.X - player.Dest_X, 2) + Math.Pow(player.Y - player.Dest_Y, 2) + Math.Pow(player.Z - player.Dest_Z, 2)) < Globals.THRESHOLD)) { player.Moving = false; } } } }//unlock catch { Globals.l2net_home.Add_Error("crash: Animate other players"); } finally { Globals.PlayerLock.ExitReadLock(); } //animate npcs Globals.NPCLock.EnterReadLock(); try { foreach (NPCInfo npc in Globals.gamedata.nearby_npcs.Values) { if (npc.Moving) { if (npc.MoveTarget != 0) { found = false; //need to set the dest switch (npc.MoveTargetType) { case TargetType.ERROR: case TargetType.NONE: //shouldn't get this ever... //Globals.l2net_home.Add_OnlyDebug("MoveToPawn MoveTargetType invalid - npc: " + npc.Name + ":" + npc.ID.ToString() + "--: " + npc.MoveTarget.ToString()); break; case TargetType.SELF: npc.Dest_X = Globals.gamedata.my_char.X; npc.Dest_Y = Globals.gamedata.my_char.Y; npc.Dest_Z = Globals.gamedata.my_char.Z; found = true; break; case TargetType.MYPET: npc.Dest_X = Globals.gamedata.my_pet.X; npc.Dest_Y = Globals.gamedata.my_pet.Y; npc.Dest_Z = Globals.gamedata.my_pet.Z; found = true; break; case TargetType.MYPET1: npc.Dest_X = Globals.gamedata.my_pet1.X; npc.Dest_Y = Globals.gamedata.my_pet1.Y; npc.Dest_Z = Globals.gamedata.my_pet1.Z; found = true; break; case TargetType.MYPET2: npc.Dest_X = Globals.gamedata.my_pet2.X; npc.Dest_Y = Globals.gamedata.my_pet2.Y; npc.Dest_Z = Globals.gamedata.my_pet2.Z; found = true; break; case TargetType.MYPET3: npc.Dest_X = Globals.gamedata.my_pet3.X; npc.Dest_Y = Globals.gamedata.my_pet3.Y; npc.Dest_Z = Globals.gamedata.my_pet3.Z; found = true; break; case TargetType.PLAYER: CharInfo player_target = null; Globals.PlayerLock.EnterReadLock(); try { player_target = Util.GetChar(npc.MoveTarget); } finally { Globals.PlayerLock.ExitReadLock(); } if (player_target != null) { npc.Dest_X = player_target.X; npc.Dest_Y = player_target.Y; npc.Dest_Z = player_target.Z; found = true; } break; case TargetType.NPC: NPCInfo npc_target = null; //no need to lock... we already have a writer lock npc_target = Util.GetNPC(npc.MoveTarget); if (npc_target != null) { npc.Dest_X = npc_target.X; npc.Dest_Y = npc_target.Y; npc.Dest_Z = npc_target.Z; found = true; } break; case TargetType.ITEM: ItemInfo item_target = null; Globals.ItemLock.EnterReadLock(); try { item_target = Util.GetItem(npc.MoveTarget); } finally { Globals.ItemLock.ExitReadLock(); } if (item_target != null) { npc.Dest_X = item_target.X; npc.Dest_Y = item_target.Y; npc.Dest_Z = item_target.Z; found = true; } break; }//end of switch if (!found) { npc.Dest_X = npc.X; npc.Dest_Y = npc.Y; npc.Dest_Z = npc.Z; } } vx = npc.Dest_X - npc.X; vy = npc.Dest_Y - npc.Y; vz = npc.Dest_Z - npc.Z; if (npc.isRunning != 0) { movespeed = npc.RunSpeed * npc.MoveSpeedMult; } else { movespeed = npc.WalkSpeed * npc.MoveSpeedMult; } time = Convert.ToSingle((DateTime.Now - npc.lastMoveTime).Milliseconds) * Globals.INV_THOUSAND; vxx = Convert.ToSingle(Math.Sqrt(vx * vx + vy * vy + vz * vz)); if (vxx != 0) { vxx = Util.Float_Cap(movespeed * time / vxx); } vx *= vxx; vy *= vxx; vz *= vxx; npc.X += Util.Float_Int32(vx); npc.Y += Util.Float_Int32(vy); npc.Z += Util.Float_Int32(vz); npc.lastMoveTime = DateTime.Now; if ((npc.MoveTarget == 0) && (Math.Sqrt(Math.Pow(npc.X - npc.Dest_X, 2) + Math.Pow(npc.Y - npc.Dest_Y, 2) + Math.Pow(npc.Z - npc.Dest_Z, 2)) < Globals.THRESHOLD)) { npc.Moving = false; } } } }//unlock catch { Globals.l2net_home.Add_Error("crash: Animate npcs"); } finally { Globals.NPCLock.ExitReadLock(); } }//end of AnimateStuff
static public int Distance(uint id, TargetType type) { //no locks needed... since the calling function has the locks in it switch (type) { case TargetType.ERROR: case TargetType.NONE: return(System.Int32.MaxValue); case TargetType.SELF: return(0); case TargetType.MYPET: return((int)System.Math.Sqrt( System.Math.Pow(Globals.gamedata.my_pet.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(Globals.gamedata.my_pet.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(Globals.gamedata.my_pet.Z - Globals.gamedata.my_char.Z, 2))); case TargetType.MYPET1: return((int)System.Math.Sqrt( System.Math.Pow(Globals.gamedata.my_pet1.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(Globals.gamedata.my_pet1.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(Globals.gamedata.my_pet1.Z - Globals.gamedata.my_char.Z, 2))); case TargetType.MYPET2: return((int)System.Math.Sqrt( System.Math.Pow(Globals.gamedata.my_pet2.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(Globals.gamedata.my_pet2.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(Globals.gamedata.my_pet2.Z - Globals.gamedata.my_char.Z, 2))); case TargetType.MYPET3: return((int)System.Math.Sqrt( System.Math.Pow(Globals.gamedata.my_pet3.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(Globals.gamedata.my_pet3.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(Globals.gamedata.my_pet3.Z - Globals.gamedata.my_char.Z, 2))); case TargetType.PLAYER: CharInfo player = GetChar(id); if (player != null) { return((int)System.Math.Sqrt( System.Math.Pow(player.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(player.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(player.Z - Globals.gamedata.my_char.Z, 2))); } break; case TargetType.NPC: NPCInfo npc = GetNPC(id); if (npc != null) { return((int)System.Math.Sqrt( System.Math.Pow(npc.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(npc.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(npc.Z - Globals.gamedata.my_char.Z, 2))); } break; case TargetType.ITEM: ItemInfo item = GetItem(id); if (item != null) { return((int)System.Math.Sqrt( System.Math.Pow(item.X - Globals.gamedata.my_char.X, 2) + System.Math.Pow(item.Y - Globals.gamedata.my_char.Y, 2) + System.Math.Pow(item.Z - Globals.gamedata.my_char.Z, 2))); } break; } return(System.Int32.MaxValue); }
public void CopyNew(CharInfo ch_inf) { X = ch_inf.X; Y = ch_inf.Y; Z = ch_inf.Z; Underwear = ch_inf.Underwear; Head = ch_inf.Head; RHand = ch_inf.RHand; LHand = ch_inf.LHand; Gloves = ch_inf.Gloves; Chest = ch_inf.Chest; Legs = ch_inf.Legs; Feet = ch_inf.Feet; Back = ch_inf.Back; LRHand = ch_inf.LRHand; Hair = ch_inf.Hair; DollFace = ch_inf.DollFace; aug_RHand = ch_inf.aug_RHand; aug_LHand = ch_inf.aug_LHand; PvPFlag = ch_inf.PvPFlag; Karma = ch_inf.Karma; MatkSpeed = ch_inf.MatkSpeed; PatkSpeed = ch_inf.PatkSpeed; PvPFlag2 = ch_inf.PvPFlag2; Karma2 = ch_inf.Karma2; RunSpeed = ch_inf.RunSpeed; WalkSpeed = ch_inf.WalkSpeed; SwimRunSpeed = ch_inf.SwimRunSpeed; SwimWalkSpeed = ch_inf.SwimWalkSpeed; flRunSpeed = ch_inf.flRunSpeed; flWalkSpeed = ch_inf.flWalkSpeed; FlyRunSpeed = ch_inf.FlyRunSpeed; FlyWalkSpeed = ch_inf.FlyWalkSpeed; MoveSpeedMult = ch_inf.MoveSpeedMult; AttackSpeedMult = ch_inf.AttackSpeedMult; CollisionRadius = ch_inf.CollisionRadius; CollisionHeight = ch_inf.CollisionHeight; HairSytle = ch_inf.HairSytle; HairColor = ch_inf.HairColor; Face = ch_inf.Face; Title = ch_inf.Title; ClanID = ch_inf.ClanID; ClanCrestID = ch_inf.ClanCrestID; AllyID = ch_inf.AllyID; AllyCrestID = ch_inf.AllyCrestID; SiegeFlags = ch_inf.SiegeFlags; isSitting = ch_inf.isSitting; isRunning = ch_inf.isRunning; isInCombat = ch_inf.isInCombat; isAlikeDead = ch_inf.isAlikeDead; isFlying = ch_inf.isFlying; RecAmount = ch_inf.RecAmount; Class = ch_inf.Class; BaseClass = ch_inf.BaseClass; HeroIcon = ch_inf.HeroIcon; HeroGlow = ch_inf.HeroGlow; isFishing = ch_inf.isFishing; FishX = ch_inf.FishX; FishY = ch_inf.FishY; FishZ = ch_inf.FishZ; NameColor = ch_inf.NameColor; DemonSword = ch_inf.DemonSword; AbnormalEffects = ch_inf.AbnormalEffects; ExtendedEffects = ch_inf.ExtendedEffects; // Relation = ch_inf.Relation; }
public static long TARGET_INT(string req) { switch (Globals.gamedata.my_char.CurrentTargetType) { case TargetType.ERROR: case TargetType.NONE: break; case TargetType.SELF: switch (req) { case "KARMA": return((long)Globals.gamedata.my_char.Karma); case "TARGETID": return((long)Globals.gamedata.my_char.TargetID); case "ID": return((long)Globals.gamedata.my_char.ID); case "TYPEID": return((long)0); case "X": return((long)Globals.gamedata.my_char.X); case "Y": return((long)Globals.gamedata.my_char.Y); case "Z": return((long)Globals.gamedata.my_char.Z); case "DESTX": return((long)Globals.gamedata.my_char.Dest_X); case "DESTY": return((long)Globals.gamedata.my_char.Dest_Y); case "DESTZ": return((long)Globals.gamedata.my_char.Dest_Z); case "IS_MOVING": return(Globals.gamedata.my_char.Moving ? 1L : 0L); case "MAX_HP": return((long)Globals.gamedata.my_char.Max_HP); case "MAX_MP": return((long)Globals.gamedata.my_char.Max_MP); case "MAX_CP": return((long)Globals.gamedata.my_char.Max_CP); case "CUR_HP": return((long)Globals.gamedata.my_char.Cur_HP); case "CUR_MP": return((long)Globals.gamedata.my_char.Cur_MP); case "CUR_CP": return((long)Globals.gamedata.my_char.Cur_CP); case "PER_HP": return((long)(100.0 * (Globals.gamedata.my_char.Cur_HP / Globals.gamedata.my_char.Max_HP))); case "PER_MP": return((long)(100.0 * (Globals.gamedata.my_char.Cur_MP / Globals.gamedata.my_char.Max_MP))); case "PER_CP": return((long)(100.0 * (Globals.gamedata.my_char.Cur_CP / Globals.gamedata.my_char.Max_CP))); case "RUN_SPEED": return((long)(Globals.gamedata.my_char.RunSpeed * Globals.gamedata.my_char.MoveSpeedMult)); case "WALK_SPEED": return((long)(Globals.gamedata.my_char.WalkSpeed * Globals.gamedata.my_char.MoveSpeedMult)); case "ATTACK_SPEED": return((long)Globals.gamedata.my_char.AttackSpeedMult); case "CAST_SPEED": return((long)Globals.gamedata.my_char.MatkSpeed); case "EVAL": return((long)Globals.gamedata.my_char.RecAmount); case "RUNNING": return((long)Globals.gamedata.my_char.isRunning); case "SITTING": return((long)Globals.gamedata.my_char.isSitting); case "LOOKS_DEAD": return((long)Globals.gamedata.my_char.isAlikeDead); default: ScriptEngine.Script_Error("invalid target data(self) request"); break; } break; case TargetType.MYPET: switch (req) { case "KARMA": return((long)Globals.gamedata.my_pet.Karma); case "TARGETID": return((long)Globals.gamedata.my_pet.TargetID); case "ID": return((long)Globals.gamedata.my_pet.ID); case "TYPEID": return((long)Globals.gamedata.my_pet.NPCID); case "X": return((long)Globals.gamedata.my_pet.X); case "Y": return((long)Globals.gamedata.my_pet.Y); case "Z": return((long)Globals.gamedata.my_pet.Z); case "DESTX": return((long)Globals.gamedata.my_pet.Dest_X); case "DESTY": return((long)Globals.gamedata.my_pet.Dest_Y); case "DESTZ": return((long)Globals.gamedata.my_pet.Dest_Z); case "IS_MOVING": return(Globals.gamedata.my_pet.Moving ? 1L : 0L); case "MAX_HP": return((long)Globals.gamedata.my_pet.Max_HP); case "MAX_MP": return((long)Globals.gamedata.my_pet.Max_MP); case "MAX_CP": return((long)Globals.gamedata.my_pet.Max_CP); case "CUR_HP": return((long)Globals.gamedata.my_pet.Cur_HP); case "CUR_MP": return((long)Globals.gamedata.my_pet.Cur_MP); case "CUR_CP": return((long)Globals.gamedata.my_pet.Cur_CP); case "PER_HP": return((long)(100.0 * (Globals.gamedata.my_pet.Cur_HP / Globals.gamedata.my_pet.Max_HP))); case "PER_MP": return((long)(100.0 * (Globals.gamedata.my_pet.Cur_MP / Globals.gamedata.my_pet.Max_MP))); case "PER_CP": return((long)(100.0 * (Globals.gamedata.my_pet.Cur_CP / Globals.gamedata.my_pet.Max_CP))); case "RUN_SPEED": return((long)(Globals.gamedata.my_pet.RunSpeed * Globals.gamedata.my_pet.MoveSpeedMult)); case "WALK_SPEED": return((long)(Globals.gamedata.my_pet.WalkSpeed * Globals.gamedata.my_pet.MoveSpeedMult)); case "ATTACK_SPEED": return((long)Globals.gamedata.my_pet.AttackSpeedMult); case "CAST_SPEED": return((long)Globals.gamedata.my_pet.MatkSpeed); case "EVAL": return((long)0); case "RUNNING": return((long)Globals.gamedata.my_pet.isRunning); case "SITTING": return((long)0); case "LOOKS_DEAD": return((long)Globals.gamedata.my_pet.isAlikeDead); default: ScriptEngine.Script_Error("invalid target data(self) request"); break; } break; case TargetType.MYPET1: switch (req) { case "KARMA": return((long)Globals.gamedata.my_pet1.Karma); case "TARGETID": return((long)Globals.gamedata.my_pet1.TargetID); case "ID": return((long)Globals.gamedata.my_pet1.ID); case "TYPEID": return((long)Globals.gamedata.my_pet1.NPCID); case "X": return((long)Globals.gamedata.my_pet1.X); case "Y": return((long)Globals.gamedata.my_pet1.Y); case "Z": return((long)Globals.gamedata.my_pet1.Z); case "DESTX": return((long)Globals.gamedata.my_pet1.Dest_X); case "DESTY": return((long)Globals.gamedata.my_pet1.Dest_Y); case "DESTZ": return((long)Globals.gamedata.my_pet1.Dest_Z); case "IS_MOVING": return(Globals.gamedata.my_pet1.Moving ? 1L : 0L); case "MAX_HP": return((long)Globals.gamedata.my_pet1.Max_HP); case "MAX_MP": return((long)Globals.gamedata.my_pet1.Max_MP); case "MAX_CP": return((long)Globals.gamedata.my_pet1.Max_CP); case "CUR_HP": return((long)Globals.gamedata.my_pet1.Cur_HP); case "CUR_MP": return((long)Globals.gamedata.my_pet1.Cur_MP); case "CUR_CP": return((long)Globals.gamedata.my_pet1.Cur_CP); case "PER_HP": return((long)(100.0 * (Globals.gamedata.my_pet1.Cur_HP / Globals.gamedata.my_pet1.Max_HP))); case "PER_MP": return((long)(100.0 * (Globals.gamedata.my_pet1.Cur_MP / Globals.gamedata.my_pet1.Max_MP))); case "PER_CP": return((long)(100.0 * (Globals.gamedata.my_pet1.Cur_CP / Globals.gamedata.my_pet1.Max_CP))); case "RUN_SPEED": return((long)(Globals.gamedata.my_pet1.RunSpeed * Globals.gamedata.my_pet1.MoveSpeedMult)); case "WALK_SPEED": return((long)(Globals.gamedata.my_pet1.WalkSpeed * Globals.gamedata.my_pet1.MoveSpeedMult)); case "ATTACK_SPEED": return((long)Globals.gamedata.my_pet1.AttackSpeedMult); case "CAST_SPEED": return((long)Globals.gamedata.my_pet1.MatkSpeed); case "EVAL": return((long)0); case "RUNNING": return((long)Globals.gamedata.my_pet1.isRunning); case "SITTING": return((long)0); case "LOOKS_DEAD": return((long)Globals.gamedata.my_pet1.isAlikeDead); default: ScriptEngine.Script_Error("invalid target data(self) request"); break; } break; case TargetType.MYPET2: switch (req) { case "KARMA": return((long)Globals.gamedata.my_pet2.Karma); case "TARGETID": return((long)Globals.gamedata.my_pet2.TargetID); case "ID": return((long)Globals.gamedata.my_pet2.ID); case "TYPEID": return((long)Globals.gamedata.my_pet2.NPCID); case "X": return((long)Globals.gamedata.my_pet2.X); case "Y": return((long)Globals.gamedata.my_pet2.Y); case "Z": return((long)Globals.gamedata.my_pet2.Z); case "DESTX": return((long)Globals.gamedata.my_pet2.Dest_X); case "DESTY": return((long)Globals.gamedata.my_pet2.Dest_Y); case "DESTZ": return((long)Globals.gamedata.my_pet2.Dest_Z); case "IS_MOVING": return(Globals.gamedata.my_pet2.Moving ? 1L : 0L); case "MAX_HP": return((long)Globals.gamedata.my_pet2.Max_HP); case "MAX_MP": return((long)Globals.gamedata.my_pet2.Max_MP); case "MAX_CP": return((long)Globals.gamedata.my_pet2.Max_CP); case "CUR_HP": return((long)Globals.gamedata.my_pet2.Cur_HP); case "CUR_MP": return((long)Globals.gamedata.my_pet2.Cur_MP); case "CUR_CP": return((long)Globals.gamedata.my_pet2.Cur_CP); case "PER_HP": return((long)(100.0 * (Globals.gamedata.my_pet2.Cur_HP / Globals.gamedata.my_pet2.Max_HP))); case "PER_MP": return((long)(100.0 * (Globals.gamedata.my_pet2.Cur_MP / Globals.gamedata.my_pet2.Max_MP))); case "PER_CP": return((long)(100.0 * (Globals.gamedata.my_pet2.Cur_CP / Globals.gamedata.my_pet2.Max_CP))); case "RUN_SPEED": return((long)(Globals.gamedata.my_pet2.RunSpeed * Globals.gamedata.my_pet2.MoveSpeedMult)); case "WALK_SPEED": return((long)(Globals.gamedata.my_pet2.WalkSpeed * Globals.gamedata.my_pet2.MoveSpeedMult)); case "ATTACK_SPEED": return((long)Globals.gamedata.my_pet2.AttackSpeedMult); case "CAST_SPEED": return((long)Globals.gamedata.my_pet2.MatkSpeed); case "EVAL": return((long)0); case "RUNNING": return((long)Globals.gamedata.my_pet2.isRunning); case "SITTING": return((long)0); case "LOOKS_DEAD": return((long)Globals.gamedata.my_pet2.isAlikeDead); default: ScriptEngine.Script_Error("invalid target data(self) request"); break; } break; case TargetType.MYPET3: switch (req) { case "KARMA": return((long)Globals.gamedata.my_pet3.Karma); case "TARGETID": return((long)Globals.gamedata.my_pet3.TargetID); case "ID": return((long)Globals.gamedata.my_pet3.ID); case "TYPEID": return((long)Globals.gamedata.my_pet3.NPCID); case "X": return((long)Globals.gamedata.my_pet3.X); case "Y": return((long)Globals.gamedata.my_pet3.Y); case "Z": return((long)Globals.gamedata.my_pet3.Z); case "DESTX": return((long)Globals.gamedata.my_pet3.Dest_X); case "DESTY": return((long)Globals.gamedata.my_pet3.Dest_Y); case "DESTZ": return((long)Globals.gamedata.my_pet3.Dest_Z); case "IS_MOVING": return(Globals.gamedata.my_pet3.Moving ? 1L : 0L); case "MAX_HP": return((long)Globals.gamedata.my_pet3.Max_HP); case "MAX_MP": return((long)Globals.gamedata.my_pet3.Max_MP); case "MAX_CP": return((long)Globals.gamedata.my_pet3.Max_CP); case "CUR_HP": return((long)Globals.gamedata.my_pet3.Cur_HP); case "CUR_MP": return((long)Globals.gamedata.my_pet3.Cur_MP); case "CUR_CP": return((long)Globals.gamedata.my_pet3.Cur_CP); case "PER_HP": return((long)(100.0 * (Globals.gamedata.my_pet3.Cur_HP / Globals.gamedata.my_pet3.Max_HP))); case "PER_MP": return((long)(100.0 * (Globals.gamedata.my_pet3.Cur_MP / Globals.gamedata.my_pet3.Max_MP))); case "PER_CP": return((long)(100.0 * (Globals.gamedata.my_pet3.Cur_CP / Globals.gamedata.my_pet3.Max_CP))); case "RUN_SPEED": return((long)(Globals.gamedata.my_pet3.RunSpeed * Globals.gamedata.my_pet3.MoveSpeedMult)); case "WALK_SPEED": return((long)(Globals.gamedata.my_pet3.WalkSpeed * Globals.gamedata.my_pet3.MoveSpeedMult)); case "ATTACK_SPEED": return((long)Globals.gamedata.my_pet3.AttackSpeedMult); case "CAST_SPEED": return((long)Globals.gamedata.my_pet3.MatkSpeed); case "EVAL": return((long)0); case "RUNNING": return((long)Globals.gamedata.my_pet3.isRunning); case "SITTING": return((long)0); case "LOOKS_DEAD": return((long)Globals.gamedata.my_pet3.isAlikeDead); default: ScriptEngine.Script_Error("invalid target data(self) request"); break; } break; case TargetType.PLAYER: Globals.PlayerLock.EnterReadLock(); try { CharInfo player = Util.GetChar(Globals.gamedata.my_char.TargetID); if (player != null) { switch (req) { case "KARMA": return((long)player.Karma); case "TARGETID": return((long)player.TargetID); case "ID": return((long)player.ID); case "TYPEID": return((long)0); case "X": return((long)player.X); case "Y": return((long)player.Y); case "Z": return((long)player.Z); case "DESTX": return((long)player.Dest_X); case "DESTY": return((long)player.Dest_Y); case "DESTZ": return((long)player.Dest_Z); case "IS_MOVING": return(player.Moving ? 1L : 0L); case "MAX_HP": return((long)player.Max_HP); case "MAX_MP": return((long)player.Max_MP); case "MAX_CP": return((long)player.Max_CP); case "CUR_HP": return((long)player.Cur_HP); case "CUR_MP": return((long)player.Cur_MP); case "CUR_CP": return((long)player.Cur_CP); case "PER_HP": return((long)(100.0 * (player.Cur_HP / player.Max_HP))); case "PER_MP": return((long)(100.0 * (player.Cur_MP / player.Max_MP))); case "PER_CP": return((long)(100.0 * (player.Cur_CP / player.Max_CP))); case "RUN_SPEED": return((long)(player.RunSpeed * Globals.gamedata.my_char.MoveSpeedMult)); case "WALK_SPEED": return((long)(player.WalkSpeed * Globals.gamedata.my_char.MoveSpeedMult)); case "ATTACK_SPEED": return((long)player.AttackSpeedMult); case "CAST_SPEED": return((long)player.MatkSpeed); case "EVAL": return((long)player.RecAmount); case "RUNNING": return((long)player.isRunning); case "SITTING": return((long)player.isSitting); case "LOOKS_DEAD": return((long)player.isAlikeDead); default: ScriptEngine.Script_Error("invalid target data(player) request"); break; } } } //unlock finally { Globals.PlayerLock.ExitReadLock(); } break; case TargetType.NPC: Globals.NPCLock.EnterReadLock(); try { NPCInfo npc = Util.GetNPC(Globals.gamedata.my_char.TargetID); if (npc != null) { switch (req) { case "KARMA": return((long)npc.Karma); case "TARGETID": return((long)npc.TargetID); case "ID": return((long)npc.ID); case "TYPEID": return((long)npc.NPCID); case "X": return((long)npc.X); case "Y": return((long)npc.Y); case "Z": return((long)npc.Z); case "DESTX": return((long)npc.Dest_X); case "DESTY": return((long)npc.Dest_Y); case "DESTZ": return((long)npc.Dest_Z); case "IS_MOVING": return(npc.Moving ? 1L : 0L); case "MAX_HP": return((long)npc.Max_HP); case "MAX_MP": return((long)npc.Max_MP); case "MAX_CP": return((long)npc.Max_CP); case "CUR_HP": return((long)npc.Cur_HP); case "CUR_MP": return((long)npc.Cur_MP); case "CUR_CP": return((long)npc.Cur_CP); case "PER_HP": return((long)(100.0 * (npc.Cur_HP / npc.Max_HP))); case "PER_MP": return((long)(100.0 * (npc.Cur_MP / npc.Max_MP))); case "PER_CP": return((long)(100.0 * (npc.Cur_CP / npc.Max_CP))); case "RUN_SPEED": return((long)(npc.RunSpeed * Globals.gamedata.my_char.MoveSpeedMult)); case "WALK_SPEED": return((long)(npc.WalkSpeed * Globals.gamedata.my_char.MoveSpeedMult)); case "ATTACK_SPEED": return((long)npc.AttackSpeedMult); case "CAST_SPEED": return((long)npc.MatkSpeed); case "SPOILED": if (Globals.gamedata.my_char.TargetSpoiled) { return((long)(1)); } else { return((long)(0)); } case "RUNNING": return((long)npc.isRunning); case "SITTING": return((long)npc.isSitting); case "LOOKS_DEAD": return((long)npc.isAlikeDead); default: ScriptEngine.Script_Error("invalid target data(npc) request"); break; } } } //unlock finally { Globals.NPCLock.ExitReadLock(); } break; } return((long)0); }
public static string TARGET_STRING(string req) { switch (Globals.gamedata.my_char.CurrentTargetType) { case TargetType.ERROR: case TargetType.NONE: break; case TargetType.SELF: switch (req) { case "NAME": return(Globals.gamedata.my_char.Name); case "TITLE": return(Globals.gamedata.my_char.Title); case "CLAN": return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).ClanName); case "ALLY": return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).AllyName); default: ScriptEngine.Script_Error("invalid invalid target data(self) request"); break; } break; case TargetType.MYPET: switch (req) { case "NAME": return(Globals.gamedata.my_pet.Name); case "TITLE": return(Globals.gamedata.my_pet.Title); case "CLAN": return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).ClanName); case "ALLY": return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).AllyName); default: ScriptEngine.Script_Error("invalid invalid target data(my pet) request"); break; } break; case TargetType.MYPET1: switch (req) { case "NAME": return(Globals.gamedata.my_pet1.Name); case "TITLE": return(Globals.gamedata.my_pet1.Title); case "CLAN": return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).ClanName); case "ALLY": return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).AllyName); default: ScriptEngine.Script_Error("invalid invalid target data(my pet) request"); break; } break; case TargetType.MYPET2: switch (req) { case "NAME": return(Globals.gamedata.my_pet2.Name); case "TITLE": return(Globals.gamedata.my_pet2.Title); case "CLAN": return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).ClanName); case "ALLY": return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).AllyName); default: ScriptEngine.Script_Error("invalid invalid target data(my pet) request"); break; } break; case TargetType.MYPET3: switch (req) { case "NAME": return(Globals.gamedata.my_pet3.Name); case "TITLE": return(Globals.gamedata.my_pet3.Title); case "CLAN": return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).ClanName); case "ALLY": return(((Clan_Info)Globals.clanlist[Globals.gamedata.my_char.ClanID]).AllyName); default: ScriptEngine.Script_Error("invalid invalid target data(my pet) request"); break; } break; case TargetType.PLAYER: Globals.PlayerLock.EnterReadLock(); try { CharInfo player = Util.GetChar(Globals.gamedata.my_char.TargetID); if (player != null) { switch (req) { case "NAME": return(player.Name); case "TITLE": return(player.Title); case "CLAN": return(((Clan_Info)Globals.clanlist[player.ClanID]).ClanName); case "ALLY": return(((Clan_Info)Globals.clanlist[player.ClanID]).AllyName); default: ScriptEngine.Script_Error("invalid invalid target data(player) request"); break; } } } //unlock finally { Globals.PlayerLock.ExitReadLock(); } break; case TargetType.NPC: Globals.NPCLock.EnterReadLock(); try { NPCInfo npc = Util.GetNPC(Globals.gamedata.my_char.TargetID); if (npc != null) { switch (req) { case "NAME": return(Util.GetNPCName(npc.NPCID)); case "TITLE": return(npc.Title); default: ScriptEngine.Script_Error("invalid target data(npc) request"); break; } } } //unlock finally { Globals.NPCLock.ExitReadLock(); } break; } return(""); }
private void button_attack_Click(object sender, EventArgs e) { switch (Globals.gamedata.my_char.CurrentTargetType) { case TargetType.ERROR: case TargetType.NONE: break; case TargetType.SELF: break; case TargetType.MYPET: ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet.X), Util.Float_Int32(Globals.gamedata.my_pet.Y), Util.Float_Int32(Globals.gamedata.my_pet.Z), false); break; case TargetType.MYPET1: ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet1.X), Util.Float_Int32(Globals.gamedata.my_pet1.Y), Util.Float_Int32(Globals.gamedata.my_pet1.Z), false); break; case TargetType.MYPET2: ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet2.X), Util.Float_Int32(Globals.gamedata.my_pet2.Y), Util.Float_Int32(Globals.gamedata.my_pet2.Z), false); break; case TargetType.MYPET3: ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(Globals.gamedata.my_pet3.X), Util.Float_Int32(Globals.gamedata.my_pet3.Y), Util.Float_Int32(Globals.gamedata.my_pet3.Z), false); break; case TargetType.PLAYER: Globals.PlayerLock.EnterReadLock(); try { CharInfo player = Util.GetChar(Globals.gamedata.my_char.TargetID); if (player != null) { ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(player.X), Util.Float_Int32(player.Y), Util.Float_Int32(player.Z), false); } } finally { Globals.PlayerLock.ExitReadLock(); } break; case TargetType.NPC: Globals.NPCLock.EnterReadLock(); try { NPCInfo npc = Util.GetNPC(Globals.gamedata.my_char.TargetID); if (npc != null) { ServerPackets.Force_Attack(Globals.gamedata.my_char.TargetID, Util.Float_Int32(npc.X), Util.Float_Int32(npc.Y), Util.Float_Int32(npc.Z), false); } } finally { Globals.NPCLock.ExitReadLock(); } break; } }