Exemplo n.º 1
0
            public coordheading FindEntry(int Playfield, int DestinationNumber)
            {
                coordheading ret = new coordheading();

                ret.Coordinates.x = -1;
                foreach (Collision.WallCollision.Line l in Collision.WallCollision.destinations[Playfield].playfield.lines)
                {
                    if (l.ID != DestinationNumber)
                    {
                        continue;
                    }
                    ret.Coordinates.x = (l.start.X + l.end.X) / 2;
                    ret.Coordinates.y = (l.start.Y + l.end.Y) / 2;
                    ret.Coordinates.z = (l.start.Z + l.end.Z) / 2;
                    // TODO: Calculate the right Quaternion for the heading...
                    // - Algorithman
                    Quaternion q = new Quaternion(new Vector3((l.end.X - l.start.X), 1, -(l.end.Z - l.start.Z)));
                    ret.Heading.x = q.x;
                    ret.Heading.y = q.y;
                    ret.Heading.z = q.z;
                    ret.Heading.w = q.w;
                }
                return(ret);
            }
Exemplo n.º 2
0
            public void Execute(Client cli, Statel parent, int Eventnumber)
            {
                switch (FunctionNumber)
                {
                // Hit
                case 53002:
                {
                    int statnum = Int32.Parse(Arguments.ElementAt(0));
                    int min     = Int32.Parse(Arguments.ElementAt(1));
                    int max     = Int32.Parse(Arguments.ElementAt(2));
                    if (min > max)
                    {
                        min = max;
                        max = Int32.Parse(Arguments.ElementAt(1));
                    }
                    Random rnd = new Random();
                    cli.Character.Stats.Set(statnum, (uint)(cli.Character.Stats.Get(statnum) + rnd.Next(min, max)));
                    break;
                }

                // Lineteleport
                //
                case 53059:
                {
#if DEBUG
                    Console.WriteLine("Function 53059 (LineTeleport)");
                    Console.WriteLine("Object: " + parent.Type + ":" + parent.Instance);
#endif
                    uint arg2 = UInt32.Parse(Arguments.ElementAt(1));         // Linesegment and playfield (lower word)
                    arg2 = arg2 >> 16;
                    int          to_pf = Int32.Parse(Arguments.ElementAt(2));
                    coordheading a     = FindEntry(to_pf, (Int32)arg2);
                    if (a.Coordinates.x != -1)
                    {
                        cli.Teleport(a.Coordinates, a.Heading, to_pf);
                        break;
                    }
                    break;
                }

                case 53082:     // Teleport Proxy
                {
                    Identity pfinstance = new Identity();
                    pfinstance.Type     = Int32.Parse(Arguments.ElementAt(0));
                    pfinstance.Instance = Int32.Parse(Arguments.ElementAt(1));
                    Identity id2 = new Identity();
                    id2.Type     = Int32.Parse(Arguments.ElementAt(2));
                    id2.Instance = Int32.Parse(Arguments.ElementAt(3));
                    Identity id3 = new Identity();
                    id3.Type     = Int32.Parse(Arguments.ElementAt(4));
                    id3.Instance = Int32.Parse(Arguments.ElementAt(5));

                    SqlWrapper ms = new SqlWrapper();
                    DataTable  dt = ms.ReadDT("SELECT * from proxydestinations WHERE playfield=" + pfinstance.Instance);
                    if (dt.Rows.Count == 0)
                    {
#if DEBUG
                        cli.SendChatText("No Destination found for playfield " + pfinstance.Instance);
                        cli.SendChatText("Statel " + parent.Type.ToString() + ":" + parent.Instance.ToString() + " handling " + Eventnumber.ToString() + " Function " + FunctionNumber.ToString() + " " + cli.Character.Coordinates.ToString());
                        foreach (string arg in Arguments)
                        {
                            cli.SendChatText("Argument: " + arg);
                        }
#endif
                    }
                    else
                    {
                        AOCoord a = new AOCoord();
                        a.x = (Single)dt.Rows[0][1];
                        a.y = (Single)dt.Rows[0][2];
                        a.z = (Single)dt.Rows[0][3];
                        Quaternion q = new Quaternion(0, 0, 0, 0);
                        q.x = (Single)dt.Rows[0][4];
                        q.y = (Single)dt.Rows[0][5];
                        q.z = (Single)dt.Rows[0][6];
                        q.w = (Single)dt.Rows[0][7];
                        cli.TeleportProxy(a, q, pfinstance.Instance, pfinstance, 1, (Int32)parent.Instance, id2, id3);
                    }
                    break;
                }

                case 53092:     // Bank
                {
                    Packets.BankOpen.Send(cli);
                    break;
                }

                case 53083:     // Teleport Proxy 2
                {
                    Identity pfinstance = new Identity();
                    pfinstance.Type     = Int32.Parse(Arguments.ElementAt(0));
                    pfinstance.Instance = Int32.Parse(Arguments.ElementAt(1));
                    int      gs = 1;
                    int      sg = 0;
                    Identity R  = new Identity();
                    R.Type     = Int32.Parse(Arguments.ElementAt(2));
                    R.Instance = Int32.Parse(Arguments.ElementAt(3));
                    Identity dest = new Identity();
                    dest.Type     = Int32.Parse(Arguments.ElementAt(4));
                    dest.Instance = Int32.Parse(Arguments.ElementAt(5));
                    int          to_pf = (Int32)((UInt32)(dest.Instance & 0xffff));
                    int          arg2  = (Int32)((UInt32)(dest.Instance >> 16));
                    coordheading a     = FindEntry(to_pf, arg2);

                    if (a.Coordinates.x != -1)
                    {
                        cli.TeleportProxy(a.Coordinates, a.Heading, to_pf, pfinstance, gs, sg, R, dest);
                        break;
                    }
                    break;
                }

                // Teleport
                case 53016:
                {
                    Quaternion q = new Quaternion(0, 1, 0, 0);
                    AOCoord    a = new AOCoord();
                    a.x = Int32.Parse(Arguments.ElementAt(0));
                    a.y = Int32.Parse(Arguments.ElementAt(1));
                    a.z = Int32.Parse(Arguments.ElementAt(2));
                    cli.Teleport(a, q, Int32.Parse(Arguments.ElementAt(3)));
                    break;
                }

                case 53044:
                {
                    string text = Arguments.ElementAt(0);
                    Packets.SystemText.Send(cli, text, 0);
                    break;
                }

                default:
                {
#if DEBUG
                    cli.SendChatText("Statel " + parent.Type.ToString() + ":" + parent.Instance.ToString() + " handling " + Eventnumber.ToString() + " Function " + FunctionNumber.ToString() + " " + cli.Character.Coordinates.ToString());
                    foreach (string arg in Arguments)
                    {
                        cli.SendChatText("Argument: " + arg);
                    }
#endif
                    break;
                }
                }
            }
Exemplo n.º 3
0
 public coordheading FindEntry(int Playfield, int DestinationNumber)
 {
     coordheading ret = new coordheading();
     ret.Coordinates.x = -1;
     foreach (Collision.WallCollision.Line l in Collision.WallCollision.destinations[Playfield].playfield.lines)
     {
         if (l.ID != DestinationNumber)
         {
             continue;
         }
         ret.Coordinates.x = (l.start.X + l.end.X) / 2;
         ret.Coordinates.y = (l.start.Y + l.end.Y) / 2;
         ret.Coordinates.z = (l.start.Z + l.end.Z) / 2;
         // TODO: Calculate the right Quaternion for the heading...
         // - Algorithman
         Quaternion q = new Quaternion(new Vector3((l.end.X - l.start.X), 1, -(l.end.Z - l.start.Z)));
         ret.Heading.x = q.x;
         ret.Heading.y = q.y;
         ret.Heading.z = q.z;
         ret.Heading.w = q.w;
     }
     return ret;
 }