Page 1 of 1
Buff/debuff packet fixes
Posted: Tue Jan 02, 2007 3:55 am
by Bracco
heya... i played a bit with the 0xDF packet, the one for buff/debuff show... and i found the data on packetguide incorrect
so i fired up runuo and investigated, this is what i came up with. (basically i adjusted this according to runuo packet, so its not really my own work, credits goes to them)
Packet Build:
BYTE[1] Cmd
BYTE[2] Length
BYTE[4] Serial of player
BYTE[2] Icon Number to show
BYTE[2] 0x1 = Show, 0x0 = Remove. On remove byte, packet ends here.
BYTE[4] 0x00000000
BYTE[2] Icon Number to show.
BYTE[2] 0x1 = Show
BYTE[4] 0x00000000
BYTE[2] Time in seconds (simple countdown without automatic remove)
BYTE[2] 0x0000
BYTE[1] 0x00
BYTE[4] Cliloc ID of title of icon.
BYTE[4] Cliloc ID for the Description of the icon. If no arguments for cliloc, then add 10 more bytes 0x00000000000000000000 and end packet
BYTE[4] 0x00000000
BYTE[2] 0x01
BYTE[2] 0x0000
BYTE[len(str)*2] Flipped Unicode String ("\t"+str) (To seperate the entrys add "\t")
BYTE[2] 0x01
BYTE[2] 0x0000
what i don't get is why there is 2 times the buff ID and show/remove
also too many zeros here and there
Posted: Tue Jan 02, 2007 10:20 am
by MuadDib
Info updated, will update the news section soon as I finish getting all my programs reinstalled since my pc crashed the other day, lol.
Posted: Sun Oct 28, 2007 4:25 am
by OldnGrey
I've finally started playing with this packet.
One question I have - does the core ever send minimal packets for this or am I going to have to write a looping script to cycle through players and call this packet function?
I had hopes that UOFeatureEnable=0x1a0 in servspecopt.cfg would enable this and at least send a blank buff packet (a few bytes only), but it doesn't. The exported packethook I wrote never fires.
Failing that, anyone got any advice as to how often you would be sending these packets and updating the client?
Every 1 second? Every 5 or even 10?? I've not had the experience of ever seeing it in action before.
Posted: Sun Oct 28, 2007 4:47 am
by MuadDib
Since you are already probably using TimedScripts in Distro for the "buffs and debuffs" you are modifying the player with, why not use them to send the buff/defuff packet when adding or removing the buff?
Posted: Sun Oct 28, 2007 5:14 am
by OldnGrey
Well the packet is mostly working when I send it manually. So in case someone else is interested, MuadDib confirmed that POL never sends the DF packet.
Are you saying that the packet only needs to be sent ONCE when the buff is applied and ONCE when the buff expires? Or is it something that should be sent frequently?
Yep, if it only needs doing at start/stop then timed scripts would be perfect.
Posted: Sun Oct 28, 2007 9:25 am
by MuadDib
iirc yes, beginning and end. However, at the end, it is only needed to be sent if expiring early, since the buffs SHOULD (iirc again) expire themselves if they run the full duration. Would need to test to be sure
Posted: Sun Oct 28, 2007 10:13 pm
by OldnGrey
I've done some more tests here with nightsight as my test subject.
Sending the packet displays it on the client, but the duration doesn't seem to count down automatically so you need to keep sending the packet to update the displayed duration. Sending it every 5 seconds seems to work okay and the tooltip even updates dynamically when your mouse hovers over the icon. So a really nice feature. It's all done with clilocs so the expected bandwidth is not great.
I will do more tests. The scripts themselves seem to be very simple but I've only tried it with one buff so far. If I use it with timed scripts it will not be a simple matter of starting a timer.
Posted: Mon Oct 29, 2007 4:11 am
by OldnGrey
Some more tests and it seems that the DF packet integrates very well indeed into Timedscripts of the 097 distro.
All it needed was a couple of extra parameters in the timedScripts.cfg file to hold the icon and the cliloc numbers used, and an extra function in timedScripts.inc to send the packet. The packets are sent by two simple scripts in the subScript directory.
I was wrong about the timer not counting down automatically. It counts down in 5 second increments, by co-incidence exactly how often I was resending the packet.
ops:
My simple example of nightsight works so well that I think I am ready to incorporate all buffs into the timedscripts. Since the packets are only sent at the start and end of the buff, I can safely say there is no significant bandwidth overhead.
Posted: Tue Oct 30, 2007 3:33 pm
by MuadDib
Handle accordingly for anything that lasts through logoff and logon. AKA, they cast Magic Resistance, get the Icon. Log off, log back on later, and still have it active, need the icon resent.
Posted: Tue Oct 30, 2007 4:52 pm
by OldnGrey
I am fine tuning it as I go. Currently I am working through all the other conditions like restart, logoff and casting a second time.
But so far the changes to the timedscripts package is nicely minimal.
Having trouble getting the parameters for cliloc2 to display - so far it's a unicode character unrelated to what I'm sending!
Posted: Wed Oct 31, 2007 7:46 am
by tartaros
btw. since which client version is this thing supported?
Posted: Wed Oct 31, 2007 2:48 pm
by OldnGrey
I understand it to be from v5. (5.0.2b according to one packet guide I have)
I'm not sure of the effects of sending this packet to v4 or earlier client but to be safe I am using .clientversion to determine whether or not to send the packet.
Posted: Wed Oct 31, 2007 6:54 pm
by OldnGrey
This is a working dot command example of the packet. Something like this has been done in another topic, but for some reason I had trouble with it. Several versions of the DF packet have been published but to get it working was a little trial and error.
All this does is turn on and off the STRENGTH icon and tooltips on the buff/debuff gump.
(Must be v5 client or later. Bring up the status gump and click the button on there)
It will count down every 5 seconds.
In theory this is easily wrapped into timedScripts.inc to control the gump and actually do the buff. I am still have problems with logon/logoff with that though.
.dfpacket 1
turns it on
.dfpacket 0
turns it off
Code: Select all
// Manually turns on and off the STRENGTH icon in the buff/debuff gump.
// Use:
// .dfpacket 1 to show
// .dfpacket 0 to remove
use uo;
use os;
use polsys;
program DFPacket(mobile, show)
if ( show )
show := CInt(show);
else
show := 0;
endif
var icon := 1047;
var cliloc1 := 1015014;
var cliloc2 := 1060485;
var duration := 20;
var str := " +20"; // the space at the start is important. Use cliloc parm rules for multiple parameters
// define the offsets to make it easier
var OFFSET_SERIAL := 3;
var OFFSET_ICONNUMBER1 := 7;
var OFFSET_SHOW1 := 9;
var OFFSET_ICONNUMBER2 := 15;
var OFFSET_SHOW2 := 17;
var OFFSET_TIME := 23;
var OFFSET_CLILOC1 := 28;
var OFFSET_CLILOC2 := 32;
var OFFSET_CLILOC2PARMS := 42;
// var BLANK_CLILOC := 1005007; // a cliloc number with blank text
// var ERROR_CLILOC := 500267; // an cliloc showing an error
var packet := CreatePacket(0xDF, MSGLEN_VARIABLE);
packet.setint32(OFFSET_SERIAL, mobile.serial);
packet.setint16(OFFSET_ICONNUMBER1, icon);
packet.setint16(OFFSET_SHOW1, show);
if ( show )
packet.setint16(OFFSET_ICONNUMBER2, icon);
packet.setint16(OFFSET_SHOW2, show);
packet.setint16(OFFSET_TIME, duration);
packet.setint32(OFFSET_CLILOC1, cliloc1);
packet.setint32(OFFSET_CLILOC2, cliloc2);
packet.SetUnicodeStringFlipped(OFFSET_CLILOC2PARMS, CAscZ(str), 1);
var Length_ID := packet.GetSize();
packet.setint16(Length_ID, 0x1);
endif
packet.sendpacket(mobile);
endprogram
Posted: Sat May 17, 2008 4:03 am
by gha
hi
where I can find the clicloc1 and clicloc2 constants? is it inside .mul files?
Posted: Sat May 17, 2008 5:58 am
by OldnGrey
Use localisation editor v2.1 I think. Older versions don't handle all the numbers of later clients.
Look for it on this excellent tools site:
http://ultima.lonet.cz/download.php
Re: Buff/debuff packet fixes
Posted: Fri Aug 22, 2008 5:47 am
by Nightson
Hi i have problem with this packet sometime it shows duration ( time of buff/debuff ) and sometimes not why?
Re: Buff/debuff packet fixes
Posted: Fri Aug 22, 2008 7:16 am
by OldnGrey
I've implemented just about all the tempmods on my shard and they all show the duration reasonably correctly - within a few seconds.
I have no idea why you have a problem - not enough information.
Re: Buff/debuff packet fixes
Posted: Fri Aug 22, 2008 11:37 am
by Nightson
i probaly found reason when i cast bless for example then logout and login in few seconds then cast bless it shows everything ok except duration so i have to remove 0xDF in logon.src and everything is fine
Re: Buff/debuff packet fixes
Posted: Sat Oct 18, 2008 11:15 am
by Pierce
Fixed some errors and added some information in this packet:
http://docs.polserver.com/packets/index.php?Packet=0xDF
If someone uses the missing cliloc messages and wants to share them please
send me a PM with the cliloc numbers. I'll add them in that case.
For an easy use of that packet I post my BuffDebuff.inc (Pol 96/97) here:
(based on a i think it was a tekproxy script/post, i'm not sure)
Code: Select all
use polsys;
const BUFF_CMD := 0xDF;
const OFFSET_MSGLEN := 1;
const OFFSET_SERIAL := 3;
function HandleBuffs(who, params)
if(who.isa(POLCLASS_NPC))
return;
endif
var cv := who.clientversion;
var cvcheck := SplitWords(cv, ".");
if(Cint(cvcheck[1]) < 5)
return;
else
if(Cint(cvcheck[1]) == 5)
if(Cint(cvcheck[2]) == 0)
if(Cint(cvcheck[3][1]) < 2)
return;
endif
endif
endif
endif
var action := params[1];
var method := params[2];
var tile, showmethod := 0;
var time := Cint(params[3]);
var cliloc1,cliloc2;
var i,values := "";
for(i:=4;i<=params.size();i+=1)
values := values + "\t";
values := values + CStr(params[i]);
endfor
case(lower(method))
"on" : showmethod := 1;
"off" : showmethod := 0;
"data": showmethod := 2;
endcase
case(lower(action))
"dismount":
tile := 1001;
cliloc1 := 1075635;
cliloc2 := 1075636;
"disarm":
tile := 1002;
cliloc1 := 1075637;
cliloc2 := 1075638;
"nightsight":
tile := 1005;
cliloc1 := 1075643;
cliloc2 := 1075644;
"deathstrike":
tile := 1006;
"evilomen":
tile := 1007;
"dontknow1":
tile := 1008;
"regeneration":
tile := 1009;
cliloc1 := 1044106;
cliloc2 := 1075106;
"divinefury":
tile := 1010;
"enemyofone":
tile := 1011;
"stealth":
tile := 1012;
cliloc1 := 1044107;
cliloc2 := 1075655;
"meditation":
tile := 1013;
cliloc1 := 1044106;
cliloc2 := 1075106;
"bloodoathcaster":
tile := 1014;
"bloodoathcurse":
tile := 1015;
"corpseskin":
tile := 1016;
"mindrot":
tile := 1017;
"painstrike":
tile := 1018;
"strangle":
tile := 1019;
"giftofrenewal":
tile := 1020;
"attunewapon":
tile := 1021;
"thunderstorm":
tile := 1022;
"essenceofwind":
tile := 1023;
"etheralvoyage":
tile := 1024;
"giftoflife":
tile := 1025;
"arcaneempowerment":
tile := 1026;
"mortalstrike":
tile := 1027;
"reactivearmor":
tile := 1028;
cliloc1 := 1075812;
cliloc2 := 1075813;
"protection":
tile := 1029;
cliloc1 := 1075814;
cliloc2 := 1075815;
"archprotection":
tile := 1030;
cliloc1 := 1075816;
cliloc2 := 1075816;
"magicreflection":
tile := 1031;
cliloc1 := 1075817;
cliloc2 := 1075818;
"incognito":
tile := 1032;
cliloc1 := 1075819;
cliloc2 := 1075820;
"disguised":
tile := 1033;
"animalform":
tile := 1034;
"polymorph":
tile := 1035;
cliloc1 := 1075824;
cliloc2 := 1075820;
"invisibility":
tile := 1036;
cliloc1 := 1075825;
cliloc2 := 1075826;
"paralyse":
tile := 1037;
cliloc1 := 1075827;
cliloc2 := 1075828;
"poison":
tile := 1038;
cliloc1 := 0x0F8627;
cliloc2 := 0x1069B1;
"bleed":
tile := 1039;
cliloc1 := 0x106a75;
cliloc2 := 0x106a76;
"clumsy":
tile := 1040;
cliloc1 := 0x106a77;
cliloc2 := 0x106a78;
"feeblemind":
tile := 1041;
cliloc1 := 0x106a79;
cliloc2 := 0x106a7a;
"weaken":
tile := 1042;
cliloc1 := 1075837;
cliloc2 := 1075838;
"curse":
tile := 1043;
cliloc1 := 1075835;
cliloc2 := 1075836;
"masscurse":
tile := 1044;
cliloc1 := 0x106a7f;
cliloc2 := 0x106a80;
"agility":
tile := 1045;
cliloc1 := 0x106a81;
cliloc2 := 0x106a82;
"cunning":
tile := 1046;
cliloc1 := 0x106a83;
cliloc2 := 0x106a84;
"strength":
tile := 1047;
cliloc1 := 0x106a85;
cliloc2 := 0x106a86;
"bless":
tile := 1048;
cliloc1 := 0x106a87;
cliloc2 := 0x106a88;
endcase
var outpkt2 := CreatePacket(BUFF_CMD, MSGLEN_VARIABLE);
outpkt2.SetInt16(OFFSET_MSGLEN, outpkt2.GetSize());
outpkt2.SetInt32(OFFSET_SERIAL, who.serial);
outpkt2.SetInt16(7, tile); // Icon Nr.
outpkt2.SetInt8(9, 0);
outpkt2.SetInt8(10, showmethod); //2 additional data, 1 add, 0 remove
outpkt2.SetInt32(11, 0);
outpkt2.SetInt16(15, tile); // Icon Nr.
outpkt2.SetInt8(17, 0);
outpkt2.SetInt8(18, showmethod); //2 additional data, 1 add, 0 remove
if(showmethod)
outpkt2.SetInt32(19, 0);
outpkt2.SetInt16(23, time);
outpkt2.SetInt16(25, 0x0);
outpkt2.SetInt8(27, 0x0);
outpkt2.SetInt32(28, cliloc1);
outpkt2.SetInt32(32, cliloc2);
outpkt2.SetInt32(36, 0x0);
outpkt2.SetInt8(40, 0x0);
outpkt2.SetInt8(41, 0x1);
outpkt2.SetUnicodeString(43,CAscZ(values),1);
endif
outpkt2.SendPacket(who);
endfunction
You surely need to edit the different spell/statmod scripts or logon scripts to use it.
I'll give some examples:
Code: Select all
reactive armor on:
HandleBuffs(cast_on, array("reactivearmor", "on", duration, mod_amount, 0, 0, 0, 0));
reactive armor off:
HandleBuffs(cast_on, array("reactivearmor", "off", 0));
magic reflect on:
HandleBuffs(caster, array("magicreflection", "on", 86000, 0, 0, 0, 0, 0));
magic reflect off:
HandleBuffs(cast_on, array("magicreflection", "off", 0));
in that case e.g. logon.src if magic reflect is active:
if (GetObjProperty(who, "mr"))
HandleBuffs(who, array("magicreflection", "on", 86000, 0, 0, 0, 0, 0));
endif
strength:
HandleBuffs(who, array("strength", "on", duration, percent));
Re: Buff/debuff packet fixes
Posted: Tue Dec 02, 2008 10:45 am
by guialtran
Code: Select all
Use attributes;
Use basic;
Use boat;
Use cfgfile;
Use cliloc;
Use datafile;
Use file;
Use guilds;
Use http;
Use math;
Use npc;
Use os;
Use polsys;
Use storage;
Use unicode;
Use uo;
Use util;
Use vitals;
//add icon
function BuffDebuff_adicionaIcone(character,icone,tempo)
var packet := CreatePacket(0xDF, MSGLEN_VARIABLE);//0 BYTE[1] Cmd
//packet.SetInt16(1, packet.GetSize());//1 BYTE[2] Length "tem que ser no fim"
packet.SetInt32(3, character.serial);//3 BYTE[4] Serial of player
packet.setint16(7, icone);//7 BYTE[2] Icon Number to show
packet.setint16(9, 0x1);//9 BYTE[2] 0x1 = Show, 0x0 = Remove. On remove byte, packet ends here.
packet.SetInt32(11, 0x0);//11 BYTE[4] 0x00000000
packet.SetInt16(15, icone);//15 BYTE[2] Icon Number to show.
packet.SetInt16(17, 0x1);//17 BYTE[2] 0x1 = Show
packet.SetInt32(19, 0x0);//19 BYTE[4] 0x00000000
packet.SetInt16(23, tempo);//23 BYTE[2] Time in seconds (simple countdown without automatic remove)
packet.SetInt16(25, 0x0);//25 BYTE[2] 0x0000
packet.SetInt8(27, 0x0);//27 BYTE[1] 0x00
packet.SetInt32(28, 1005007);//28 BYTE[4] Cliloc message ID1 cliloc "enu"(cliloc 1042971 == "~1_NOTHING~") (cliloc 1005007 == "")
packet.SetInt32(32, 1042971);//32 BYTE[4] Cliloc message ID2 cliloc "enu"(cliloc 1042971 == "~1_NOTHING~") (cliloc 1005007 == "")
packet.SetInt32(36, 0x0);//36 BYTE[4] 0x00000000
packet.SetInt32(40, 0x1);//40 BYTE[2] 0x0001
var msg := " ";// tem que ter esse " " para ele concatenar!
case(icone)
1001://1001: Dismount
msg := msg+"<BASEFONT COLOR=#ff00ff>Dismount</BASEFONT>";
break;
1002://1002: Disarm
msg := msg+"<BASEFONT COLOR=#ff00ff>Disarm</BASEFONT>";
break;
1005://1005: Nightsight
msg := msg+"<BASEFONT COLOR=#ff00ff>Nightsight</BASEFONT>";
break;
1006://1006: Death Strike
msg := msg+"<BASEFONT COLOR=#ff00ff>Death Strike</BASEFONT>";
break;
1007://1007: Evil Omen
msg := msg+"<BASEFONT COLOR=#ff00ff>Evil Omen</BASEFONT>";
break;
1008://1008: unknown? (GumpID 0x7556)
msg := msg+"<BASEFONT COLOR=#ff00ff>unknown 1?</BASEFONT>";
break;
1009://1009: Regeneration (cliloc1=1044106,cliloc2=1075106)
msg := msg+"<BASEFONT COLOR=#ff00ff>unknown 2?</BASEFONT>";
break;
1010://1010: Divine Fury
msg := msg+"<BASEFONT COLOR=#ff00ff>Divine Fury</BASEFONT>";
break;
1011://1011: Enemy Of One
msg := msg+"<BASEFONT COLOR=#ff00ff>Enemy Of One</BASEFONT>";
break;
1012://1012: Stealth (cliloc1=1044107,cliloc2=1075655)
msg := msg+"<BASEFONT COLOR=#ff00ff>Stealth</BASEFONT>";
break;
1013://1013: Active Meditation (cliloc1=1044106,cliloc2=1075106)
msg := msg+"<BASEFONT COLOR=#ff00ff>Active Meditation</BASEFONT>";
break;
1014://1014: Blood Oath caster
msg := msg+"<BASEFONT COLOR=#ff00ff>Blood Oath caster</BASEFONT>";
break;
1015://1015: Blood Oath curse
msg := msg+"<BASEFONT COLOR=#ff00ff>Blood Oath curse</BASEFONT>";
break;
1016://1016: Corpse Skin
msg := msg+"<BASEFONT COLOR=#ff00ff>Corpse Skin</BASEFONT>";
break;
1017://1017: Mindrot
msg := msg+"<BASEFONT COLOR=#ff00ff>Mindrot</BASEFONT>";
break;
1018://1018: Pain Spike
msg := msg+"<BASEFONT COLOR=#ff00ff>Pain Spike</BASEFONT>";
break;
1019://1019: Strangle
msg := msg+"<BASEFONT COLOR=#ff00ff>Strangle</BASEFONT>";
break;
1020://1020: Gift of Renewal
msg := msg+"<BASEFONT COLOR=#ff00ff>Gift of Renewal</BASEFONT>";
break;
1021://1021: Attune Weapon
msg := msg+"<BASEFONT COLOR=#ff00ff>Attune Weapon</BASEFONT>";
break;
1022://1022: Thunderstorm
msg := msg+"<BASEFONT COLOR=#ff00ff>Thunderstorm</BASEFONT>";
break;
1023://1023: Essence of Wind
msg := msg+"<BASEFONT COLOR=#ff00ff>Essence of Wind</BASEFONT>";
break;
1024://1024: Ethereal Voyage
msg := msg+"<BASEFONT COLOR=#ff00ff>Ethereal Voyage</BASEFONT>";
break;
1025://1025: Gift Of Life
msg := msg+"<BASEFONT COLOR=#ff00ff>Gift Of Life</BASEFONT>";
break;
1026://1026: Arcane Empowerment
msg := msg+"<BASEFONT COLOR=#ff00ff>Arcane Empowerment</BASEFONT>";
break;
1027://1027: Mortal Strike
msg := msg+"<BASEFONT COLOR=#ff00ff>Mortal Strike</BASEFONT>";
break;
1028://1028: Reactive Armor (cliloc1=1075812,cliloc2=1075813)
msg := msg+"<BASEFONT COLOR=#ff00ff>Reactive Armor</BASEFONT>";
break;
1029://1029: Protection (cliloc1=1075814,cliloc2=1075815)
msg := msg+"<BASEFONT COLOR=#ff00ff>Protection</BASEFONT>";
break;
1030://1030: Arch Protection (cliloc1=1075816,cliloc2=1075816)
msg := msg+"<BASEFONT COLOR=#ff00ff>Arch Protection</BASEFONT>";
break;
1031://1031: Magic Reflection (cliloc1=1075817,cliloc2=1075818)
msg := msg+"<BASEFONT COLOR=#ff00ff>Magic Reflection</BASEFONT>";
break;
1032://1032: Incognito (cliloc1=1075819,cliloc2=1075820)
msg := msg+"<BASEFONT COLOR=#ff00ff>Incognito</BASEFONT>";
break;
1033://1033: Disguised
msg := msg+"<BASEFONT COLOR=#ff00ff>Disguised</BASEFONT>";
break;
1034://1034: Animal Form
msg := msg+"<BASEFONT COLOR=#ff00ff>Animal Form</BASEFONT>";
break;
1035://1035: Polymorph (cliloc1=1075824,cliloc2=1075820)
msg := msg+"<BASEFONT COLOR=#ff00ff>Polymorph</BASEFONT>";
break;
1036://1036: Invisibility (cliloc1=1075825,cliloc2=1075826)
msg := msg+"<BASEFONT COLOR=#ff00ff>Invisibility</BASEFONT>";
break;
1037://1037: Paralyze (cliloc1=1075827,cliloc2=1075828)
msg := msg+"<BASEFONT COLOR=#ff00ff>Paralyze</BASEFONT>";
break;
1038://1038: Poison (cliloc1=0x0F8627, cliloc2=0x1069B1)
msg := msg+"<BASEFONT COLOR=#ff00ff>Poison</BASEFONT>";
break;
1039://1039: Bleed (cliloc1=0x106a75,cliloc2=0x106a76)
msg := msg+"<BASEFONT COLOR=#ff00ff>Bleed</BASEFONT>";
break;
1040://1040: Clumsy (cliloc1=0x106a77,cliloc2=0x106a78)
msg := msg+"<BASEFONT COLOR=#ff00ff>Clumsy</BASEFONT>";
break;
1041://1041: Feeble Mind (cliloc1=0x106a79,cliloc2=0x106a7a)
msg := msg+"<BASEFONT COLOR=#ff00ff>Feeble Mind</BASEFONT>";
break;
1042://1042: Weaken (cliloc1=1075837,cliloc2=1075838)
msg := msg+"<BASEFONT COLOR=#ff00ff>Weaken</BASEFONT>";
break;
1043://1043: Curse (cliloc1=1075835,cliloc2=1075836)
msg := msg+"<BASEFONT COLOR=#ff00ff>Curse</BASEFONT>";
break;
1044://1044: Mass Curse (cliloc1=0x106a7f,cliloc2=0x106a80)
msg := msg+"<BASEFONT COLOR=#ff00ff>Mass</BASEFONT>";
break;
1045://1045: Agility (cliloc1=0x106a81,cliloc2=0x106a82)
msg := msg+"<BASEFONT COLOR=#ff00ff>Agility</BASEFONT>";
break;
1046://1046: Cunning (cliloc1=0x106a83,cliloc2=0x106a84)
msg := msg+"<BASEFONT COLOR=#ff00ff>Cunning</BASEFONT>";
break;
1047://1047: Strength (cliloc1=0x106a85,cliloc2=0x106a86)
msg := msg+"<BASEFONT COLOR=#ff00ff>Strength</BASEFONT>";
break;
1048://1048: Bless (cliloc1=0x106a87,cliloc2=0x106a88)
msg := msg+"<BASEFONT COLOR=#ff00ff>Bless</BASEFONT>";
break;
default:
return 0;
break;
endcase
packet.SetUnicodeStringFlipped(42,CAscZ(msg),1);//42 BYTE[len(str)*2] Flipped Unicode String (" "+str) (To seperate the entrys add " ")
//? BYTE[2] 0x0000 , o valor "1" do terceiro parametro da funcao ".SetUnicodeString(,,1)" indica que ele ja coloca um duplo zero no fim.
packet.SetInt16(1, packet.GetSize());//1 BYTE[2] Length
packet.sendpacket(character);
return 1;
endfunction
//remove icon
function BuffDebuff_removeIcone(character,icone)
var packet := CreatePacket(0xDF, MSGLEN_VARIABLE);//0 BYTE[1] Cmd
//packet.SetInt16(1, packet.GetSize());//1 BYTE[2] Length "tem que ser no fim"
packet.SetInt32(3, character.serial);//3 BYTE[4] Serial of player
packet.setint16(7, icone);//7 BYTE[2] Icon Number to show
packet.setint16(9, 0x0);//9 BYTE[2] 0x1 = Show, 0x0 = Remove. On remove byte, packet ends here.
packet.SetInt32(11, 0x0);//11 BYTE[4] 0x00000000
packet.SetInt16(15, icone);//15 BYTE[2] Icon Number to show.
packet.SetInt16(17, 0x0);//17 BYTE[2] 0x1 = Show
packet.SetInt32(19, 0x0);//19 BYTE[4] 0x00000000
packet.SetInt16(23, 0x0);//23 BYTE[2] Time in seconds (simple countdown without automatic remove)
packet.SetInt16(25, 0x0);//25 BYTE[2] 0x0000
packet.SetInt8(27, 0x0);//27 BYTE[1] 0x00
packet.SetInt32(28, 1005007);//28 BYTE[4] Cliloc message ID1 cliloc "enu"(cliloc 1042971 == "~1_NOTHING~") (cliloc 1005007 == "")
packet.SetInt32(32, 1005007);//32 BYTE[4] Cliloc message ID2 cliloc "enu"(cliloc 1042971 == "~1_NOTHING~") (cliloc 1005007 == "")
packet.SetInt32(36, 0x0);//36 BYTE[4] 0x00000000
packet.SetInt32(40, 0x1);//40 BYTE[2] 0x0001
var msg := "";// tem que ter esse " " para ele concatenar!
packet.SetUnicodeStringFlipped(42,CAscZ(msg),1);//42 BYTE[len(str)*2] Flipped Unicode String (" "+str) (To seperate the entrys add " ")
//? BYTE[2] 0x0000 , o valor "1" do terceiro parametro da funcao ".SetUnicodeString(,,1)" indica que ele ja coloca um duplo zero no fim.
packet.SetInt16(1, packet.GetSize());//1 BYTE[2] Length
packet.sendpacket(character);
return 1;
endfunction
program testMemoryLeak(mobile)
var total := 0;
var j;
for(j:=0;j<=100000;j:=j+1)
var i;
for(i:=1001;i<=1048;i:=i+1)
BuffDebuff_adicionaIcone(mobile,i,100);
total := total + 1;
sleepms(1);
endfor;
for(i:=1048;i>=1001;i:=i-1)
BuffDebuff_removeIcone(mobile,i);
total := total + 1;
sleepms(1);
endfor
print(total);
endfor
endprogram
40000 packages sent == Memory leak 10 MB
Re: Buff/debuff packet fixes
Posted: Tue Dec 09, 2008 8:19 am
by guialtran
Code: Select all
Use attributes;
Use basic;
Use boat;
Use cfgfile;
Use cliloc;
Use datafile;
Use file;
Use guilds;
Use http;
Use math;
Use npc;
Use os;
Use polsys;
Use storage;
Use unicode;
Use uo;
Use util;
Use vitals;
program testMemoryLeak(mobile)
var total := 0;
var j;
for(j:=0;j<=10000;j:=j+1)
var i;
for(i:=1001;i<=1048;i:=i+1)
BuffDebuff_adicionaIcone2(mobile,i,2);
total := total + 1;
sleepms(1);
endfor;
for(i:=1048;i>=1001;i:=i-1)
BuffDebuff_removeIcone2(mobile,i);
total := total + 1;
sleepms(1);
endfor
print(total);
endfor
endprogram
function BuffDebuff_adicionaIcone2(character,icone,tempo)
var msg := Packet_newB1(0xdf);//0 BYTE[1] Cmd
msg := msg+Packet_newB2(0x0);//1 BYTE[2] Length "tem que ser no fim"
msg := msg+Packet_newB4(character.serial);//3 BYTE[4] Serial of player
msg := msg+Packet_newB2(icone);//7 BYTE[2] Icon Number to show
msg := msg+Packet_newB2(0x1);//9 BYTE[2] 0x1 = Show, 0x0 = Remove. On remove byte, packet ends here.
msg := msg+Packet_newB4(0x0);//11 BYTE[4] 0x00000000
msg := msg+Packet_newB2(icone);//15 BYTE[2] Icon Number to show.
msg := msg+Packet_newB2(0x1);//17 BYTE[2] 0x1 = Show
msg := msg+Packet_newB4(0x0);//19 BYTE[4] 0x00000000
msg := msg+Packet_newB2(hex(tempo));//23 BYTE[2] Time in seconds (simple countdown without automatic remove)
msg := msg+Packet_newB2(0x0);//25 BYTE[2] 0x0000
msg := msg+Packet_newB1(0x0);//27 BYTE[1] 0x00
msg := msg+Packet_newB4(1005007);//28 BYTE[4] Cliloc message ID1 cliloc "enu"(cliloc 1042971 == "~1_NOTHING~") (cliloc 1005007 == "")
msg := msg+Packet_newB4(1042971);//32 BYTE[4] Cliloc message ID2 cliloc "enu"(cliloc 1042971 == "~1_NOTHING~") (cliloc 1005007 == "")
msg := msg+Packet_newB4(0x0);//36 BYTE[4] 0x00000000
msg := msg+Packet_newB2(0x1);//40 BYTE[2] 0x0001
var msgAux := " ";// tem que ter esse " " para ele concatenar!
case(icone)
1001://1001: Dismount
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Dismount</BASEFONT>";
break;
1002://1002: Disarm
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Disarm</BASEFONT>";
break;
1005://1005: Nightsight
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Nightsight</BASEFONT>";
break;
1006://1006: Death Strike
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Death Strike</BASEFONT>";
break;
1007://1007: Evil Omen
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Evil Omen</BASEFONT>";
break;
1008://1008: unknown? (GumpID 0x7556)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>unknown 1?</BASEFONT>";
break;
1009://1009: Regeneration (cliloc1=1044106,cliloc2=1075106)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>unknown 2?</BASEFONT>";
break;
1010://1010: Divine Fury
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Divine Fury</BASEFONT>";
break;
1011://1011: Enemy Of One
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Enemy Of One</BASEFONT>";
break;
1012://1012: Stealth (cliloc1=1044107,cliloc2=1075655)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Stealth</BASEFONT>";
break;
1013://1013: Active Meditation (cliloc1=1044106,cliloc2=1075106)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Active Meditation</BASEFONT>";
break;
1014://1014: Blood Oath caster
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Blood Oath caster</BASEFONT>";
break;
1015://1015: Blood Oath curse
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Blood Oath curse</BASEFONT>";
break;
1016://1016: Corpse Skin
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Corpse Skin</BASEFONT>";
break;
1017://1017: Mindrot
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Mindrot</BASEFONT>";
break;
1018://1018: Pain Spike
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Pain Spike</BASEFONT>";
break;
1019://1019: Strangle
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Strangle</BASEFONT>";
break;
1020://1020: Gift of Renewal
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Gift of Renewal</BASEFONT>";
break;
1021://1021: Attune Weapon
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Attune Weapon</BASEFONT>";
break;
1022://1022: Thunderstorm
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Thunderstorm</BASEFONT>";
break;
1023://1023: Essence of Wind
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Essence of Wind</BASEFONT>";
break;
1024://1024: Ethereal Voyage
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Ethereal Voyage</BASEFONT>";
break;
1025://1025: Gift Of Life
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Gift Of Life</BASEFONT>";
break;
1026://1026: Arcane Empowerment
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Arcane Empowerment</BASEFONT>";
break;
1027://1027: Mortal Strike
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Mortal Strike</BASEFONT>";
break;
1028://1028: Reactive Armor (cliloc1=1075812,cliloc2=1075813)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Reactive Armor</BASEFONT>";
break;
1029://1029: Protection (cliloc1=1075814,cliloc2=1075815)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Protection</BASEFONT>";
break;
1030://1030: Arch Protection (cliloc1=1075816,cliloc2=1075816)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Arch Protection</BASEFONT>";
break;
1031://1031: Magic Reflection (cliloc1=1075817,cliloc2=1075818)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Magic Reflection</BASEFONT>";
break;
1032://1032: Incognito (cliloc1=1075819,cliloc2=1075820)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Incognito</BASEFONT>";
break;
1033://1033: Disguised
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Disguised</BASEFONT>";
break;
1034://1034: Animal Form
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Animal Form</BASEFONT>";
break;
1035://1035: Polymorph (cliloc1=1075824,cliloc2=1075820)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Polymorph</BASEFONT>";
break;
1036://1036: Invisibility (cliloc1=1075825,cliloc2=1075826)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Invisibility</BASEFONT>";
break;
1037://1037: Paralyze (cliloc1=1075827,cliloc2=1075828)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Paralyze</BASEFONT>";
break;
1038://1038: Poison (cliloc1=0x0F8627, cliloc2=0x1069B1)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Poison</BASEFONT>";
break;
1039://1039: Bleed (cliloc1=0x106a75,cliloc2=0x106a76)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Bleed</BASEFONT>";
break;
1040://1040: Clumsy (cliloc1=0x106a77,cliloc2=0x106a78)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Clumsy</BASEFONT>";
break;
1041://1041: Feeble Mind (cliloc1=0x106a79,cliloc2=0x106a7a)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Feeble Mind</BASEFONT>";
break;
1042://1042: Weaken (cliloc1=1075837,cliloc2=1075838)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Weaken</BASEFONT>";
break;
1043://1043: Curse (cliloc1=1075835,cliloc2=1075836)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Curse</BASEFONT>";
break;
1044://1044: Mass Curse (cliloc1=0x106a7f,cliloc2=0x106a80)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Mass</BASEFONT>";
break;
1045://1045: Agility (cliloc1=0x106a81,cliloc2=0x106a82)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Agility</BASEFONT>";
break;
1046://1046: Cunning (cliloc1=0x106a83,cliloc2=0x106a84)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Cunning</BASEFONT>";
break;
1047://1047: Strength (cliloc1=0x106a85,cliloc2=0x106a86)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Strength</BASEFONT>";
break;
1048://1048: Bless (cliloc1=0x106a87,cliloc2=0x106a88)
msgAux := msgAux+"<BASEFONT COLOR=#ff00ff>Bless</BASEFONT>";
break;
default:
return 0;
break;
endcase
msg := msg+Packet_newUnicodeStringFlipped(msgAux);//42 BYTE[len(str)*2] Flipped Unicode String (" "+str) (To seperate the entrys add " ")
msg := msg+"0000";//? BYTE[2] 0x0000 , o valor "1" do terceiro parametro da funcao ".SetUnicodeString(,,1)" indica que ele ja coloca um duplo zero no fim.
msg := Packet_setSize(msg,1,2);//1 BYTE[2] Length
SendPacket(character,msg);
return 1;
endfunction
function BuffDebuff_removeIcone2(character,icone)
var msg := Packet_newB1(0xdf);//0 BYTE[1] Cmd
msg := msg+Packet_newB2(0x0);//1 BYTE[2] Length "tem que ser no fim"
msg := msg+Packet_newB4(character.serial);//3 BYTE[4] Serial of player
msg := msg+Packet_newB2(icone);//7 BYTE[2] Icon Number to show
msg := msg+Packet_newB2(0x0);//9 BYTE[2] 0x1 = Show, 0x0 = Remove. On remove byte, packet ends here.
msg := msg+Packet_newB4(0x0);//11 BYTE[4] 0x00000000
msg := msg+Packet_newB2(icone);//15 BYTE[2] Icon Number to show.
msg := msg+Packet_newB2(0x0);//17 BYTE[2] 0x1 = Show
msg := msg+Packet_newB4(0x0);//19 BYTE[4] 0x00000000
msg := msg+Packet_newB2(0x0);//23 BYTE[2] Time in seconds (simple countdown without automatic remove)
msg := msg+Packet_newB2(0x0);//25 BYTE[2] 0x0000
msg := msg+Packet_newB1(0x0);//27 BYTE[1] 0x00
msg := msg+Packet_newB4(1005007);//28 BYTE[4] Cliloc message ID1 cliloc "enu"(cliloc 1042971 == "~1_NOTHING~") (cliloc 1005007 == "")
msg := msg+Packet_newB4(1005007);//32 BYTE[4] Cliloc message ID2 cliloc "enu"(cliloc 1042971 == "~1_NOTHING~") (cliloc 1005007 == "")
msg := msg+Packet_newB4(0x0);//36 BYTE[4] 0x00000000
msg := msg+Packet_newB4(0x1);//40 BYTE[2] 0x0001
msg := msg+Packet_newUnicodeStringFlipped("");//42 BYTE[len(str)*2] Flipped Unicode String (" "+str) (To seperate the entrys add " ")
msg := msg+"00";//? BYTE[2] 0x0000 , o valor "1" do terceiro parametro da funcao ".SetUnicodeString(,,1)" indica que ele ja coloca um duplo zero no fim.
msg := Packet_setSize(msg,1,2);//1 BYTE[2] Length
SendPacket(character,msg);
return 1;
endfunction
// .INC !!!
function Packet_setSize(ByRef msg,index,bytes)
msg := CStr(msg);
index := ((index*2)+1);
bytes := bytes*2;
var size := hex(len(msg)/2);
size := size[3,len(size)];
while(bytes>len(size))
size := "0"+size;
endwhile
var i;
for(i:=0;i<len(size);i:=i+1)
msg[(i+index)]:= size[i+1];
endfor
return msg;
endfunction
function Packet_newB1(valor)
valor := Hex(valor);
valor := valor[3,len(valor)];
valor := "0"+valor;
valor := valor[(len(valor)-1),2];
return valor;
endfunction
function Packet_newB2(valor)
valor := Hex(valor);
valor := valor[3,len(valor)];
valor := "000"+valor;
valor := valor[(len(valor)-3),4];
return valor;
endfunction
function Packet_newB4(valor)
valor := Hex(valor);
valor := valor[3,len(valor)];
valor := "0000000"+valor;
valor := valor[(len(valor)-7),8];
return valor;
endfunction
function Packet_newB2Flipped(valor)
valor := Hex(valor);
valor := valor[3,len(valor)];
valor := "000"+valor;
valor := valor[(len(valor)-3),4];
valor := valor[3,2]+ valor[1,2];
return valor;
endfunction
function Packet_newB4Flipped(valor)
valor := Hex(valor);
valor := valor[3,len(valor)];
valor := "0000000"+valor;
valor := valor[(len(valor)-7),8];
valor := valor[7,2]+valor[5,2]+valor[3,2]+valor[1,2];
return valor;
endfunction
function Packet_newString(valor)
valor := CStr(valor);
var i;
var str := "";
var aux;
for(i:=1;i<=len(valor);i:=i+1)
aux := Hex(CAsc(valor[i]));
aux := "0"+aux[3,2];
str := str+aux[(len(aux)-1),2];
endfor
return str;
endfunction
function Packet_newUnicodeString(valor)
valor := CStr(valor);
var i;
var str := "";
var aux;
for(i:=1;i<=len(valor);i:=i+1)
aux := Hex(CAsc(valor[i]));
aux := "000"+aux[3,4];
str := str+aux[(len(aux)-3),4];
endfor
return str;
endfunction
function Packet_newUnicodeStringFlipped(valor)
valor := CStr(valor);
var i;
var str := "";
var aux;
for(i:=1;i<=len(valor);i:=i+1)
aux := Hex(CAsc(valor[i]));
aux := "000"+aux[3,4];
str := str+aux[(len(aux)-1),2]+aux[(len(aux)-3),2];
endfor
return str;
endfunction
100000 packages sent == Memory leak 0 MB
msn
cr0n0s_7@hotmail.com
Re: Buff/debuff packet fixes
Posted: Tue Dec 09, 2008 9:29 pm
by OldnGrey
hey, care to help find the reason? comparing hundreds of lines is NO fun
Re: Buff/debuff packet fixes
Posted: Wed Dec 10, 2008 12:48 am
by ncrsn
Looks to me the difference is in using CreatePacket() -> packet.SendPacket(who) and msg := "" -> UO::SendPacket(who, msg).
I have not compared these methods myself, but should these work as guialtran said, this could be useful information to devs.
Re: Buff/debuff packet fixes
Posted: Wed Dec 10, 2008 2:00 am
by OldnGrey
I still have to restart my shard every 25 hours, but I do make heavy use of these packets plus tons of megaclilocs (using plain text and not clilocs it must be admitted). We accumulate RAM too. Oh I hope we discover how to keep our shards up for longer. I know Taxman is severely impacted and it's hard to see why I need 1.2GB of RAM for pol.exe.
We probably should start a campaign to use clilocs whereever possible, but that's another story.
Re: Buff/debuff packet fixes
Posted: Wed Dec 10, 2008 4:49 am
by guialtran
msg :="eeeeeeeeee";
index:=1;
bytes:=2
Packet_setSize(ByRef msg,index,bytes)
msg == "ee000aeeee"
valor:="0xe"
Packet_newB1(valor)
return "0e"
valor:="0xe"
Packet_newB2(valor)
return "000e"
valor:="0xe"
Packet_newB4(valor)
return "0000000e"
valor:="0x234" == 0x0234
Packet_newB2Flipped(valor)
return "3402"
valor:="0x10234" == 0x00010234
Packet_newB4Flipped(valor)
return "34020100"
valor := "123" ... 1==0x31...1==0x32....
Packet_newString(valor)
return "313233"
valor := "123" ... 1==0x31...1==0x32....
Packet_newUnicodeString(valor)
return "003100320033"
valor := "123" ... 1==0x31...1==0x32....
Packet_newUnicodeStringFlipped(valor)
return "310032003300"