from some random source I read:
The quick bar system sends a couple of new packets in the 0xBF extended command range. These are for the targeted quick bar icons. (when u drag an icon down, and right click on it, u'll see 3 target types, self, cursor and current).
Currently only the cursor type is working, as it sends one of the traditional packet. Both of the targeted commands needs additional supporting.
Also, these packets seem to have a lot of junk info in there, so beware, don't get thrown off.
A few more packets regarding the KR quickbar system
Alright, more info flows in
Targeted Item Use: (0xBF subcommand 0x2C)
BYTE BF
BYTE[2] LEN 00 0D // 13 bytes
BYTE[2] SUBCMD 00 2C
BYTE[4] SOURCE ITEM SERIAL
BYTE[4] TARGET SERIAL
Targeted Spell Cast: (0xBF sub 0x2D)
BYTE BF
BYTE[2] LEN 00 0B // 11 bytes
BYTE[2] SUBCMD 00 2D
BYTE[2] SPELL ID // 1-based (clumsy is 1)
BYTE[4] TARGET SERIAL
Targeted Skill Use: (0xBF sub 0x2E)
same structure as Targeted Spell Cast
suggested RunUO handlers:
In EventSink.cs, declare eventargs:
and also events with invoke methods
Then in packethandlers.cs, add in the proper handler routine:
and finally, in the static constructor:
This is all the core mod required. Now in the script side it must register an eventhandler to each type of event, and handle them properly there - it's up to you to decide how you should handle them.
Targeted Item Use: (0xBF subcommand 0x2C)
BYTE BF
BYTE[2] LEN 00 0D // 13 bytes
BYTE[2] SUBCMD 00 2C
BYTE[4] SOURCE ITEM SERIAL
BYTE[4] TARGET SERIAL
Targeted Spell Cast: (0xBF sub 0x2D)
BYTE BF
BYTE[2] LEN 00 0B // 11 bytes
BYTE[2] SUBCMD 00 2D
BYTE[2] SPELL ID // 1-based (clumsy is 1)
BYTE[4] TARGET SERIAL
Targeted Skill Use: (0xBF sub 0x2E)
same structure as Targeted Spell Cast
suggested RunUO handlers:
In EventSink.cs, declare eventargs:
Code: Alles auswählen
#region UOKR Quick Bar Event Args
public class TargetedSpellEventArgs : EventArgs
{
private NetState state;
private IEntity target;
private short spellID;
public NetState NetState
{
get { return state; }
}
public IEntity Target
{
get { return target; }
}
public short SpellID
{
get { return spellID; }
}
public TargetedSpellEventArgs(NetState state, IEntity target, short spellID)
{
this.state = state;
this.target = target;
this.spellID = spellID;
}
}
public class TargetedSkillEventArgs : EventArgs
{
private NetState state;
private IEntity target;
private short spellID;
public NetState NetState
{
get { return state; }
}
public IEntity Target
{
get { return target; }
}
public short SpellID
{
get { return spellID; }
}
public TargetedSkillEventArgs(NetState state, IEntity target, short spellID)
{
this.state = state;
this.target = target;
this.spellID = spellID;
}
}
public class TargetedItemUseEventArgs : EventArgs
{
private NetState state;
private IEntity src;
private IEntity target;
public NetState NetState
{
get { return state; }
}
public IEntity Source
{
get { return src; }
}
public IEntity Target
{
get { return target; }
}
public TargetedItemUseEventArgs(NetState state, IEntity src, IEntity target)
{
this.state = state;
this.src = src;
this.target = target;
}
}
#endregion
Code: Alles auswählen
/* UOKR Quick Bar */
public static event EventHandler<TargetedSpellEventArgs> TargetedSpellCast;
public static event EventHandler<TargetedSkillEventArgs> TargetedSkillUse;
public static event EventHandler<TargetedItemUseEventArgs> TargetedItemUse;
public static void InvokeTargetedSpellCast( NetState ns, IEntity target, short spellID )
{
if (TargetedSpellCast != null)
TargetedSpellCast(ns, new TargetedSpellEventArgs(ns, target, spellID));
}
public static void InvokeTargetedSkillUse(NetState ns, IEntity target, short skillId)
{
if (TargetedSkillUse != null)
TargetedSkillUse(ns, new TargetedSkillEventArgs(ns, target, skillId));
}
public static void InvokeTargetedItemUse(NetState ns, IEntity src, IEntity target)
{
if (TargetedItemUse != null)
TargetedItemUse(ns, new TargetedItemUseEventArgs(ns, src, target));
}
Code: Alles auswählen
public static void TargetedSpell(NetState ns, PacketReader pvSrc)
{
short spellId = (short)(pvSrc.ReadInt16()-1); // zero based;
Serial target = pvSrc.ReadInt32();
EventSink.InvokeTargetedSpellCast(ns, World.FindEntity(target), spellId);
}
public static void TargetedItemUse(NetState ns, PacketReader pvSrc)
{
Serial target = pvSrc.ReadInt32();
Serial srcItem = pvSrc.ReadInt32();
if (srcItem.IsItem)
EventSink.InvokeTargetedItemUse(ns, World.FindItem(srcItem), World.FindEntity(target));
}
public static void TargetedSkillUse(NetState ns, PacketReader pvSrc)
{
short skillId = pvSrc.ReadInt16();
Serial target = pvSrc.ReadInt32();
EventSink.InvokeTargetedSkillUse(ns, World.FindEntity(target), skillId);
}
Code: Alles auswählen
RegisterExtended(0x2C, true, new OnPacketReceive(TargetedItemUse));
RegisterExtended(0x2D, true, new OnPacketReceive(TargetedSpell));
RegisterExtended(0x2E, true, new OnPacketReceive(TargetedSkillUse));
Zuletzt geändert von pmouse am 09 Jul 2007 07:30, insgesamt 1-mal geändert.
Cannot implicitly convert type 'int' to 'short'. An explicit conversion exists (are you missing a cast?) (CS0266) - F:\Documents and Settings\Matthew Garbett.MATTHEW\Desktop\MSPUO Development Server\Core Project\Server\Network\PacketHandlers.cs:180,29
public static void TargetedSpell(NetState ns, PacketReader pvSrc)
{
short spellId = pvSrc.ReadInt16()-1; // zero based;
Serial target = pvSrc.ReadInt32();
EventSink.InvokeTargetedSpellCast(ns, World.FindEntity(target), spellId);
}
public static void TargetedSpell(NetState ns, PacketReader pvSrc)
{
short spellId = pvSrc.ReadInt16()-1; // zero based;
Serial target = pvSrc.ReadInt32();
EventSink.InvokeTargetedSpellCast(ns, World.FindEntity(target), spellId);
}
public static void TargetedItemUse(NetState ns, PacketReader pvSrc)
{
Serial [highlight=red]srcItem[/highlight] = pvSrc.ReadInt32();
Serial [highlight=red]target[/highlight] = pvSrc.ReadInt32();
if (srcItem.IsItem)
EventSink.InvokeTargetedItemUse(ns, World.FindItem(srcItem), World.FindEntity(target));
}
{
Serial [highlight=red]srcItem[/highlight] = pvSrc.ReadInt32();
Serial [highlight=red]target[/highlight] = pvSrc.ReadInt32();
if (srcItem.IsItem)
EventSink.InvokeTargetedItemUse(ns, World.FindItem(srcItem), World.FindEntity(target));
}