C#:
using System;
using System.Linq;
using System.Collections.Generic;
using NewWidget.Core;
using NewWidget.Core.Native;
using NewWidget.Core.Scripting;
using NewWidget.Core.Network;
using System.Reflection;
public class Script : ScriptBase {
int delay = 100; //делей на добавление атрибута в мс
int ActiveStoneId;
int ActiveItemId;
public override void OnStart() {
base.OnStart();
ClientPacket(p => p.Id == 0xD0 && p.ExtendedId == 0x35, p => ActiveItemId = p.GetReader().ReadD());
ClientPacket(p => p.Id == 0x19 && GetAttStone(p) != null, p => ActiveStoneId = GetAttStone(p).Id);
CreateTimer(delay, () => ActiveStoneId > 0 && CommonInventory.Any(i => i.ObjectId == ActiveItemId), AddAttribute);
EnabledChanged(false, () => { ActiveStoneId = 0; ActiveItemId = 0;});
}
void AddAttribute() {
var item = CommonInventory.FirstOrDefault(i => i.ObjectId == ActiveItemId);
if(Me.ItemCount(ActiveStoneId) == 0)
Done();
//проверяем наличие атакующего атрибута
if(item.Attribute.AttackValue > 0 && ((ActiveStoneId <= 9551 && item.Attribute.AttackValue < 150) ||
(ActiveStoneId <= 9557 && ActiveStoneId > 9551 && item.Attribute.AttackValue < 300) ||
(ActiveStoneId <= 9563 && ActiveStoneId > 9557 && item.Attribute.AttackValue < 450) ||
(ActiveStoneId <= 9569 && ActiveStoneId > 9563 && item.Attribute.AttackValue < 600))) {
Client.UseItem(ActiveStoneId);
Client.EnchantAttributeItem(item);
return;
}
else if(item.Attribute.AttackValue > 0)
Done();
//ищем дефенс атрибут под наш камень
foreach(var attProp in item.Attribute.GetType().GetProperties()) {
if(attProp.Name == "AttackElement" || attProp.Name == "AttackValue") {
continue;
}
if(Elements[attProp.Name].Contains(ActiveStoneId)) {
var Value = (int)attProp.GetValue(item.Attribute);
if((ActiveStoneId <= 9551 && Value < 60) ||
(ActiveStoneId <= 9557 && ActiveStoneId > 9551 && Value < 120) ||
(ActiveStoneId <= 9563 && ActiveStoneId > 9557 && Value < 180) ||
(ActiveStoneId <= 9569 && ActiveStoneId > 9563 && Value < 240)) {
Client.UseItem(ActiveStoneId);
Client.EnchantAttributeItem(item);
}
else
Done();
}
}
}
L2Item GetAttStone(Packet pck) {
return CommonInventory.FirstOrDefault(i => i.ObjectId == pck.GetReader().ReadD() && i.Id >= 9546 && i.Id <= 9569);
}
void Done() {
ActiveItemId = 0;
ActiveStoneId = 0;
L2Helper.PlaySound("hp.wav");
L2Helper.ShowBalloon("Атрибут вставлен/кончились камни", 5000);
}
Dictionary<string, int[]> Elements = new Dictionary<string, int[]>() {
{"DefenceFire", new int[]{9547, 9553, 9559, 9565}},
{"DefenceWater", new int[]{9546, 9552, 9558, 9564}},
{"DefenceWind", new int[]{9548, 9554, 9560, 9566}},
{"DefenceEarth", new int[]{9549, 9555, 9561, 9567}},
{"DefenceHoly", new int[]{9550, 9556, 9562, 9568}},
{"DefenceDark", new int[]{9551, 9557, 9563, 9569}}
};
}