Jump to content

__SetItemTitle uitooltip.py - New Pet System


Recommended Posts

  • Bot

Hello, I am trying to put the name of the pet as the item title, something like in the official servers.

This is the code that contains the uipetsystem.py file by default:

class PetSystemMain(ui.ScriptWindow):

	def SetDefaultInfo(self):
		[...]
		self.petname.SetText("")
		[...]

	def SetName(self, name):
		if name != "":
			self.nutribtn.Enable()
			self.sviluppobtn.Enable()
			self.itemexp.Enable()
		else:
			self.nutribtn.Disable()
			self.sviluppobtn.Disable()
			self.itemexp.Disable()
		self.petname.SetText(name)

 

uitooltip.py:

This is the code that contains the uitooltip.py file by default:

import uipetsystem

def SetTitle(self, name):
	self.AppendTextLine(name, self.TITLE_COLOR)

def __SetItemTitle(self, itemVnum, metinSlot, attrSlot):
	[...]
	# I added this within the definition
	if itemVnum >=55701 and itemVnum <= 55704:
		self.__SetPetItemTitle()
	[...]

And I added two new definitions:

def __SetPetName(self, name):
	uipetsystem.PetSystemMain().SetName(name)
	self.AppendTextLine(name)

def __SetPetItemTitle(self):
	self.SetTitle(self.__SetPetName)

But it is not displayed when the cursor is moved to the item.

45acf8eba082b8e49bf7b51e77e43842.png

If I put a title manually, it does read it.

def __SetPetItemTitle(self):
	self.SetTitle("HelloWorld")

7d3726bd2c1ec01b0f1b5d2e227a4216.png

What am I doing wrong?

Please, if someone can give me a clue or help me.

Thanks in advance.

Edited by Metin2 Dev
Core X - External 2 Internal

english_banner.gif

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Premium

I don't have tutorial for new_pet system but maybe those codes will help you finding the right way:

game.py

	if app.NEW_PET_SYSTEM:
		def SetPetEvolution(self, evo):
			petname = ["Jung", "Wild", "Tapfer", "Heroisch"]
			self.petmain.SetEvolveName(petname[int(evo)])
			constInfo.PETMINIEVO = int(evo)

		def SetPetName(self, name):
			if len(name) > 1 and name != "":
				self.petmini.Show()
			self.petmain.SetName(name)

		def SetPetLevel(self, level):
			self.petmain.SetLevel(level)
			constInfo.PETMINILEVEL = int(level)

		def SetPetDuration(self, dur, durt):
			if int(durt) > 0:
				self.petmini.SetDuration(dur, durt)
			self.petmain.SetDuration(dur, durt)

		def SetPetBonus(self, hp, dif, sp):
			self.petmain.SetHp(hp)
			self.petmain.SetDef(dif)
			self.petmain.SetSp(sp)

		def SetPetskill(self, slot, idx, lv):
			#chat.AppendChat(chat.CHAT_TYPE_INFO, "slot %d %d" % (int(slot),int(idx)))
			self.petmini.SetSkill(slot, idx, lv)
			self.petmain.SetSkill(slot, idx, lv)
			self.affectShower.BINARY_NEW_AddAffect(5400+int(idx),int(constInfo.LASTAFFECT_POINT)+1,int(constInfo.LASTAFFECT_VALUE)+1, 0)
			if int(slot)==0:
				constInfo.SKILL_PET1=5400+int(idx)
			if int(slot)==1:
				constInfo.SKILL_PET2=5400+int(idx)
			if int(slot)==2:
				constInfo.SKILL_PET3=5400+int(idx)

		def SetPetIcon(self, vnum):
			if int(vnum) > 0:
				self.petmini.SetImageSlot(vnum)
			self.petmain.SetImageSlot(vnum)
			
		def SetPetExp(self, exp, expi, exptot):
			if int(exptot) > 0:
				self.petmini.SetExperience(exp, expi, exptot)
			self.petmain.SetExperience(exp, expi, exptot)

		def PetUnsummon(self):
			self.petmini.SetDefaultInfo()
			self.petmini.Close()
			self.petmain.SetDefaultInfo()
			self.affectShower.BINARY_NEW_RemoveAffect(int(constInfo.SKILL_PET1),0)
			self.affectShower.BINARY_NEW_RemoveAffect(int(constInfo.SKILL_PET2),0)
			self.affectShower.BINARY_NEW_RemoveAffect(int(constInfo.SKILL_PET3),0)
			constInfo.SKILL_PET1 = 0
			constInfo.SKILL_PET2 = 0
			constInfo.SKILL_PET3 = 0

		def OpenPetMainGui(self):
			if constInfo.PETGUI == 0:
				self.petmain.Show()
				self.petmain.SetTop()
				constInfo.PETGUI = 1
			else:
				self.petmain.Close()
				constInfo.PETGUI = 0

		def OpenPetIncubator(self, pet_new = 0):
			import uipetincubatrice
			self.petinc = uipetincubatrice.PetSystemIncubator(pet_new)
			self.petinc.Show()
			self.petinc.SetTop()
			
		def OpenPetMini(self):
			self.petmini.Show()
			self.petmini.SetTop()

		def OpenPetFeed(self):
			self.feedwind = uipetfeed.PetFeedWindow()
			self.feedwind.Show()
			self.feedwind.SetTop()

 

uitooltip.py

Before import

if app.NEW_PET_SYSTEM:
	def pointop(n):
		t = int(n)
		if t / 10 < 1:
			return "0."+n
		else:		
			return n[0:len(n)-1]+"."+n[len(n)-1:]
                      
Before AddItemData

	if app.NEW_PET_SYSTEM:
		def check_sigillo(self, item_vnum):
			for x in range(55701,55706):
				if x == item_vnum:
					return TRUE	
			if item_vnum == 55801:
				return TRUE
			return FALSE
               
On AddItemData function, after
		### Description ###
		self.AppendDescription(itemDesc, 26)
		self.AppendDescription(itemSummary, 26, self.CONDITION_COLOR)
                      
		if app.NEW_PET_SYSTEM:
			if self.check_sigillo(itemVnum) or itemVnum == 55002 or itemVnum == 55706:
				if attrSlot[0][1] != 0:
					self.AppendSpace(5)
					self.AppendTextLine("Level: "+str(metinSlot[1]), self.NORMAL_COLOR)
					self.AppendTextLine("TP: +"+pointop(str(attrSlot[0][1]))+"%", self.SPECIAL_POSITIVE_COLOR)
					self.AppendTextLine("DEF: +"+pointop(str(attrSlot[1][1]))+"%", self.SPECIAL_POSITIVE_COLOR)
					self.AppendTextLine("MP: +"+pointop(str(attrSlot[2][1]))+"%", self.SPECIAL_POSITIVE_COLOR)
					self.AppendSpace(5)
					if itemVnum != 55002:
						days = (int(attrSlot[3][1])/60)/24
						hours = (int(attrSlot[3][1]) - (days*60*24)) / 60
						mins = int(attrSlot[3][1]) - (days*60*24) - (hours*60)
						self.AppendTextLine("Verbl. Zeit: %d Tage %d Std. %d Min." % (days, hours, mins), self.SPECIAL_POSITIVE_COLOR)

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

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.