Compare commits
5 Commits
0.0.1-alph
...
0.0.2-alph
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad7a4c3074 | ||
|
|
5f19cc1f76 | ||
|
|
abadf90d4a | ||
|
|
4a45d1d615 | ||
|
|
248099b323 |
@@ -13,6 +13,10 @@
|
|||||||
MouseLeave="ContentControl_MouseLeave"
|
MouseLeave="ContentControl_MouseLeave"
|
||||||
MouseMove="ContentControl_MouseMove"
|
MouseMove="ContentControl_MouseMove"
|
||||||
>
|
>
|
||||||
|
<ContentControl.Resources>
|
||||||
|
<BitmapImage x:Key="FallbackImage" UriSource="../../Assets/maps/fallback.jpg" />
|
||||||
|
<Int32Collection x:Key="mapLevels">0,1,2,3,4,5</Int32Collection>
|
||||||
|
</ContentControl.Resources>
|
||||||
<Grid Background="Transparent">
|
<Grid Background="Transparent">
|
||||||
<Grid.InputBindings>
|
<Grid.InputBindings>
|
||||||
<MouseBinding Gesture="LeftClick" Command="{Binding MouseLeftClickCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Grid}}" />
|
<MouseBinding Gesture="LeftClick" Command="{Binding MouseLeftClickCommand}" CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=Grid}}" />
|
||||||
@@ -29,7 +33,7 @@
|
|||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<Image
|
<Image
|
||||||
Source="{Binding ImageSource,Mode=OneWay}"
|
Source="{Binding ImageSource,Mode=OneWay,FallbackValue={StaticResource FallbackImage},TargetNullValue={StaticResource FallbackImage}}"
|
||||||
Width="{Binding Size,Mode=OneWay}"
|
Width="{Binding Size,Mode=OneWay}"
|
||||||
Height="{Binding Size,Mode=OneWay}"
|
Height="{Binding Size,Mode=OneWay}"
|
||||||
Visibility="{Binding Visible,Converter={StaticResource BooleanToVisibilityConverter}}"
|
Visibility="{Binding Visible,Converter={StaticResource BooleanToVisibilityConverter}}"
|
||||||
@@ -286,10 +290,17 @@
|
|||||||
<StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Right" Background="#66ffffff">
|
<StackPanel VerticalAlignment="Bottom" HorizontalAlignment="Right" Background="#66ffffff">
|
||||||
<Grid Margin="10 5">
|
<Grid Margin="10 5">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="Auto"></ColumnDefinition>
|
||||||
<ColumnDefinition Width="90"></ColumnDefinition>
|
<ColumnDefinition Width="90"></ColumnDefinition>
|
||||||
<ColumnDefinition Width="30"></ColumnDefinition>
|
<ColumnDefinition Width="30"></ColumnDefinition>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock Padding="0 0 0 3">
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Label>Map level:</Label>
|
||||||
|
<ComboBox
|
||||||
|
SelectedValue="{Binding MapLevel}"
|
||||||
|
ItemsSource="{StaticResource mapLevels}" Margin="0,0,10,0"/>
|
||||||
|
</StackPanel>
|
||||||
|
<TextBlock Grid.Column="1" Padding="0 0 0 3" VerticalAlignment="Center">
|
||||||
<TextBlock.Text>
|
<TextBlock.Text>
|
||||||
<MultiBinding StringFormat="{}{0:F0}, {1:F0}">
|
<MultiBinding StringFormat="{}{0:F0}, {1:F0}">
|
||||||
<Binding Path="MousePosition.X" Mode="OneWay"/>
|
<Binding Path="MousePosition.X" Mode="OneWay"/>
|
||||||
@@ -297,7 +308,7 @@
|
|||||||
</MultiBinding>
|
</MultiBinding>
|
||||||
</TextBlock.Text>
|
</TextBlock.Text>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
<TextBlock Grid.Column="1" Text="{Binding Scale,Mode=OneWay,StringFormat='{}1:{0}'}" HorizontalAlignment="Right" />
|
<Label Grid.Column="2" Content="{Binding Scale,Mode=OneWay,StringFormat='{}1:{0}'}" HorizontalAlignment="Right" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Client.Application.ViewModels
|
|||||||
{
|
{
|
||||||
public class MapBlockViewModel : ObservableObject
|
public class MapBlockViewModel : ObservableObject
|
||||||
{
|
{
|
||||||
public string ImageSource => "/Assets/maps/" + mapBlock.BlockX + "_" + mapBlock.BlockY + ".jpg";
|
public string ImageSource => "/Assets/maps/" + mapBlock.BlockX + "_" + mapBlock.BlockY + (mapBlock.Level > 0 ? "_" + mapBlock.Level : "") + ".jpg";
|
||||||
public float DeltaX => mapBlock.DeltaX;
|
public float DeltaX => mapBlock.DeltaX;
|
||||||
public float DeltaY => mapBlock.DeltaY;
|
public float DeltaY => mapBlock.DeltaY;
|
||||||
public float Size => mapBlock.Size;
|
public float Size => mapBlock.Size;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Client.Application.Commands;
|
using Client.Application.Commands;
|
||||||
|
using Client.Application.Components;
|
||||||
using Client.Domain.Common;
|
using Client.Domain.Common;
|
||||||
using Client.Domain.DTO;
|
using Client.Domain.DTO;
|
||||||
using Client.Domain.Entities;
|
using Client.Domain.Entities;
|
||||||
@@ -83,6 +84,19 @@ namespace Client.Application.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int MapLevel
|
||||||
|
{
|
||||||
|
get => mapLevel;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (mapLevel != value)
|
||||||
|
{
|
||||||
|
mapLevel = value;
|
||||||
|
UpdateMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Vector3 MousePosition
|
public Vector3 MousePosition
|
||||||
{
|
{
|
||||||
get => mousePosition;
|
get => mousePosition;
|
||||||
@@ -107,7 +121,7 @@ namespace Client.Application.ViewModels
|
|||||||
|
|
||||||
if (hero != null)
|
if (hero != null)
|
||||||
{
|
{
|
||||||
var blocks = selector.SelectImages((float)ViewportWidth, (float)ViewportHeight, hero.Transform.Position, Scale);
|
var blocks = selector.SelectImages((float)ViewportWidth, (float)ViewportHeight, hero.Transform.Position, Scale, MapLevel);
|
||||||
|
|
||||||
foreach (var block in blocks)
|
foreach (var block in blocks)
|
||||||
{
|
{
|
||||||
@@ -328,7 +342,7 @@ namespace Client.Application.ViewModels
|
|||||||
public readonly static float MAX_SCALE = 128;
|
public readonly static float MAX_SCALE = 128;
|
||||||
private readonly AsyncPathMoverInterface pathMover;
|
private readonly AsyncPathMoverInterface pathMover;
|
||||||
private MapImageSelector selector = new MapImageSelector();
|
private MapImageSelector selector = new MapImageSelector();
|
||||||
private Dictionary<uint, MapBlockViewModel> blocks = new Dictionary<uint, MapBlockViewModel>();
|
private Dictionary<int, MapBlockViewModel> blocks = new Dictionary<int, MapBlockViewModel>();
|
||||||
private Hero? hero;
|
private Hero? hero;
|
||||||
private float scale = 8;
|
private float scale = 8;
|
||||||
private double viewportWidth = 0;
|
private double viewportWidth = 0;
|
||||||
@@ -336,5 +350,6 @@ namespace Client.Application.ViewModels
|
|||||||
private Vector3 mousePosition = new Vector3(0, 0, 0);
|
private Vector3 mousePosition = new Vector3(0, 0, 0);
|
||||||
private object pathCollectionLock = new object();
|
private object pathCollectionLock = new object();
|
||||||
private AICombatZoneMapViewModel? combatZone = null;
|
private AICombatZoneMapViewModel? combatZone = null;
|
||||||
|
private int mapLevel = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
Client/Assets/maps/fallback.jpg
Normal file
BIN
Client/Assets/maps/fallback.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -47,11 +47,11 @@ namespace Client.Domain.AI
|
|||||||
if (isEnabled && worldHandler.Hero != null)
|
if (isEnabled && worldHandler.Hero != null)
|
||||||
{
|
{
|
||||||
states[currentState].Execute();
|
states[currentState].Execute();
|
||||||
foreach (var transition in locator.Get(Type).Build())
|
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(worldHandler, config, states[currentState]))
|
if (transition.predicate(states[currentState]))
|
||||||
{
|
{
|
||||||
states[currentState].OnLeave();
|
states[currentState].OnLeave();
|
||||||
currentState = transition.toState;
|
currentState = transition.toState;
|
||||||
|
|||||||
@@ -27,10 +27,7 @@ namespace Client.Domain.AI.Combat
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (skill.IsReadyToUse && hero.VitalStats.Mp >= skill.Cost)
|
return skill;
|
||||||
{
|
|
||||||
return skill;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,25 +12,25 @@ namespace Client.Domain.AI.Combat
|
|||||||
{
|
{
|
||||||
public class TransitionBuilder : TransitionBuilderInterface
|
public class TransitionBuilder : TransitionBuilderInterface
|
||||||
{
|
{
|
||||||
public List<TransitionBuilderInterface.Transition> Build()
|
public List<TransitionBuilderInterface.Transition> Build(WorldHandler worldHandler, Config config, AsyncPathMoverInterface pathMover)
|
||||||
{
|
{
|
||||||
if (transitions.Count == 0)
|
if (transitions.Count == 0)
|
||||||
{
|
{
|
||||||
transitions = new List<TransitionBuilderInterface.Transition>()
|
transitions = new List<TransitionBuilderInterface.Transition>()
|
||||||
{
|
{
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Any}, BaseState.Type.Dead, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Any}, BaseState.Type.Dead, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return worldHandler.Hero.VitalStats.IsDead;
|
return worldHandler.Hero.VitalStats.IsDead;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Dead}, BaseState.Type.Idle, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Dead}, BaseState.Type.Idle, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !worldHandler.Hero.VitalStats.IsDead;
|
return !worldHandler.Hero.VitalStats.IsDead;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Idle, BaseState.Type.MoveToTarget, BaseState.Type.Rest, BaseState.Type.MoveToSpot}, BaseState.Type.FindTarget, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Idle, BaseState.Type.MoveToTarget, BaseState.Type.Rest, BaseState.Type.MoveToSpot}, BaseState.Type.FindTarget, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -45,13 +45,13 @@ namespace Client.Domain.AI.Combat
|
|||||||
|
|
||||||
return worldHandler.Hero.AttackerIds.Count > 0;
|
return worldHandler.Hero.AttackerIds.Count > 0;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.FindTarget}, BaseState.Type.MoveToTarget, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.FindTarget}, BaseState.Type.MoveToTarget, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return worldHandler.Hero.HasValidTarget;
|
return worldHandler.Hero.HasValidTarget;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.FindTarget}, BaseState.Type.MoveToSpot, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.FindTarget}, BaseState.Type.MoveToSpot, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -59,7 +59,7 @@ namespace Client.Domain.AI.Combat
|
|||||||
return Helper.GetMobsToAttackByConfig(worldHandler, config, worldHandler.Hero).Count == 0
|
return Helper.GetMobsToAttackByConfig(worldHandler, config, worldHandler.Hero).Count == 0
|
||||||
&& !Helper.IsOnSpot(worldHandler, config, worldHandler.Hero);
|
&& !Helper.IsOnSpot(worldHandler, config, worldHandler.Hero);
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.MoveToSpot}, BaseState.Type.Idle, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.MoveToSpot}, BaseState.Type.Idle, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -70,27 +70,27 @@ namespace Client.Domain.AI.Combat
|
|||||||
|
|
||||||
return Helper.IsOnSpot(worldHandler, config, worldHandler.Hero);
|
return Helper.IsOnSpot(worldHandler, config, worldHandler.Hero);
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.MoveToTarget}, BaseState.Type.Idle, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.MoveToTarget}, BaseState.Type.Idle, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !worldHandler.Hero.HasValidTarget;
|
return !worldHandler.Hero.HasValidTarget;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Idle}, BaseState.Type.Rest, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Idle}, BaseState.Type.Rest, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
return worldHandler.Hero.AttackerIds.Count == 0 && (worldHandler.Hero.VitalStats.HpPercent < config.Combat.RestStartPercentHp
|
return worldHandler.Hero.AttackerIds.Count == 0 && (worldHandler.Hero.VitalStats.HpPercent < config.Combat.RestStartPercentHp
|
||||||
|| worldHandler.Hero.VitalStats.MpPercent < config.Combat.RestStartPecentMp);
|
|| worldHandler.Hero.VitalStats.MpPercent < config.Combat.RestStartPecentMp);
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Rest}, BaseState.Type.Idle, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Rest}, BaseState.Type.Idle, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return worldHandler.Hero.VitalStats.HpPercent >= config.Combat.RestEndPecentHp
|
return worldHandler.Hero.VitalStats.HpPercent >= config.Combat.RestEndPecentHp
|
||||||
&& worldHandler.Hero.VitalStats.MpPercent >= config.Combat.RestEndPecentMp;
|
&& worldHandler.Hero.VitalStats.MpPercent >= config.Combat.RestEndPecentMp;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.MoveToTarget}, BaseState.Type.Attack, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.MoveToTarget}, BaseState.Type.Attack, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -99,6 +99,11 @@ 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) {
|
||||||
@@ -109,21 +114,21 @@ 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);
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Attack}, BaseState.Type.Pickup, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Attack}, BaseState.Type.Pickup, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !worldHandler.Hero.HasValidTarget;
|
return !worldHandler.Hero.HasValidTarget;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Attack}, BaseState.Type.FindTarget, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Attack}, BaseState.Type.FindTarget, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return worldHandler.Hero.HasValidTarget && worldHandler.Hero.AttackerIds.Count > 0 && !worldHandler.Hero.AttackerIds.Contains(worldHandler.Hero.TargetId);
|
return worldHandler.Hero.HasValidTarget && worldHandler.Hero.AttackerIds.Count > 0 && !worldHandler.Hero.AttackerIds.Contains(worldHandler.Hero.TargetId);
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Pickup}, BaseState.Type.Idle, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Pickup}, BaseState.Type.Idle, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,37 +12,39 @@ namespace Client.Domain.AI.Deleveling
|
|||||||
{
|
{
|
||||||
public class TransitionBuilder : TransitionBuilderInterface
|
public class TransitionBuilder : TransitionBuilderInterface
|
||||||
{
|
{
|
||||||
public List<TransitionBuilderInterface.Transition> Build()
|
|
||||||
|
// todo add MoveToDropState, SweepState
|
||||||
|
public List<TransitionBuilderInterface.Transition> Build(WorldHandler worldHandler, Config config, AsyncPathMoverInterface pathMover)
|
||||||
{
|
{
|
||||||
if (transitions.Count == 0)
|
if (transitions.Count == 0)
|
||||||
{
|
{
|
||||||
transitions = new List<TransitionBuilderInterface.Transition>()
|
transitions = new List<TransitionBuilderInterface.Transition>()
|
||||||
{
|
{
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Any}, BaseState.Type.Dead, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Any}, BaseState.Type.Dead, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return worldHandler.Hero.VitalStats.IsDead;
|
return worldHandler.Hero.VitalStats.IsDead;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Dead}, BaseState.Type.Idle, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Dead}, BaseState.Type.Idle, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return !worldHandler.Hero.VitalStats.IsDead;
|
return !worldHandler.Hero.VitalStats.IsDead;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.FindGuard}, BaseState.Type.MoveToTarget, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.FindGuard}, BaseState.Type.MoveToTarget, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return worldHandler.Hero.Target != null;
|
return worldHandler.Hero.Target != null;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.MoveToTarget}, BaseState.Type.Idle, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.MoveToTarget}, BaseState.Type.Idle, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return worldHandler.Hero.Target == null;
|
return worldHandler.Hero.Target == null;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.MoveToTarget}, BaseState.Type.AttackGuard, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.MoveToTarget}, BaseState.Type.AttackGuard, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -55,7 +57,7 @@ namespace Client.Domain.AI.Deleveling
|
|||||||
var expectedDistance = config.Deleveling.AttackDistance;
|
var expectedDistance = config.Deleveling.AttackDistance;
|
||||||
return distance < expectedDistance;
|
return distance < expectedDistance;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.AttackGuard}, BaseState.Type.FindGuard, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.AttackGuard}, BaseState.Type.FindGuard, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -68,7 +70,7 @@ namespace Client.Domain.AI.Deleveling
|
|||||||
var expectedDistance = config.Deleveling.AttackDistance;
|
var expectedDistance = config.Deleveling.AttackDistance;
|
||||||
return distance >= expectedDistance;
|
return distance >= expectedDistance;
|
||||||
}),
|
}),
|
||||||
new(new List<BaseState.Type>{BaseState.Type.Idle}, BaseState.Type.FindGuard, (worldHandler, config, state) => {
|
new(new List<BaseState.Type>{BaseState.Type.Idle}, BaseState.Type.FindGuard, (state) => {
|
||||||
if (worldHandler.Hero == null) {
|
if (worldHandler.Hero == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace Client.Domain.AI.State
|
|||||||
}
|
}
|
||||||
|
|
||||||
var skill = Helper.GetSkillByConfig(worldHandler, config, hero, hero.Target);
|
var skill = Helper.GetSkillByConfig(worldHandler, config, hero, hero.Target);
|
||||||
if (skill != null)
|
if (skill != null && skill.IsReadyToUse && hero.VitalStats.Mp >= skill.Cost)
|
||||||
{
|
{
|
||||||
worldHandler.RequestUseSkill(skill.Id, false, false);
|
worldHandler.RequestUseSkill(skill.Id, false, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ namespace Client.Domain.AI.State
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (distance >= Helper.GetAttackDistanceByConfig(worldHandler, config, hero, target))
|
var hasLineOfSight = asyncPathMover.Pathfinder.HasLineOfSight(hero.Transform.Position, target.Transform.Position);
|
||||||
|
if (distance >= Helper.GetAttackDistanceByConfig(worldHandler, config, hero, target) || !hasLineOfSight)
|
||||||
{
|
{
|
||||||
asyncPathMover.MoveAsync(target.Transform.Position);
|
asyncPathMover.MoveAsync(target.Transform.Position);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,16 +14,16 @@ namespace Client.Domain.AI
|
|||||||
{
|
{
|
||||||
public readonly Dictionary<BaseState.Type, BaseState.Type> fromStates;
|
public readonly Dictionary<BaseState.Type, BaseState.Type> fromStates;
|
||||||
public readonly BaseState.Type toState;
|
public readonly BaseState.Type toState;
|
||||||
public readonly Func<WorldHandler, Config, BaseState, bool> predicate;
|
public readonly Func<BaseState, bool> predicate;
|
||||||
|
|
||||||
public Transition(List<BaseState.Type> fromStates, BaseState.Type toState, Func<WorldHandler, Config, BaseState, bool>? predicate = null)
|
public Transition(List<BaseState.Type> fromStates, BaseState.Type toState, Func<BaseState, bool>? predicate = null)
|
||||||
{
|
{
|
||||||
this.fromStates = fromStates.ToDictionary(x => x, x => x);
|
this.fromStates = fromStates.ToDictionary(x => x, x => x);
|
||||||
this.toState = toState;
|
this.toState = toState;
|
||||||
this.predicate = predicate != null ? predicate : (worldHandler, config, state) => { return true; };
|
this.predicate = predicate != null ? predicate : (state) => { return true; };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Transition> Build();
|
List<Transition> Build(WorldHandler worldHandler, Config config, AsyncPathMoverInterface pathMover);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace Client.Domain.Service
|
|||||||
{
|
{
|
||||||
public interface AsyncPathMoverInterface
|
public interface AsyncPathMoverInterface
|
||||||
{
|
{
|
||||||
|
public PathfinderInterface Pathfinder { get; }
|
||||||
public ObservableCollection<PathSegment> Path { get; }
|
public ObservableCollection<PathSegment> Path { get; }
|
||||||
public Task<bool> MoveAsync(Vector3 location);
|
public Task<bool> MoveAsync(Vector3 location);
|
||||||
public Task MoveUntilReachedAsync(Vector3 location);
|
public Task MoveUntilReachedAsync(Vector3 location);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace Client.Domain.Service
|
|||||||
private static readonly uint DELTA_X = 20;
|
private static readonly uint DELTA_X = 20;
|
||||||
private static readonly uint DELTA_Y = 18;
|
private static readonly uint DELTA_Y = 18;
|
||||||
|
|
||||||
public List<MapBlock> SelectImages(float viewportWidth, float viewportHeight, Vector3 heroPosition, float scale)
|
public List<MapBlock> SelectImages(float viewportWidth, float viewportHeight, Vector3 heroPosition, float scale, int level)
|
||||||
{
|
{
|
||||||
var viewportCenter = new Tuple<float, float>(viewportWidth / 2, viewportHeight / 2);
|
var viewportCenter = new Tuple<float, float>(viewportWidth / 2, viewportHeight / 2);
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ namespace Client.Domain.Service
|
|||||||
(blockTopLeft.Item2 - topLeft.Item2) / scale
|
(blockTopLeft.Item2 - topLeft.Item2) / scale
|
||||||
);
|
);
|
||||||
|
|
||||||
result.Add(new MapBlock(x, y, delta.Item1, delta.Item2, BLOCK_SIZE / scale));
|
result.Add(new MapBlock(x, y, delta.Item1, delta.Item2, BLOCK_SIZE / scale, level));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ 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);
|
||||||
|
public bool HasLineOfSight(Vector3 start, Vector3 end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,20 +13,24 @@ namespace Client.Domain.ValueObjects
|
|||||||
private float deltaY;
|
private float deltaY;
|
||||||
private float size;
|
private float size;
|
||||||
|
|
||||||
public uint Id => (BlockX + BlockY) * (BlockX + BlockY + 1) / 2 + BlockX;
|
public int Id => (IdWithOutLevel + Level) * (IdWithOutLevel + Level + 1) / 2 + IdWithOutLevel;
|
||||||
public uint BlockX { get; set; }
|
public uint BlockX { get; set; }
|
||||||
public uint BlockY { get; set; }
|
public uint BlockY { get; set; }
|
||||||
public float DeltaX { get => deltaX; set { if (value != deltaX) { deltaX = value; OnPropertyChanged(); } } }
|
public float DeltaX { get => deltaX; set { if (value != deltaX) { deltaX = value; OnPropertyChanged(); } } }
|
||||||
public float DeltaY { get => deltaY; set { if (value != deltaY) { deltaY = value; OnPropertyChanged(); } } }
|
public float DeltaY { get => deltaY; set { if (value != deltaY) { deltaY = value; OnPropertyChanged(); } } }
|
||||||
public float Size { get => size; set { if (value != size) { size = value; OnPropertyChanged(); } } }
|
public float Size { get => size; set { if (value != size) { size = value; OnPropertyChanged(); } } }
|
||||||
|
public int Level { get; set; }
|
||||||
|
|
||||||
public MapBlock(uint blockX, uint blockY, float deltaX, float deltaY, float size)
|
private int IdWithOutLevel => (int) ((BlockX + BlockY) * (BlockX + BlockY + 1) / 2 + BlockX);
|
||||||
|
|
||||||
|
public MapBlock(uint blockX, uint blockY, float deltaX, float deltaY, float size, int level)
|
||||||
{
|
{
|
||||||
BlockX = blockX;
|
BlockX = blockX;
|
||||||
BlockY = blockY;
|
BlockY = blockY;
|
||||||
DeltaX = deltaX;
|
DeltaX = deltaX;
|
||||||
DeltaY = deltaY;
|
DeltaY = deltaY;
|
||||||
Size = size;
|
Size = size;
|
||||||
|
Level = level;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ namespace Client.Infrastructure.Service
|
|||||||
private readonly int nextNodeDistanceTolerance;
|
private readonly int nextNodeDistanceTolerance;
|
||||||
private CancellationTokenSource? cancellationTokenSource;
|
private CancellationTokenSource? cancellationTokenSource;
|
||||||
|
|
||||||
|
public PathfinderInterface Pathfinder => pathfinder;
|
||||||
public ObservableCollection<PathSegment> Path { get; private set; } = new ObservableCollection<PathSegment>();
|
public ObservableCollection<PathSegment> Path { get; private set; } = new ObservableCollection<PathSegment>();
|
||||||
public bool IsLocked { get; private set; } = false;
|
public bool IsLocked { get; private set; } = false;
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ namespace Client.Infrastructure.Service
|
|||||||
[DllImport("L2JGeoDataPathFinder.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport("L2JGeoDataPathFinder.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
private static extern uint ReleasePath(IntPtr arrayPtr);
|
private static extern uint ReleasePath(IntPtr arrayPtr);
|
||||||
|
|
||||||
|
[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);
|
||||||
|
|
||||||
public L2jGeoDataPathfinder(string geodataDirectory, ushort maxPassableHeight)
|
public L2jGeoDataPathfinder(string geodataDirectory, ushort maxPassableHeight)
|
||||||
{
|
{
|
||||||
this.geodataDirectory = geodataDirectory;
|
this.geodataDirectory = geodataDirectory;
|
||||||
@@ -48,6 +51,11 @@ namespace Client.Infrastructure.Service
|
|||||||
return BuildPath(nodes);
|
return BuildPath(nodes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasLineOfSight(Vector3 start, Vector3 end)
|
||||||
|
{
|
||||||
|
return HasLineOfSight(GetGeodataFullpath(), start.X, start.Y, start.Z, end.X, end.Y, maxPassableHeight);
|
||||||
|
}
|
||||||
|
|
||||||
private List<PathSegment> BuildPath(List<PathNode> nodes)
|
private List<PathSegment> BuildPath(List<PathNode> nodes)
|
||||||
{
|
{
|
||||||
var result = new List<PathSegment>();
|
var result = new List<PathSegment>();
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::GetNextCreature failed");
|
throw RuntimeException(L"UNetworkHandler::GetNextCreature failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,7 +83,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::GetUser failed");
|
throw RuntimeException(L"UNetworkHandler::GetUser failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::GetItem failed");
|
throw RuntimeException(L"UNetworkHandler::GetItem failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::MTL failed");
|
throw RuntimeException(L"UNetworkHandler::MTL failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,7 +123,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::Action failed");
|
throw RuntimeException(L"UNetworkHandler::Action failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,7 +136,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::RequestMagicSkillUse failed");
|
throw RuntimeException(L"UNetworkHandler::RequestMagicSkillUse failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::RequestUseItem failed");
|
throw RuntimeException(L"UNetworkHandler::RequestUseItem failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::RequestAutoSoulShot failed");
|
throw RuntimeException(L"UNetworkHandler::RequestAutoSoulShot failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,7 +176,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::ChangeWaitType failed");
|
throw RuntimeException(L"UNetworkHandler::ChangeWaitType failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,7 +190,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::RequestItemList failed");
|
throw RuntimeException(L"UNetworkHandler::RequestItemList failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +203,7 @@ namespace Interlude
|
|||||||
}
|
}
|
||||||
__except (EXCEPTION_EXECUTE_HANDLER)
|
__except (EXCEPTION_EXECUTE_HANDLER)
|
||||||
{
|
{
|
||||||
throw CriticalRuntimeException(L"UNetworkHandler::RequestRestartPoint failed");
|
throw RuntimeException(L"UNetworkHandler::RequestRestartPoint failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
11
README.md
11
README.md
@@ -18,3 +18,14 @@ Communication between the client and the injected code occurs through a named pi
|
|||||||
Pathfinding is done using [L2jGeodataPathFinder](https://github.com/k0t9i/L2jGeodataPathFinder).
|
Pathfinding is done using [L2jGeodataPathFinder](https://github.com/k0t9i/L2jGeodataPathFinder).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## AI
|
||||||
|
The bot client have two AI: combat and deleveling.
|
||||||
|
|
||||||
|
Combat AI can attack and spoil mobs in any combination depending on the settings. It can also collect the selected drop and rest when it reaches a certain level of HP and MP.
|
||||||
|
|
||||||
|
Deleveling AI can automatically attack guards in any town/village until it reaches a configured level.
|
||||||
|
|
||||||
|
Both AIs use pathfinding to achieve desired goals.
|
||||||
|
|
||||||
|

|
||||||
|
|||||||
Reference in New Issue
Block a user