# Forum > Diablo 3 > TurboHUD > TurboHUD Support > [How To] Convention of Elements position for current player on top of char

## gramoun

Hi, 
The standard CoE plugin from KJ show CoE state near of Portrait, left of screen

It would be usefull that my CoE appears on top of my char.

I've seen in standard ConventionOfElementsBuffListPlugin.cs in plugins\default, that position is calculated for each player of game list.

I'm sure that i m first of this list  :Wink: 

In PaintTopInGame(ClipState clipState) 

position is calculated depend on portrait from current step (end of structure)

var portraitRect = player.PortraitUiElement.Rectangle;

var x = portraitRect.Right;
var y = portraitRect.Top + portraitRect.Height * 0.51f;

A easy solution would be to say sommething as 
if not first player
var x = portraitRect.Right;
var y = portraitRect.Top + portraitRect.Height * 0.51f;
else 
var x = ????
var y = .????
endif

I m a retired programer, and C# is not my speciality, i know assembler... (gramounausuarus) lol

How could be this plugn modified or overided

Thanks for help

----------


## misuny

I would love to be able to see the CoE rotation but right underneath my character. This would be a wonderful plugin.

----------


## SeaDragon

```
                var portraitRect = player.PortraitUiElement.Rectangle;

                var x = portraitRect.Right;
                var y = portraitRect.Top + portraitRect.Height * 0.51f;
				if(player.IsMe)
				{
					if(MeScreenPaint)
					{
						BuffPainter.PaintHorizontalCenter(_ruleCalculator.PaintInfoList, 0, Hud.Window.Size.Height * 0.5f - Hud.Window.Size.Height * 0.2f, Hud.Window.Size.Width, _ruleCalculator.StandardIconSize, 0);
					}
					if(MePortraitPaint)
					{
						BuffPainter.PaintHorizontal(_ruleCalculator.PaintInfoList, x, y, _ruleCalculator.StandardIconSize, 0);
					}
				}
				else
				{
					if(OtherScreenPaint)
					{
						BuffPainter.PaintHorizontalCenter(_ruleCalculator.PaintInfoList, player.ScreenCoordinate.X, player.ScreenCoordinate.Y - Hud.Window.Size.Height * 0.1f, 0, _ruleCalculator.StandardIconSize, 0);
					}
					if(OtherPortraitPaint)
					{
						BuffPainter.PaintHorizontal(_ruleCalculator.PaintInfoList, x, y, _ruleCalculator.StandardIconSize, 0);
					}
				}
```

----------


## odaru7788

請教SeaDragon

如何不要讓他蓋在在其他選單之上

--------------------------------------

using System.Collections.Generic;
using System.Linq;
using System;
using Turbo.Plugins.Default;

namespace Turbo.Plugins.User
{

public class COEBuffListPlugin : BasePlugin, IInGameTopPainter
{

public bool HideWhenUiIsHidden { get; set; }
public BuffPainter BuffPainter { get; set; }

private BuffRuleCalculator _ruleCalculator;

public COEBuffListPlugin()
{
Enabled = true;
}

public override void Load(IController hud)
{
base.Load(hud);

HideWhenUiIsHidden = false;
BuffPainter = new BuffPainter(Hud, true)
{
Opacity = 1.0f,
TimeLeftFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, true, false, 255, 0, 0, 0, true),
};

_ruleCalculator = new BuffRuleCalculator(Hud);
_ruleCalculator.SizeMultiplier = 0.7f;

_ruleCalculator.Rules.Add(new BuffRule(430674) { IconIndex = 1, MinimumIconCount = 0, DisableName = true }); // Arcane
_ruleCalculator.Rules.Add(new BuffRule(430674) { IconIndex = 2, MinimumIconCount = 0, DisableName = true }); // Cold
_ruleCalculator.Rules.Add(new BuffRule(430674) { IconIndex = 3, MinimumIconCount = 0, DisableName = true }); // Fire
_ruleCalculator.Rules.Add(new BuffRule(430674) { IconIndex = 4, MinimumIconCount = 0, DisableName = true }); // Holy
_ruleCalculator.Rules.Add(new BuffRule(430674) { IconIndex = 5, MinimumIconCount = 0, DisableName = true }); // Lightning
_ruleCalculator.Rules.Add(new BuffRule(430674) { IconIndex = 6, MinimumIconCount = 0, DisableName = true }); // Physical
_ruleCalculator.Rules.Add(new BuffRule(430674) { IconIndex = 7, MinimumIconCount = 0, DisableName = true }); // Poison
}

private IEnumerable<BuffRule> GetCurrentRules(HeroClass heroClass)
{
for (int i = 1; i <= 7; i++)
{
switch (heroClass)
{
case HeroClass.Barbarian: if (i == 1 || i == 4 || i == 7) continue; break;
case HeroClass.Crusader: if (i == 1 || i == 2 || i == 7) continue; break;
case HeroClass.DemonHunter: if (i == 1 || i == 4 || i == 7) continue; break;
case HeroClass.Monk: if (i == 1 || i == 7) continue; break;
case HeroClass.WitchDoctor: if (i == 1 || i == 4 || i == 5) continue; break;
case HeroClass.Wizard: if (i == 4 || i == 6 || i == 7) continue; break;
}
yield return _ruleCalculator.Rules[i - 1];
}
}

public void PaintTopInGame(ClipState clipState)
{
if (clipState != ClipState.BeforeClip) return;
if (HideWhenUiIsHidden && Hud.Render.UiHidden) return;

foreach (var player in Hud.Game.Players)
{
if (player.IsMe)
{
var buff = player.Powers.GetBuff(430674);

if ((buff == null) || (buff.IconCounts[0] <= 0)) break; 

var classSpecificRules = GetCurrentRules(player.HeroClassDefinition.HeroClass);

_ruleCalculator.CalculatePaintInfo(player, classSpecificRules);

if (_ruleCalculator.PaintInfoList.Count == 0) return;
if (!_ruleCalculator.PaintInfoList.Any(info => info.TimeLeft > 0)) return;

var highestElementalBonus = player.Offense.HighestElementalDamageBonus;

for (int i = 0; i < _ruleCalculator.PaintInfoList.Count; i++)
 {
var info = _ruleCalculator.PaintInfoList[0];

if (info.TimeLeft <= 0)
{
_ruleCalculator.PaintInfoList.RemoveAt(0);
_ruleCalculator.PaintInfoList.Add(info);
}
else break;
}

for (int orderIndex = 0; orderIndex < _ruleCalculator.PaintInfoList.Count; orderIndex++)
{
var info = _ruleCalculator.PaintInfoList[orderIndex];
var best = false;

switch (info.Rule.IconIndex)
{
case 1: best = player.Offense.BonusToArcane == highestElementalBonus; break;
case 2: best = player.Offense.BonusToCold == highestElementalBonus; break;
case 3: best = player.Offense.BonusToFire == highestElementalBonus; break;
case 4: best = player.Offense.BonusToHoly == highestElementalBonus; break;
case 5: best = player.Offense.BonusToLightning == highestElementalBonus; break;
case 6: best = player.Offense.BonusToPhysical == highestElementalBonus; break;
case 7: best = player.Offense.BonusToPoison == highestElementalBonus; break;
}

if (best) info.Size *= 1.35f;

if (best && orderIndex > 0)
{
info.TimeLeft = (orderIndex - 1) * 4 + _ruleCalculator.PaintInfoList[0].TimeLeft;
}
else info.TimeLeftNumbersOverride = false;
}

var portraitRect = player.PortraitUiElement.Rectangle;

var x = portraitRect.Right * 8.05f;
var y = portraitRect.Top + portraitRect.Height * 1.56f;

BuffPainter.PaintHorizontal(_ruleCalculator.PaintInfoList, x, y, _ruleCalculator.StandardIconSize, 0);

break;
}
} // end foreach
} // end PaintTopInGame
} // end class
}

----------


## SeaDragon

不是很明白你说的什么意思

----------


## odaru7788

點巔峰 或技能時 元素戒的圖示都會在最上層 蓋在技能選單上

----------


## SeaDragon

if (clipState != ClipState.BeforeClip) return;
这行代码就是让它不覆盖游戏UI界面啊，但我看你代码里有这行

----------


## odaru7788

不知道 他就是會出現

----------


## SeaDragon

我用你的代码测试了，一切正常，没有出现遮挡情况

----------


## odaru7788

你開魔方看看 一開就檔

----------


## SeaDragon

从截图看，问题不在代码，而是插件本身的问题哈
只能让KJ解决
@KillJohn
The CanCubed can not cover the painting
By the way, it doesn't make any difference to me

----------


## misuny

Is there a way to make it show just 1 Icon that is Active?

----------


## gramoun

No feature for that
I m not sure it s a good idea
Objective is to, prepare to burst, when main skill is boosted by CoE
For that icon of element who has more % dmg is bigger
Counter indicate when it will be op
My advice, i m not conceptor

----------


## Stormreaver

Just wondering, why not use customize() method to add CoE BuffRules to *PlayerTopBuffListPlugin* under *BuffLists* ?

----------


## JarekCz

Is this up to date?
I copied both versions into 

plugins\Default\BuffLists\ConventionOfElementsBuffListPlugin.cs

But it did't work
Anything else that I need to do as well?

----------


## Stormreaver

Just use this in customize( ) method:



```
Hud.RunOnPlugin<PlayerBottomBuffListPlugin>(plugin =>
   {

		/*
		Convention of Elements Ring cycle per class (4s each), corresponding IconIndex:
		1 Arcane, 2 Cold, 3 Fire, 4 Holy, 5 Lightning, 6 Physical, 7 Poison
				
		BARB (4):	Cold, Fire, Lightning, Physical
		CRUS (4):	Fire, Holy, Lightning, Physical
		MONK (5):	Cold, Fire, Holy, Lightning, Physical
		DH   (4):	Cold, Fire, Lightning, Physical
		WD   (4):	Cold, Fire, Physical, Poison
		WIZ  (4):	Arcane, Cold, Fire, Lightning
		NEC  (3):	Cold, Physical, Poison
		*/

      		// COE: ALL
	plugin.RuleCalculator.Rules.Add(new BuffRule(430674) {
		IconIndex = null, MinimumIconCount = 1, ShowTimeLeft = true, IconSizeMultiplier = IS1, });
			
		// COE: Cold only
	plugin.RuleCalculator.Rules.Add(new BuffRule(430674) {
		 IconIndex = 2, MinimumIconCount = 1, ShowTimeLeft = true, IconSizeMultiplier = IS1, });
	
		// COE: Fire only
	plugin.RuleCalculator.Rules.Add(new BuffRule(430674) {
		IconIndex = 3, MinimumIconCount = 1, ShowTimeLeft = true, IconSizeMultiplier = IS1, });
			
		// COE: Lightning only
	plugin.RuleCalculator.Rules.Add(new BuffRule(430674) {
		IconIndex = 5, MinimumIconCount = 1, ShowTimeLeft = true, IconSizeMultiplier = IS1, });

   }
```

Included are some examples, just chose the ones u want

----------


## JarekCz

I get exceptions that ")" and ";" are missing. But when I try to put them after last bracket from your code, I get even more errors.
Can you help? Sorry, I'm a lousy programmer  :Smile:  My PluginEnablerOrDisablerPlugin.cs looks like that:




> public void Customize()
> {
> Hud.RunOnPlugin<PlayerBottomBuffListPlugin>(plugin =>
> {
> 
> /*
> Convention of Elements Ring cycle per class (4s each), corresponding IconIndex:
> 1 Arcane, 2 Cold, 3 Fire, 4 Holy, 5 Lightning, 6 Physical, 7 Poison
> 
> ...

----------


## Stormreaver

Try this:


```
public void Customize()
{
	
	Hud.RunOnPlugin<PlayerBottomBuffListPlugin>(plugin =>
	{

		/*
		Convention of Elements Ring cycle per class (4s each), corresponding IconIndex:
		1 Arcane, 2 Cold, 3 Fire, 4 Holy, 5 Lightning, 6 Physical, 7 Poison

		BARB (4):	Cold, Fire, Lightning, Physical
		CRUS (4):	Fire, Holy, Lightning, Physical
		MONK (5):	Cold, Fire, Holy, Lightning, Physical
		DH (4):	Cold, Fire, Lightning, Physical
		WD (4):	Cold, Fire, Physical, Poison
		WIZ (4):	Arcane, Cold, Fire, Lightning
		NEC (3):	Cold, Physical, Poison
		*/
		
		// COE: Lightning only
		plugin.RuleCalculator.Rules.Add(new BuffRule(430674) {
		IconIndex = 5, MinimumIconCount = 1, ShowTimeLeft = true, IconSizeMultiplier = 1.0f, });
		
	});
}
```

----------


## JarekCz

Now it says it cannot find „RuleCalculator” in current context.
I have a feeling I'm missing some basics.

Should I do anything else except renaming file from .txt to .cs?

Entire file looks like that:



```
using Turbo.Plugins.Default;
namespace Turbo.Plugins.User
{

    public class PluginEnablerOrDisablerPlugin : BasePlugin, ICustomizer
    {

        public PluginEnablerOrDisablerPlugin()
        {
            Enabled = true;
        }

        public override void Load(IController hud)
        {
            base.Load(hud);
        }

public void Customize()
{
	
	Hud.RunOnPlugin<PlayerBottomBuffListPlugin>(plugin =>
	{

		/*
		Convention of Elements Ring cycle per class (4s each), corresponding IconIndex:
		1 Arcane, 2 Cold, 3 Fire, 4 Holy, 5 Lightning, 6 Physical, 7 Poison

		BARB (4):	Cold, Fire, Lightning, Physical
		CRUS (4):	Fire, Holy, Lightning, Physical
		MONK (5):	Cold, Fire, Holy, Lightning, Physical
		DH (4):	Cold, Fire, Lightning, Physical
		WD (4):	Cold, Fire, Physical, Poison
		WIZ (4):	Arcane, Cold, Fire, Lightning
		NEC (3):	Cold, Physical, Poison
		*/
		
		// COE: Lightning only
		RuleCalculator.Rules.Add(new BuffRule(430674) {
		IconIndex = 5, MinimumIconCount = 1, ShowTimeLeft = true, IconSizeMultiplier = 1.0f, });
		
	}); //Hud.RunOnPlugin<PlayerBottomBuffListPlugin>(plugin =>

} //public void Customize()
} //public class PluginEnablerOrDisablerPlugin : BasePlugin, ICustomizer
} //namespace Turbo.Plugins.User
```

----------


## Stormreaver

Try the code now.
The word *plugin.* was missing before 

```
RuleCalculator.Rules.Add(new BuffRule(79528)
```

 :P

----------


## JarekCz

Thanks, it works now.

----------

