Skip to content

Commit

Permalink
show karma and pvp/pk kills in stats
Browse files Browse the repository at this point in the history
  • Loading branch information
shnok committed Nov 10, 2024
1 parent 275139d commit 7eadad2
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 69 deletions.
8 changes: 6 additions & 2 deletions l2-unity-todo.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
TODO (priority from top to bottom)

sync monstergrp (HP amount) with interlude
FIX: if click to move during the FIRST attack animation after log-in or teleport, cant move

handle AOE hits
show karma and pvp/pk kills in stats

title and player colors + pvp/karma in player name color
chat window message limit, scroll limit, message filtering, message history
sound spatialization fix
Expand All @@ -19,6 +20,9 @@ Nature renderer for deco layer

DONE

show karma and pvp/pk kills in stats
show hp based on npcgrp HPShowable
sync monstergrp (HP amount) with interlude (send max hp in npc info)
show player weapons/exp/karma in character select
dont use skillbar shortcuts when chat is opened
make arrows stick to entity when hit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ui:VisualElement style="flex-grow: 1;">
<ui:Label text="Label" name="TargetName" style="-unity-font-definition: url(&quot;project://database/Assets/Resources/Data/UI/Assets/Font/tahoma.ttf?fileID=12800000&amp;guid=96fb7a735e76e0742bf125e2d4734bf3&amp;type=3#tahoma&quot;); color: rgb(255, 255, 255); flex-grow: 0; margin-top: 2px; font-size: 11px; text-shadow: 0.5px 0.5px 0 rgb(0, 0, 0); letter-spacing: 3px; -unity-text-outline-color: rgba(0, 0, 0, 0.99); -unity-text-outline-width: 0.1px;" />
<ui:VisualElement style="flex-grow: 1;">
<ui:VisualElement name="HPBarContainer" template="HpBar" class="bar-container" style="margin-top: 4px;">
<ui:VisualElement name="HPBarContainer" template="HpBar" class="bar-container target-bar-container">
<ui:GroupBox name="HPBarBG" class="bar-inner" style="width: 100%;">
<ui:VisualElement name="BGLeft" class="left bar-height" style="background-image: url(&quot;project://database/Assets/Resources/Data/UI/Assets/Status/Gauge/Gauge_DF_Large_HP/Gauge_DF_Large_HP_bg_Left.png?fileID=2800000&amp;guid=eb4faf84cfe537245a613ac946a5eb78&amp;type=3#Gauge_DF_Large_HP_bg_Left&quot;);" />
<ui:VisualElement name="BGCenter" class="center bar-height" style="background-image: url(&quot;project://database/Assets/Resources/Data/UI/Assets/Status/Gauge/Gauge_DF_Large_HP/Gauge_DF_Large_HP_bg_Center.png?fileID=2800000&amp;guid=9a39b86abc753c1468dc586de59e7d7c&amp;type=3#Gauge_DF_Large_HP_bg_Center&quot;);" />
Expand Down
11 changes: 10 additions & 1 deletion l2-unity/Assets/Resources/Data/UI/_Elements/L2StyleSheet.uss
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@
}

.nameplate.hidden {
opacity: 0%;
opacity: 0;
}

.nameplate.gauge .nameplate-gauge {
Expand Down Expand Up @@ -3843,3 +3843,12 @@
flex-direction: row;
justify-content: center;
}

.target-bar-container {
margin-top: 4px;
opacity: 0;
}

.target-bar-container.visible {
opacity: 100;
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ private void ConfigureIdentity(Entity npc, NetworkIdentity identity, Npcgrp npcg
{
npc.Identity = identity;
npc.Identity.NpcClass = npcgrp.ClassName;
npc.Identity.IsHpShowable = npcgrp.HpVisible;

if (string.IsNullOrEmpty(npc.Identity.Name))
npc.Identity.Name = npcName.Name;
Expand All @@ -144,9 +145,10 @@ private void ConfigureIdentity(Entity npc, NetworkIdentity identity, Npcgrp npcg
private void ConfigureStats(Entity npc, Status status, Stats stats, Npcgrp npcgrp)
{
npc.Status = status;
npc.Status.Hp = (int)npcgrp.MaxHp;
npc.Stats = stats;
npc.Stats.MaxHp = (int)npcgrp.MaxHp;
// npc.Stats.MaxHp = (int)npcgrp.MaxHp; //Now shared by server
// npc.Status.Hp = (int)npcgrp.MaxHp;
npc.Status.Hp = npc.Stats.MaxHp;
}

private void InitializeNpcComponents(Entity npc)
Expand Down
2 changes: 1 addition & 1 deletion l2-unity/Assets/Scripts/Game/Manager/World/WorldCombat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public Task EntityAttacks(Vector3 attackerPosition, int sender, Hit hit)

public void StatusUpdate(Entity entity, List<Attribute> attributes)
{
// Debug.Log("Word combat: Status update");
Debug.Log("Word combat: Status update");
Status status = entity.Status;
Stats stats = entity.Stats;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public override void Parse()
Stats.WalkSpeed = (int)(Stats.MoveSpeedMultiplier > 0 ? Stats.WalkSpeed * Stats.MoveSpeedMultiplier : Stats.WalkSpeed);

Stats.AttackRange = ReadI() / 52.5f;
Stats.MaxHp = ReadI();

Debug.LogWarning(ToString());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Text;
using UnityEngine;

public class StatusUpdatePacket : ServerPacket
Expand Down Expand Up @@ -83,5 +84,24 @@ public override void Parse()

_attributes.Add(new Attribute(attributeId, attributeValue));
}

Debug.LogWarning(ToString());
}

public override string ToString()
{
var sb = new StringBuilder();
sb.AppendLine($"StatusUpdatePacket:");
sb.AppendLine($"ObjectId: {_objectId}");
sb.AppendLine($"AttributeCount: {_attributeCount}");

sb.AppendLine("Attributes:");
foreach (var attribute in _attributes)
{
var attributeName = (AttributeType)attribute.id;
sb.AppendLine($" - {attributeName} (0x{attribute.id:X2}): {attribute.value}");
}

return sb.ToString();
}
}
2 changes: 2 additions & 0 deletions l2-unity/Assets/Scripts/Networking/Unity/NetworkIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class NetworkIdentity
{
[SerializeField] private EntityType _entityType;
[SerializeField] private int _id;
[SerializeField] private bool _isHpShowable;
[SerializeField] private string _name;
[SerializeField] private string _title;
[SerializeField] private string _titleColor = "9CE8A9FF"; // default color
Expand Down Expand Up @@ -35,6 +36,7 @@ public class NetworkIdentity
public bool Owned { get => _owned; set => _owned = value; }
public byte PlayerClass { get => _playerClass; set => _playerClass = value; }
public bool IsMage { get => _isMage; set => _isMage = value; }
public bool IsHpShowable { get => _isHpShowable; set => _isHpShowable = value; }

public NetworkIdentity() { }

Expand Down
4 changes: 2 additions & 2 deletions l2-unity/Assets/Scripts/UI/Game/CharacterWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ private void UpdateCombatValues(bool running, PlayerStats stats)

private void UpdateSocial(PlayerStats stats)
{
_repLabel.text = "0";
_pvpLabel.text = "0 / 0";
_repLabel.text = stats.Karma.ToString();
_pvpLabel.text = $"{stats.PvpKills} / {stats.PkKills}";
_recLabel.text = "0 / 0";
_raidLabel.text = "0";
}
Expand Down
39 changes: 33 additions & 6 deletions l2-unity/Assets/Scripts/UI/Game/TargetWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
public class TargetWindow : L2PopupWindow
{
private Label _nameLabel;
private VisualElement _HPBarContainer;
private VisualElement _HPBar;
private VisualElement _HPBarBG;

Expand Down Expand Up @@ -75,7 +76,13 @@ protected override IEnumerator BuildWindow(VisualElement root)
_HPBarBG = GetElementById("HPBarBG");
if (_HPBarBG == null)
{
Debug.LogError("Target window HPBarBG is null");
Debug.LogError("Target window _HPBarBG is null");
}

_HPBarContainer = GetElementById("HPBarContainer");
if (_HPBarContainer == null)
{
Debug.LogError("Target window _HPBarContainer is null");
}

_windowEle.style.position = Position.Absolute;
Expand All @@ -102,14 +109,34 @@ private void FixedUpdate()
{
_nameLabel.text = targetData.Identity.Name;
}
if (_HPBarBG != null && _HPBar != null)

if (_HPBarContainer != null)
{
float hpRatio = (float)targetData.Status.Hp / targetData.Stats.MaxHp;
float bgWidth = _HPBarBG.resolvedStyle.width;
float barWidth = bgWidth * hpRatio;
_HPBar.style.width = barWidth;
if (targetData.Identity.IsHpShowable)
{
if (!_HPBarContainer.ClassListContains("visible"))
{
_HPBarContainer.AddToClassList("visible");
}

if (_HPBarBG != null && _HPBar != null)
{
float hpRatio = (float)targetData.Status.Hp / targetData.Stats.MaxHp;
float bgWidth = _HPBarBG.resolvedStyle.width;
float barWidth = bgWidth * hpRatio;
_HPBar.style.width = barWidth;
}
}
else
{
if (_HPBarContainer.ClassListContains("visible"))
{
_HPBarContainer.RemoveFromClassList("visible");
}
}
}
}

else if (!_isWindowHidden)
{
HideWindow();
Expand Down
Loading

0 comments on commit 7eadad2

Please sign in to comment.