Jump to content
×
×
  • Create New...

[AS2] Dégâts en couleurs


mathias52
 Share

Recommended Posts

Bonjours,

 

Screen :

.png

 

Code :

piou.Packet.setParser("D2", function(packet, error) {
var c2 = packet.charAt(2);
if (c2 == "F") {
	var c3 = packet.charAt(3);
	if (c3 == "L") {
		packet = packet.substring(4);
		var list = packet.split(";");
		var name = list[0];
		var finalDmg = list[1];
		var i = 1;

		var string = "";
		var lastColor = 0;

		var nbr = 0;

		while (++i, i < list.length) {
			if (i == 2) {
				string += " (";	
			} else {
				string += " + ";	
			}

			++nbr;

			var array = list[i].split(",");
			var dmg = array[0];
			var effect = array[1];
			var color = 0;

			/*var eau = new Array(85, 91, 96, 275);
			var terre = new Array(86, 92, 97, 276);
			var air = new Array(87, 93, 98, 277);
			var feu = new Array(88, 94, 99, 278);
			var neutre = new Array(89, 95, 100, 279);*/

			if (effect == 85 || effect == 91 || effect == 96 || effect == 275) {
				color = "00BFFF";
			} else if (effect == 86 || effect == 92 || effect == 97 || effect == 276) {
				color = "3B170B";
			} else if (effect == 87 || effect == 93 || effect == 98 || effect == 277) {
				color = "BEF781";
			} else if (effect == 88 || effect == 94 || effect == 99 || effect == 278) {
				color = "FF0000";
			} else if (effect == 89 || effect == 95 || effect == 100 || effect == 279) {
				color = "848484";
			}

			if (lastColor == 0) {
				lastColor = color;
			} else if (lastColor != color) {
				lastColor = "8258FA";
			}

			string += "" + dmg + "";
		}
		if (i > 2) {
			string += ").";	
		}
		string = "" + api.datacenter.Sprites.getItemAt(name).name + " perd " + "" + finalDmg + "" + " PDV" + (nbr > 1 ? string : ".");
		api.kernel.showMessage(undefined, string, "INFO_FIGHT_CHAT");
	}

}
});
 

le code peut être amélioré et vous pouvez changer les couleurs si vous le voulez, j'ai fait sa rapidement car j'en avais besoin...

 

Il faudra adapter un peu le code en fonction du packet que vous voulez envoyé (et si vous avez ou non le Module Loader) ("D2FL" + character id + ";" finalDmg (que l'on peut calculé dans la fonction) + ";" + dmg + "," + color + ";" + dmg + "," + color ...)

Exemple : D2FL1;50;10,85;10,86;10,87;10,88;10,89

Le personnage 1 subbit 50 dégats, 10 dans chaque éléments.

 

Merci

  • J'adore 1
Link to comment
Share on other sites

  • Replies 10
  • Created
  • Last Reply

Top Posters In This Topic

  • 1 month later...
  • 1 month later...
  • 1 year later...
  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share



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.