Updated chicken logic to work on beta- I do not run ES characters; therefore, I will not update for es chicken.
Chicken.cs
ChickenSettings.cs
SettingsGui
Chicken.cs
Code:
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Markup;
using log4net;
using System;
using Loki.Bot;
using Loki.Game;
using Loki.Game.GameData;
using Loki.Game.Objects;
using Loki.Game.Objects.Items;
using Loki.Utilities;
namespace Chicken
{
internal class Chicken : IPlugin
{
private static readonly ILog Log = Logger.GetLoggerInstanceForType();
#region Implementation of IPlugin
/// <summary> The name of the plugin. </summary>
public string Name
{
get { return "Chicken"; }
}
/// <summary> The description of the plugin. </summary>
public string Description
{
get { return "A plugin that provides Chicken use."; }
}
/// <summary>The author of the plugin.</summary>
public string Author
{
get { return "Bossland GmbH"; }
}
/// <summary>The version of the plugin.</summary>
public Version Version
{
get { return new Version(0, 0, 1, 2); }
}
/// <summary>Initializes this plugin.</summary>
public void Initialize()
{
Log.DebugFormat("[Chicken] Initialize");
}
/// <summary> The plugin start callback. Do any initialization here. </summary>
public void Start()
{
Log.DebugFormat("[Chicken] Start");
}
/// <summary> The plugin tick callback. Do any update logic here. </summary>
public void Tick()
{
if (!LokiPoe.IsInGame || LokiPoe.Me.IsInTown || LokiPoe.Me.IsDead)
return;
// Life
if (LokiPoe.Me.HealthPercent < ChickenSettings.Instance.HpChickenPercentTrigger)
{
var res = LokiPoe.EscapeState.LogoutToTitleScreen();
Log.DebugFormat("LogoutToTitleScreen returned {0}.", res);
}
}
/// <summary> The plugin stop callback. Do any pre-dispose cleanup here. </summary>
public void Stop()
{
Log.DebugFormat("[Chicken] Stop");
}
public JsonSettings Settings
{
get { return ChickenSettings.Instance; }
}
/// <summary> The routine's settings control. This will be added to the Exilebuddy Settings tab.</summary>
public UserControl Control
{
get
{
using (var fs = new FileStream(@"Plugins\Chicken\SettingsGui.xaml", FileMode.Open))
{
var root = (UserControl)XamlReader.Load(fs);
// Your settings binding here.
if (
!Wpf.SetupTextBoxBinding(root, "HpChickenPercentTriggerTextBox", "HpChickenPercentTrigger",
BindingMode.TwoWay, ChickenSettings.Instance))
{
Log.DebugFormat(
"[SettingsControl] SetupTextBoxBinding failed for 'HpChickenPercentTriggerTextBox'.");
throw new Exception("The SettingsControl could not be created.");
}
return root;
}
}
}
/// <summary> The plugin is being enabled.</summary>
public void OnEnable()
{
Log.DebugFormat("[Chicken] OnEnable");
}
/// <summary> The plugin is being disabled.</summary>
public void OnDisable()
{
Log.DebugFormat("[Chicken] OnDisable");
}
#endregion
#region Implementation of IDisposable
/// <summary> </summary>
public void Dispose()
{
}
#endregion
#region Override of Object
/// <summary>
///
/// </summary>
/// <returns></returns>
public override string ToString()
{
return Name + ": " + Description;
}
#endregion
}
}
ChickenSettings.cs
Code:
using System.ComponentModel;
using Loki.Bot.Settings;
using Loki.Utilities;
namespace Chicken
{
/// <summary>Settings for the AutoFlask. </summary>
public class ChickenSettings : JsonSettings
{
private static ChickenSettings _instance;
/// <summary>The current instance for this class. </summary>
public static ChickenSettings Instance
{
get { return _instance ?? (_instance = new ChickenSettings()); }
}
/// <summary>The default ctor. Will use the settings path "AutoFlask".</summary>
public ChickenSettings()
: base(GetSettingsFilePath(Configuration.Instance.Name, string.Format("{0}.json", "Chicken")))
{
// Setup defaults here if needed for properties that don't support DefaultValue.
}
private int _HpChickenPercentTrigger;
/// <summary>The % to trigger hp flasks.</summary>
[DefaultValue(50)]
public int HpChickenPercentTrigger
{
get { return _HpChickenPercentTrigger; }
set
{
if (value.Equals(_HpChickenPercentTrigger))
{
return;
}
_HpChickenPercentTrigger = value;
NotifyPropertyChanged(() => HpChickenPercentTrigger);
}
}
}
}
SettingsGui
Code:
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="440" d:DesignWidth="627">
<Grid x:Name="Root">
<Grid.Resources>
<Style TargetType="Label" x:Key="TitleLabel">
<Setter Property="Margin" Value="15,0,0,0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Foreground" Value="White"/>
</Style>
<Style TargetType="Label" x:Key="Label">
<Setter Property="Margin" Value="15,0,0,0"/>
<Setter Property="VerticalAlignment" Value="Center"/>
<Setter Property="Foreground" Value="White"/>
</Style>
<Style TargetType="TextBox" x:Key="TextBox">
<Setter Property="Margin" Value="3"/>
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="#333333"/>
<Setter Property="BorderBrush" Value="black"/>
</Style>
</Grid.Resources>
<ScrollViewer VerticalScrollBarVisibility="Auto">
<StackPanel>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" MinHeight="30"/>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" MinWidth="50" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" MinWidth="50" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" MinWidth="50" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- life flask support -->
<Label Grid.Row="0" Grid.Column="0" Style="{StaticResource TitleLabel}" Content="Chicken"/>
<Label Grid.Row="1" Grid.Column="0" Style="{StaticResource Label}" Content="Trigger (%): " ToolTipService.ToolTip="The % life your character has to be at to trigger Chicken."/>
<TextBox Grid.Row="1" Grid.Column="1" x:Name="HpChickenPercentTriggerTextBox" Style="{StaticResource TextBox}"/>
</Grid>
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>
Last edited: