WOW záložky func. bacha!
Datum: 22/11/2014 23:55:56
Staženo: 466x
Popis:
statusform.cs
Tento script může upravovat jen znalej člověk
Příkazy:
Kód:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Phoenix;
using System.Windows.Forms;
using Phoenix.WorldData;
using System.Drawing;
using Phoenix.Gui.Controls;
using MulLib;
using Phoenix.Communication.Packets;
using Phoenix.Communication;
using System.Threading;
using System.Runtime.InteropServices;
using System.Reflection;
namespace Scripts.Status
{
class StatusForm : InGameWindow
{
private UOColor[] notorietyColors = new UOColor[] { Env.DefaultConsoleColor, 0x0063, 0x0044, 0x03E9, 0x03E5, 0x0030, 0x0026, 0x0481 };
private Label name;
private Label hits;
private UOCharacter mobile;
private HealthBar healthBar;
private WorldLocation lastloc;
private bool lastWar;
private DateTime lastRequest;
private bool statusNeeded = true;
public bool Transparency { get; set; }
// wowo mode
private bool wowmodes = true;
/// <summary>
/// Initializes a new instance of the <see cref="T:StatusForm"/> class.
/// </summary>
public StatusForm(Serial id)
{
InitializeComponent();
MouseEnter += new EventHandler(StatusForm_MouseEnter);
MouseLeave += new EventHandler(StatusForm_MouseLeave);
MouseDoubleClick += new MouseEventHandler(StatusForm_MouseDoubleClick);
Target += new EventHandler(StatusForm_Target);
mobile = new UOCharacter(id);
}
protected override bool Targettable
{
get { return true; }
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
mobile.Changed += new ObjectChangedEventHandler(mobile_Changed);
World.Player.Changed += new ObjectChangedEventHandler(Player_Changed);
World.CharacterAppeared += new CharacterAppearedEventHandler(World_CharacterAppeared);
if (Transparency) {
Opacity = 0.8;
}
UpdateStats();
}
protected override void Dispose(bool disposing)
{
mobile.Changed -= new ObjectChangedEventHandler(mobile_Changed);
World.Player.Changed -= new ObjectChangedEventHandler(Player_Changed);
World.CharacterAppeared -= new CharacterAppearedEventHandler(World_CharacterAppeared);
base.Dispose(disposing);
}
public Serial MobileId
{
get { return mobile.Serial; }
}
void World_CharacterAppeared(object sender, CharacterAppearedEventArgs e)
{
if (e.Serial == mobile.Serial) {
UpdateStats();
}
}
void Player_Changed(object sender, ObjectChangedEventArgs e)
{
if (WalkHandling.DesiredPosition.X != lastloc.X && WalkHandling.DesiredPosition.Y != lastloc.Y) {
UpdateStats();
}
if (World.Player.Warmode != lastWar) {
lastWar = World.Player.Warmode;
UpdateCursor();
}
}
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
UpdateStats();
}
protected override void OnClosed(EventArgs e)
{
mobile.Changed -= mobile_Changed;
base.OnClosed(e);
}
void mobile_Changed(object sender, ObjectChangedEventArgs e)
{
UpdateStats();
}
private ushort ColorsStats(int hits)
{
ushort barvas = 0x0000;
// kladne
if (hits > 0 && hits <= 5) { barvas = 0x004D; }
if (hits > 5 && hits <= 10) { barvas = 0x004E; }
if (hits > 10 && hits <= 15) { barvas = 0x004F; }
if (hits > 20 && hits <= 25) { barvas = 0x0050; }
if (hits > 30 && hits <= 60) { barvas = 0x0051; }
if (hits > 60 && hits <= 100) { barvas = 0x0693; }
if (hits > 100) { barvas = 0x062D; }
// zaporne
if (hits < 0 && hits >= -5) { barvas = 0x04F0; }
if (hits < -5 && hits >= -10) { barvas = 0x0504; }
if (hits < -10 && hits >= -15) { barvas = 0x0020; }
if (hits < -20 && hits >= -25) { barvas = 0x0021; }
if (hits < -30 && hits >= -60) { barvas = 0x0022; }
if (hits < -60 && hits >= -100) { barvas = 0x0023; }
if (hits < -100) { barvas = 0x0024; }
return barvas;
}
private void ShowsStats(int hits, Serial mobile)
{
if (healthBar.Aktualne != 0)
{
if (healthBar.Aktualne != hits && healthBar.Aktualne != (hits - 1) && healthBar.Aktualne != (hits + 1))
{
UOCharacter characters = new UOCharacter(mobile);
int cislo_napis = (hits - healthBar.Aktualne);
UOColor barvicka_na_vys = ColorsStats(cislo_napis);
characters.Print(barvicka_na_vys, "{0}", cislo_napis.ToString());
healthBar.Aktualne = hits;
}
else
{ healthBar.Aktualne = hits; }
}
else
{ healthBar.Aktualne = hits; }
}
private void UpdateStats()
{
if (InvokeRequired) {
BeginInvoke(new ThreadStart(UpdateStats));
return;
}
if (mobile.Name != null) {
name.Text = mobile.Name;
}
if (mobile.MaxHits > -1) {
hits.Text = String.Format("{0}/{1}", mobile.Hits, mobile.MaxHits);
healthBar.Hits = mobile.Hits;
healthBar.MaxHits = mobile.MaxHits;
healthBar.Poison = mobile.Poisoned;
if (wowmodes == true) { ShowsStats(mobile.Hits, mobile.Serial);}
healthBar.Unknown = false;
statusNeeded = false;
}
else {
healthBar.Unknown = true;
}
Notoriety n = mobile.Notoriety;
if (mobile.Distance > 18) {
n = Notoriety.Unknown;
healthBar.Unknown = true;
}
HueEntry notoh = DataFiles.Hues.Get(notorietyColors[(int)n]);
ushort noto = notoh.Colors[12];
BackColor = Color.FromArgb(UOColorConverter.ToArgb(noto) | (0xFF << 24));
// Do we need status?
if (healthBar.Unknown) {
statusNeeded = true;
}
// Request if mob is visible
if (statusNeeded && mobile.Distance < 19 && DateTime.Now - lastRequest < TimeSpan.FromSeconds(10)) {
statusNeeded = false;
lastRequest = DateTime.Now;
mobile.RequestStatus();
}
}
#region System
void StatusForm_MouseEnter(object sender, EventArgs e)
{
if (Transparency) {
// Opacity = 1.0;
}
}
void StatusForm_MouseLeave(object sender, EventArgs e)
{
if (Transparency) {
Opacity = 0.8;
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
base.OnPaintBackground(e);
e.Graphics.DrawRectangle(Pens.Black, new Rectangle(0, 0, Width - 1, Height - 1));
}
void StatusForm_Target(object sender, EventArgs e)
{
// Simulate click
byte[] data = PacketBuilder.Target(0, UIManager.ClientTargetId, 0, mobile.Serial, mobile.X, mobile.Y, mobile.Z, 0);
Core.SendToServer(data, true);
Client.Window.PostMessage(WM_KEYDOWN, 27, 0x00010001);
UpdateCursor();
// Select in client
// MarkAsAttacked();
}
private void MarkAsAttacked()
{
byte[] data = new byte[5];
data[0] = 0xAA;
ByteConverter.BigEndian.ToBytes((uint)mobile.Serial, data, 1);
Core.SendToClient(data, false);
}
void StatusForm_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (World.Player.Warmode)
UO.Attack(mobile.Serial);
else
mobile.Use();
}
#endregion
#region WinForms
private void InitializeComponent()
{
this.name = new System.Windows.Forms.Label();
this.hits = new System.Windows.Forms.Label();
this.healthBar = new Scripts.Status.HealthBar();
this.SuspendLayout();
//
// name
//
this.name.AutoSize = true;
this.name.BackColor = System.Drawing.Color.Transparent;
this.name.Enabled = false;
this.name.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.name.ForeColor = System.Drawing.Color.Silver;
this.name.Location = new System.Drawing.Point(7, 3);
this.name.Name = "name";
this.name.Size = new System.Drawing.Size(39, 14);
this.name.TabIndex = 0;
this.name.Text = "label1";
//
// hits
//
this.hits.AutoSize = true;
this.hits.BackColor = System.Drawing.Color.Transparent;
this.hits.Enabled = false;
this.hits.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.hits.ForeColor = System.Drawing.Color.Silver;
this.hits.Location = new System.Drawing.Point(7, 15);
this.hits.Name = "hits";
this.hits.Size = new System.Drawing.Size(66, 15);
this.hits.TabIndex = 1;
this.hits.Text = "0000/0000";
//
// healthBar
//
this.healthBar.Enabled = false;
this.healthBar.Hits = 0;
this.healthBar.Location = new System.Drawing.Point(7, 30);
this.healthBar.MaxHits = 0;
this.healthBar.Name = "healthBar";
this.healthBar.Size = new System.Drawing.Size(128, 15);
this.healthBar.TabIndex = 2;
this.healthBar.Text = "healthBar1";
this.healthBar.Unknown = false;
//
// StatusForm
//
this.BackColor = System.Drawing.Color.Black;
this.ClientSize = new System.Drawing.Size(142, 50);
this.Controls.Add(this.hits);
this.Controls.Add(this.name);
this.Controls.Add(this.healthBar);
this.DoubleBuffered = true;
this.Name = "StatusForm";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
}
}

