command flash

Need help with your JScripts? Got questions concerning the DFNs? Come forward, step inside :)
Post Reply
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

command flash

Post by dragon slayer »

I was trying to figure how to get this command to work right
function command_FLASH( socket, cmdString )
{
    //var socket = pUser.socket;
    // Notes
    // FadeOut = 0x00  
    // FadeIn = 0x01   
    // LightFlash = 0x02       
    // FadeInOut = 0x03
    // DarkFlash = 0x04
   
    var myPacket = new Packet; // Create new packet stream
    myPacket.ReserveSize( 3 ); // Reserve packet size of 3, which is optimal for packet 0xBC in this case
    myPacket.WriteByte( 0, 0x70 ); // Write packetID (0x70) at position 0
    myPacket.WriteByte( 1, 0x02 ); // Write Season flag at position 1 (0+WriteByte, or 0+1)
    myPacket.WriteByte( 2, 0x00 ); // Write PlayMusic (0x00 = no, 0x01 = yes - doesn't seem to work) at position 2 (1+WriteByte, or 0+1)
    socket.Send( myPacket );
    myPacket.Free();
    return false;
}
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

I think you should remove or update the comments in that script, to avoid confusion. They don't make any sense for that packet (0x70) :)

Basically you need to reserve the correct size for the particle (which in 0x70 case is 28, according to various packet docs), and you need to send all the necessary details. I'll quote the relevant sections from one of the packet doc guides:
RUOSI Packet Guide wrote:Graphical Effect Packet.
28 bytes
from server
byte ID (70)
byte Type (0x00 = from source to destination, 0x01 = lightning strike, 0x02 = stay with destination, 0x03 = stay with source, 0x04 = special effects)
dword Character Serial
dword Target Serial
word Object ID (for type = 0x04 use 0x00 - 0x04 values for different special flash effects)
word Source X
word Source Y
sbyte Source Z
word Destination X
word Destination Y
sbyte Destination Z
byte Speed
byte Duration
word 0x00
byte Fixed Direction (0x00 = No, 0x01 = Yes)
byte Explode (0x00 = No, 0x01 = Yes)
Since UO:SA this packet can be used for special effects.
Basically in UOX3 terms, a byte is the same as WriteByte(), a word is the same as WriteShort(), and an int is the same as WriteLong().

I'm guessing you would need something like...

Code: Select all

pStream.ReserveSize( 28 ); //packet Size
pStream.WriteByte( 0, 0x70 ); //packet ID
pStream.WriteByte( 1, 0x04 ); //type 0x04 - special effects
pStream.WriteLong( 2, 0 ); //From serial
pStream.WriteLong( 6, 0 ); //To serial
Then depending on whether or not you're using the special effect type (0x04):

Code: Select all

// For type 0x04:
pStream.WriteLong( 10, 0 ); //filling up packet
pStream.WriteLong( 14, 0 ); //filling up packet
pStream.WriteLong( 18, 0 ); //filling up packet
pStream.WriteLong( 22, 0 ); //filling up packet
pStream.WriteShort( 26, 0 ); //filling up packet

Code: Select all

// For other types:
pStream.WriteShort( 10, modelID );
pStream.WriteShort( 12, xLocation );
pStream.WriteShort( 14, yLocation );
pStream.WriteByte( 16, zLocation );
pStream.WriteShort( 17, targxLocation );
pStream.WriteShort( 19, targyLocation );
pStream.WriteByte( 21, targzLocation );
pStream.WriteByte( 22, animSpeed );
pStream.WriteByte( 23, duration ); //0 long, 1 short
pStream.WriteShort( 24, unknown ); //0?
pStream.WriteByte( 26, adjustDir ); //1?
pStream.WriteByte( 27, explode? ); //0 or 1?
Ending of course with the regular socket.Send( pStream ); and pStream.Free stuff. Observe how the packet ends up with a size of 27 (+1 byte for the last WriteByte) bytes, which is the same as what we reserved at the start :) No idea if this will work, but it's a start, at least.
-= Ho Eyo He Hum =-
dragon slayer
UOX3 Guru
Posts: 776
Joined: Thu Dec 21, 2006 7:37 am
Has thanked: 4 times
Been thanked: 26 times

Post by dragon slayer »

aw okay. Well I'm going to read those guides see if i can come to some kind of understanding about packets
Post Reply