Compare commits
9 Commits
0.0.2-alph
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa078bcead | ||
|
|
f50e218013 | ||
|
|
ee37ffb219 | ||
|
|
ca86371137 | ||
|
|
e0ffa3a62e | ||
|
|
936697defc | ||
|
|
d0baa5c21a | ||
|
|
914f6ba20f | ||
|
|
4e2e108076 |
@@ -120,8 +120,7 @@ namespace Client
|
|||||||
.AddSingleton(
|
.AddSingleton(
|
||||||
typeof(PathfinderInterface),
|
typeof(PathfinderInterface),
|
||||||
x => new L2jGeoDataPathfinder(
|
x => new L2jGeoDataPathfinder(
|
||||||
config.GetValue<string>("GeoDataDirectory") ?? "",
|
config.GetValue<string>("GeoDataDirectory") ?? ""
|
||||||
config.GetValue<ushort>("MaxPassableHeight")
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.AddSingleton(
|
.AddSingleton(
|
||||||
@@ -129,10 +128,10 @@ namespace Client
|
|||||||
x => new AsyncPathMover(
|
x => new AsyncPathMover(
|
||||||
x.GetRequiredService<WorldHandler>(),
|
x.GetRequiredService<WorldHandler>(),
|
||||||
x.GetRequiredService<PathfinderInterface>(),
|
x.GetRequiredService<PathfinderInterface>(),
|
||||||
config.GetValue<int>("PathNumberOfAttempts"),
|
|
||||||
config.GetValue<double>("NodeWaitingTime"),
|
config.GetValue<double>("NodeWaitingTime"),
|
||||||
config.GetValue<int>("NodeDistanceTolerance"),
|
config.GetValue<int>("NodeDistanceTolerance"),
|
||||||
config.GetValue<int>("NextNodeDistanceTolerance")
|
config.GetValue<int>("NextNodeDistanceTolerance"),
|
||||||
|
config.GetValue<ushort>("MaxPassableHeight")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -117,6 +117,8 @@ namespace Client.Application.ViewModels
|
|||||||
public byte DelevelingTargetLevel { get => delevelingTargetLevel; set { if (value != delevelingTargetLevel) { delevelingTargetLevel = value; OnPropertyChanged(); } } }
|
public byte DelevelingTargetLevel { get => delevelingTargetLevel; set { if (value != delevelingTargetLevel) { delevelingTargetLevel = value; OnPropertyChanged(); } } }
|
||||||
public uint DelevelingAttackDistance { get => delevelingAttackDistance; set { if (value != delevelingAttackDistance) { delevelingAttackDistance = value; OnPropertyChanged(); } } }
|
public uint DelevelingAttackDistance { get => delevelingAttackDistance; set { if (value != delevelingAttackDistance) { delevelingAttackDistance = value; OnPropertyChanged(); } } }
|
||||||
public uint DelevelingSkillId { get => delevelingSkillId; set { if (value != delevelingSkillId) { delevelingSkillId = value; OnPropertyChanged(); } } }
|
public uint DelevelingSkillId { get => delevelingSkillId; set { if (value != delevelingSkillId) { delevelingSkillId = value; OnPropertyChanged(); } } }
|
||||||
|
public byte MaxPassableHeight { get => maxPassableHeight; set { if (value != maxPassableHeight) { maxPassableHeight = value; OnPropertyChanged(); } } }
|
||||||
|
public short PickupRadius { get => pickupRadius; set { if (value != pickupRadius) { pickupRadius = value; OnPropertyChanged(); } } }
|
||||||
|
|
||||||
public void LoadConfig()
|
public void LoadConfig()
|
||||||
{
|
{
|
||||||
@@ -151,6 +153,8 @@ namespace Client.Application.ViewModels
|
|||||||
DelevelingTargetLevel = config.Deleveling.TargetLevel;
|
DelevelingTargetLevel = config.Deleveling.TargetLevel;
|
||||||
DelevelingAttackDistance = config.Deleveling.AttackDistance;
|
DelevelingAttackDistance = config.Deleveling.AttackDistance;
|
||||||
DelevelingSkillId = config.Deleveling.SkillId;
|
DelevelingSkillId = config.Deleveling.SkillId;
|
||||||
|
MaxPassableHeight = config.Combat.MaxPassableHeight;
|
||||||
|
PickupRadius = config.Combat.PickupRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveConfig()
|
private void SaveConfig()
|
||||||
@@ -181,6 +185,8 @@ namespace Client.Application.ViewModels
|
|||||||
config.Deleveling.TargetLevel = DelevelingTargetLevel;
|
config.Deleveling.TargetLevel = DelevelingTargetLevel;
|
||||||
config.Deleveling.AttackDistance = DelevelingAttackDistance;
|
config.Deleveling.AttackDistance = DelevelingAttackDistance;
|
||||||
config.Deleveling.SkillId = DelevelingSkillId;
|
config.Deleveling.SkillId = DelevelingSkillId;
|
||||||
|
config.Combat.MaxPassableHeight = MaxPassableHeight;
|
||||||
|
config.Combat.PickupRadius = PickupRadius;
|
||||||
SaveCollections();
|
SaveCollections();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -318,7 +324,7 @@ namespace Client.Application.ViewModels
|
|||||||
private readonly ConfigDeserializerInterface configDeserializer;
|
private readonly ConfigDeserializerInterface configDeserializer;
|
||||||
private uint mobsMaxDeltaZ = 0;
|
private uint mobsMaxDeltaZ = 0;
|
||||||
private byte? mobLevelLowerLimit = null;
|
private byte? mobLevelLowerLimit = null;
|
||||||
private byte? mobLevelUpperLimit = null;
|
private byte maxPassableHeight = 0;
|
||||||
private bool spoilIfPossible = false;
|
private bool spoilIfPossible = false;
|
||||||
private bool spoilIsPriority = false;
|
private bool spoilIsPriority = false;
|
||||||
private uint spoilSkillId = 0;
|
private uint spoilSkillId = 0;
|
||||||
@@ -340,5 +346,7 @@ namespace Client.Application.ViewModels
|
|||||||
private byte delevelingTargetLevel = 0;
|
private byte delevelingTargetLevel = 0;
|
||||||
private uint delevelingAttackDistance = 0;
|
private uint delevelingAttackDistance = 0;
|
||||||
private uint delevelingSkillId = 0;
|
private uint delevelingSkillId = 0;
|
||||||
|
private byte? mobLevelUpperLimit = null;
|
||||||
|
private short pickupRadius = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace Client.Application.ViewModels
|
|||||||
|
|
||||||
private async Task OnMouseRightClick(object? obj)
|
private async Task OnMouseRightClick(object? obj)
|
||||||
{
|
{
|
||||||
await pathMover.MoveUntilReachedAsync(creature.Transform.Position);
|
await pathMover.MoveAsync(creature.Transform.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreatureListViewModel(WorldHandler worldHandler, AsyncPathMoverInterface pathMover, CreatureInterface creature, Hero hero)
|
public CreatureListViewModel(WorldHandler worldHandler, AsyncPathMoverInterface pathMover, CreatureInterface creature, Hero hero)
|
||||||
@@ -62,6 +62,14 @@ namespace Client.Application.ViewModels
|
|||||||
this.pathMover = pathMover;
|
this.pathMover = pathMover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UnsubscribeAll()
|
||||||
|
{
|
||||||
|
creature.PropertyChanged -= Creature_PropertyChanged;
|
||||||
|
creature.Transform.Position.PropertyChanged -= Position_PropertyChanged;
|
||||||
|
hero.Transform.Position.PropertyChanged -= HeroPosition_PropertyChanged;
|
||||||
|
hero.PropertyChanged -= Hero_PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
OnPropertyChanged("Distance");
|
OnPropertyChanged("Distance");
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ namespace Client.Application.ViewModels
|
|||||||
|
|
||||||
private async Task OnMouseRightClick(object? obj)
|
private async Task OnMouseRightClick(object? obj)
|
||||||
{
|
{
|
||||||
await pathMover.MoveUntilReachedAsync(creature.Transform.Position);
|
await pathMover.MoveAsync(creature.Transform.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreatureMapViewModel(WorldHandler worldHandler, AsyncPathMoverInterface pathMover, CreatureInterface creature, Hero hero)
|
public CreatureMapViewModel(WorldHandler worldHandler, AsyncPathMoverInterface pathMover, CreatureInterface creature, Hero hero)
|
||||||
@@ -109,6 +109,16 @@ namespace Client.Application.ViewModels
|
|||||||
MouseRightClickCommand = new RelayCommand(async (o) => await OnMouseRightClick(o));
|
MouseRightClickCommand = new RelayCommand(async (o) => await OnMouseRightClick(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UnsubscribeAll()
|
||||||
|
{
|
||||||
|
creature.PropertyChanged -= Creature_PropertyChanged;
|
||||||
|
creature.Transform.PropertyChanged -= Transform_PropertyChanged;
|
||||||
|
creature.Transform.Position.PropertyChanged -= Position_PropertyChanged;
|
||||||
|
creature.VitalStats.PropertyChanged -= VitalStats_PropertyChanged;
|
||||||
|
hero.Transform.Position.PropertyChanged -= HeroPosition_PropertyChanged;
|
||||||
|
hero.PropertyChanged -= Hero_PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private void VitalStats_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void VitalStats_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.PropertyName == "Hp" || e.PropertyName == "MaxHp")
|
if (e.PropertyName == "Hp" || e.PropertyName == "MaxHp")
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace Client.Application.ViewModels
|
|||||||
}
|
}
|
||||||
private async Task OnMouseRightClick(object? obj)
|
private async Task OnMouseRightClick(object? obj)
|
||||||
{
|
{
|
||||||
await pathMover.MoveUntilReachedAsync(drop.Transform.Position);
|
await pathMover.MoveAsync(drop.Transform.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DropListViewModel(WorldHandler worldHandler, AsyncPathMoverInterface pathMover, Drop drop, Hero hero)
|
public DropListViewModel(WorldHandler worldHandler, AsyncPathMoverInterface pathMover, Drop drop, Hero hero)
|
||||||
@@ -92,6 +92,13 @@ namespace Client.Application.ViewModels
|
|||||||
MouseRightClickCommand = new RelayCommand(async (o) => await OnMouseRightClick(o));
|
MouseRightClickCommand = new RelayCommand(async (o) => await OnMouseRightClick(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UnsubscribeAll()
|
||||||
|
{
|
||||||
|
drop.PropertyChanged -= Drop_PropertyChanged;
|
||||||
|
drop.Transform.Position.PropertyChanged -= DropPosition_PropertyChanged;
|
||||||
|
hero.Transform.Position.PropertyChanged -= HeroPosition_PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
OnPropertyChanged("Distance");
|
OnPropertyChanged("Distance");
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace Client.Application.ViewModels
|
|||||||
}
|
}
|
||||||
private async Task OnMouseRightClick(object? obj)
|
private async Task OnMouseRightClick(object? obj)
|
||||||
{
|
{
|
||||||
await pathMover.MoveUntilReachedAsync(drop.Transform.Position);
|
await pathMover.MoveAsync(drop.Transform.Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DropMapViewModel(WorldHandler worldHandler, AsyncPathMoverInterface pathMover, Drop drop, Hero hero)
|
public DropMapViewModel(WorldHandler worldHandler, AsyncPathMoverInterface pathMover, Drop drop, Hero hero)
|
||||||
@@ -73,24 +73,31 @@ namespace Client.Application.ViewModels
|
|||||||
this.hero = hero;
|
this.hero = hero;
|
||||||
this.worldHandler = worldHandler;
|
this.worldHandler = worldHandler;
|
||||||
this.pathMover = pathMover;
|
this.pathMover = pathMover;
|
||||||
drop.PropertyChanged += Creature_PropertyChanged;
|
drop.PropertyChanged += Drop_PropertyChanged;
|
||||||
drop.Transform.Position.PropertyChanged += Position_PropertyChanged;
|
drop.Transform.Position.PropertyChanged += DropPosition_PropertyChanged;
|
||||||
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
|
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
|
||||||
MouseLeftClickCommand = new RelayCommand(OnMouseLeftClick);
|
MouseLeftClickCommand = new RelayCommand(OnMouseLeftClick);
|
||||||
MouseRightClickCommand = new RelayCommand(async (o) => await OnMouseRightClick(o));
|
MouseRightClickCommand = new RelayCommand(async (o) => await OnMouseRightClick(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UnsubscribeAll()
|
||||||
|
{
|
||||||
|
drop.PropertyChanged -= Drop_PropertyChanged;
|
||||||
|
drop.Transform.Position.PropertyChanged -= DropPosition_PropertyChanged;
|
||||||
|
hero.Transform.Position.PropertyChanged -= HeroPosition_PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private void HeroPosition_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
private void HeroPosition_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
OnPropertyChanged("Position");
|
OnPropertyChanged("Position");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Position_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
private void DropPosition_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
OnPropertyChanged("Position");
|
OnPropertyChanged("Position");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Creature_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
private void Drop_PropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.PropertyName == "Name" || e.PropertyName == "Amount")
|
if (e.PropertyName == "Name" || e.PropertyName == "Amount")
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
using Client.Domain.Common;
|
using Client.Domain.AI;
|
||||||
|
using Client.Domain.Common;
|
||||||
using Client.Domain.Entities;
|
using Client.Domain.Entities;
|
||||||
using Client.Domain.ValueObjects;
|
using Client.Domain.ValueObjects;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -59,13 +61,6 @@ namespace Client.Application.ViewModels
|
|||||||
return hero.InventoryInfo;
|
return hero.InventoryInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public ulong Money
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TargetSummaryInfoViewModel? Target
|
public TargetSummaryInfoViewModel? Target
|
||||||
{
|
{
|
||||||
@@ -81,10 +76,33 @@ namespace Client.Application.ViewModels
|
|||||||
return hero.AttackerIds.ToList();
|
return hero.AttackerIds.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public HeroSummaryInfoViewModel(Hero hero)
|
public string AIType
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ai.Type.ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string AIState
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ai.IsEnabled ? ai.CurrentState.ToString() : "Disabled";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int InventoryOccupiedSlots
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return items.Count + questItems.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public HeroSummaryInfoViewModel(Hero hero, AIInterface ai, ObservableCollection<ItemListViewModel> items, ObservableCollection<ItemListViewModel> questItems)
|
||||||
{
|
{
|
||||||
this.hero = hero;
|
this.hero = hero;
|
||||||
|
this.ai = ai;
|
||||||
|
this.items = items;
|
||||||
|
this.questItems = questItems;
|
||||||
hero.FullName.PropertyChanged += FullName_PropertyChanged;
|
hero.FullName.PropertyChanged += FullName_PropertyChanged;
|
||||||
hero.Phenotype.PropertyChanged += Phenotype_PropertyChanged;
|
hero.Phenotype.PropertyChanged += Phenotype_PropertyChanged;
|
||||||
hero.ExperienceInfo.PropertyChanged += ExperienceInfo_PropertyChanged;
|
hero.ExperienceInfo.PropertyChanged += ExperienceInfo_PropertyChanged;
|
||||||
@@ -92,6 +110,31 @@ namespace Client.Application.ViewModels
|
|||||||
hero.VitalStats.PropertyChanged += VitalStats_PropertyChanged;
|
hero.VitalStats.PropertyChanged += VitalStats_PropertyChanged;
|
||||||
hero.InventoryInfo.PropertyChanged += InventoryInfo_PropertyChanged;
|
hero.InventoryInfo.PropertyChanged += InventoryInfo_PropertyChanged;
|
||||||
hero.PropertyChanged += Hero_PropertyChanged;
|
hero.PropertyChanged += Hero_PropertyChanged;
|
||||||
|
ai.PropertyChanged += Ai_PropertyChanged;
|
||||||
|
items.CollectionChanged += Items_CollectionChanged;
|
||||||
|
questItems.CollectionChanged += QuestItems_CollectionChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void QuestItems_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
OnPropertyChanged("InventoryOccupiedSlots");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Items_CollectionChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
OnPropertyChanged("InventoryOccupiedSlots");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Ai_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.PropertyName == "Type")
|
||||||
|
{
|
||||||
|
OnPropertyChanged("AIType");
|
||||||
|
}
|
||||||
|
if (e.PropertyName == "CurrentState" || e.PropertyName == "IsEnabled")
|
||||||
|
{
|
||||||
|
OnPropertyChanged("AIState");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Hero_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void Hero_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
@@ -105,6 +148,7 @@ namespace Client.Application.ViewModels
|
|||||||
}
|
}
|
||||||
else if (target != null && hero.Target == null)
|
else if (target != null && hero.Target == null)
|
||||||
{
|
{
|
||||||
|
target.UnsubscribeAll();
|
||||||
target = null;
|
target = null;
|
||||||
OnPropertyChanged("Target");
|
OnPropertyChanged("Target");
|
||||||
}
|
}
|
||||||
@@ -146,6 +190,9 @@ namespace Client.Application.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly Hero hero;
|
private readonly Hero hero;
|
||||||
|
private readonly AIInterface ai;
|
||||||
|
private readonly ObservableCollection<ItemListViewModel> items;
|
||||||
|
private readonly ObservableCollection<ItemListViewModel> questItems;
|
||||||
private TargetSummaryInfoViewModel? target;
|
private TargetSummaryInfoViewModel? target;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using Client.Domain.Entities;
|
|||||||
using Client.Domain.Events;
|
using Client.Domain.Events;
|
||||||
using Client.Domain.Service;
|
using Client.Domain.Service;
|
||||||
using Client.Domain.ValueObjects;
|
using Client.Domain.ValueObjects;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@@ -38,7 +39,7 @@ namespace Client.Application.ViewModels
|
|||||||
|
|
||||||
public void Handle(HeroCreatedEvent @event)
|
public void Handle(HeroCreatedEvent @event)
|
||||||
{
|
{
|
||||||
Hero = new HeroSummaryInfoViewModel(@event.Hero);
|
Hero = new HeroSummaryInfoViewModel(@event.Hero, ai, Items, QuestItems);
|
||||||
hero = @event.Hero;
|
hero = @event.Hero;
|
||||||
Map.Hero = hero;
|
Map.Hero = hero;
|
||||||
Map.CombatZone = new AICombatZoneMapViewModel(aiConfig.Combat.Zone, hero);
|
Map.CombatZone = new AICombatZoneMapViewModel(aiConfig.Combat.Zone, hero);
|
||||||
@@ -72,7 +73,12 @@ namespace Client.Application.ViewModels
|
|||||||
|
|
||||||
public void Handle(CreatureDeletedEvent @event)
|
public void Handle(CreatureDeletedEvent @event)
|
||||||
{
|
{
|
||||||
Creatures.RemoveAll(x => x.Id == @event.Id);
|
var creature = Creatures.Where(x => x.Id == @event.Id).FirstOrDefault();
|
||||||
|
if (creature != null)
|
||||||
|
{
|
||||||
|
creature.UnsubscribeAll();
|
||||||
|
Creatures.Remove(creature);
|
||||||
|
}
|
||||||
RemoveCreature(@event.Id);
|
RemoveCreature(@event.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,8 +93,18 @@ namespace Client.Application.ViewModels
|
|||||||
|
|
||||||
public void Handle(DropDeletedEvent @event)
|
public void Handle(DropDeletedEvent @event)
|
||||||
{
|
{
|
||||||
Drops.RemoveAll(x => x.Id == @event.Id);
|
var drop = Drops.Where(x => x.Id == @event.Id).FirstOrDefault();
|
||||||
Map.Drops.RemoveAll(x => x.Id == @event.Id);
|
if (drop != null)
|
||||||
|
{
|
||||||
|
drop.UnsubscribeAll();
|
||||||
|
Drops.Remove(drop);
|
||||||
|
}
|
||||||
|
var mapDrop = Map.Drops.Where(x => x.Id == @event.Id).FirstOrDefault();
|
||||||
|
if (mapDrop != null)
|
||||||
|
{
|
||||||
|
mapDrop.UnsubscribeAll();
|
||||||
|
Map.Drops.Remove(mapDrop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Handle(ChatMessageCreatedEvent @event)
|
public void Handle(ChatMessageCreatedEvent @event)
|
||||||
@@ -156,7 +172,12 @@ namespace Client.Application.ViewModels
|
|||||||
|
|
||||||
private void RemoveCreature(uint id)
|
private void RemoveCreature(uint id)
|
||||||
{
|
{
|
||||||
Map.Creatures.RemoveAll(x => x.Id == id);
|
var creature = Map.Creatures.Where(x => x.Id == id).FirstOrDefault();
|
||||||
|
if (creature != null)
|
||||||
|
{
|
||||||
|
creature.UnsubscribeAll();
|
||||||
|
Map.Creatures.Remove(creature);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnToggleAI(object? sender)
|
private void OnToggleAI(object? sender)
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ namespace Client.Application.ViewModels
|
|||||||
hero.Transform.Position.Z
|
hero.Transform.Position.Z
|
||||||
);
|
);
|
||||||
|
|
||||||
await pathMover.MoveUntilReachedAsync(location);
|
await pathMover.MoveAsync(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMouseWheel(object sender, MouseWheelEventArgs e)
|
public void OnMouseWheel(object sender, MouseWheelEventArgs e)
|
||||||
@@ -230,11 +230,16 @@ namespace Client.Application.ViewModels
|
|||||||
{
|
{
|
||||||
foreach (var item in e.OldItems)
|
foreach (var item in e.OldItems)
|
||||||
{
|
{
|
||||||
|
Path[0].UnsubscribeAll();
|
||||||
Path.RemoveAt(0);
|
Path.RemoveAt(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.Action == NotifyCollectionChangedAction.Reset)
|
else if (e.Action == NotifyCollectionChangedAction.Reset)
|
||||||
{
|
{
|
||||||
|
foreach (var item in Path)
|
||||||
|
{
|
||||||
|
item.UnsubscribeAll();
|
||||||
|
}
|
||||||
Path.RemoveAll();
|
Path.RemoveAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,11 @@ namespace Client.Application.ViewModels
|
|||||||
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
|
hero.Transform.Position.PropertyChanged += HeroPosition_PropertyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UnsubscribeAll()
|
||||||
|
{
|
||||||
|
hero.Transform.Position.PropertyChanged -= HeroPosition_PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void HeroPosition_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
OnPropertyChanged("From");
|
OnPropertyChanged("From");
|
||||||
|
|||||||
@@ -38,6 +38,14 @@ namespace Client.Application.ViewModels
|
|||||||
this.hero = hero;
|
this.hero = hero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UnsubscribeAll()
|
||||||
|
{
|
||||||
|
creature.PropertyChanged -= Creature_PropertyChanged;
|
||||||
|
creature.Transform.Position.PropertyChanged -= Position_PropertyChanged;
|
||||||
|
creature.VitalStats.PropertyChanged -= VitalStats_PropertyChanged;
|
||||||
|
hero.Transform.Position.PropertyChanged -= HeroPosition_PropertyChanged;
|
||||||
|
}
|
||||||
|
|
||||||
private void VitalStats_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void VitalStats_PropertyChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.PropertyName == "Hp")
|
if (e.PropertyName == "Hp")
|
||||||
|
|||||||
@@ -40,10 +40,19 @@
|
|||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<CheckBox Grid.Row="0" Grid.Column="0" IsChecked="{Binding AutoUseShots}">Auto use soul and spiritshots</CheckBox>
|
<CheckBox Grid.Row="0" Grid.Column="0" IsChecked="{Binding AutoUseShots}">Auto use soul and spiritshots</CheckBox>
|
||||||
<CheckBox Grid.Row="1" Grid.Column="0" IsChecked="{Binding UseOnlySkills}">Use only skills</CheckBox>
|
<CheckBox Grid.Row="1" Grid.Column="0" IsChecked="{Binding UseOnlySkills}">Use only skills</CheckBox>
|
||||||
<StackPanel Grid.Row="2" Grid.Column="0">
|
<StackPanel Grid.Row="2" Grid.Column="0">
|
||||||
|
<Label>Pathfinder max passable height:</Label>
|
||||||
|
<TextBox Width="100" HorizontalAlignment="Left">
|
||||||
|
<TextBox.Text>
|
||||||
|
<Binding Path="MaxPassableHeight" UpdateSourceTrigger="PropertyChanged"/>
|
||||||
|
</TextBox.Text>
|
||||||
|
</TextBox>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="3" Grid.Column="0">
|
||||||
<Label>Attack distance for mili weapon:</Label>
|
<Label>Attack distance for mili weapon:</Label>
|
||||||
<TextBox Width="100" HorizontalAlignment="Left">
|
<TextBox Width="100" HorizontalAlignment="Left">
|
||||||
<TextBox.Text>
|
<TextBox.Text>
|
||||||
@@ -51,7 +60,7 @@
|
|||||||
</TextBox.Text>
|
</TextBox.Text>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="3" Grid.Column="0">
|
<StackPanel Grid.Row="4" Grid.Column="0">
|
||||||
<Label>Attack distance for bows:</Label>
|
<Label>Attack distance for bows:</Label>
|
||||||
<TextBox Width="100" HorizontalAlignment="Left">
|
<TextBox Width="100" HorizontalAlignment="Left">
|
||||||
<TextBox.Text>
|
<TextBox.Text>
|
||||||
@@ -59,7 +68,7 @@
|
|||||||
</TextBox.Text>
|
</TextBox.Text>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="4" Grid.Column="0">
|
<StackPanel Grid.Row="5" Grid.Column="0">
|
||||||
<Label>Skill conditions:</Label>
|
<Label>Skill conditions:</Label>
|
||||||
<DataGrid
|
<DataGrid
|
||||||
AutoGenerateColumns="False"
|
AutoGenerateColumns="False"
|
||||||
@@ -91,7 +100,7 @@
|
|||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="5" Grid.Column="0">
|
<StackPanel Grid.Row="6" Grid.Column="0">
|
||||||
<Label>Combat zone:</Label>
|
<Label>Combat zone:</Label>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
@@ -193,9 +202,18 @@
|
|||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
<RowDefinition Height="Auto"></RowDefinition>
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
|
<RowDefinition Height="Auto"></RowDefinition>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<CheckBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" IsChecked="{Binding PickupIfPossible}">Pickup if possible</CheckBox>
|
<CheckBox Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" IsChecked="{Binding PickupIfPossible}">Pickup if possible</CheckBox>
|
||||||
<StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
|
<StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
|
||||||
|
<Label>Pickup radius:</Label>
|
||||||
|
<TextBox Width="100" HorizontalAlignment="Left">
|
||||||
|
<TextBox.Text>
|
||||||
|
<Binding Path="PickupRadius" UpdateSourceTrigger="PropertyChanged"/>
|
||||||
|
</TextBox.Text>
|
||||||
|
</TextBox>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
|
||||||
<Label>Max delta z:</Label>
|
<Label>Max delta z:</Label>
|
||||||
<TextBox Width="100" HorizontalAlignment="Left">
|
<TextBox Width="100" HorizontalAlignment="Left">
|
||||||
<TextBox.Text>
|
<TextBox.Text>
|
||||||
@@ -203,7 +221,7 @@
|
|||||||
</TextBox.Text>
|
</TextBox.Text>
|
||||||
</TextBox>
|
</TextBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2">
|
<StackPanel Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2">
|
||||||
<Label>Pickup attempts count:</Label>
|
<Label>Pickup attempts count:</Label>
|
||||||
<TextBox Width="100" HorizontalAlignment="Left">
|
<TextBox Width="100" HorizontalAlignment="Left">
|
||||||
<TextBox.Text>
|
<TextBox.Text>
|
||||||
@@ -212,13 +230,13 @@
|
|||||||
</TextBox>
|
</TextBox>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<components:MultipleObjectSelector
|
<components:MultipleObjectSelector
|
||||||
Grid.Row="3"
|
Grid.Row="4"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Source="{Binding ExcludedItems}"
|
Source="{Binding ExcludedItems}"
|
||||||
Target="{Binding SelectedExcludedItems}"
|
Target="{Binding SelectedExcludedItems}"
|
||||||
Header="Excluded:"/>
|
Header="Excluded:"/>
|
||||||
<components:MultipleObjectSelector
|
<components:MultipleObjectSelector
|
||||||
Grid.Row="3"
|
Grid.Row="4"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Source="{Binding IncludedItems}"
|
Source="{Binding IncludedItems}"
|
||||||
Target="{Binding SelectedIncludedItems}"
|
Target="{Binding SelectedIncludedItems}"
|
||||||
|
|||||||
@@ -225,8 +225,8 @@
|
|||||||
<TextBlock Padding="0 0 0 3">Position:</TextBlock>
|
<TextBlock Padding="0 0 0 3">Position:</TextBlock>
|
||||||
<TextBlock Padding="0 0 0 3">Exp:</TextBlock>
|
<TextBlock Padding="0 0 0 3">Exp:</TextBlock>
|
||||||
<TextBlock Padding="0 0 0 3">Weight:</TextBlock>
|
<TextBlock Padding="0 0 0 3">Weight:</TextBlock>
|
||||||
<TextBlock Padding="0 0 0 3">Adena:</TextBlock>
|
|
||||||
<TextBlock Padding="0 0 0 3">Inv. slots:</TextBlock>
|
<TextBlock Padding="0 0 0 3">Inv. slots:</TextBlock>
|
||||||
|
<TextBlock Padding="0 0 0 3">AI:</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<TextBlock Padding="0 0 0 3">
|
<TextBlock Padding="0 0 0 3">
|
||||||
@@ -254,12 +254,19 @@
|
|||||||
</MultiBinding>
|
</MultiBinding>
|
||||||
</TextBlock.Text>
|
</TextBlock.Text>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<TextBlock Text="{Binding Path=Money, Mode=OneWay}" Padding="0 0 0 3"></TextBlock>
|
|
||||||
<TextBlock Padding="0 0 0 3">
|
<TextBlock Padding="0 0 0 3">
|
||||||
<TextBlock.Text>
|
<TextBlock.Text>
|
||||||
<MultiBinding StringFormat="{}{0}/{1}">
|
<MultiBinding StringFormat="{}{0}/{1}">
|
||||||
|
<Binding Path="InventoryOccupiedSlots" Mode="OneWay"/>
|
||||||
<Binding Path="InventoryInfo.Slots" Mode="OneWay"/>
|
<Binding Path="InventoryInfo.Slots" Mode="OneWay"/>
|
||||||
<Binding Path="InventoryInfo.Slots" Mode="OneWay"/>
|
</MultiBinding>
|
||||||
|
</TextBlock.Text>
|
||||||
|
</TextBlock>
|
||||||
|
<TextBlock Padding="0 0 0 3">
|
||||||
|
<TextBlock.Text>
|
||||||
|
<MultiBinding StringFormat="{}{0} ({1})">
|
||||||
|
<Binding Path="AIType" Mode="OneWay"/>
|
||||||
|
<Binding Path="AIState" Mode="OneWay"/>
|
||||||
</MultiBinding>
|
</MultiBinding>
|
||||||
</TextBlock.Text>
|
</TextBlock.Text>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Client.Domain.AI.State;
|
using Client.Domain.AI.State;
|
||||||
|
using Client.Domain.Common;
|
||||||
using Client.Domain.Entities;
|
using Client.Domain.Entities;
|
||||||
using Client.Domain.Events;
|
using Client.Domain.Events;
|
||||||
using Client.Domain.Service;
|
using Client.Domain.Service;
|
||||||
@@ -13,7 +14,7 @@ using System.Windows.Input;
|
|||||||
|
|
||||||
namespace Client.Domain.AI
|
namespace Client.Domain.AI
|
||||||
{
|
{
|
||||||
public class AI : AIInterface
|
public class AI : ObservableObject, AIInterface
|
||||||
{
|
{
|
||||||
public AI(WorldHandler worldHandler, Config config, AsyncPathMoverInterface asyncPathMover, TransitionBuilderLocator locator)
|
public AI(WorldHandler worldHandler, Config config, AsyncPathMoverInterface asyncPathMover, TransitionBuilderLocator locator)
|
||||||
{
|
{
|
||||||
@@ -27,16 +28,17 @@ namespace Client.Domain.AI
|
|||||||
|
|
||||||
public void Toggle()
|
public void Toggle()
|
||||||
{
|
{
|
||||||
isEnabled = !isEnabled;
|
IsEnabled = !IsEnabled;
|
||||||
if (isEnabled)
|
if (IsEnabled)
|
||||||
{
|
{
|
||||||
ResetState();
|
ResetState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsEnabled => isEnabled;
|
public bool IsEnabled { get { return isEnabled; } private set { if (isEnabled != value) { isEnabled = value; OnPropertyChanged(); } } }
|
||||||
|
|
||||||
public TypeEnum Type { get { return type; } set { if (type != value) { type = value; ResetState(); } } }
|
public TypeEnum Type { get { return type; } set { if (type != value) { type = value; ResetState(); OnPropertyChanged(); } } }
|
||||||
|
public BaseState.Type CurrentState { get { return currentState; } private set { if (currentState != value) { currentState = value; OnPropertyChanged(); } } }
|
||||||
|
|
||||||
public async Task Update()
|
public async Task Update()
|
||||||
{
|
{
|
||||||
@@ -44,19 +46,18 @@ namespace Client.Domain.AI
|
|||||||
|
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
{
|
{
|
||||||
if (isEnabled && worldHandler.Hero != null)
|
if (IsEnabled && worldHandler.Hero != null)
|
||||||
{
|
{
|
||||||
states[currentState].Execute();
|
states[CurrentState].Execute();
|
||||||
foreach (var transition in locator.Get(Type).Build(worldHandler, config, asyncPathMover))
|
foreach (var transition in locator.Get(Type).Build(worldHandler, config, asyncPathMover))
|
||||||
{
|
{
|
||||||
if (transition.fromStates.ContainsKey(BaseState.Type.Any) && transition.toState != currentState || transition.fromStates.ContainsKey(currentState))
|
if (transition.fromStates.ContainsKey(BaseState.Type.Any) && transition.toState != CurrentState || transition.fromStates.ContainsKey(CurrentState))
|
||||||
{
|
{
|
||||||
if (transition.predicate(states[currentState]))
|
if (transition.predicate(states[CurrentState]))
|
||||||
{
|
{
|
||||||
states[currentState].OnLeave();
|
states[CurrentState].OnLeave();
|
||||||
currentState = transition.toState;
|
CurrentState = transition.toState;
|
||||||
Debug.WriteLine(currentState.ToString());
|
states[CurrentState].OnEnter();
|
||||||
states[currentState].OnEnter();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,7 +88,7 @@ namespace Client.Domain.AI
|
|||||||
|
|
||||||
private void ResetState()
|
private void ResetState()
|
||||||
{
|
{
|
||||||
currentState = BaseState.Type.Idle;
|
CurrentState = BaseState.Type.Idle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly WorldHandler worldHandler;
|
private readonly WorldHandler worldHandler;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Client.Domain.Events;
|
using Client.Domain.AI.State;
|
||||||
|
using Client.Domain.Common;
|
||||||
|
using Client.Domain.Events;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@@ -8,7 +10,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Client.Domain.AI
|
namespace Client.Domain.AI
|
||||||
{
|
{
|
||||||
public interface AIInterface
|
public interface AIInterface : ObservableObjectInterface
|
||||||
{
|
{
|
||||||
Task Update();
|
Task Update();
|
||||||
|
|
||||||
@@ -17,5 +19,6 @@ namespace Client.Domain.AI
|
|||||||
bool IsEnabled { get; }
|
bool IsEnabled { get; }
|
||||||
|
|
||||||
TypeEnum Type { get; set; }
|
TypeEnum Type { get; set; }
|
||||||
|
BaseState.Type CurrentState { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace Client.Domain.AI.Combat
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Drop> GetDropByConfig(WorldHandler worldHandler, Config config)
|
public static List<Drop> GetDropByConfig(WorldHandler worldHandler, Config config, Hero hero)
|
||||||
{
|
{
|
||||||
if (!config.Combat.PickupIfPossible)
|
if (!config.Combat.PickupIfPossible)
|
||||||
{
|
{
|
||||||
@@ -49,6 +49,8 @@ namespace Client.Domain.AI.Combat
|
|||||||
result = result.Where(x => config.Combat.IncludedItemIdsToPickup.ContainsKey(x.ItemId));
|
result = result.Where(x => config.Combat.IncludedItemIdsToPickup.ContainsKey(x.ItemId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = result.Where(x => x.Transform.Position.HorizontalDistance(hero.Transform.Position) <= config.Combat.PickupRadius);
|
||||||
|
|
||||||
return result.ToList();
|
return result.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,6 @@ namespace Client.Domain.AI.Combat
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO если нет цели, а тебя атаковали, то моб берется автоматом в таргет, из-за этого баг в Rest и MoveToSpot
|
|
||||||
// а без этой проверки зацикливается MoveToTarget->FindTarget->MoveToTarget
|
|
||||||
// один из вариантов решения, брать себя в таргет при входе в Rest и MoveToSpot
|
|
||||||
if (worldHandler.Hero.Target != null && (worldHandler.Hero.AttackerIds.Contains(worldHandler.Hero.Target.Id) || worldHandler.Hero.Target.VitalStats.IsDead))
|
if (worldHandler.Hero.Target != null && (worldHandler.Hero.AttackerIds.Contains(worldHandler.Hero.Target.Id) || worldHandler.Hero.Target.VitalStats.IsDead))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -99,11 +96,6 @@ namespace Client.Domain.AI.Combat
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pathMover.Pathfinder.HasLineOfSight(worldHandler.Hero.Transform.Position, worldHandler.Hero.Target.Transform.Position))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (config.Combat.SpoilIsPriority) {
|
if (config.Combat.SpoilIsPriority) {
|
||||||
var spoil = worldHandler.GetSkillById(config.Combat.SpoilSkillId);
|
var spoil = worldHandler.GetSkillById(config.Combat.SpoilSkillId);
|
||||||
if (spoil != null && !spoil.IsReadyToUse) {
|
if (spoil != null && !spoil.IsReadyToUse) {
|
||||||
@@ -112,7 +104,8 @@ namespace Client.Domain.AI.Combat
|
|||||||
}
|
}
|
||||||
|
|
||||||
var distance = worldHandler.Hero.Transform.Position.HorizontalDistance(worldHandler.Hero.Target.Transform.Position);
|
var distance = worldHandler.Hero.Transform.Position.HorizontalDistance(worldHandler.Hero.Target.Transform.Position);
|
||||||
return distance < Helper.GetAttackDistanceByConfig(worldHandler, config, worldHandler.Hero, worldHandler.Hero.Target);
|
return distance < Helper.GetAttackDistanceByConfig(worldHandler, config, worldHandler.Hero, worldHandler.Hero.Target)
|
||||||
|
&& pathMover.Pathfinder.HasLineOfSight(worldHandler.Hero.Transform.Position, worldHandler.Hero.Target.Transform.Position);
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Attack}, BaseState.Type.Pickup, (state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Attack}, BaseState.Type.Pickup, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ namespace Client.Domain.AI
|
|||||||
public uint AttackDistanceBow { get; set; } = 500;
|
public uint AttackDistanceBow { get; set; } = 500;
|
||||||
public bool UseOnlySkills { get; set; } = false;
|
public bool UseOnlySkills { get; set; } = false;
|
||||||
public List<SkillCondition> SkillConditions { get; set; } = new List<SkillCondition>();
|
public List<SkillCondition> SkillConditions { get; set; } = new List<SkillCondition>();
|
||||||
|
public byte MaxPassableHeight { get; set; } = 30;
|
||||||
|
|
||||||
public bool SpoilIfPossible { get; set; } = true;
|
public bool SpoilIfPossible { get; set; } = true;
|
||||||
public bool SpoilIsPriority { get; set; } = false;
|
public bool SpoilIsPriority { get; set; } = false;
|
||||||
@@ -47,6 +48,7 @@ namespace Client.Domain.AI
|
|||||||
public byte PickupAttemptsCount { get; set; } = 10;
|
public byte PickupAttemptsCount { get; set; } = 10;
|
||||||
public Dictionary<uint, bool> ExcludedItemIdsToPickup { get; set; } = new Dictionary<uint, bool>();
|
public Dictionary<uint, bool> ExcludedItemIdsToPickup { get; set; } = new Dictionary<uint, bool>();
|
||||||
public Dictionary<uint, bool> IncludedItemIdsToPickup { get; set; } = new Dictionary<uint, bool>();
|
public Dictionary<uint, bool> IncludedItemIdsToPickup { get; set; } = new Dictionary<uint, bool>();
|
||||||
|
public short PickupRadius = 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DelevelingSection
|
public class DelevelingSection
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace Client.Domain.AI.State
|
|||||||
config.Combat.Zone.Center.X,
|
config.Combat.Zone.Center.X,
|
||||||
config.Combat.Zone.Center.Y,
|
config.Combat.Zone.Center.Y,
|
||||||
hero.Transform.Position.Z
|
hero.Transform.Position.Z
|
||||||
));
|
), config.Combat.MaxPassableHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
using Client.Domain.AI.Combat;
|
using Client.Domain.AI.Combat;
|
||||||
using Client.Domain.Entities;
|
using Client.Domain.Entities;
|
||||||
using Client.Domain.Service;
|
using Client.Domain.Service;
|
||||||
using Client.Infrastructure.Service;
|
using Client.Domain.ValueObjects;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Client.Domain.AI.State
|
namespace Client.Domain.AI.State
|
||||||
{
|
{
|
||||||
@@ -19,17 +20,32 @@ namespace Client.Domain.AI.State
|
|||||||
target = hero;
|
target = hero;
|
||||||
}
|
}
|
||||||
|
|
||||||
var distance = hero.Transform.Position.HorizontalDistance(target.Transform.Position);
|
var distanceToPrevPosition = targetPosition != null ? targetPosition.HorizontalDistance(target.Transform.Position) : 0;
|
||||||
|
|
||||||
|
var routeNeedsToBeAdjusted = MathF.Abs(distanceToPrevPosition) > config.Combat.AttackDistanceMili;
|
||||||
|
if (routeNeedsToBeAdjusted)
|
||||||
|
{
|
||||||
|
asyncPathMover.Unlock();
|
||||||
|
}
|
||||||
|
|
||||||
if (asyncPathMover.IsLocked)
|
if (asyncPathMover.IsLocked)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var hasLineOfSight = asyncPathMover.Pathfinder.HasLineOfSight(hero.Transform.Position, target.Transform.Position);
|
|
||||||
if (distance >= Helper.GetAttackDistanceByConfig(worldHandler, config, hero, target) || !hasLineOfSight)
|
var distance = hero.Transform.Position.HorizontalDistance(target.Transform.Position);
|
||||||
|
if (routeNeedsToBeAdjusted || distance >= Helper.GetAttackDistanceByConfig(worldHandler, config, hero, target) || !asyncPathMover.Pathfinder.HasLineOfSight(hero.Transform.Position, target.Transform.Position))
|
||||||
{
|
{
|
||||||
asyncPathMover.MoveAsync(target.Transform.Position);
|
targetPosition = target.Transform.Position.Clone() as Vector3;
|
||||||
|
asyncPathMover.MoveAsync(target.Transform.Position, config.Combat.MaxPassableHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void DoOnLeave(WorldHandler worldHandler, Config config, Hero hero)
|
||||||
|
{
|
||||||
|
targetPosition = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Vector3? targetPosition = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,14 @@ namespace Client.Domain.AI.State
|
|||||||
|
|
||||||
public List<Drop> GetDrops(WorldHandler worldHandler, Config config)
|
public List<Drop> GetDrops(WorldHandler worldHandler, Config config)
|
||||||
{
|
{
|
||||||
var drops = Helper.GetDropByConfig(worldHandler, config);
|
var hero = worldHandler.Hero;
|
||||||
|
|
||||||
|
if (hero == null)
|
||||||
|
{
|
||||||
|
return new List<Drop>();
|
||||||
|
}
|
||||||
|
|
||||||
|
var drops = Helper.GetDropByConfig(worldHandler, config, hero);
|
||||||
for (var i = drops.Count - 1; i >= 0; i--)
|
for (var i = drops.Count - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (pickupAttempts.ContainsKey(drops[0].Id) && pickupAttempts[drops[0].Id] > config.Combat.PickupAttemptsCount)
|
if (pickupAttempts.ContainsKey(drops[0].Id) && pickupAttempts[drops[0].Id] > config.Combat.PickupAttemptsCount)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Client.Domain.Common
|
namespace Client.Domain.Common
|
||||||
{
|
{
|
||||||
public class ObservableObject : INotifyPropertyChanged
|
public class ObservableObject : ObservableObjectInterface
|
||||||
{
|
{
|
||||||
public event PropertyChangedEventHandler? PropertyChanged;
|
public event PropertyChangedEventHandler? PropertyChanged;
|
||||||
public void OnPropertyChanged([CallerMemberName] string prop = "")
|
public void OnPropertyChanged([CallerMemberName] string prop = "")
|
||||||
|
|||||||
15
Client/Domain/Common/ObservableObjectInterface.cs
Normal file
15
Client/Domain/Common/ObservableObjectInterface.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Client.Domain.Common
|
||||||
|
{
|
||||||
|
public interface ObservableObjectInterface : INotifyPropertyChanged
|
||||||
|
{
|
||||||
|
void OnPropertyChanged([CallerMemberName] string prop = "");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,10 +13,9 @@ namespace Client.Domain.Service
|
|||||||
{
|
{
|
||||||
public PathfinderInterface Pathfinder { get; }
|
public PathfinderInterface Pathfinder { get; }
|
||||||
public ObservableCollection<PathSegment> Path { get; }
|
public ObservableCollection<PathSegment> Path { get; }
|
||||||
|
public Task<bool> MoveAsync(Vector3 location, ushort maxPassableHeight);
|
||||||
public Task<bool> MoveAsync(Vector3 location);
|
public Task<bool> MoveAsync(Vector3 location);
|
||||||
public Task MoveUntilReachedAsync(Vector3 location);
|
|
||||||
public bool IsLocked { get; }
|
public bool IsLocked { get; }
|
||||||
|
|
||||||
public void Unlock();
|
public void Unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace Client.Domain.Service
|
|||||||
{
|
{
|
||||||
public interface PathfinderInterface
|
public interface PathfinderInterface
|
||||||
{
|
{
|
||||||
public List<PathSegment> FindPath(Vector3 start, Vector3 end);
|
public List<PathSegment> FindPath(Vector3 start, Vector3 end, ushort maxPassableHeight);
|
||||||
public bool HasLineOfSight(Vector3 start, Vector3 end);
|
public bool HasLineOfSight(Vector3 start, Vector3 end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System;
|
|||||||
|
|
||||||
namespace Client.Domain.ValueObjects
|
namespace Client.Domain.ValueObjects
|
||||||
{
|
{
|
||||||
public class Vector3 : ObservableObject
|
public class Vector3 : ObservableObject, ICloneable
|
||||||
{
|
{
|
||||||
private float x;
|
private float x;
|
||||||
private float y;
|
private float y;
|
||||||
@@ -77,6 +77,11 @@ namespace Client.Domain.ValueObjects
|
|||||||
return MathF.Sqrt(MathF.Pow(x - other.x, 2) + MathF.Pow(y - other.y, 2) + MathF.Pow(z - other.z, 2));
|
return MathF.Sqrt(MathF.Pow(x - other.x, 2) + MathF.Pow(y - other.y, 2) + MathF.Pow(z - other.z, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public object Clone()
|
||||||
|
{
|
||||||
|
return MemberwiseClone();
|
||||||
|
}
|
||||||
|
|
||||||
public static Vector3 operator -(Vector3 left, Vector3 right)
|
public static Vector3 operator -(Vector3 left, Vector3 right)
|
||||||
{
|
{
|
||||||
return new Vector3(left.x - right.x, left.y - right.y, left.z - right.z);
|
return new Vector3(left.x - right.x, left.y - right.y, left.z - right.z);
|
||||||
|
|||||||
@@ -11,13 +11,15 @@ namespace Client.Domain.ValueObjects
|
|||||||
private uint maxMp;
|
private uint maxMp;
|
||||||
private uint cp;
|
private uint cp;
|
||||||
private uint maxCp;
|
private uint maxCp;
|
||||||
|
private bool isDead;
|
||||||
|
|
||||||
public uint Hp { get => hp; set { if (value != hp) { hp = value; OnPropertyChanged(); OnPropertyChanged("MaxHp"); OnPropertyChanged("IsDead"); } } }
|
public uint Hp { get => hp; set { if (value != hp) { hp = value; OnPropertyChanged(); OnPropertyChanged("MaxHp"); } } }
|
||||||
public uint MaxHp { get => Math.Max(hp, maxHp); set { if (value != maxHp) { maxHp = value; OnPropertyChanged(); OnPropertyChanged("IsDead"); } } }
|
public uint MaxHp { get => Math.Max(hp, maxHp); set { if (value != maxHp) { maxHp = value; OnPropertyChanged(); } } }
|
||||||
public uint Mp { get => mp; set { if (value != mp) { mp = value; OnPropertyChanged(); } } }
|
public uint Mp { get => mp; set { if (value != mp) { mp = value; OnPropertyChanged(); } } }
|
||||||
public uint MaxMp { get => maxMp; set { if (value != maxMp) { maxMp = value; OnPropertyChanged(); } } }
|
public uint MaxMp { get => maxMp; set { if (value != maxMp) { maxMp = value; OnPropertyChanged(); } } }
|
||||||
public uint Cp { get => cp; set { if (value != cp) { cp = value; OnPropertyChanged(); } } }
|
public uint Cp { get => cp; set { if (value != cp) { cp = value; OnPropertyChanged(); } } }
|
||||||
public uint MaxCp { get => maxCp; set { if (value != maxCp) { maxCp = value; OnPropertyChanged(); } } }
|
public uint MaxCp { get => maxCp; set { if (value != maxCp) { maxCp = value; OnPropertyChanged(); } } }
|
||||||
|
public bool IsDead { get => isDead; set { if (value != isDead) { isDead = value; OnPropertyChanged(); } } }
|
||||||
|
|
||||||
public double HpPercent
|
public double HpPercent
|
||||||
{
|
{
|
||||||
@@ -41,9 +43,7 @@ namespace Client.Domain.ValueObjects
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsDead => MaxHp > 0 && hp == 0;
|
public VitalStats(uint hp, uint maxHp, uint mp, uint maxMp, uint cp, uint maxCp, bool isDead)
|
||||||
|
|
||||||
public VitalStats(uint hp, uint maxHp, uint mp, uint maxMp, uint cp, uint maxCp)
|
|
||||||
{
|
{
|
||||||
this.hp = hp;
|
this.hp = hp;
|
||||||
this.maxHp = maxHp;
|
this.maxHp = maxHp;
|
||||||
@@ -51,6 +51,7 @@ namespace Client.Domain.ValueObjects
|
|||||||
this.maxMp = maxMp;
|
this.maxMp = maxMp;
|
||||||
this.cp = cp;
|
this.cp = cp;
|
||||||
this.maxCp = maxCp;
|
this.maxCp = maxCp;
|
||||||
|
this.isDead = isDead;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ namespace Client.Infrastructure.Service
|
|||||||
{
|
{
|
||||||
private readonly WorldHandler worldHandler;
|
private readonly WorldHandler worldHandler;
|
||||||
private readonly PathfinderInterface pathfinder;
|
private readonly PathfinderInterface pathfinder;
|
||||||
private readonly int pathNumberOfAttempts;
|
|
||||||
private readonly double nodeWaitingTime;
|
private readonly double nodeWaitingTime;
|
||||||
private readonly int nodeDistanceTolerance;
|
private readonly int nodeDistanceTolerance;
|
||||||
private readonly int nextNodeDistanceTolerance;
|
private readonly int nextNodeDistanceTolerance;
|
||||||
|
private readonly ushort maxPassableHeight;
|
||||||
private CancellationTokenSource? cancellationTokenSource;
|
private CancellationTokenSource? cancellationTokenSource;
|
||||||
|
|
||||||
public PathfinderInterface Pathfinder => pathfinder;
|
public PathfinderInterface Pathfinder => pathfinder;
|
||||||
@@ -43,16 +43,7 @@ namespace Client.Infrastructure.Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task MoveUntilReachedAsync(Vector3 location)
|
public async Task<bool> MoveAsync(Vector3 location, ushort maxPassableHeight)
|
||||||
{
|
|
||||||
var remainingAttempts = pathNumberOfAttempts;
|
|
||||||
while (!await MoveAsync(location) && remainingAttempts > 0)
|
|
||||||
{
|
|
||||||
remainingAttempts--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> MoveAsync(Vector3 location)
|
|
||||||
{
|
{
|
||||||
IsLocked = true;
|
IsLocked = true;
|
||||||
|
|
||||||
@@ -69,7 +60,7 @@ namespace Client.Infrastructure.Service
|
|||||||
return await Task.Run(async () =>
|
return await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Find path started");
|
Debug.WriteLine("Find path started");
|
||||||
FindPath(location);
|
FindPath(location, maxPassableHeight);
|
||||||
Debug.WriteLine("Find path finished");
|
Debug.WriteLine("Find path finished");
|
||||||
|
|
||||||
|
|
||||||
@@ -99,17 +90,22 @@ namespace Client.Infrastructure.Service
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AsyncPathMover(WorldHandler worldHandler, PathfinderInterface pathfinder, int pathNumberOfAttempts, double nodeWaitingTime, int nodeDistanceTolerance, int nextNodeDistanceTolerance)
|
public async Task<bool> MoveAsync(Vector3 location)
|
||||||
|
{
|
||||||
|
return await MoveAsync(location, maxPassableHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AsyncPathMover(WorldHandler worldHandler, PathfinderInterface pathfinder, double nodeWaitingTime, int nodeDistanceTolerance, int nextNodeDistanceTolerance, ushort maxPassableHeight)
|
||||||
{
|
{
|
||||||
this.worldHandler = worldHandler;
|
this.worldHandler = worldHandler;
|
||||||
this.pathfinder = pathfinder;
|
this.pathfinder = pathfinder;
|
||||||
this.pathNumberOfAttempts = pathNumberOfAttempts;
|
|
||||||
this.nodeWaitingTime = nodeWaitingTime;
|
this.nodeWaitingTime = nodeWaitingTime;
|
||||||
this.nodeDistanceTolerance = nodeDistanceTolerance;
|
this.nodeDistanceTolerance = nodeDistanceTolerance;
|
||||||
this.nextNodeDistanceTolerance = nextNodeDistanceTolerance;
|
this.nextNodeDistanceTolerance = nextNodeDistanceTolerance;
|
||||||
|
this.maxPassableHeight = maxPassableHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FindPath(Vector3 location)
|
private void FindPath(Vector3 location, ushort maxPassableHeight)
|
||||||
{
|
{
|
||||||
var hero = worldHandler.Hero;
|
var hero = worldHandler.Hero;
|
||||||
|
|
||||||
@@ -119,7 +115,7 @@ namespace Client.Infrastructure.Service
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var path = pathfinder.FindPath(hero.Transform.Position, location);
|
var path = pathfinder.FindPath(hero.Transform.Position, location, maxPassableHeight);
|
||||||
foreach (var segment in path)
|
foreach (var segment in path)
|
||||||
{
|
{
|
||||||
Path.Add(segment);
|
Path.Add(segment);
|
||||||
|
|||||||
@@ -20,13 +20,12 @@ namespace Client.Infrastructure.Service
|
|||||||
[DllImport("L2JGeoDataPathFinder.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("L2JGeoDataPathFinder.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
private static extern bool HasLineOfSight(string geoDataDirectory, float startX, float startY, float startZ, float endX, float endY, ushort maxPassableHeight);
|
private static extern bool HasLineOfSight(string geoDataDirectory, float startX, float startY, float startZ, float endX, float endY, ushort maxPassableHeight);
|
||||||
|
|
||||||
public L2jGeoDataPathfinder(string geodataDirectory, ushort maxPassableHeight)
|
public L2jGeoDataPathfinder(string geodataDirectory)
|
||||||
{
|
{
|
||||||
this.geodataDirectory = geodataDirectory;
|
this.geodataDirectory = geodataDirectory;
|
||||||
this.maxPassableHeight = maxPassableHeight;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PathSegment> FindPath(Vector3 start, Vector3 end)
|
public List<PathSegment> FindPath(Vector3 start, Vector3 end, ushort maxPassableHeight)
|
||||||
{
|
{
|
||||||
var arrayPtr = IntPtr.Zero;
|
var arrayPtr = IntPtr.Zero;
|
||||||
var size = FindPath(out arrayPtr, GetGeodataFullpath(), start.X, start.Y, start.Z, end.X, end.Y, maxPassableHeight);
|
var size = FindPath(out arrayPtr, GetGeodataFullpath(), start.X, start.Y, start.Z, end.X, end.Y, maxPassableHeight);
|
||||||
@@ -53,7 +52,7 @@ namespace Client.Infrastructure.Service
|
|||||||
|
|
||||||
public bool HasLineOfSight(Vector3 start, Vector3 end)
|
public bool HasLineOfSight(Vector3 start, Vector3 end)
|
||||||
{
|
{
|
||||||
return HasLineOfSight(GetGeodataFullpath(), start.X, start.Y, start.Z, end.X, end.Y, maxPassableHeight);
|
return HasLineOfSight(GetGeodataFullpath(), start.X, start.Y, start.Z, end.X, end.Y, LINE_OF_SIGHT_HEIGHT_OF_OBSTACLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<PathSegment> BuildPath(List<PathNode> nodes)
|
private List<PathSegment> BuildPath(List<PathNode> nodes)
|
||||||
@@ -98,6 +97,6 @@ namespace Client.Infrastructure.Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly string geodataDirectory;
|
private readonly string geodataDirectory;
|
||||||
private readonly ushort maxPassableHeight;
|
private const ushort LINE_OF_SIGHT_HEIGHT_OF_OBSTACLE = 999;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -31,7 +31,7 @@ namespace L2Bot::Domain::Entities
|
|||||||
WorldObject::Update(transform);
|
WorldObject::Update(transform);
|
||||||
|
|
||||||
m_FullName = fullName;
|
m_FullName = fullName;
|
||||||
m_VitalStats = vitalStats;
|
m_VitalStats.LoadFromOther(vitalStats);
|
||||||
m_Phenotype = phenotype;
|
m_Phenotype = phenotype;
|
||||||
m_ExperienceInfo = experienceInfo;
|
m_ExperienceInfo = experienceInfo;
|
||||||
m_PermanentStats = permanentStats;
|
m_PermanentStats = permanentStats;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace L2Bot::Domain::Entities
|
|||||||
m_IsHostile = isHostile;
|
m_IsHostile = isHostile;
|
||||||
m_NpcId = npcId;
|
m_NpcId = npcId;
|
||||||
m_FullName = fullName;
|
m_FullName = fullName;
|
||||||
m_VitalStats = vitalStats;
|
m_VitalStats.LoadFromOther(vitalStats);
|
||||||
}
|
}
|
||||||
const size_t GetHash() const override
|
const size_t GetHash() const override
|
||||||
{
|
{
|
||||||
@@ -45,6 +45,10 @@ namespace L2Bot::Domain::Entities
|
|||||||
{
|
{
|
||||||
return "npc";
|
return "npc";
|
||||||
}
|
}
|
||||||
|
void MarkAsDead()
|
||||||
|
{
|
||||||
|
m_VitalStats.MarkAsDead();
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace L2Bot::Domain::Entities
|
|||||||
|
|
||||||
m_FullName = fullName;
|
m_FullName = fullName;
|
||||||
m_Phenotype = phenotype;
|
m_Phenotype = phenotype;
|
||||||
m_VitalStats = vitalStats;
|
m_VitalStats.LoadFromOther(vitalStats);
|
||||||
}
|
}
|
||||||
const size_t GetHash() const override
|
const size_t GetHash() const override
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ namespace L2Bot::Domain::ValueObjects
|
|||||||
class VitalStats : public Serializers::Serializable, public Entities::Hashable
|
class VitalStats : public Serializers::Serializable, public Entities::Hashable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const bool IsAlive() const
|
const bool IsDead() const
|
||||||
{
|
{
|
||||||
return m_MaxHp <= 0 || m_Hp > 0;
|
return m_IsDead || (m_MaxHp > 0 && m_Hp <= 0);
|
||||||
}
|
}
|
||||||
const uint32_t GetMaxHp() const
|
const uint32_t GetMaxHp() const
|
||||||
{
|
{
|
||||||
@@ -46,9 +46,19 @@ namespace L2Bot::Domain::ValueObjects
|
|||||||
std::hash<uint32_t>{}(m_MaxMp),
|
std::hash<uint32_t>{}(m_MaxMp),
|
||||||
std::hash<uint32_t>{}(m_Mp),
|
std::hash<uint32_t>{}(m_Mp),
|
||||||
std::hash<uint32_t>{}(m_MaxCp),
|
std::hash<uint32_t>{}(m_MaxCp),
|
||||||
std::hash<uint32_t>{}(m_Cp)
|
std::hash<uint32_t>{}(m_Cp),
|
||||||
|
std::hash<bool>{}(m_IsDead)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
void LoadFromOther(VitalStats other)
|
||||||
|
{
|
||||||
|
m_MaxHp = other.m_MaxHp;
|
||||||
|
m_Hp = other.m_Hp;
|
||||||
|
m_MaxMp = other.m_MaxMp;
|
||||||
|
m_Mp = other.m_Mp;
|
||||||
|
m_MaxCp = other.m_MaxCp;
|
||||||
|
m_Cp = other.m_Cp;
|
||||||
|
}
|
||||||
|
|
||||||
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
const std::vector<Serializers::Node> BuildSerializationNodes() const override
|
||||||
{
|
{
|
||||||
@@ -59,9 +69,14 @@ namespace L2Bot::Domain::ValueObjects
|
|||||||
{ L"maxMp", std::to_wstring(m_MaxMp) },
|
{ L"maxMp", std::to_wstring(m_MaxMp) },
|
||||||
{ L"mp", std::to_wstring(m_Mp) },
|
{ L"mp", std::to_wstring(m_Mp) },
|
||||||
{ L"maxCp", std::to_wstring(m_MaxCp) },
|
{ L"maxCp", std::to_wstring(m_MaxCp) },
|
||||||
{ L"cp", std::to_wstring(m_Cp) }
|
{ L"cp", std::to_wstring(m_Cp) },
|
||||||
|
{ L"isDead", std::to_wstring(IsDead()) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
void MarkAsDead()
|
||||||
|
{
|
||||||
|
m_IsDead = true;;
|
||||||
|
}
|
||||||
|
|
||||||
VitalStats(
|
VitalStats(
|
||||||
uint32_t maxHp,
|
uint32_t maxHp,
|
||||||
@@ -90,5 +105,6 @@ namespace L2Bot::Domain::ValueObjects
|
|||||||
uint32_t m_Mp = 0;
|
uint32_t m_Mp = 0;
|
||||||
uint32_t m_MaxCp = 0;
|
uint32_t m_MaxCp = 0;
|
||||||
uint32_t m_Cp = 0;
|
uint32_t m_Cp = 0;
|
||||||
|
uint32_t m_IsDead = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,4 +78,4 @@ private:
|
|||||||
|
|
||||||
const std::wstring Application::PIPE_NAME = std::wstring(L"PipeL2Bot");
|
const std::wstring Application::PIPE_NAME = std::wstring(L"PipeL2Bot");
|
||||||
const uint16_t Application::CREATURE_RADIUS = 4000;
|
const uint16_t Application::CREATURE_RADIUS = 4000;
|
||||||
const uint16_t Application::DROP_RADIUS = 1000;
|
const uint16_t Application::DROP_RADIUS = 4000;
|
||||||
@@ -103,7 +103,11 @@ namespace Interlude
|
|||||||
{
|
{
|
||||||
if (m_Hero->GetId() == casted.GetTargetId())
|
if (m_Hero->GetId() == casted.GetTargetId())
|
||||||
{
|
{
|
||||||
m_Hero->AddAttacker(casted.GetAttackerId());
|
const auto attacker = m_NetworkHandler.GetUser(casted.GetAttackerId());
|
||||||
|
if (attacker && attacker->userType == L2::UserType::NPC)
|
||||||
|
{
|
||||||
|
m_Hero->AddAttacker(casted.GetAttackerId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (casted.GetAttackerId() != casted.GetTargetId())
|
else if (casted.GetAttackerId() != casted.GetTargetId())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -111,6 +111,9 @@ namespace Interlude
|
|||||||
m_Spoiled[casted.GetCreatureId()] = Enums::SpoilStateEnum::none;
|
m_Spoiled[casted.GetCreatureId()] = Enums::SpoilStateEnum::none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (m_Npcs.find(casted.GetCreatureId()) != m_Npcs.end()) {
|
||||||
|
m_Npcs[casted.GetCreatureId()]->MarkAsDead();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user