-
Active Member
How to get my equipped health potion sno id ?
After getting the sno id, i get the icon texture and display on screen on certain condition
-
First Dev On The Internet
Originally Posted by
takayo72
After getting the sno id, i get the icon texture and display on screen on certain condition
var EquippedPotion = Hud.Game.Items.FirstOrDefault(x => x.Location == ItemLocation.MerchantAvaibleItemsForPurchase);
-
Post Thanks / Like - 1 Thanks
JarJarD3 (1 members gave Thanks to User5981 for this useful post)
-
Active Member
it's not working. There is an exception error
'IEnumerable<IItem>' does not contain a definition for 'FirstOrDefault' and no accessible extension method 'FirstOrDefault' accepting a first argument of type 'IEnumerable<IItem>' could be found (are you missing a using directive or an assembly reference?)
-
First Dev On The Internet
Originally Posted by
takayo72
it's not working. There is an exception error
'IEnumerable<IItem>' does not contain a definition for 'FirstOrDefault' and no accessible extension method 'FirstOrDefault' accepting a first argument of type 'IEnumerable<IItem>' could be found (are you missing a using directive or an assembly reference?)
That plugin of mine where I picked up the code line works for months :
Resu/PotionPerfectionPlugin.cs at master . User5981/Resu . GitHub
FirstOrDefault needs System.Linq
Enumerable.FirstOrDefault Method (System.Linq) | Microsoft Docs
you have to add
using System.Linq;
at the beginning of your code.
-
Active Member
my original hard-code a potion and it is working
Code:
public ITexture Icon_Texture { get; set; }
Icon_Texture = Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_09);
Icon_Texture.Draw(MessageX+10, MessageY, 30.0f, 30.0f);
Now I changed to show the equipped potion on screen
Code:
public ITexture Icon_Texture { get; set; }
var EquippedPotion = Hud.Game.Items.FirstOrDefault(x => x.Location == ItemLocation.MerchantAvaibleItemsForPurchase);
Icon_Texture = Hud.Texture.GetItemTexture(EquippedPotion.SnoItem);
Icon_Texture.Draw(MessageX+10, MessageY, 30.0f, 30.0f);
No exception error. But No potion icon drawn on the screen.
-
First Dev On The Internet
Give the full code if you want help
-
Active Member
full source code
Code:
using System;
using System.Linq;
using Turbo.Plugins.Default;
namespace Turbo.Plugins.adrian
{
public class HealthPotionSkillOverlayMessage : BasePlugin, IInGameTopPainter
{
public IFont OverlayMessageFont { get; set; }
public string OverlayMessage { get; set; }
public float MessageX { get; set; }
public float MessageY { get; set; }
private float HudWidth { get { return Hud.Window.Size.Width; } }
private float HudHeight { get { return Hud.Window.Size.Height; } }
public float OffsetX { get; set; }
public float OffsetY { get; set; }
public ITexture Icon_Texture { get; set; }
public HealthPotionSkillOverlayMessage()
{
Enabled = true;
}
public override void Load(IController hud)
{
base.Load(hud);
var EquippedPotion = Hud.Game.Items.FirstOrDefault(x => x.Location == ItemLocation.MerchantAvaibleItemsForPurchase);
//Icon_Texture = Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_09);
Icon_Texture = Hud.Texture.GetItemTexture(EquippedPotion.SnoItem);
OverlayMessageFont = Hud.Render.CreateFont("tahoma", 9, 255, 255, 0, 0, true, false, true);
OffsetX = 0.625f;
OffsetY = 0;
OverlayMessage = "POTION IS READY!!";
}
public void PaintTopInGame(ClipState clipState)
{
if (Hud.Render.UiHidden) return;
if (clipState != ClipState.BeforeClip) return;
MessageY = HudHeight * OffsetY;
MessageX = HudWidth * OffsetX;
double Cooldown;
bool OnCooldown;
Cooldown = (Hud.Game.Me.Powers.HealthPotionSkill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60d;
OnCooldown = Cooldown <= 30 && Cooldown >= 0 ? true : false;
if (!OnCooldown)
{
//OverlayMessageFont.DrawText(OverlayMessage, MessageX, MessageY);
Icon_Texture.Draw(MessageX+10, MessageY, 30.0f, 30.0f);
}
}
}
}
-
First Dev On The Internet
maybe try
OverlayMessage = EquippedPotion.SnoItem.ToString();
to see what is displayed and identify the problem.
-
Active Member
Originally Posted by
User5981
maybe try
OverlayMessage = EquippedPotion.SnoItem.ToString();
to see what is displayed and identify the problem.
Nothing displayed
-
Legendary
Originally Posted by
takayo72
Nothing displayed
Try this, I made some changes:
Code:
using System.Linq;
using Turbo.Plugins.Default;
namespace Turbo.Plugins.adrian
{
public class HealthPotionSkillOverlayMessage : BasePlugin, IInGameTopPainter
{
public IFont OverlayMessageFont { get; set; }
public string OverlayMessage { get; set; }
public float MessageX { get; set; }
public float MessageY { get; set; }
private float HudWidth { get { return Hud.Window.Size.Width; } }
private float HudHeight { get { return Hud.Window.Size.Height; } }
public float OffsetX { get; set; }
public float OffsetY { get; set; }
public ITexture Icon_Texture { get; set; }
public HealthPotionSkillOverlayMessage()
{
Enabled = true;
}
public override void Load(IController hud)
{
base.Load(hud);
OverlayMessageFont = Hud.Render.CreateFont("tahoma", 9, 255, 255, 0, 0, true, false, true);
OffsetX = 0.625f;
OffsetY = 0;
OverlayMessage = "POTION IS READY!!";
}
public void PaintTopInGame(ClipState clipState)
{
if (Hud.Render.UiHidden) return;
if (clipState != ClipState.BeforeClip) return;
MessageY = HudHeight * OffsetY;
MessageX = HudWidth * OffsetX;
var EquippedPotion = Hud.Game.Items.FirstOrDefault(x => x.Location == ItemLocation.MerchantAvaibleItemsForPurchase);
Icon_Texture = Hud.Texture.GetItemTexture( (EquippedPotion != null)? EquippedPotion.SnoItem : Hud.Sno.SnoItems.HealthPotionBottomless);
if (!Hud.Game.Me.Powers.HealthPotionSkill.IsOnCooldown)
{
OverlayMessageFont.DrawText(OverlayMessage, MessageX, MessageY);
Icon_Texture.Draw(MessageX - 40, MessageY, 30.0f, 30.0f);
}
}
}
}
Last edited by RNN; 09-07-2019 at 08:50 AM.
Reason: if we change the potion its texture will be updated
-
Active Member
Wrong placement of code of mine
thx RNN~~~~~
-
Member
is there any plugin that shows potion taken by player in party and cooldown (kull for walls or any potion icon) ?