Jump to content

Monster health


Recommended Posts

  • Premium
41 minutes ago, Artagnanxd said:

welcome to 2012 xd

Actually, it doesn't work the way you think. It sends the data from server to client so you have accurate health of the monster. Previously, if you had system based only on Python script, you had approximate value (ex 90% of 1.000.000 HP is 900.000 HP and 1% step is 10.000 HP so value isn't really close to the real one). 

  • Love 2
Link to comment
Share on other sites

  • 4 months later...
  • 6 months later...

help me please

.png

 

and i didint understand last lines bcs my english bad pls help me i will share my ui and uitarget

 

my ui.py:

class Gauge(Window):

	SLOT_WIDTH = 16
	SLOT_HEIGHT = 7

	GAUGE_TEMPORARY_PLACE = 12
	GAUGE_WIDTH = 16

	def __init__(self):
		Window.__init__(self)
		self.__oldValue = 0
		self.__newValue = 0
		self.width = 0

	def __del__(self):
		Window.__del__(self)

	def MakeGauge(self, width, color):

		self.width = max(48, width)

		imgSlotLeft = ImageBox()
		imgSlotLeft.SetParent(self)
		imgSlotLeft.LoadImage("d:/ymir work/ui/pattern/gauge_slot_left.tga")
		imgSlotLeft.Show()

		imgSlotRight = ImageBox()
		imgSlotRight.SetParent(self)
		imgSlotRight.LoadImage("d:/ymir work/ui/pattern/gauge_slot_right.tga")
		imgSlotRight.Show()
		imgSlotRight.SetPosition(width - self.SLOT_WIDTH, 0)

		imgSlotCenter = ExpandedImageBox()
		imgSlotCenter.SetParent(self)
		imgSlotCenter.LoadImage("d:/ymir work/ui/pattern/gauge_slot_center.tga")
		imgSlotCenter.Show()
		imgSlotCenter.SetRenderingRect(0.0, 0.0, float((width - self.SLOT_WIDTH*2) - self.SLOT_WIDTH) / self.SLOT_WIDTH, 0.0)
		imgSlotCenter.SetPosition(self.SLOT_WIDTH, 0)

		imgGaugeBack = ExpandedImageBox()
		imgGaugeBack.SetParent(self)
		imgGaugeBack.LoadImage("d:/ymir work/ui/pattern/gauge_yellow.tga")
		imgGaugeBack.Hide()
		imgGaugeBack.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
		imgGaugeBack.SetPosition(self.GAUGE_TEMPORARY_PLACE, 0)

		imgGauge = ExpandedImageBox()
		imgGauge.SetParent(self)
		imgGauge.LoadImage("d:/ymir work/ui/pattern/gauge_yellow.tga")
		imgGauge.Show()
		imgGauge.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
		imgGauge.SetPosition(self.GAUGE_TEMPORARY_PLACE, 0)

		imgSlotLeft.AddFlag("attach")
		imgSlotCenter.AddFlag("attach")
		imgGaugeBack.AddFlag("attach")
		imgSlotRight.AddFlag("attach")

	if app.BL_PARTY_UPDATE:
		def GaugeImgBoxAddFlag(self, flag):
			self.imgLeft.AddFlag(flag)
			self.imgCenter.AddFlag(flag)
			self.imgRight.AddFlag(flag)
			self.imgGauge.AddFlag(flag)

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

		self.imgLeft = imgSlotLeft
		self.imgCenter = imgSlotCenter
		self.imgRight = imgSlotRight
		self.imgGauge = imgGauge
		self.imgGaugeBack = imgGaugeBack

		self.SetSize(width, self.SLOT_HEIGHT)

	def SetPercentage(self, curValue, maxValue):

		# PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
		if maxValue > 0.0:
			percentage = min(1.0, float(curValue)/float(maxValue))
		else:
			percentage = 0.0
		# END_OF_PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR

		self.__oldValue = self.__newValue
		self.__newValue = percentage

		gaugeSize = -1.0 + float(self.width - self.GAUGE_TEMPORARY_PLACE*2) * percentage / self.GAUGE_WIDTH
		self.imgGauge.SetRenderingRect(0.0, 0.0, gaugeSize, 0.0)

		self.SetPercentageBack(self.__oldValue, 1.0)

	def SetPercentageBack(self, curValue, maxValue):
		if not self.imgGaugeBack.IsShow():
			self.imgGaugeBack.Show()

		if maxValue > 0.0:
			percentage = min(1.0, float(curValue) / float(maxValue))
		else:
			percentage = 0.0

		gaugeSize = -1.0 + float(self.width - self.GAUGE_TEMPORARY_PLACE * 2) * percentage / self.GAUGE_WIDTH
		self.imgGaugeBack.SetRenderingRect(0.0, 0.0, gaugeSize, 0.0)

	def OnUpdate(self):
		if self.IsShow() and self.__oldValue > self.__newValue:
			self.__oldValue = self.__oldValue - 0.005
			self.SetPercentageBack(self.__oldValue, 1.0)

 

my uitarget.py:

	def SetHP(self, hpNow, hpMax):
		if not self.hpGauge.IsShow():

			self.SetSize(200 + 7 * self.nameLength, self.GetHeight())
			self.name.SetPosition(23, 13)
			self.name.SetWindowHorizontalAlignLeft()
			self.name.SetHorizontalAlignLeft()

			self.hpGauge.Show()
			self.hpText.Show()
			self.UpdatePosition()

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

		self.hpGauge.SetPercentage(hpNow, hpMax)

		self.hpText.SetText("%s/%s (%.2f%%)" 
							% (localeInfo.NumberToMoneyString(hpNow)[:-5],
							   localeInfo.NumberToMoneyString(hpMax)[:-5],
							   max(0, (float(hpNow) / max(1, float(hpMax)) * 100))))

 

 

only the last lines

I wrote the other lines as they were

Edited by uncons
Link to comment
Share on other sites

5 hours ago, uncons said:

help me please

.png

 

and i didint understand last lines bcs my english bad pls help me i will share my ui and uitarget

 

my ui.py:

class Gauge(Window):

	SLOT_WIDTH = 16
	SLOT_HEIGHT = 7

	GAUGE_TEMPORARY_PLACE = 12
	GAUGE_WIDTH = 16

	def __init__(self):
		Window.__init__(self)
		self.__oldValue = 0
		self.__newValue = 0
		self.width = 0

	def __del__(self):
		Window.__del__(self)

	def MakeGauge(self, width, color):

		self.width = max(48, width)

		imgSlotLeft = ImageBox()
		imgSlotLeft.SetParent(self)
		imgSlotLeft.LoadImage("d:/ymir work/ui/pattern/gauge_slot_left.tga")
		imgSlotLeft.Show()

		imgSlotRight = ImageBox()
		imgSlotRight.SetParent(self)
		imgSlotRight.LoadImage("d:/ymir work/ui/pattern/gauge_slot_right.tga")
		imgSlotRight.Show()
		imgSlotRight.SetPosition(width - self.SLOT_WIDTH, 0)

		imgSlotCenter = ExpandedImageBox()
		imgSlotCenter.SetParent(self)
		imgSlotCenter.LoadImage("d:/ymir work/ui/pattern/gauge_slot_center.tga")
		imgSlotCenter.Show()
		imgSlotCenter.SetRenderingRect(0.0, 0.0, float((width - self.SLOT_WIDTH*2) - self.SLOT_WIDTH) / self.SLOT_WIDTH, 0.0)
		imgSlotCenter.SetPosition(self.SLOT_WIDTH, 0)

		imgGaugeBack = ExpandedImageBox()
		imgGaugeBack.SetParent(self)
		imgGaugeBack.LoadImage("d:/ymir work/ui/pattern/gauge_yellow.tga")
		imgGaugeBack.Hide()
		imgGaugeBack.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
		imgGaugeBack.SetPosition(self.GAUGE_TEMPORARY_PLACE, 0)

		imgGauge = ExpandedImageBox()
		imgGauge.SetParent(self)
		imgGauge.LoadImage("d:/ymir work/ui/pattern/gauge_yellow.tga")
		imgGauge.Show()
		imgGauge.SetRenderingRect(0.0, 0.0, 0.0, 0.0)
		imgGauge.SetPosition(self.GAUGE_TEMPORARY_PLACE, 0)

		imgSlotLeft.AddFlag("attach")
		imgSlotCenter.AddFlag("attach")
		imgGaugeBack.AddFlag("attach")
		imgSlotRight.AddFlag("attach")

	if app.BL_PARTY_UPDATE:
		def GaugeImgBoxAddFlag(self, flag):
			self.imgLeft.AddFlag(flag)
			self.imgCenter.AddFlag(flag)
			self.imgRight.AddFlag(flag)
			self.imgGauge.AddFlag(flag)

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

		self.imgLeft = imgSlotLeft
		self.imgCenter = imgSlotCenter
		self.imgRight = imgSlotRight
		self.imgGauge = imgGauge
		self.imgGaugeBack = imgGaugeBack

		self.SetSize(width, self.SLOT_HEIGHT)

	def SetPercentage(self, curValue, maxValue):

		# PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
		if maxValue > 0.0:
			percentage = min(1.0, float(curValue)/float(maxValue))
		else:
			percentage = 0.0
		# END_OF_PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR

		self.__oldValue = self.__newValue
		self.__newValue = percentage

		gaugeSize = -1.0 + float(self.width - self.GAUGE_TEMPORARY_PLACE*2) * percentage / self.GAUGE_WIDTH
		self.imgGauge.SetRenderingRect(0.0, 0.0, gaugeSize, 0.0)

		self.SetPercentageBack(self.__oldValue, 1.0)

	def SetPercentageBack(self, curValue, maxValue):
		if not self.imgGaugeBack.IsShow():
			self.imgGaugeBack.Show()

		if maxValue > 0.0:
			percentage = min(1.0, float(curValue) / float(maxValue))
		else:
			percentage = 0.0

		gaugeSize = -1.0 + float(self.width - self.GAUGE_TEMPORARY_PLACE * 2) * percentage / self.GAUGE_WIDTH
		self.imgGaugeBack.SetRenderingRect(0.0, 0.0, gaugeSize, 0.0)

	def OnUpdate(self):
		if self.IsShow() and self.__oldValue > self.__newValue:
			self.__oldValue = self.__oldValue - 0.005
			self.SetPercentageBack(self.__oldValue, 1.0)

 

my uitarget.py:

	def SetHP(self, hpNow, hpMax):
		if not self.hpGauge.IsShow():

			self.SetSize(200 + 7 * self.nameLength, self.GetHeight())
			self.name.SetPosition(23, 13)
			self.name.SetWindowHorizontalAlignLeft()
			self.name.SetHorizontalAlignLeft()

			self.hpGauge.Show()
			self.hpText.Show()
			self.UpdatePosition()

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

		self.hpGauge.SetPercentage(hpNow, hpMax)

		self.hpText.SetText("%s/%s (%.2f%%)" 
							% (localeInfo.NumberToMoneyString(hpNow)[:-5],
							   localeInfo.NumberToMoneyString(hpMax)[:-5],
							   max(0, (float(hpNow) / max(1, float(hpMax)) * 100))))

 

 

only the last lines

I wrote the other lines as they were

If u dont use BL_PARTY_UPDATE then delete this liens with it.

 

Link to comment
Share on other sites

1 hour ago, Hanma said:

BL_PARTY_UPDATE kullanmıyorsanız, onunla birlikte bu hacizleri silin.

 

I added it, but this time other errors started to appear, I think it's all errors related to the yellow effect because when I removed the things related to it, the system was added to the game, except for the effect.

this ss :  

Spoiler

.png

and this error : when i add BL_PARTY_UPDATE client source

new error:

.png

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.