Ejemplo n.º 1
0
        private void RandomizeAllObjects(World world)
        {
            world.ReadObjectNames();
            Dictionary <string, Pointer <SuperObject> > superObjects = world.GetActiveSuperObjects();

            foreach (SuperObject *superObject in superObjects.Values)
            {
                Perso *perso       = (Perso *)superObject->engineObjectPtr;
                int    aiModelID   = perso->stdGamePtr->modelID;
                string aiModelName = world.ObjectNames[ObjectSet.Model][aiModelID];

                if (aiModelName == "DS1_GEN_PTC_GenCKS" || aiModelName == "DS1_GEN_PTC_GenBigFile")
                {
                    perso->brain = null;
                    continue;
                }

                RandomizeObject(superObject);
            }

            SuperObject *global  = superObjects["global"];
            DsgMem *     dsgMem  = ((Perso *)global->engineObjectPtr)->brain->mind->dsgMem;
            DsgVar *     dsgVars = *dsgMem->dsgVar;
            DsgVarInfo   info    = dsgVars->dsgVarInfos[63];

            bool *bool63 = (bool *)((int)dsgMem->memoryBufferCurrent + info.offsetInBuffer);

            *bool63 = false;
        }
Ejemplo n.º 2
0
        public List <DsgVarInfoAndValues> GetDsgVarList()
        {
            var result = new List <DsgVarInfoAndValues>();

            if (brain == null || brain->mind == null || brain->mind->dsgMem == null || brain->mind->dsgMem->dsgVar == null)
            {
                return(result);
            }

            DsgMem *dsgMem = brain->mind->dsgMem;
            DsgVar *dsgVar = *(dsgMem->dsgVar);

            for (int i = 0; i < dsgVar->dsgVarInfosLength; i++)
            {
                var info = dsgVar->dsgVarInfos[i];
                result.Add(new DsgVarInfoAndValues()
                {
                    info            = info,
                    valuePtrCurrent = new IntPtr(dsgMem->memoryBufferCurrent + info.offsetInBuffer),
                    valuePtrInitial = new IntPtr(dsgMem->memoryBufferInitial + info.offsetInBuffer)
                });
            }

            return(result);
        }
Ejemplo n.º 3
0
        private void RandomizeObject(SuperObject *superObject)
        {
            Perso *perso = (Perso *)superObject->engineObjectPtr;

            Brain *brain = perso->brain;

            if (brain == null)
            {
                return;
            }

            DsgMem *dsgMem = brain->mind->dsgMem;

            if (dsgMem == null)
            {
                return;
            }

            DsgVar *dsgVars = *dsgMem->dsgVar;

            for (int i = 0; i < dsgVars->dsgVarInfosLength; i++)
            {
                if (random.NextDouble() > randomizeChance)
                {
                    continue;
                }

                DsgVarInfo info = dsgVars->dsgVarInfos[i];
                DsgVarType type = info.type;

                byte *buffer = dsgMem->memoryBufferCurrent;
                int   ptr    = (int)buffer + info.offsetInBuffer;

                switch (type)
                {
                case DsgVarType.Boolean:
                    *(bool *)ptr = random.Next(0, 2) == 0;
                    break;

                case DsgVarType.Byte:
                    *(sbyte *)ptr = (sbyte)random.Next(-127, 128);
                    break;

                case DsgVarType.UByte:
                    *(byte *)ptr = (byte)random.Next(0, 256);
                    break;

                case DsgVarType.Short:
                    *(short *)ptr = (short)random.Next();
                    break;

                case DsgVarType.UShort:
                    *(ushort *)ptr = (ushort)random.Next();
                    break;

                case DsgVarType.Int:
                    *(int *)ptr = random.Next();
                    break;

                case DsgVarType.UInt:
                    *(uint *)ptr = (uint)random.Next();
                    break;

                case DsgVarType.Float:
                    *(float *)ptr += random.RandomFloat(-10f, 10f);
                    break;

                case DsgVarType.Vector:
                    Vector3 *vector = (Vector3 *)ptr;
                    vector->X += random.RandomFloat(-10f, 10f);
                    vector->Y += random.RandomFloat(-10f, 10f);
                    vector->Z += random.RandomFloat(-10f, 10f);
                    break;

                case DsgVarType.IntegerArray:
                    int *array = brain->mind->GetDsgVar <int>(i, buffer, out byte size);
                    for (int j = 0; j < size; j++)
                    {
                        array[j] = random.Next();
                    }
                    break;
                }
            }
        }