Jump to content

Recommended Posts

This is the hidden content, please

This is the hidden content, please

 

Greetings to all the community, I decided to improve the affectshower, I found a code that I really did not like at all, then I found a publication of @ filipw1 , but from my point of view was improvable, so I decided to work on it.

I want to clarify that I worked as a base the idea of @ filipw1 and I was modifying it as I was reading the changes that he made.

 

 

Changes

 

added the polyform visualization

added visual detail of image resizing, with setscale

added directory to add new affect as needed

 

			#here you can add new effects that do not require you to define them, 
			#for example the polymorph and if you want to add the blend
			allowed_affects = [
				chr.NEW_AFFECT_POLYMORPH,
			]
			#note in this way you can add new affect to show that you have defined, 
			# for example I created an affect to load by time the opening of the remote shop.
			# if app.BL_REMOTE_SHOP:
				# allowed_affects.append(chr.AFFECT_REMOTE_SHOP)


added SkillIndexToAffectIndex to get skill affect id, because BINARY_NEW_AddAffect we get the skill id directly

added extra information for skills

necessary modifications to the affectimage class and the definition BINARY_NEW_AddAffect

other minor changes

I know the code can be improved, I am open to hearing ways in which it can be improved.

I will be working on it and improving it as I see fit and will probably update the publication.

next updates:
removal of unnecessary code.
improvement of information.
remove affect
addition of blends affect
attribute information for necessary affects

spacer.png

 

I hope someone will find it useful, it is a first version.

  • Metin2 Dev 139
  • Eyes 1
  • Sad 1
  • Confused 1
  • Good 20
  • Love 2
  • Love 73
Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/
Share on other sites

 

Update 1.1:

a considerable amount of changes were updated, I recommend you to review well the affectimage class this was completely rewritten.

rewrote a considerable amount of changes in the class AffectImage(ui.ExpandedImageBox):

all the so-called ToolTip is now correct, according to how it should be used.

All unusable code has been removed.

added verifications for a control of the information being handled
 

self.isToolTipVisible = False  # The tooltip is not initially visible
self.skillIndex = None  # New attribute to store the skill index


the whole class is commented so that you understand the changes made, the problems that were previously had with the OnUpdate were solved.

so that ToolTip calls can now be handled correctly.

the SetToolTipText was modified and a check was added to prevent the information from being rewritten.

texts are now being loaded by AppendTextLine

the FormatTime was replaced now based on the idea that @ VegaS™ gave some time ago
 

		def FormatTime(self, time):
			if time < 0:
				return "0s"  # Be sure to manage negative times

			(d, remainder) = divmod(time, 86400)
			(h, remainder) = divmod(remainder, 3600)
			(m, s) = divmod(remainder, 60)

			# Create a list of non-empty values
			time_parts = [
				"{}d".format(d) if d > 0 else "",
				"{}h".format(h) if h > 0 else "",
				"{}m".format(m) if m > 0 else "",
				"{}s".format(s) if s > 0 else "",
			]

			# Filter out empty values and join them with a space
			formatted_time = " ".join(filter(None, time_parts))
			return formatted_time


we made changes in the UpdateSkillDescription, now it no longer receives the information directly so we work the information of the skill in a new definition "SetSkillIndex"

was removed SetClock is no longer required

in BINARY_NEW_AddAffect the way we send information was slightly modified, to handle the data correctly

in OnUpdate a check was added so that it only updates when necessary (when you use the mouse)

I also made a small change

 

if image.GetAffect() == chr.NEW_AFFECT_AUTO_HP_RECOVERY or image.GetAffect() == chr.NEW_AFFECT_AUTO_SP_RECOVERY:

we now work with in

if image.GetAffect() in [chr.NEW_AFFECT_AUTO_HP_RECOVERY, chr.NEW_AFFECT_AUTO_SP_RECOVERY]:

we also added to the OnUpdate the call to update the skills information

we add a new definition

 SyncAffectImages to keep the tooltip information updated, when showing and hiding the window (this is up to each one, I rewrote how I call the uiaffectshower, I manage it by interface and not by game)

added show definition to load SyncAffectImages 

I thought about working with the bonus value information that mali uses for the bonus window, but I don't think it's really necessary

if you notice any error, please report it, the code although I feel that I improved it, it can still be better, if any of you have any recommendation I will be delighted to hear it

 

next updates:

reworking of the __ArrangeImageList, to handle how we want the affect list to be displayed.

function to remove affect

update now available in git repository

  • Metin2 Dev 1
  • Good 1
  • muscle 2
  • Love 1
  • Love 1
Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/#findComment-170290
Share on other sites

Next update:

Is in testing at the moment, but so far it is working perfectly.

 

changes made:

 

Removed code added in the source by filip, no longer needed.

deleted code not in use

the code is now compatible with python3 for those who use it, it is still compatible with python2.

the __ArrangeImageList was rewritten, it works giving priority to lovePointImage and horseImage, then it works with a sort to order the affect list by priority, now it has a definition in which we calculate affect priority, where I have added priority to be first, priority to be last and it has 3 ranges where it works the grouping of the affects, mall, water and dew.
(is fully compatible with the contribution of comrade quin on the affect of dew and watter.)

the Onupdate received changes to have a little more performance, and be easier to understand (the improvement is minimal, but from my point of view is important).


added two lists to manage affect that you want to have priority to leave first or priority to leave last

	# Define priority lists
	PRIORITY_FIRST = {
		chr.NEW_AFFECT_AUTO_HP_RECOVERY,
		chr.NEW_AFFECT_AUTO_SP_RECOVERY,
		chr.AFFECT_ATT_SPEED_POTION,
		chr.AFFECT_MOV_SPEED_POTION,
	}  #These elements will appear first
	PRIORITY_LAST = {
		chr.NEW_AFFECT_POLYMORPH,
	}  # These elements will appear at the end
	if app.BL_REMOTE_SHOP:
		PRIORITY_LAST.add(chr.AFFECT_REMOTE_SHOP)


now we work with AutoAppendTextLine so we can keep any text inside the tooltip

added remove affect, allows to remove skills and poly, also added a list of affect that should not be removed to have a better control of the system, in order to avoid abuse of the command

There are more changes to improve the readability of the code but they are minimal.
when I finish the full testing phase I will probably release this update.

spacer.png

note: I dont know why the gif looks slow to me, but i dont have any lag or loss of performance when recording.

  • Metin2 Dev 2
  • Good 1
  • Love 1
Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/#findComment-170334
Share on other sites

It works smoothly and flawlessly. Thank you very much for your help and contributions @DeadOfLove

https://metin2.download/picture/Z3X841HX0FPOFns4l7RTsntQl90Fo9eu/.jpg

Edited by Metin2 Dev International
Core X - External 2 Internal
  • Love 1
Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/#findComment-170352
Share on other sites

  • 4 weeks later...
  • Active Member

Hello, i dont have any PRIORITY_FIRST 

0514 18:00:11215 :: global name 'PRIORITY_FIRST' is not defined

only this: 17e9230473e62252d0f14489e0ae3cd3.png

 

nothing else. can you check the repo please?

Edited by Metin2 Dev International
Core X - External 2 Internal
Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/#findComment-170767
Share on other sites

  • 3 weeks later...
On 5/14/2025 at 11:16 AM, Anielle Noir said:

Hello, i dont have any PRIORITY_FIRST 

0514 18:00:11215 :: global name 'PRIORITY_FIRST' is not defined

only this: 17e9230473e62252d0f14489e0ae3cd3.png

 

nothing else. can you check the repo please?

	# Define priority lists
	PRIORITY_FIRST = {
		chr.NEW_AFFECT_AUTO_HP_RECOVERY,
		chr.NEW_AFFECT_AUTO_SP_RECOVERY,
		chr.AFFECT_ATT_SPEED_POTION,
		chr.AFFECT_MOV_SPEED_POTION,
	}  #These elements will appear first
	PRIORITY_LAST = {
		chr.NEW_AFFECT_POLYMORPH,
	}  # These elements will appear at the end
	if app.BL_REMOTE_SHOP:
		PRIORITY_LAST.add(chr.AFFECT_REMOTE_SHOP)

check this should be outside of the classes, at the beginning of the file you could put it.

sorry for the late reply, I was traveling.

33 minutes ago, Klaus said:

Perfect!

Question: after teleporting, time is frozen until OnUpdate is called. When teleporting, wouldn't it be interesting to reset the currentTime variable so that time continues to run visually?

that was solved many patches ago, check how you made the guide

  • Love 2
Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/#findComment-171024
Share on other sites

Hey thanks for release ❤️

Buffs from others are not displayed any ideas?  

https://metin2.download/video/x6a8HQESNIUim633IZcYvZs5RGx05Jtt/.mp4

Edited by Metin2 Dev International
Core X - External 2 Internal
Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/#findComment-171095
Share on other sites

  • 2 months later...
On 8/22/2025 at 6:03 AM, xGalardo said:

If another player gives you a buff, you will not see the affect type, duration and value.
https://metin2.download/video/x6a8HQESNIUim633IZcYvZs5RGx05Jtt/.mp4

Its not a bug, dont publish that feature

Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/#findComment-171973
Share on other sites

  • 2 months later...
On 11/11/2025 at 8:25 PM, DeadOfLove said:

I will update the repository shortly

Thanks so much im waiting, also i have a bug after relog or teleport affect timer is frozen and not updating and ideas on fix?

 

    def OnUpdate(self):
        try:
            currentTime = app.GetGlobalTime()
            if currentTime - self.lastUpdateTime > self.TOOLTIP_UPDATE_INTERVAL:
                self.lastUpdateTime = currentTime

                for image in self.affectImageDict.values():
                    if not image.isToolTipVisible:
                        continue

                    if image.GetAffect() in [chr.NEW_AFFECT_AUTO_HP_RECOVERY, chr.NEW_AFFECT_AUTO_SP_RECOVERY]:
                        image.UpdateAutoPotionDescription()
                    elif image.IsSkillAffect():
                        image.UpdateSkillDescription()
                    else:
                        image.UpdateDescription()
        except Exception as e:
            print "AffectShower::OnUpdate error:", e
    if app.ENABLE_RENEWAL_AFFECT_SHOWER:
        def SyncAffectImages(self):
            for image in self.affectImageDict.values():
                image.isToolTipVisible = False
                image.toolTip.HideToolTip()

        def __QuestionRemoveAffect(self, arg, affect, name):
            self.RemoveQuestionDialog = uiCommon.QuestionDialog()
            self.RemoveQuestionDialog.SetText(localeInfo.AFFECT_REMOVE_QUESTION % name)
            self.RemoveQuestionDialog.SetAcceptEvent(lambda arg=True: self.AnswerRemoveAffect(arg))
            self.RemoveQuestionDialog.SetCancelEvent(lambda arg=False: self.AnswerRemoveAffect(arg))
            self.RemoveQuestionDialog.affect = affect
            self.RemoveQuestionDialog.Open()

        def AnswerRemoveAffect(self, flag):
            if not self.RemoveQuestionDialog:
                return
            if flag:
                net.SendChatPacket("/remove_affect %d" % self.RemoveQuestionDialog.affect)
            self.RemoveQuestionDialog.Close()
            self.RemoveQuestionDialog = None
		def UpdateDescription(self):
			if not self.toolTip:
				return

			if not self.description:
				return

			self.toolTip.ClearToolTip()

			self.toolTip.AutoAppendTextLine(self.description, self.BONUS_COLOR)
			if self.endTime > 0:
				remaining_time = self.endTime - app.GetGlobalTimeStamp()
				# If duration is absurdly large (e.g., 2+ years), treat as permanent
				if remaining_time > 63113904:  # 2 years in seconds
					timeText = "(Permanent)"
					self.toolTip.AutoAppendTextLine(timeText, self.NORMAL_COLOR)
				else:
					leftTime = self.FormatTime(remaining_time)
					timeText = "(%s : %s)" % (localeInfo.LEFT_TIME, leftTime)
					self.toolTip.AutoAppendTextLine(timeText, self.NORMAL_COLOR)

			if self.Canberemoved:
				self.toolTip.AutoAppendTextLine(localeInfo.AFFECTSHOWER_REMOVE_TEXT, self.NORMAL_COLOR)

			self.toolTip.AlignHorizonalCenter()
			self.toolTip.ResizeToolTip()

 

Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/#findComment-173034
Share on other sites

On 11/11/2025 at 5:25 PM, DeadOfLove said:

I will update the repository shortly

The system works as expected, without any issues.
However, as mentioned before, it could use an update so that when receiving buffs from other characters, the skill duration is also displayed — not just the one from the player’s own character.
Other than that, the system is perfect and works very well.
I had to add some code to make it work, mainly missing code related to remove_affect, but apart from that, it’s perfect.

  • Love 1
Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/#findComment-173037
Share on other sites

  • 3 weeks later...
22 hours ago, Dex666 said:

author probably abandoned the project 😩

Does anyone know how to add time to purple and green potion

AylMJhv.png  to make it looks like this cRGXbjr.png

I have not abandoned the project. If you are looking for information about purple positions, you must make changes to your server to obtain the information. Secondly, this is a free publication, which means that whenever I have free time, I will update it as I see fit. Therefore, I may refuse to make specific changes that you request.

 

 Updated Repository:

There are minor changes in the code that i thought were necessary.

Added functions to the server source code. Please note that this is modern code, so if you need C++ version 14, it may work in 11, but keep in mind that changes may be necessary.

Inside, i have added a list of affects that cannot be deleted. If you want to change it, you can edit it.
 

	constexpr std::array<DWORD, 9> nonRemovableAffects = {
		AFFECT_BLEND,
		AFFECT_MOV_SPEED,
		AFFECT_ATT_SPEED,
		AFFECT_BLOCK_CHAT,
		AFFECT_POISON,
		AFFECT_STUN,
		AFFECT_SLOW,
		AFFECT_FIRE,
		66 // ID additional
	};

 

Please remember that this is a contribution to the community.

I do not provide support if you want me to change the system. If you have ideas that could improve the code or how it works, i would be happy to hear them.

If you want to modify it and have questions, you can ask.

Sometimes i have a lot of work, so if i dont respond in the forum, you can write to me on Discord.

 

 

Edited by Metin2 Dev International
Core X - External 2 Internal
  • Metin2 Dev 5
  • Good 1
  • Love 1
Link to comment
https://metin2.dev/topic/33626-renewal-affect-shower/#findComment-173293
Share on other sites

Don't use any images from : imgur, turkmmop, freakgamers, inforge, hizliresim... Or your content will be deleted without notice...
Use : https://metin2.download/media/add/

Please use https://metin2.download/ when uploading files smaller than 100MB, otherwise the approval will take longer due to manual upload.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.