Skip to content

Commit

Permalink
Merge pull request #25 from jsebold666/fix-healthbar
Browse files Browse the repository at this point in the history
Fix healthbar
  • Loading branch information
jsebold666 authored Apr 7, 2024
2 parents 55cbe65 + cfffe19 commit 0b616db
Show file tree
Hide file tree
Showing 10 changed files with 250 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/ClassicUO.Client/ClassicUO.Client.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<ApplicationIcon>cuoicon.ico</ApplicationIcon>
<AssemblyName>ClassicUO</AssemblyName>
<RootNamespace>ClassicUO</RootNamespace>
Expand Down
2 changes: 2 additions & 0 deletions src/ClassicUO.Client/Configuration/Profile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ internal sealed class Profile
public bool PreviewFields { get; set; }
public bool OwnAuraByHP { get; set; }
public int HighlightLastTargetType { get; set; } = 0; // 0 = off, 1 = white, 2 = pink, 3 = ice, 4 = fire, 5 = custom
public int HighlighFriendsGuildType { get; set; } = 0;
public ushort HighlightLastTargetTypeHue { get; set; } = 0x0044;
public ushort HighlighFriendsGuildTypeHue { get; set; } = 0x0044;
public int HighlightLastTargetTypePoison { get; set; } = 0; // 0 = off, 1 = white, 2 = pink, 3 = ice, 4 = fire, 5 = special, 6 = custom
public ushort HighlightLastTargetTypePoisonHue { get; set; } = 0x0044;
public int HighlightLastTargetTypePara { get; set; } = 0; // 0 = off, 1 = white, 2 = pink, 3 = ice, 4 = fire, 5 = special, 6 = custom
Expand Down
67 changes: 64 additions & 3 deletions src/ClassicUO.Client/Dust765/Dust765/CombatCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,54 @@ public static ushort OwnAuraColorByHP()

return color;
}

public static ushort LastFriendHue(Mobile mobile, ushort hue)
{
WMapEntity wme = World.WMapManager.GetEntity(mobile.Serial);

if (wme != null)
{
if (mobile.NotorietyFlag == NotorietyFlag.Ally || World.Party.Contains(mobile.Serial) || wme.IsGuild)
{


if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 1)
hue = BRIGHT_WHITE_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 2)
hue = BRIGHT_PINK_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 3)
hue = BRIGHT_ICE_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 4)
hue = BRIGHT_FIRE_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 5)
hue = ProfileManager.CurrentProfile.HighlighFriendsGuildTypeHue;
}
return hue;
}
else
{
if (mobile.NotorietyFlag == NotorietyFlag.Ally || World.Party.Contains(mobile.Serial))
{


if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 1)
hue = BRIGHT_WHITE_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 2)
hue = BRIGHT_PINK_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 3)
hue = BRIGHT_ICE_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 4)
hue = BRIGHT_FIRE_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 5)
hue = ProfileManager.CurrentProfile.HighlighFriendsGuildTypeHue;
}
return hue;
}



}

public static ushort WeaponsHue(ushort hue)
{
if (ProfileManager.CurrentProfile.GlowingWeaponsType == 1)
Expand Down Expand Up @@ -324,6 +372,19 @@ public static ushort LastTargetHue(Mobile mobile, ushort hue)
hue = BRIGHT_FIRE_COLOR;
else if (ProfileManager.CurrentProfile.HighlightLastTargetType == 5)
hue = ProfileManager.CurrentProfile.HighlightLastTargetTypeHue;
if (mobile.NotorietyFlag == NotorietyFlag.Ally)
{
if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 1)
hue = BRIGHT_WHITE_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 2)
hue = BRIGHT_PINK_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 3)
hue = BRIGHT_ICE_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 4)
hue = BRIGHT_FIRE_COLOR;
else if (ProfileManager.CurrentProfile.HighlighFriendsGuildType == 5)
hue = ProfileManager.CurrentProfile.HighlighFriendsGuildTypeHue;
}

if (mobile.IsPoisoned)
{
Expand Down Expand Up @@ -515,7 +576,7 @@ public static bool MultiFieldPreview(Multi obj)
}
}
}
if (GameActions.LastSpellIndexCursor == 48 || GameActions.LastSpellIndexCursor == 49 || GameActions.LastSpellIndexCursor == 55)
if (GameActions.LastSpellIndexCursor == 48 || GameActions.LastSpellIndexCursor == 49 || GameActions.LastSpellIndexCursor == 55 || GameActions.LastSpellIndexCursor == 22)
{
if (SelectedObject.Object != null && (SelectedObject.Object.RealScreenPosition.X + 22) == obj.RealScreenPosition.X && (SelectedObject.Object.RealScreenPosition.Y + 22) == obj.RealScreenPosition.Y)
{
Expand Down Expand Up @@ -748,7 +809,7 @@ public static bool StaticFieldPreview(Static obj)
}
}
}
if (GameActions.LastSpellIndexCursor == 48 || GameActions.LastSpellIndexCursor == 49 || GameActions.LastSpellIndexCursor == 55)
if (GameActions.LastSpellIndexCursor == 48 || GameActions.LastSpellIndexCursor == 49 || GameActions.LastSpellIndexCursor == 55 || GameActions.LastSpellIndexCursor == 22)
{
if (SelectedObject.Object != null && (SelectedObject.Object.RealScreenPosition.X + 22) == obj.RealScreenPosition.X && (SelectedObject.Object.RealScreenPosition.Y + 22) == obj.RealScreenPosition.Y)
{
Expand Down Expand Up @@ -982,7 +1043,7 @@ public static bool LandFieldPreview(Land obj)
}
}
}
if (GameActions.LastSpellIndexCursor == 48 || GameActions.LastSpellIndexCursor == 49 || GameActions.LastSpellIndexCursor == 55)
if (GameActions.LastSpellIndexCursor == 48 || GameActions.LastSpellIndexCursor == 49 || GameActions.LastSpellIndexCursor == 55 || GameActions.LastSpellIndexCursor == 22)
{
if (SelectedObject.Object != null && (SelectedObject.Object.RealScreenPosition.X + 22) == obj.RealScreenPosition.X && (SelectedObject.Object.RealScreenPosition.Y + 22) == obj.RealScreenPosition.Y)
{
Expand Down
6 changes: 4 additions & 2 deletions src/ClassicUO.Client/Dust765/External/OnCastingGump.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,11 @@ public void Start(uint _spell_id, uint _re = 0)
SpellAction spell = (SpellAction)_spell_id;
circle = (uint)SpellManager.GetCircle(spell);
uint protection_delay = 0;
if (World.Player.IsBuffIconExists(BuffIconType.Protection) || World.Player.IsBuffIconExists(BuffIconType.ArchProtection))
bool ignore_proctetion_delay = (spell == SpellAction.Protection || spell == SpellAction.ArchProtection);
if (World.Player.IsBuffIconExists(BuffIconType.Protection) && !ignore_proctetion_delay
|| World.Player.IsBuffIconExists(BuffIconType.EssenceOfWind))
{
protection_delay = protection_delay + 4;
protection_delay = 2;
}
_endTime = _startTime + 400 + (circle + protection_delay) * 250 + _re; // (0.5+ 0.25 * circle) * 1000
GameActions.iscasting = true;
Expand Down
8 changes: 8 additions & 0 deletions src/ClassicUO.Client/Game/GameObjects/Views/MobileView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,15 @@ public override bool Draw(UltimaBatcher2D batcher, int posX, int posY, float dep
}
}


// ## BEGIN - END ## // VISUAL HELPERS

if (ProfileManager.CurrentProfile.HighlighFriendsGuildType != 0)
{
overridedHue = CombatCollection.LastFriendHue(this, overridedHue);
hueVec.Y = 1;
}

if (ProfileManager.CurrentProfile.HighlightLastTargetType != 0 && World.Get(TargetManager.LastTargetInfo.Serial) == this)
{
overridedHue = CombatCollection.LastTargetHue(this, overridedHue);
Expand Down
85 changes: 85 additions & 0 deletions src/ClassicUO.Client/Game/Managers/TargetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
using ClassicUO.Network;
using ClassicUO.Resources;
using ClassicUO.Utility;
using System;

namespace ClassicUO.Game.Managers
{
Expand Down Expand Up @@ -560,5 +561,89 @@ private static void TargetPacket(ushort graphic, ushort x, ushort y, sbyte z)
Mouse.CancelDoubleClick = true;
ClearTargetingWithoutTargetCancelPacket();
}

public static void TargetFromHealthBar(uint serial)
{
if (!IsTargeting)
{
return;
}

if (serial != null)

Check warning on line 572 in src/ClassicUO.Client/Game/Managers/TargetManager.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

The result of the expression is always 'true' since a value of type 'uint' is never equal to 'null' of type 'uint?'

Check warning on line 572 in src/ClassicUO.Client/Game/Managers/TargetManager.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The result of the expression is always 'true' since a value of type 'uint' is never equal to 'null' of type 'uint?'

Check warning on line 572 in src/ClassicUO.Client/Game/Managers/TargetManager.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

The result of the expression is always 'true' since a value of type 'uint' is never equal to 'null' of type 'uint?'
{
switch (TargetingState)
{
case CursorTarget.Invalid: return;

case CursorTarget.MultiPlacement:
case CursorTarget.Position:
case CursorTarget.Object:
case CursorTarget.HueCommandTarget:
case CursorTarget.SetTargetClientSide:

if (serial != World.Player.Serial)
{
LastTargetInfo.SetEntity(serial);
}


if (TargetingState != CursorTarget.SetTargetClientSide)
{
_lastDataBuffer[0] = 0x6C;

_lastDataBuffer[1] = 0x00;

_lastDataBuffer[2] = (byte)(_targetCursorId >> 24);
_lastDataBuffer[3] = (byte)(_targetCursorId >> 16);
_lastDataBuffer[4] = (byte)(_targetCursorId >> 8);
_lastDataBuffer[5] = (byte)_targetCursorId;

_lastDataBuffer[6] = (byte)TargetingType;

_lastDataBuffer[7] = (byte)(serial >> 24);
_lastDataBuffer[8] = (byte)(serial >> 16);
_lastDataBuffer[9] = (byte)(serial >> 8);
_lastDataBuffer[10] = (byte)serial;

_lastDataBuffer[11] = (byte)(0 >> 8);
_lastDataBuffer[12] = (byte)0;

_lastDataBuffer[13] = (byte)(0 >> 8);
_lastDataBuffer[14] = (byte)0;

_lastDataBuffer[15] = (byte)(0 >> 8);
_lastDataBuffer[16] = (byte)0;

_lastDataBuffer[17] = (byte)(0 >> 8);
_lastDataBuffer[18] = (byte)0;


NetClient.Socket.Send_TargetObject(serial,
0,
0,
0,
0,
_targetCursorId,
(byte)TargetingType);



}

if (SerialHelper.IsMobile(serial) && LastTargetInfo.Serial == serial)
{
GameActions.RequestMobileStatus(serial);
}

ClearTargetingWithoutTargetCancelPacket();

Mouse.CancelDoubleClick = true;

break;


}
}
}
}
}
Loading

0 comments on commit 0b616db

Please sign in to comment.