Jump to content

Poisoning HP Effect


Recommended Posts

  • Honorable Member

 

M2 Download Center

This is the hidden content, please
( Internal )

305521Action-30-11-2021-11-16-01.gif

30564833.gif

When a player or monster is poisoned, a poisoning effect will appear in the life bar.
The idea belongs to Whistlee
 from the Turkish forum. However, in Whistlee version this system does not work for monsters and has no connection with the source code, so the effect is visible only to us.
I don't know if I can give a specific place where the original comes from, so I won't do it, but I put here github Whistlee's, where you can find the original code. GITHUB: 

This is the hidden content, please

 

Special thanks for helping me with this code for Intern,VegaS™ and HITRON.

////////// CLIENT GAME

Spoiler

 

01. Open taskbar.py (root/locale/?????/ui) and find this:

						{
							"name" : "HPRecoveryGaugeBar",
							"type" : "bar",

							"x" : 0,
							"y" : 0,
							"width" : 95,
							"height" : 13,
							"color" : 0x55ff0000,
						},
						{
							"name" : "HPGauge",
							"type" : "ani_image",

							"x" : 0,
							"y" : 0,

							"delay" : 6,

							"images" :
							(
								"D:/Ymir Work/UI/Pattern/HPGauge/01.tga",
								"D:/Ymir Work/UI/Pattern/HPGauge/02.tga",
								"D:/Ymir Work/UI/Pattern/HPGauge/03.tga",
								"D:/Ymir Work/UI/Pattern/HPGauge/04.tga",
								"D:/Ymir Work/UI/Pattern/HPGauge/05.tga",
								"D:/Ymir Work/UI/Pattern/HPGauge/06.tga",
								"D:/Ymir Work/UI/Pattern/HPGauge/07.tga",
							),
						},

and under add this:

						{
							"name" : "HPPoisonRecoveryGaugeBar",
							"type" : "bar",

							"x" : 0,
							"y" : 0,
							"width" : 95,
							"height" : 13,
							"color" : 0x55008000,
						},
						{
							"name" : "HPPoisonGauge",
							"type" : "ani_image",

							"x" : 0,
							"y" : 0,

							"delay" : 6,

							"images" :
							(
								"D:/Ymir Work/UI/Pattern/HPPoisonGauge/01.tga",
								"D:/Ymir Work/UI/Pattern/HPPoisonGauge/02.tga",
								"D:/Ymir Work/UI/Pattern/HPPoisonGauge/03.tga",
								"D:/Ymir Work/UI/Pattern/HPPoisonGauge/04.tga",
								"D:/Ymir Work/UI/Pattern/HPPoisonGauge/05.tga",
								"D:/Ymir Work/UI/Pattern/HPPoisonGauge/06.tga",
								"D:/Ymir Work/UI/Pattern/HPPoisonGauge/07.tga",
							),
						},

02. Open ui.py (root/) and at the end of the class: class Gauge(Window): add this:

	if app.ENABLE_POISON_GAUGE_EFFECT:
		def SetGaugeColor(self, color):
			if self.imgGauge:
				self.imgGauge.LoadImage("d:/ymir work/ui/pattern/gauge_" + color + ".tga")

03. Open uiparty.py (root/) and at the beginning of the file add this:

Attention! Don't add an import app if it's already in the file!

import app

if app.ENABLE_POISON_GAUGE_EFFECT:
	import chr
	import chrmgr

find this:

		hpPercentage = max(0, hpPercentage)

and above add it:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			if chrmgr.HasAffectByVID(self.GetCharacterVID(), chr.AFFECT_POISON):
				self.gauge.SetGaugeColor("lime")
			else:
				self.gauge.SetGaugeColor("red")

04. Open uiplayergauge.py (root/) and at the beginning of the file add this:

Attention! Don't add an import app if it's already in the file!

import app

if app.ENABLE_POISON_GAUGE_EFFECT:
	import chrmgr

find this:

		self.SetPercentage(self.curHP, self.maxHP)

and above add it:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			if chrmgr.HasAffectByVID(player.GetMainCharacterIndex(), chr.AFFECT_POISON):
				self.SetGaugeColor("lime")
			else:
				self.SetGaugeColor("red")

05. Open uitarget.py (root/) and at the beginning of the file add this:

Attention! Don't add an import app if it's already in the file!

import app

if app.ENABLE_POISON_GAUGE_EFFECT:
	import chrmgr

find this:

		hpGauge = ui.Gauge()
		hpGauge.SetParent(self)
		hpGauge.MakeGauge(130, "red")
		hpGauge.Hide()

and under add this:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			hpPoisonGauge = ui.Gauge()
			hpPoisonGauge.SetParent(self)
			hpPoisonGauge.MakeGauge(130, "lime")
			hpPoisonGauge.SetPosition(175, 17)
			hpPoisonGauge.SetWindowHorizontalAlignRight()
			hpPoisonGauge.Hide()

find this:

		self.hpGauge = None

Attention! There may be more these self.hpGauge = None lines in the file. If yes, make changes under all.

and under add this:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			self.hpPoisonGauge = None

find this:

		self.hpGauge = hpGauge

and under add this:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			self.hpPoisonGauge = hpPoisonGauge

find this:

		self.hpGauge.Hide()

and under add this:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			self.hpPoisonGauge.Hide()

find this:

		self.hpGauge.SetPercentage(hpPercentage, 100)

and under add this:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			self.hpPoisonGauge.SetPercentage(hpPercentage, 100)

find this:

	def OnUpdate(self):

and under add this:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			if self.hpGauge and self.hpGauge.IsShow():
				if chrmgr.HasAffectByVID(self.GetTargetVID(), chr.AFFECT_POISON):
					self.hpPoisonGauge.Show()
				else:
					self.hpPoisonGauge.Hide()

06. Open uitaskbar.py (root/) and at the beginning of the file add this:

Attention! Don't add an import app if it's already in the file!

import app

if app.ENABLE_POISON_GAUGE_EFFECT:
	import chr
	import chrmgr

find this:

		self.spRecoveryGaugeBar = self.GetChild("SPRecoveryGaugeBar")

and under add this:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			self.hpPoisonGauge = self.GetChild("HPPoisonGauge")
			self.hpPoisonRecoveryGaugeBar = self.GetChild("HPPoisonRecoveryGaugeBar")
			self.hpPoisonGauge.Hide()
			self.hpPoisonRecoveryGaugeBar.Hide()

find this:

		self.spRecoveryGaugeBar = None

and under add this:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			self.hpPoisonGauge = None
			self.hpPoisonRecoveryGaugeBar = None

find this:

		self.SetHP(curHP, recoveryHP, maxHP)

and under add this:

		if app.ENABLE_POISON_GAUGE_EFFECT:
			if chrmgr.HasAffectByVID(player.GetMainCharacterIndex(), chr.AFFECT_POISON):
				self.hpGauge.Hide()
				self.hpPoisonGauge.Show()
			else:
				self.hpPoisonGauge.Hide()
				self.hpGauge.Show()

find this:

			self.hpGauge.SetPercentage(curPoint, maxPoint)

and under add this:

			if app.ENABLE_POISON_GAUGE_EFFECT:
				self.hpPoisonGauge.SetPercentage(curPoint, maxPoint)

in function:

	def SetHP(self, curPoint, recoveryPoint, maxPoint):

find this:

			if 0 == recoveryPoint:

and under add this:

				if app.ENABLE_POISON_GAUGE_EFFECT:
						self.hpPoisonRecoveryGaugeBar.Hide()

find this:

				self.hpRecoveryGaugeBar.SetSize(newWidth, self.GAUGE_HEIGHT)
				self.hpRecoveryGaugeBar.Show()

and above add it:

				if app.ENABLE_POISON_GAUGE_EFFECT:
					if chrmgr.HasAffectByVID(player.GetMainCharacterIndex(), chr.AFFECT_POISON):
						if self.hpRecoveryGaugeBar.IsShow():
							self.hpRecoveryGaugeBar.Hide()
						self.hpPoisonRecoveryGaugeBar.SetSize(newWidth, self.GAUGE_HEIGHT)
						self.hpPoisonRecoveryGaugeBar.Show()
						return
					else:
						if self.hpPoisonRecoveryGaugeBar.IsShow():
							self.hpPoisonRecoveryGaugeBar.Hide()

07. Ddd to our game this: 

This is the hidden content, please

 

 

////////// SOURCE BIN

Spoiler

 

01. Open locale_inc.h (client\UserInterface) and add to the file:

#define ENABLE_POISON_GAUGE_EFFECT

02. Open PythonApplicationModule.cpp (client\UserInterface) and find this:

#ifdef USE_OPENID
	PyModule_AddIntConstant(poModule, "USE_OPENID",	1);

and above add it:

#ifdef ENABLE_POISON_GAUGE_EFFECT
	PyModule_AddIntConstant(poModule, "ENABLE_POISON_GAUGE_EFFECT",	1);
#else
	PyModule_AddIntConstant(poModule, "ENABLE_POISON_GAUGE_EFFECT",	0);
#endif

03. Open PythonCharacterManagerModule.cpp (client\UserInterface) and find this:

void initchrmgr()

and above add it:

#ifdef ENABLE_POISON_GAUGE_EFFECT
PyObject * chrmgrHasAffectByVID(PyObject * poSelf, PyObject * poArgs)
{
	int iVID, iAffect;

	if (!PyTuple_GetInteger(poArgs, 0, &iVID))
		return Py_BadArgument();

	if (!PyTuple_GetInteger(poArgs, 1, &iAffect))
		return Py_BadArgument();

	CPythonCharacterManager & rkChrMgr = CPythonCharacterManager::Instance();

	CInstanceBase * p = rkChrMgr.CPythonCharacterManager::GetInstancePtr(iVID);

	if (p)
		return Py_BuildValue("i", p->IsAffect(iAffect));

	return Py_BuildNone();
}
#endif

find this:

		{ NULL,							NULL,									NULL },

and above add it:

#ifdef ENABLE_POISON_GAUGE_EFFECT
		{ "HasAffectByVID",				chrmgrHasAffectByVID,					METH_VARARGS },
#endif

 

 

Edited by Tatsumaru
  • Metin2 Dev 125
  • Eyes 1
  • Not Good 1
  • Cry 1
  • Smile Tear 2
  • Scream 1
  • Lmao 1
  • Good 30
  • Love 6
  • Love 78

GhwYizE.gif

Link to comment
Share on other sites

  • Forum Moderator

You don't need server source for this, you can do it directly via source client.

For being in real time you'll need to do a boolean variable inside of CInstanceBase class which is updated from RecvAffectAddPacketRecvAffectRemovePacket for each instance.

So with that you could do a function like chrmgr.IsPoisoned(self.GetTargetVID()) which will result the status of poison for specific vid and check it in OnUpdate.

Btw, the implementation is very bad, if i would want to do this, i don't touch the hpGauge, just add a new gauge bar over the hpGauge and hide/show it, that's all, could be done just with few lines, without ☠️ the python. 

This is the hidden content, please

 

Edited by VegaS™
  • Metin2 Dev 88
  • Sad 1
  • Think 2
  • Confused 2
  • Scream 1
  • Good 19
  • Love 2
  • Love 36
Link to comment
Share on other sites

  • Bronze
1 hour ago, VegaS™ said:

You don't need server source for this, you can do it directly via source client.

For being in real time you'll need to do a boolean variable inside of CInstanceBase class which is updated from RecvAffectAddPacketRecvAffectRemovePacket for each instance.

So with that you could do a function like chrmgr.IsPoisoned(self.GetTargetVID()) which will result the status of poison for specific vid and check it in OnUpdate.

Btw, the implementation is very bad, if i would want to do this, i don't touch the hpGauge, just add a new gauge bar over the hpGauge and hide/show it, that's all, could be done just with few lines, without ☠️ the python.

 

Or you can simply use chrmgr.HasAffectByVID(self.GetTargetVID(), chr.AFFECT_POISON) in Python instead to add this new functions that is not really needed to check if the vid is poisoned and you can change it also to AFFECT_BLEEDING, AFFECT_FIRE etc less code and the SetPoison etc is not really needed cause the OnUpdate will update it anyways in every player that have selected the vid thats is poisoned and sow on.

 

Function: HasAffectByVID

PyObject * chrmgrHasAffectByVID(PyObject * poSelf, PyObject * poArgs)
{
	int iVID, iAffect;

	if (!PyTuple_GetInteger(poArgs, 0, &iVID))
		return Py_BadArgument();

	if (!PyTuple_GetInteger(poArgs, 1, &iAffect))
		return Py_BadArgument();

	CPythonCharacterManager & rkChrMgr = CPythonCharacterManager::Instance();

	CInstanceBase * p = rkChrMgr.CPythonCharacterManager::GetInstancePtr(iVID);

	if (p)
		return Py_BuildValue("i", p->IsAffect(iAffect));

	return Py_BuildNone();
}

 

Edited by HITRON
  • Love 1
Link to comment
Share on other sites

  • Forum Moderator
12 minutes ago, HITRON said:

Or you can simply use chrmgr.HasAffectByVID(self.GetTargetVID(), chr.AFFECT_POISON) in Python instead to add new code in c++ to check if the vid is poisoned and you can change it also to AFFECT_BLEEDING, AFFECT_FIRE etc less code.

 

You're wrong, i don't know from where you copy-paste this function, this isn't by default in metin2 source.

Could be done this very easily too, but here we talked about the poisoning, why i should do something general for affects, this is another subject.

@xP3NG3Rx Already shared this but is implemented via CPythonPlayer, which means is just for your client instance, you've to implement it in CInstanceBase for each of player instance and will work fine or try to use IsAffect as well.

 

Edited by VegaS™
  • Love 1
Link to comment
Share on other sites

  • Bronze
1 minute ago, VegaS™ said:

 

You're wrong, i don't know from where you copy-paste this function, this isn't by default in metin2 source.

Could be done this very easily too, but here we talked about the poisoning, why i should do something general for affects, this is another subject.

@xP3NG3Rx Already shared this but is implemented via CPythonPlayer, which means is just for your client instance, you've to implement it in CInstanceBase for each of player instance and will work fine.

 

If you mean that the Poisoning is not updating in all characters that have clicked on the Target after or before then you are wrong, the function that i did long time ago that i don't even remember that is not existing in the metin2 source by default, is working pretty fine.

  • Love 1
Link to comment
Share on other sites

  • Forum Moderator
8 minutes ago, HITRON said:

If you mean that the Poisoning is not updating in all characters that have clicked on the Target after or before then you are wrong

I didn't mentioned anything about this. ?

I said just you're wrong because you told me, "use this instead of adding new code in c++", and i told you that this function from module doesn't exist in source, but you edited the topic when i replied and you added a new function, it's fine.

Let's chill, you take it too seriously.

Edited by VegaS™
  • Love 3
Link to comment
Share on other sites

  • Honorable Member

CODE UPDATE!

Now the code is shorter and more accurate than the previous version. There is no problem with the poisoning effect on the monster's life bar. General, I did not notice any problems in the operation of the poisoning effect after adding the new version.

 

Special thanks for helping me with this code for InternVegaS™ and HITRON.

Edited by Tatsumaru
  • Love 4

GhwYizE.gif

Link to comment
Share on other sites

8 minutes ago, Tatsumaru said:

CODE UPDATE!

Now the code is shorter and more accurate than the previous version. There is no problem with the poisoning effect on the monster's life bar. General, I did not notice any problems in the operation of the poisoning effect after adding the new version.

 

Special thanks for helping me with this code for Intern and VegaS™

 

Good job and thanks for sharing!

  • Love 1

mindset

Link to comment
Share on other sites

c5e60f44a10b64f75a1b95fe08bda5d7.gif

 

This is how the SetHP() part should look.

# uiTaskbar.py
# def SetHP(self, curPoint, recoveryPoint, maxPoint):

				if app.ENABLE_POISON_GAUGE_EFFECT:
					if chrmgr.HasAffectByVID(player.GetMainCharacterIndex(), chr.AFFECT_POISON):
						if self.hpRecoveryGaugeBar.IsShow():
							self.hpRecoveryGaugeBar.Hide()

						self.hpPoisonRecoveryGaugeBar.SetSize(newWidth, self.GAUGE_HEIGHT)
						self.hpPoisonRecoveryGaugeBar.Show()
					else:
						if self.hpPoisonRecoveryGaugeBar.IsShow():
							self.hpPoisonRecoveryGaugeBar.Hide()
						else:
							self.hpRecoveryGaugeBar.Show()

 

Edited by Metin2 Dev
Core X - External 2 Internal
  • Love 2
Link to comment
Share on other sites

@Cripplez

 

Look mob_proto like: 8001 is STUN,SLOW,CURSE,TERROR make it to STUN,SLOW,CURSE,TERROR,POISON

 

Control -> lenght.h EImmuneFlags like https://metin2.download/picture/O29kmI54cbrMhpk6qPlgR1dyyk9KwYum/.png

and ItemData.h -> is the same

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 1
  • Love 2
Link to comment
Share on other sites

  • 4 weeks later...
  • 3 weeks later...
  • 2 weeks later...
  • Bronze

1. 

Quote

 

0327 16:45:24836 :: uiParty:283: RuntimeWarning: tp_compare didn't return -1 or -2 for exception

0327 16:45:24836 :: Traceback (most recent call last):

0327 16:45:24836 ::   File "game.py", line 1266, in UpdatePartyMemberInfo

0327 16:45:24836 ::   File "interfaceModule.py", line 1140, in UpdatePartyMemberInfo

0327 16:45:24836 ::   File "uiParty.py", line 669, in UpdatePartyMemberInfo

0327 16:45:24836 ::   File "uiParty.py", line 283, in SetCharacterHP

0327 16:45:24836 :: TypeError
0327 16:45:24836 :: : 
0327 16:45:24836 :: an integer is required
0327 16:45:24838 :: 

 

when making party and the leader go offline appear this in syser and i understand is because of this.

2. still problem with poison bar on stone metin. any fix?

  • Not Good 1
Link to comment
Share on other sites

  • 3 weeks later...
  • 2 months later...
  • 1 year later...
  • Honorable Member
1 hour ago, Artix96it said:

The system seems incomplete. There are issues relating to the location of the Poison Bar at the time of poisoning, as well as issues relating to the party.

After 22 months, someone discovered that the system was incomplete. Doesn't that seem a little weird to you?

GhwYizE.gif

Link to comment
Share on other sites

4 minutes ago, Tatsumaru said:

After 22 months, someone discovered that the system was incomplete. Doesn't that seem a little weird to you?

I replied to the Thread because it interested me, regardless of the posting time. I noticed that other users had already stated that the System was not complete. In fact, the problems are different and quite annoying. I wonder why after a long time from publication, it still hasn't been fixed

Link to comment
Share on other sites

  • Honorable Member
1 hour ago, Artix96it said:

I replied to the Thread because it interested me, regardless of the posting time. I noticed that other users had already stated that the System was not complete. In fact, the problems are different and quite annoying. I wonder why after a long time from publication, it still hasn't been fixed

Because I do not experience the problems that people write about in this topic.

305521Action-30-11-2021-11-16-01.gif

30564833.gif

Edited by Tatsumaru

GhwYizE.gif

Link to comment
Share on other sites

Announcements



×
×
  • 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.