Jump to content
metin2dev
Dean

python Skills cooldown tooltip

Recommended Posts

Hi devs,

I'd like to share a script I developed the other night whilst working on a project, this script is meant to improve the quality of life of Metin2 as often players find it hard to accurately tell the cooldown of skills and end up spamming their keyboards like many of us have.

Preview:
0c51f0568e9284d618e245d2f28ac57d.png

Without any further ado, let's dig right into coding this bad boy.

First you will have to unpack your locale and look for taskbar.py in your ui folder and look for the following:

	"name" : "quick_slot_1",
	...
	"children" :

And replace the content of "children" : ( ... ), with this:

{
	"name" : "slot_1",
	"type" : "image",
	"x" : 3,
	"y" : 3,
	"image" : "d:/ymir work/ui/game/taskbar/1.sub",
	"children" :
	(
		{ 
			"name" : "slot_1_cd",
			"type" : "text",
			"x" : 0,
			"y" : 0,
			"horizontal_align" : "center",
			"vertical_align" : "center",
			"text" : "10",
			"fontname" : "Tahoma Bold:16",
			"r" : 1, "g" : 1, "b" : 0, "a" : 0,
		},
	),
},
{
	"name" : "slot_2",
	"type" : "image",
	"x" : 35,
	"y" : 3,
	"image" : "d:/ymir work/ui/game/taskbar/2.sub",
	"children" :
	(
		{ 
			"name" : "slot_2_cd",
			"type" : "text",
			"x" : 0,
			"y" : 0,
			"horizontal_align" : "center",
			"vertical_align" : "center",
			"text" : "10",
			"fontname" : "Tahoma Bold:16",
			"r" : 1, "g" : 1, "b" : 0, "a" : 0,
		},
	),
},
{
	"name" : "slot_3",
	"type" : "image",
	"x" : 67,
	"y" : 3,
	"image" : "d:/ymir work/ui/game/taskbar/3.sub",
	"children" :
	(
		{ 
			"name" : "slot_3_cd",
			"type" : "text",
			"x" : 0,
			"y" : 0,
			"horizontal_align" : "center",
			"vertical_align" : "center",
			"text" : "10",
			"fontname" : "Tahoma Bold:16",
			"r" : 1, "g" : 1, "b" : 0, "a" : 0,
		},
	),
},{
	"name" : "slot_4",
	"type" : "image",
	"x" : 99,
	"y" : 3,
	"image" : "d:/ymir work/ui/game/taskbar/4.sub",
	"children" :
	(
		{ 
			"name" : "slot_4_cd",
			"type" : "text",
			"x" : 0,
			"y" : 0,
			"horizontal_align" : "center",
			"vertical_align" : "center",
			"text" : "10",
			"fontname" : "Tahoma Bold:16",
			"r" : 1, "g" : 1, "b" : 0, "a" : 0,
		},
	),
},

Then look for:

	"name" : "quick_slot_1",
	...
	"children" :

And replace the content of its "children" : ( ... ), with the following:

{
	"name" : "slot_f1",
	"type" : "image",
	"x" : 3,
	"y" : 3,
	"image" : "d:/ymir work/ui/game/taskbar/f1.sub",
	"children" :
	(
		{ 
			"name" : "slot_f1_cd",
			"type" : "text",
			"x" : 0,
			"y" : 0,
			"horizontal_align" : "center",
			"vertical_align" : "center",
			"text" : "10",
			"fontname" : "Tahoma Bold:16",
			"r" : 1, "g" : 1, "b" : 0, "a" : 0,
		},
	),
},
{
	"name" : "slot_f2",
	"type" : "image",
	"x" : 35,
	"y" : 3,
	"image" : "d:/ymir work/ui/game/taskbar/f2.sub",
	"children" :
	(
		{ 
			"name" : "slot_f2_cd",
			"type" : "text",
			"x" : 0,
			"y" : 0,
			"horizontal_align" : "center",
			"vertical_align" : "center",
			"text" : "10",
			"fontname" : "Tahoma Bold:16",
			"r" : 1, "g" : 1, "b" : 0, "a" : 0,
		},
	),
},
{
	"name" : "slot_f3",
	"type" : "image",
	"x" : 67,
	"y" : 3,
	"image" : "d:/ymir work/ui/game/taskbar/f3.sub",
	"children" :
	(
		{ 
			"name" : "slot_f3_cd",
			"type" : "text",
			"x" : 0,
			"y" : 0,
			"horizontal_align" : "center",
			"vertical_align" : "center",
			"text" : "10",
			"fontname" : "Tahoma Bold:16",
			"r" : 1, "g" : 1, "b" : 0, "a" : 0,
		},
	),
},{
	"name" : "slot_f4",
	"type" : "image",
	"x" : 99,
	"y" : 3,
	"image" : "d:/ymir work/ui/game/taskbar/f4.sub",
	"children" :
	(
		{ 
			"name" : "slot_f4_cd",
			"type" : "text",
			"x" : 0,
			"y" : 0,
			"horizontal_align" : "center",
			"vertical_align" : "center",
			"text" : "10",
			"fontname" : "Tahoma Bold:16",
			"r" : 1, "g" : 1, "b" : 0, "a" : 0,
		},
	),
},

Now save your work in taskbar.py and pack your files.

Next we'll move onto root so I need you to unpack your root files and look for uitaskbar.py
Now I need you to look for the following line: self.quickslot = [] as you can see below:

self.quickslot = []
self.quickslot.append(self.GetChild("quick_slot_1"))
self.quickslot.append(self.GetChild("quick_slot_2"))

And then enter the following block of code above it:

self.cooldownText = []
self.cooldownText.append(self.GetChild("slot_1_cd"))
self.cooldownText.append(self.GetChild("slot_2_cd"))
self.cooldownText.append(self.GetChild("slot_3_cd"))
self.cooldownText.append(self.GetChild("slot_4_cd"))
self.cooldownText.append(self.GetChild("slot_f1_cd"))
self.cooldownText.append(self.GetChild("slot_f2_cd"))
self.cooldownText.append(self.GetChild("slot_f3_cd"))
self.cooldownText.append(self.GetChild("slot_f4_cd"))
for i in xrange(8):
	self.cooldownText[i-1].Hide()

Note: Please pay attention to code indentation

Afterwards you will need to search for:

if player.IsSkillCoolTime(Position):

and under it add the following:

(coolTime, elapsedTime) = player.GetSkillCoolTime(Position)
slot.SetSlotCoolTime(slotNumber, coolTime, elapsedTime)
cooldownDelay = 0
cooldown = coolTime-elapsedTime+cooldownDelay
self.cooldownText[slotNumber].Show()
self.cooldownText[slotNumber].SetText("%d" % cooldown)
self.cooldownText[slotNumber].SetOutline()
if cooldown < 10:
	self.cooldownText[slotNumber].SetPosition(7,0)
elif cooldown > 9 and cooldown < 100:
	self.cooldownText[slotNumber].SetPosition(2,0)
elif cooldown > 99:
	self.cooldownText[slotNumber].SetPosition(-1,0)

Note: Please pay attention to code indentation

Now make a new line under the whole code block of:

if player.IsSkillCoolTime(Position):

and add the following code:

elif not player.IsSkillCoolTime(Position):
	self.cooldownText[slotNumber].Hide()


Awesome! You should be good to go, now pack your root and head in for some testing!

If you encounter any bugs or you have suggestions please let me know! :D 
 

  • Like 6
  • Thanks 5

Share this post


Link to post
Share on other sites

That's a nice idea!

But I think I found a bug (or I messed up something when I pasted your code to my files).
When you go to another map the counters are freezing after you use a skill.

Share this post


Link to post
Share on other sites
On 7/31/2018 at 2:32 AM, Werwolf94 said:

That's a nice idea!

But I think I found a bug (or I messed up something when I pasted your code to my files).
When you go to another map the counters are freezing after you use a skill.

Hi there Werwolf, I have tested the potential bug you mentioned and I failed to encounter it.
The only aspect of the script which I'm still working on is the possibility to hide the cooldown whilst holding down Alt.
It's not a bug, just a simple adjustment I'd like to add in the future to assure 100% functionability.

Thank you all for the warm feedback, it gladdens me knowing my scripts are useful. :D 

Keep me posted if potential bugs arise.

Cheers!

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, [Dev]Medo said:

same bug here ...

 

 

 

 

Hi there Medo, could you record a video with the bug so I can get a better grasp of the issue and post it here?

Thank you!

Share this post


Link to post
Share on other sites

Works very well, thanks! :D

On 8/2/2018 at 6:03 AM, Dean said:

Hi there Werwolf, I have tested the potential bug you mentioned and I failed to encounter it.
The only aspect of the script which I'm still working on is the possibility to hide the cooldown whilst holding down Alt.
It's not a bug, just a simple adjustment I'd like to add in the future to assure 100% functionability.

Thank you all for the warm feedback, it gladdens me knowing my scripts are useful. :D 

Keep me posted if potential bugs arise.

Cheers!

And I solve your problem! :D

First of all we don't need this:

					elif not player.IsSkillCoolTime(Position):
						self.cooldownText[slotNumber].Hide()

Then search for this:

slotNumber = i+startNumber

And paste under this:

self.cooldownText[slotNumber].Hide()

That's all.

Share this post


Link to post
Share on other sites

Hi again!

I updated the two Py file and the "bug" still appears in my client when I go to another map.
In the video you can see when I go to an another map after that the cooldown text's are freezing.
If I press Alt the counters are keep going down.

 

Share this post


Link to post
Share on other sites

Hello,

 

I have a similiar error like Werwolf94.

For me the timers are stuck at 10.

 

This is my syserr:

 

0809 00:26:48145 :: Traceback (most recent call last):

0809 00:26:48145 ::   File "uiTaskBar.py", line 1007, in OnUpdate

0809 00:26:48145 ::   File "uiTaskBar.py", line 823, in RefreshQuickSlot

0809 00:26:48146 :: AttributeError
0809 00:26:48146 :: : 
0809 00:26:48146 :: 'TextLine' object has no attribute 'setText'
0809 00:26:48146 :: 

 

Share this post


Link to post
Share on other sites
En 5/8/2018 a las 23:15, Werwolf94 dijo:

Hi again!

I updated the two Py file and the "bug" still appears in my client when I go to another map.
In the video you can see when I go to an another map after that the cooldown text's are freezing.
If I press Alt the counters are keep going down.

 

Delete the uiTaskbar.py part from the guide.

Find this in def __OnUpdate(self):

		if True == self.expGaugeBoard.IsIn():
			self.tooltipEXP.Show()
		else:
			self.tooltipEXP.Hide()

Add this under:

		startNumber = 0
		for slot in self.quickslot:
			for i in xrange(4):
				slotNumber = i+startNumber
				(Type, Position) = player.GetLocalQuickSlot(slotNumber)
				if player.IsSkillCoolTime(Position):
					(coolTime, elapsedTime) = player.GetSkillCoolTime(Position)
					slot.SetSlotCoolTime(slotNumber, coolTime, elapsedTime)

					cooldownDelay = 0
					cooldown = int(coolTime-elapsedTime+cooldownDelay)
					self.cooldownText[slotNumber].SetOutline()
					self.cooldownText[slotNumber].SetText("%d" % cooldown)
					cooldown = str(cooldown)
					self.cooldownText[slotNumber].SetPosition((7, 2, -1)[len(cooldown) - 1],0)
					self.cooldownText[slotNumber].Show()
				else:
					self.cooldownText[slotNumber].Hide()
			startNumber += 4

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   1 member

×