Aller au contenu
Top-Metin2.org - Vous êtes à la recherche d'un serveur Metin 2 ? ×
×
×
  • Créer...

Python - Voir les PV après un Duel


Messages recommandés

  • Retraité

Centre de Téléchargement

Hidden Content

    Give reaction to this post to see the hidden content.
( Interne )

Bonjour, 

 

Grâce à ce tutoriel, vous pourrez, voir les PV et les PM de votre adversaire lors d'un duel. En contrepartie, il pourra voir les vôtres ! Plus de tricherie possible lors d'un duel grâce à ça <fileStore.core_Emoticons>/emoticons/smile.png

 

Pré-Requis :

  • L'accès au fichier root dépacké
  • Un accès aux files serveur (quêtes)

 

I. Installation (Partie client)

 

Révélation

 

A. Fichier constinfo.py (root)

Révélation

Rajoutez dans constinfo.py les informations suivantes :

INPUT_IGNORE = 0

VID = 0
STHX = 0
HPXD = 0

PLAYER_HP = 0
PLAYER_MAX_HP = 0
PLAYER_SP = 0
PLAYER_MAX_SP = 0
PLAYER_NAME = ""
Enregistrez, fermez, passez à game.py.

 

B. Fichier game.py (root)

Révélation

Dans game.py rajoutez cet import dans l'entête de votre fichier. Là où les autres import se situent.

import uiHealth

Puis, dans rajoutez à l'intérieur du "def __ServerCommand_Build(self):" (

Hidden Content

    Give reaction to this post to see the hidden content.
) les communications suivantes :

 

		#wskaznikiHP
		"super_quest"				: self.Tabulejtor,
		"pvp_zdruwko"				: self.Mozart,

		#inputpowerdziwko
		"get_input_value"				: self.GetInputValue,
		"get_input_start"				: self.GetInputOn,
		"get_input_end"					: self.GetInputOff,

Puis à la toute fin du fichier, rajoutez ceci :

 

def Mozart(self, data):
	dane = data.split("|")
	constInfo.PLAYER_NAME = str(dane[0])
	constInfo.PLAYER_HP = int(dane[1])
	constInfo.PLAYER_MAX_HP = int(dane[2])
	constInfo.PLAYER_SP = int(dane[3])
	constInfo.PLAYER_MAX_SP = int(dane[4])

def Tabulejtor(self, id):
	constInfo.STHX = int(id)

def GetInputOn(self):
	constInfo.INPUT_IGNORE = 1

def GetInputOff(self):
	constInfo.INPUT_IGNORE = 0

def GetInputValue(self):
	net.SendQuestInputStringPacket(str(constInfo.VID))

def OpenQuestWindow(self, skin, idx):
	if constInfo.INPUT_IGNORE == 1:
		return
	else:
		self.interface.OpenQuestWindow(skin, idx)

Vous pouvez enregistrer et fermer game.py, pour passer au fichier uitarget.py.

C. Fichier uitarget.py (root)

Révélation

 

Rajoutez dans uitarget.py les import suivants :

import uiHealth
import constInfo
import event #Petit fix chez certains n'ayant pas cet include - Gurgarath
data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==
Puis modifiez le "OnUpdate" en conséquence :
def OnUpdate(self):		
	if player.IsPVPInstance(self.vid):
		constInfo.VID = self.vid
		event.QuestButtonClick(constInfo.STHX)
		if not self.healthBoard.IsShow() and self.vid != 0:
			self.healthBoard.Show()
	else:
		self.healthBoard.Hide()

	if self.isShowButton:

		exchangeButton = self.buttonDict[locale.TARGET_BUTTON_EXCHANGE]
		distance = player.GetCharacterDistance(self.vid)

		if distance < 0:
			return

		if exchangeButton.IsShow():
			if distance > self.EXCHANGE_LIMIT_RANGE:
				self.RefreshButton()

		else:
			if distance < self.EXCHANGE_LIMIT_RANGE:
				self.RefreshButton()
data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

Par la suite, cherchez la ligne :

def __init__(self)
data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==
 

Et ajoutez ceci en dessous :

self.healthBoard = uiHealth.HealthBoard()
data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==
 

Puis la ligne :

def Close()
data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==
 

Et ajoutez ceci, toujours en dessous :

self.healthBoard.Hide()
data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==
 

D. Fichier uihealth.py (root)

Révélation

 

Rajoutez dans uitarget.py les import suivants :

import uiHealth
import constInfo
import event #Petit fix chez certains n'ayant pas cet include - Gurgarath
Puis modifiez le "OnUpdate" en conséquence :
def OnUpdate(self):		
	if player.IsPVPInstance(self.vid):
		constInfo.VID = self.vid
		event.QuestButtonClick(constInfo.STHX)
		if not self.healthBoard.IsShow() and self.vid != 0:
			self.healthBoard.Show()
	else:
		self.healthBoard.Hide()

	if self.isShowButton:

		exchangeButton = self.buttonDict[locale.TARGET_BUTTON_EXCHANGE]
		distance = player.GetCharacterDistance(self.vid)

		if distance < 0:
			return

		if exchangeButton.IsShow():
			if distance > self.EXCHANGE_LIMIT_RANGE:
				self.RefreshButton()

		else:
			if distance < self.EXCHANGE_LIMIT_RANGE:
				self.RefreshButton()

Par la suite, cherchez la ligne :

def __init__(self)
 

Et ajoutez ceci en dessous :

self.healthBoard = uiHealth.HealthBoard()
 

Puis la ligne :

def Close()
 

Et ajoutez ceci, toujours en dessous :

self.healthBoard.Hide()
data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==
 

 

II. Installation (Partie serveur -> quêtes)

 

Révélation

 

Voici la quête à rajouter à votre serveur. Vous pouvez la nommer comme vous voulez, pour l'exemple, vous pouvez la nommer "pvppvpm.quest", car le nom est... drôle ?

-- Quest Opponents HP and MP during pvp
-- Made by: Endymion_
-- Server: Ascarial.pl
quest wskaznikHpWroga begin
state start begin
	when login begin
		cmdchat("super_quest "..q.getcurrentquestindex())
	end

	when info or button begin
		cmdchat("get_input_start")
		local vid = input(cmdchat("get_input_value"))
		cmdchat("get_input_end")
		local old_pc = pc.select(vid)
		local name = pc.get_name()
		local hp = pc.get_hp()
		local max_hp = pc.get_max_hp()
		local mp = pc.get_sp()
		local max_mp = pc.get_max_sp()
		pc.select(old_pc)
		cmdchat("pvp_zdruwko "..name.."|"..hp.."|"..max_hp.."|"..mp.."|"..max_mp)
	end
end
end
data:image/gif;base64,R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

N'oubliez pas de la rajouter à votre liste de quêtes et de compiler vos quêtes et d'effectuer un "/reload q" en jeu (sur votre serveur de test).

 

III. Potentielles remarques

 

Révélation

Oh ! Le tutoriel est déjà terminé. Mais voici quelques remarques pour ceux désirant aller plus loin :

  1. Le code n'est pas sale, mais il est en Polonais, ce n'est donc pas la meilleure façon pour rendre un code attractif et lisible, notamment pour ceux qui ne lisent pas ou comprennent pas le Polonais.
  2. Pour tous ceux souhaitant améliorer le code, la meilleure chose à faire serait de le passer en C++. En effet, à cette époque, les sources n'étaient pas disponibles et donc la meilleure façon restait donc de passer par les quête -> cmdchat. Le code est propre, mais serait bien plus rapide en C++.

Si quelqu'un se sent d'améliorer le code, le code amélioré ainsi qu'une note envers l'auteur sera mis en place dans le tutoriel.

Source : ElitePvPers

 

Cordialement,

  • Metin2 Dev 2
  • Think 1
  • Good 1
  • Love 8
Lien vers le commentaire
Partager sur d’autres sites

  • Funkiest

Le tutoriel est erroné, il y à une partie dans le code de "- Ensuite, ouvrez le fichier game.py, et ajoutez y ce bout de code:"

Voici une version corrigé :

version corrigée

--------------

INSTALLATION

--------------

 

- Ajoutez ce bout de code au début du fichier costinfo.py.

INPUT_IGNORE = 0

VID = 0
STHX = 0
HPXD = 0

PLAYER_HP = 0
PLAYER_MAX_HP = 0
PLAYER_SP = 0
PLAYER_MAX_SP = 0
PLAYER_NAME = ""

 

 

- Ensuite, ouvrez le fichier game.py, et ajoutez y ce bout de code:

import uiHealth

		#wskaznikiHP
		"super_quest"				: self.Tabulejtor,
		"pvp_zdruwko"				: self.Mozart,

		#inputpowerdziwko
		"get_input_value"				: self.GetInputValue,
		"get_input_start"				: self.GetInputOn,
		"get_input_end"					: self.GetInputOff,

def Mozart(self, data):
	dane = data.split("|")
	constInfo.PLAYER_NAME = str(dane[0])
	constInfo.PLAYER_HP = int(dane[1])
	constInfo.PLAYER_MAX_HP = int(dane[2])
	constInfo.PLAYER_SP = int(dane[3])
	constInfo.PLAYER_MAX_SP = int(dane[4])

def Tabulejtor(self, id):
	constInfo.STHX = int(id)

def GetInputOn(self):
	constInfo.INPUT_IGNORE = 1

def GetInputOff(self):
	constInfo.INPUT_IGNORE = 0

def GetInputValue(self):
	net.SendQuestInputStringPacket(str(constInfo.VID))

def OpenQuestWindow(self, skin, idx):
	if constInfo.INPUT_IGNORE == 1:
		return
	else:
		self.interface.OpenQuestWindow(skin, idx)[code]

 

- Le bout de code suivant est à ajouter dans le fichier uitarget.py :

import uiHealth
import constInfo

def OnUpdate(self):		
	if player.IsPVPInstance(self.vid):
		constInfo.VID = self.vid
		event.QuestButtonClick(constInfo.STHX)
		if not self.healthBoard.IsShow() and self.vid != 0:
			self.healthBoard.Show()
	else:
		self.healthBoard.Hide()

	if self.isShowButton:

		exchangeButton = self.buttonDict[locale.TARGET_BUTTON_EXCHANGE]
		distance = player.GetCharacterDistance(self.vid)

		if distance < 0:
			return

		if exchangeButton.IsShow():
			if distance > self.EXCHANGE_LIMIT_RANGE:
				self.RefreshButton()

		else:
			if distance < self.EXCHANGE_LIMIT_RANGE:
				self.RefreshButton()

 

 

- Toujours dans le fichier uitarget.py, cherchez la ligne :

def __init__(self)

 

Et ajoutez ceci:

self.healthBoard = uiHealth.HealthBoard()

 

 

- Toujours dans le fichier uitarget.py, cherchez la ligne:

def Close()

 

Et ajoutez ceci:

self.healthBoard.Hide()

 

 

- Créez maintenant le fichier uihealth.py et collez à l'intérieur de ce fichier ( que vous placerez par la suite dans root ) :

#Krzywy
import ui
import constInfo

def GetInfoFrom(id):
table = {
	1	:	constInfo.PLAYER_NAME,
	2	:	constInfo.PLAYER_HP,
	3	:	constInfo.PLAYER_MAX_HP,
	4	:	constInfo.PLAYER_SP,
	5	:	constInfo.PLAYER_MAX_SP}

if table.has_key(id):
	return table[id]


class HealthBoard(ui.ThinBoard):

def __init__(self):
	ui.ThinBoard.__init__(self)

	self.Config()

def __del__(self):
	ui.ThinBoard.__del__(self)

def Config(self):
	self.SetSize(200, 120)
	self.SetPosition(0, 20)

	self.hp_bar = ui.Gauge()
	self.hp_bar.SetParent(self)
	self.hp_bar.SetPosition(30, 30+20)
	self.hp_bar.MakeGauge(130, "red")
	self.hp_bar.Show()

	self.sp_bar = ui.Gauge()
	self.sp_bar.SetParent(self)
	self.sp_bar.SetPosition(30, 60+20)
	self.sp_bar.MakeGauge(130, "blue")
	self.sp_bar.Show()

	self.name = ui.TextLine()
	self.name.SetParent(self)
	self.name.SetDefaultFontName()
	self.name.SetPosition(45, 30)
	self.name.SetText("")
	self.name.Show()	

	self.hp_show = ui.TextLine()
	self.hp_show.SetParent(self)
	self.hp_show.SetDefaultFontName()
	self.hp_show.SetPosition(60-15, 57)
	self.hp_show.SetText("")
	self.hp_show.Show()	

	self.sp_show = ui.TextLine()
	self.sp_show.SetParent(self)
	self.sp_show.SetDefaultFontName()
	self.sp_show.SetPosition(60-15, 80+7)
	self.sp_show.SetText("")
	self.sp_show.Show()	

def OnUpdate(self):
	if (GetInfoFrom(2)+GetInfoFrom(3)+GetInfoFrom(4)+GetInfoFrom(5)) == 0:
		self.Hide()
	self.hp_bar.SetPercentage(GetInfoFrom(2), GetInfoFrom(3))
	self.sp_bar.SetPercentage(GetInfoFrom(4), GetInfoFrom(5))
	self.name.SetText(GetInfoFrom(1))
	self.hp_show.SetText("Health Points: %s / %s" % (GetInfoFrom(2), GetInfoFrom(3)))
	self.sp_show.SetText("Mana Points: %s / %s" % (GetInfoFrom(4), GetInfoFrom(5)))
	self.name.SetText("Character: %s" % (GetInfoFrom(1)))

 

 

- La quête :

-- Quest Opponents HP and MP during pvp
-- Made by: Endymion_
-- Server: Ascarial.pl
quest wskaznikHpWroga begin
state start begin
	when login begin
		cmdchat("super_quest "..q.getcurrentquestindex())
	end

	when info or button begin
		cmdchat("get_input_start")
		local vid = input(cmdchat("get_input_value"))
		cmdchat("get_input_end")
		local old_pc = pc.select(vid)
		local name = pc.get_name()
		local hp = pc.get_hp()
		local max_hp = pc.get_max_hp()
		local mp = pc.get_sp()
		local max_mp = pc.get_max_sp()
		pc.select(old_pc)
		cmdchat("pvp_zdruwko "..name.."|"..hp.."|"..max_hp.."|"..mp.."|"..max_mp)
	end
end
end

 

*epvp

 

Enjoy.

 

 

 

Sinon, merci, très utile :)

Lien vers le commentaire
Partager sur d’autres sites

  • Retraité

Merci Galet, mais ce bout de code je ne l'avais pas oublié.

Je viens de vérifier, quand j'édite mon premier poste, je le vois.

 

Si un modérateur pouvait passer par la pour voir ce qu'il se passe , merci :)

 

-----------------------

Edit : j'avais oublié un / dans la balise de fermeture de


Merci a nouveau galet pour le signalement.

-----------------------

Lien vers le commentaire
Partager sur d’autres sites

  • 5 mois après...
  • 4 mois après...
  • 1 an après...
  • 10 mois après...
  • 1 an après...


  • brilliantdiscord_widget
  • Flux d'Activité

    1. 37
    2. 21

      Metin2 en 2020 peut-on en parler?

    3. 0

      METIN2Project

    4. 3

      Ressources - UnPack - Metin2 Client - Officiel

    5. 0

      Barre des tâches d'argent étendue

    6. 16

      Redémarrage automatique des channels

    7. 16

      Multi Logo GM / SGM / GA

  • En ligne récemment

    • Aucun utilisateur enregistré regarde cette page.

Information importante

Conditions d’utilisation / Politique de confidentialité / Règles / Nous avons placé des cookies sur votre appareil pour aider à améliorer ce site. Vous pouvez choisir d’ajuster vos paramètres de cookie, sinon nous supposerons que vous êtes d’accord pour continuer.