public void Read(RakNet.BitStream stream, RakNet.Packet packet, Client client)
        {
            int plID = 0;

            stream.Read(out plID);

            if (plID == 0 || !sWorld.VobDict.ContainsKey(plID))
            {
                throw new Exception("Vob not found!");
            }
            Vob vob = sWorld.VobDict[plID];

            if (!(vob is NPCProto))
            {
                throw new Exception("Vob is not an NPC!");
            }

            if (vob.Address == 0)
            {
                return;
            }
            Process process = Process.ThisProcess();
            oCNpc   npc     = new oCNpc(process, vob.Address);

            zVec3 pos = npc.GetPosition();

            npc.ResetPos(pos);
            pos.Dispose();
        }
Esempio n. 2
0
        public void SetLookAt(zVec3 lookAt)
        {
            zVec3 pos = GetPosition();

            float[] dir = new float[] { lookAt.X - pos.X, lookAt.Y - pos.Y, lookAt.Z - pos.Z };
            pos.Dispose();


            float revScalar = (float)Math.Sqrt(dir[0] * dir[0] + dir[1] * dir[1] + dir[2] * dir[2]);

            dir[0] /= revScalar; dir[1] /= revScalar; dir[2] /= revScalar;



            float[] upVector    = new float[] { TrafoObjToWorld.get(1), TrafoObjToWorld.get(5), TrafoObjToWorld.get(9) };
            float[] rightVector = new float[3];
            rightVector[0] = dir[1] * upVector[2] - dir[2] * upVector[1];
            rightVector[1] = dir[2] * upVector[0] - dir[0] * upVector[2];
            rightVector[2] = dir[0] * upVector[1] - dir[1] * upVector[0];

            TrafoObjToWorld.set(0, -1 * rightVector[0]);
            TrafoObjToWorld.set(4, -1 * rightVector[1]);
            TrafoObjToWorld.set(8, -1 * rightVector[2]);

            TrafoObjToWorld.set(2, dir[0]); TrafoObjToWorld.set(6, dir[1]); TrafoObjToWorld.set(10, dir[2]);
        }
Esempio n. 3
0
        public void Enable(float x, float y, float z)
        {
            zVec3 vec = zVec3.Create(Process);

            vec.X = x;
            vec.Y = y;
            vec.Z = z;

            Enable(vec);
            vec.Dispose();
        }
Esempio n. 4
0
        public void Project(float x, float y, float z, out int oX, out int oY)
        {
            zVec3 in1 = zVec3.Create(Process);

            in1.X = x;
            in1.Y = y;
            in1.Z = z;

            Project(in1, out oX, out oY);
            in1.Dispose();
        }
Esempio n. 5
0
        public void SetPositionWorld(float[] pos)
        {
            zVec3 p = zVec3.Create(Process);

            p.X = pos[0];
            p.Y = pos[1];
            p.Z = pos[2];

            SetPositionWorld(p);

            p.Dispose();
        }
        public void setScale(Vec3f scale)
        {
            this.Scale = scale;

            if (this.Address != 0)
            {
                Process process = Process.ThisProcess();
                oCNpc   npc     = new oCNpc(process, this.Address);

                zVec3 v = zVec3.Create(process);
                v.X = scale.X;
                v.Y = scale.Y;
                v.Z = scale.Z;
                npc.SetModelScale(v);
                v.Dispose();
            }
        }
        public static void setDirection(Vec3f dir)
        {
            if (playerVob == null)
            {
                return;
            }

            dir = dir.normalise();

            Process process = Process.ThisProcess();
            zCVob   vob     = playerVob;


            Vec3f zAxis = dir;
            Vec3f up    = new Vec3f(0.0f, 0.0f, 0.0f);

            if (Math.Abs(zAxis.Y) > 0.5)
            {
                if (zAxis.Y > 0)
                {
                    up.Z = -1.0f;
                }
                else
                {
                    up.Z = 1.0f;
                }
            }
            else if (Math.Abs(zAxis.X) < 0.0001 && Math.Abs(zAxis.Y) < 0.0001)
            {
                if (zAxis.Y > -0.0001)
                {
                    up.Y = 1.0f;
                }
                else
                {
                    up.Y = -1.0f;
                }
            }
            else
            {
                up.Y = 1.0f;
            }



            Vec3f xAxis = up.cross(zAxis).normalise();
            Vec3f yAxis = zAxis.cross(xAxis).normalise();

            Matrix4 trafo = vob.TrafoObjToWorld;

            trafo.set(12, 0);
            trafo.set(13, 0);
            trafo.set(14, 0);
            trafo.set(15, 1);

            trafo.set(0, xAxis.X);
            trafo.set(4, xAxis.Y);
            trafo.set(8, xAxis.Z);

            trafo.set(1, yAxis.X);
            trafo.set(5, yAxis.Y);
            trafo.set(9, yAxis.Z);

            trafo.set(2, zAxis.X);
            trafo.set(6, zAxis.Y);
            trafo.set(10, zAxis.Z);


            zVec3 p = vob.GetPosition();

            vob.SetPositionWorld(p);

            p.Dispose();
        }