PDA

Просмотр полной версии : помогите баф скрипт


nab
07.12.2009, 22:33
sorry for English but my Russian is not that good :D
on the server i play we have AIO buffers and i made 2 scripts 1 for mage and 1 for fighter buffs , the problem is when the AIO starts buffing all my clients freeze till its done buffing ....

Извините за мой английский, но русский, не очень удобно: D
на сервере я играю мы AIO буферов, и я сделал 2 скрипта 1 для магов и 1 для истребителя любители, проблема, когда начинается AIO полировки все мои клиенты заморозить до его сделали шлифовкой ....

Добавлено через 53 секунды
const
list=HStr('49 50 00 4D 00 20 00 22 00 6D 00 61 00 67 00 65 00 20 00 6F 00 72 00 20 00 22 00 66 00 69 00 67 00 68 00 74 00 65 00 72 00 00 00 03 00 00 00');
HolyResistance=HStr('39 70 05 00 00 00 00 00 00 00');
UnholyResistance=HStr('39 71 05 00 00 00 00 00 00 00');
ResistFire=HStr('39 A7 04 00 00 00 00 00 00 00');
ResistWind=HStr('39 A5 04 00 00 00 00 00 00 00');
ResistAqua=HStr('39 9E 04 00 00 00 00 00 00 00');
ElementalProtection=HStr('39 48 05 00 00 00 00 00 00 00');
DivineProtection=HStr('39 49 05 00 00 00 00 00 00 00');
ArcaneProtection=HStr('39 4A 05 00 00 00 00 00 00 00');
MentalShield=HStr('39 0B 04 00 00 00 00 00 00 00');
ResistShock=HStr('39 EB 04 00 00 00 00 00 00 00');
ImproveShieldDefense=HStr('39 DF 05 00 00 00 00 00 00 00');
ImproveMagic=HStr('39 DC 05 00 00 00 00 00 00 00');
ImproveCombat=HStr('39 DB 05 00 00 00 00 00 00 00');
ImproveCondition=HStr('39 DD 05 00 00 00 00 00 00 00');
ImproveMovement=HStr('39 E0 05 00 00 00 00 00 00 00');
WildMagic=HStr('39 17 05 00 00 00 00 00 00 00');
Acumen=HStr('39 3D 04 00 00 00 00 00 00 00');
EarthChant=HStr('39 6F 05 00 00 00 00 00 00 00');
ProphecyofWater=HStr('39 4B 05 00 00 00 00 00 00 00');
NoblesseBlessing=HStr('39 2B 05 00 00 00 00 00 00 00');
ChantofProtection=HStr('39 B5 05 00 00 00 00 00 00 00');
DanceofAquaGuard=HStr('39 33 01 00 00 00 00 00 00 00');
SongofElemental=HStr('39 11 02 00 00 00 00 00 00 00');
SongofEarth=HStr('39 08 01 00 00 00 00 00 00 00');
SongofWarding=HStr('39 0B 01 00 00 00 00 00 00 00');
SongofWind=HStr('39 0C 01 00 00 00 00 00 00 00');
SongofInvocation=HStr('39 0E 01 00 00 00 00 00 00 00');
SongofVitality=HStr('39 30 01 00 00 00 00 00 00 00');
DanceofConcentration=HStr('39 14 01 00 00 00 00 00 00 00');
SirenDance=HStr('39 6D 01 00 00 00 00 00 00 00');
DanceMystic=HStr('39 11 01 00 00 00 00 00 00 00');
SongofRenewal=HStr('39 5D 01 00 00 00 00 00 00 00');
Guidance=HStr('39 D8 04 00 00 00 00 00 00 00');
WarChant=HStr('39 6E 05 00 00 00 00 00 00 00');
ImproveCriticalAttack=HStr('39 DE 05 00 00 00 00 00 00 00');
ChantofBloodAwakening=HStr('39 EF 05 00 00 00 00 00 00 00');
ProphecyofFire=HStr('39 4C 05 00 00 00 00 00 00 00');
SongofFlameGuard=HStr('39 32 01 00 00 00 00 00 00 00');
SongofHunter=HStr('39 0D 01 00 00 00 00 00 00 00');
DanceofFury=HStr('39 13 01 00 00 00 00 00 00 00');
DanceofFire=HStr('39 12 01 00 00 00 00 00 00 00');
DanceoftheWarrior=HStr('39 0F 01 00 00 00 00 00 00 00');
SongofChampion=HStr('39 6C 01 00 00 00 00 00 00 00');
RequestAnswerJoinParty=HStr('43 01 00 00 00');

nab
07.12.2009, 22:35
var
Names: TStrings;
procedure init;
begin
Names := TStringList.Create;
Names.LoadFromFile('Names.txt');
end;
function CheckName(n: string) : Boolean;
begin
Result := False;
if (Names.IndexOf(n) > -1) then Result := True;
end;
var
name,pmsg:string;
ObjectID,n,i,y:integer;
begin
if FromServer then begin
case pck[1] of
#$39 : begin
name:=ReadS(2);
if CheckName(name) then begin
buf:=RequestAnswerJoinParty;
SendToServer;
buf:=list;
SendToServer;
end;
end;
#$4A : begin
i:=(10);
name:=ReadS(i);
pmsg:=ReadS(i);
if CheckName(name) and (Pmsg='fighter') then begin
//targets the person that PM`s
ObjectID:=ReadD(2);
buf:=#$1F;
WriteD(ObjectID);
SendToServer;
//buff list
buf:=HolyResistance;
SendToServer;
Delay(900);
buf:=UnholyResistance;
SendToServer;
Delay(900);
buf:=ResistFire;
SendToServer;
Delay(900);
buf:=ResistWind;
SendToServer;
Delay(900);
buf:=ResistAqua;
SendToServer;
Delay(900);
buf:=ElementalProtection;
SendToServer;
Delay(900);
buf:=DivineProtection;
SendToServer;
Delay(900);
buf:=ArcaneProtection;
SendToServer;
Delay(900);
buf:=MentalShield;
SendToServer;
Delay(900);
buf:=ResistShock;
SendToServer;
Delay(900);
buf:=ImproveCombat;
SendToServer;
Delay(900);
buf:=ImproveCondition;
SendToServer;
Delay(900);
buf:=ImproveMovement;
SendToServer;
Delay(900);
buf:=ImproveMagic;
SendToServer;
Delay(900);
buf:=WarChant;
SendToServer;
Delay(900);
buf:=ProphecyofFire;
SendToServer;
Delay(900);
buf:=NoblesseBlessing;
SendToServer;
Delay(900);
buf:=ChantofProtection;
SendToServer;
Delay(900);
buf:=DanceofAquaGuard;
SendToServer;
Delay(900);
buf:=SongofFlameGuard;
SendToServer;
Delay(900);
buf:=SongofElemental;
SendToServer;
Delay(900);
buf:=SongofEarth;
SendToServer;
Delay(900);
buf:=SongofWarding;
SendToServer;
Delay(900);
buf:=SongofWind;
SendToServer;
Delay(900);
buf:=SongofInvocation;
SendToServer;
Delay(900);
buf:=SongofVitality;
SendToServer;
Delay(900);
buf:=DanceofFury;
SendToServer;
Delay(900);
buf:=DanceofFire;
SendToServer;
Delay(900);
buf:=DanceoftheWarrior;
SendToServer;
Delay(900);
buf:=Guidance;
SendToServer;
Delay(900);
buf:=ImproveCriticalAttack;
SendToServer;
Delay(900);
buf:=ChantofBloodAwakening;
SendToServer;
Delay(900);
buf:=#$44; //leave party
SendToServer;
end;
end;
end;
end;
end.

alexteam
07.12.2009, 23:29
putting delay in script body - bad idea.
/deleted/

nab
08.12.2009, 10:06
i get this error :(
Undeclared Identifier 'writemask'

alexteam
08.12.2009, 12:22
nab, function writemask and variable UseForConnectName available in 3.5.24.142+
http://l2phx.pp.ru/arhive/

Добавлено через 11 минут
for older ones :
const
BufferCharacterName = 'BufferNick!'; // fill this one

var
Names: TStrings;
Timer : ttimer;
ObjectID : integer;
step : integer;

Procedure FighterBuffs(Sender:tobject);
begin
inc(step);
//BuffList.
case step of
1:CastSkillAndWait(1392, 900); //HolyResistance
2:CastSkillAndWait(1393, 900); //UnholyResistance
3:CastSkillAndWait(1191, 900); //ResistFire
4:CastSkillAndWait(1189, 900); //ResistWind
5:CastSkillAndWait(1192, 900); //ResistAqua
6:CastSkillAndWait(1352, 900); //ElementalProtection
7:CastSkillAndWait(1353, 900); //DivineProtection
8:CastSkillAndWait(1354, 900); //ArcaneProtection
9:CastSkillAndWait(1035, 900); //MentalShield
10:CastSkillAndWait(1259, 900); //ResistShock
11:CastSkillAndWait(1499, 900); //ImproveCombat
12:CastSkillAndWait(1501, 900); //ImproveCondition
13:CastSkillAndWait(1504, 900); //ImproveMovement
14:CastSkillAndWait(1500, 900); //ImproveMagic
15:CastSkillAndWait(1390, 900); //WarChant
16:CastSkillAndWait(1356, 900); //ProphecyofFire
17:CastSkillAndWait(1323, 900); //NoblesseBlessing
18:CastSkillAndWait(1461, 900); //ChantofProtection
19:CastSkillAndWait(307, 900); //DanceofAquaGuard
20:CastSkillAndWait(306, 900); //SongofFlameGuard
21:CastSkillAndWait(529, 900); //SongofElemental
22:CastSkillAndWait(264, 900); //SongofEarth
23:CastSkillAndWait(267, 900); //SongofWarding
24:CastSkillAndWait(268, 900); //SongofWind
25:CastSkillAndWait(270, 900); //SongofInvocation
26:CastSkillAndWait(304, 900); //SongofVitality
27:CastSkillAndWait(275, 900); //DanceofFury
28:CastSkillAndWait(274, 900); //DanceofFire
29:CastSkillAndWait(271, 900); //DanceoftheWarrior
30:CastSkillAndWait(1240, 900); //Guidance
31:CastSkillAndWait(1502, 900); //ImproveCriticalAttack
32:CastSkillAndWait(1519, 900); //ChantofBloodAwakening
else
begin
LeavePartyAndUntarget;
timer.enabled := false;
end;
end;
end;

Procedure MageBuffs(Sender:tobject);
begin
inc(step);
//BuffList.
case step of
1:;//...
2:;//...
3:;//...
4:;//...
else
begin
LeavePartyAndUntarget;
timer.enabled := false;
end;
end;
end;

Procedure LeavePartyAndUntarget;
begin
buf := #44;
SendToServerEx(BufferCharacterName);
buf := #48;
SendToServerEx(BufferCharacterName);
end;

Procedure CastSkillAndWait(SkillId,DelayMsec:integer);
begin
buf := #$39;
writed(skillid);
writed(0);
writed(0);
SendToServerEx(BufferCharacterName);

timer.interval := DelayMsec;
end;


procedure init;
begin
Names := TStringList.Create;
Names.LoadFromFile('Names.txt');
timer := ttimer.create(nil);
timer.interval := 100;
timer.enabled := false;
end;

procedure free;
begin
Names.free; //what about memory leaks ?
timer.free;
end;


function CheckName(n: string) : Boolean;
begin
Result := (Names.IndexOf(n) > -1);
end;

var
name,pmsg:string;
n,i,y:integer;
begin
if connectname <> BufferCharacterName then exit;

if FromServer then begin
case pck[1] of
#$39 : begin
name:=ReadS(2);
if CheckName(name) then
begin
buf:=#$43#01#00#00#00; //reply "Yes"
SendToServerEx(BufferCharacterName);
buf:=#$49;
writes('PM "mage or "fighter');
writed(3);
SendToServerEx(BufferCharacterName);
end
else
begin
buf:=#$43#00#00#00#00;//reply "No"
SendToServerEx(BufferCharacterName);
end
end;
#$4A :
if not timer.enabled then //if we are casting skills right now - ignore that pm or whatever.
begin
i:=(10);
name:=ReadS(i);
pmsg:=ReadS(i);
if CheckName(name) then
begin
step := 0;
timer.interval := 100;
ObjectID:=ReadD(2);
case lowercase(Pmsg) of
'fighter':
begin
buf:=#$1F;
WriteD(ObjectID);
SendToServerEx(BufferCharacterName);
timer.ontimer := @FighterBuffs;
timer.enabled := true;
end;
'mage':
begin
buf:=#$1F;
WriteD(ObjectID);
SendToServerEx(BufferCharacterName);
timer.ontimer := @MageBuffs;
timer.enabled := true;
end;
end;
end;
end;
end;
end;
end.

nab
08.12.2009, 22:08
works the same as mine old one did , all clients freeze when AIO starts buff :D
and on line 74 > buf := #$44; for dropping party if any ones plans on using that script :D

tnx for help :) ur script looks better then mine , but steel need to find why clients freeze when buffing :D

alexteam
08.12.2009, 22:56
grr.. 4get that Delay it's an export functions and its will runing in contex of l2ph aplication when called from any place. (or timer event runs not in contex of created for this event thread... no time for checking that)
post updated. http://coderx.ru/showpost.php?p=48435&postcount=5
about leaving party... you dont need to acept party if player name not in names.txt...
right now it's will accept party request from players in that list, then buff, and leave party after buffing.

nab
13.12.2009, 03:03
after evry Buff there is a ValidatePosition packet from Client. how to make it CastSkill wait for ValidatePosition packet move to other buff in list ? :D
that lag thing just pisses me off :D

Fer123
13.12.2009, 11:44
the problem is when the AIO starts buffing all my clients freeze till its done buffing ....
Run through phx only your aio clients and you won't have any lags on your main.