Beispiel #1
0
        protected void WriteSpells(NoxBinaryWriter wtr)
        {
            wtr.Write((long)0);             //save a spot for the length
            long startPos = wtr.BaseStream.Position;

            wtr.Write((short)0x0003);             //UNKNOWN, but always the same

            foreach (Spell spell in spellset)
            {
                wtr.Write((byte)spell.Flags);
                wtr.Write(spell.Name);
            }

            wtr.Write((byte)0x00);             //first byte of last entry is null
            wtr.Write((byte)ActiveSpellset);
            wtr.Write((byte)ActiveTrap);
            wtr.Write((byte)0x04);             //UNKNOWN, but constant

            //go back and write in the length
            long length = wtr.BaseStream.Position - startPos;

            wtr.Seek((int)startPos - 8, SeekOrigin.Begin);
            wtr.Write((long)length);
            wtr.Seek(0, SeekOrigin.End);
        }
Beispiel #2
0
        //precondition: all members are properly initialized
        public void WriteFile()
        {
            NoxBinaryWriter wtr = new NoxBinaryWriter(File.Open(filename, FileMode.Create), CryptApi.NoxCryptFormat.PLR);

            wtr.Write((long)FileType);
            switch (FileType)
            {
            case PlrFileType.MULTI:
                WriteSpells(wtr);
                wtr.Write((int)0x00000001);                         //UNKOWN, constant
                wtr.SkipToNextBoundary();

                WriteCharacterInfo(wtr);
                wtr.Write((int)0x0000000c);                         //UNKNOWN, constant
                wtr.SkipToNextBoundary();

                //write the last short section
                wtr.Write((long)3);
                wtr.Write((short)0x000B);
                wtr.Write((byte)0x00);

                wtr.SkipToNextBoundary();
                break;
            }

            wtr.Close();
        }
Beispiel #3
0
        protected void WriteCharacterInfo(NoxBinaryWriter wtr)
        {
            wtr.Write((long)0);             //save a spot for the length
            long startPos = wtr.BaseStream.Position;

            wtr.Write((short)0x000C);             //UNKNOWN, but constant
            wtr.Write((int)0x00000002);           //UNKOWN, but constant

            wtr.Write((short)SavePath.Length);
            wtr.Write(SavePath.ToCharArray());
            wtr.Write((byte)0x00);             //extra terminator

            //TODO: allow user specified datetime?
            DateTime time = DateTime.Now;

            wtr.Write((short)time.Year);
            wtr.Write((short)time.Month);
            wtr.Write((short)time.DayOfWeek);
            wtr.Write((short)time.Day);
            wtr.Write((short)time.Hour);
            wtr.Write((short)time.Minute);
            wtr.Write((short)time.Second);
            wtr.Write((short)time.Millisecond);

            wtr.WriteColor(HairColor);
            wtr.WriteColor(SkinColor);
            wtr.WriteColor(MustacheColor);
            wtr.WriteColor(BeardColor);
            wtr.WriteColor(SideburnsColor);
            wtr.WriteUserColor(PantsColor);
            wtr.WriteUserColor(ShirtColor);
            wtr.WriteUserColor(ShirtTrimColor);
            wtr.WriteUserColor(ShoesColor);
            wtr.WriteUserColor(ShoesTrimColor);

            wtr.Write((byte)(Encoding.Unicode.GetByteCount(Name) / 2));
            wtr.Write(Encoding.Unicode.GetBytes(Name));
            wtr.Write((byte)Class);
            wtr.Write((short)0x0A00);          //UNKNOWN, but constant -- may be character level, but this is always reset to 10, so what's the point of storing it in the file?!
            wtr.Write(LastMapPlayed);
            wtr.Write((byte)0x00);             //null terminator not counted in stringlength

            //go back and write in the length
            long length = wtr.BaseStream.Position - startPos;

            wtr.Seek((int)startPos - 8, SeekOrigin.Begin);
            wtr.Write((long)length);
            wtr.Seek(0, SeekOrigin.End);
        }
Beispiel #4
0
        public void WriteToObjectMod(Map.Object obj)
        {
            MemoryStream ms = new MemoryStream();
            NoxBinaryWriter bw = new NoxBinaryWriter(ms, CryptApi.NoxCryptFormat.NONE);

            bw.Write(MapName.Length + 1);
            bw.Write(Encoding.ASCII.GetBytes(MapName));
            bw.Write((byte) 0); // null terminator
            bw.Write(ExitX);
            bw.Write(ExitY);

            obj.modbuf = ms.ToArray();
            obj.ReadRule1 = 0x3C;
            bw.Close();
        }
Beispiel #5
0
 public void WriteToMapObject(Map.Object obj)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         NoxBinaryWriter bw = new NoxBinaryWriter(ms, CryptApi.NoxCryptFormat.NONE);
         bw.Write(ScriptActivated);
         // script event
         bw.Write((short) 1);
         bw.Write(UnknownScriptHandler.Length);
         bw.Write(Encoding.ASCII.GetBytes(UnknownScriptHandler));
         bw.Write((int) 0);
         // coordinates
         bw.Write(FallX);
         bw.Write(FallY);
         // script delay
         bw.Write(ScriptTime1);
         bw.Write(ScriptTimeout);
         bw.Flush();
         obj.modbuf = ms.ToArray();
         obj.ReadRule1 = 0x3C;
     }
 }
Beispiel #6
0
        /// <summary>
        /// Преобразует структуру обратно в массив байтов, и сохраняет в Map.Object
        /// </summary>
        public void WriteToObjectMod(Map.Object obj)
        {
            MemoryStream memStream = new MemoryStream();
            NoxBinaryWriter bw = new NoxBinaryWriter(memStream, CryptApi.NoxCryptFormat.NONE);
            // Направление
            bw.Write((ulong) Direction);
            // Записываем обработчики
            for (int i = 0; i < 10; i++)
            {
                if (i == 2)
                    bw.Write(DetectEventTimeout);

                bw.WriteScriptEvent(ScriptEvents[i]);
            }
            bw.Write((int) 0);
            // цвета частей тела
            Color color;
            for (int i = 0; i < 6; i++)
            {
                color = NPCColors[i];
                bw.Write(color.R);
                bw.Write(color.G);
                bw.Write(color.B);
            }
            // основная инфа
            bw.Write(ActionRoamPathFlag);
            bw.Write((uint) StatusFlags);
            bw.Write(HealthMultiplier);
            bw.Write(RetreatRatio);
            bw.Write(ResumeRatio);
            bw.Write(SightRange);
            bw.Write(Health);
            bw.Write(Aggressiveness);
            bw.Write(EscortObjName);
            // Записываем заклинания
            int knownSpellsCount = KnownSpells.Count;
            bw.Write(knownSpellsCount);
            foreach (MonsterXfer.SpellEntry se in KnownSpells)
            {
                bw.Write(se.SpellName);
                bw.Write(se.UseFlags);
            }
            bw.Write(ReactionCastingDelayMin);
            bw.Write(ReactionCastingDelayMax);
            bw.Write(BuffCastingDelayMin);
            bw.Write(BuffCastingDelayMax);
            bw.Write(DebuffCastingDelayMin);
            bw.Write(DebuffCastingDelayMax);
            bw.Write(OffensiveCastingDelayMin);
            bw.Write(OffensiveCastingDelayMax);
            bw.Write(BlinkCastingDelayMin);
            bw.Write(BlinkCastingDelayMax);
            //
            bw.Write(LockPathDistance);
            bw.Write(SpellPowerLevel);
            bw.Write(NPCStrength);
            bw.Write(NPCSpeed);
            bw.Write(AimSkillLevel);
            bw.Write(TrapSpell1);
            bw.Write(TrapSpell2);
            bw.Write(TrapSpell3);
            bw.Write(NoxEnums.AIActionStrings[DefaultAction]);
            // данные ИИ - пропускаем
            bw.Write((short) 4);
            bw.Write((byte) 0);
            // бессмертие
            bw.Write(Immortal);
            // MaxHealth - 4 bytes
            bw.Write(MagicNumber);
            bw.Write((int) MaxHealth);
            bw.Write(AddedSubclass);
            bw.Write(Health);
            bw.Write(Experience);
            bw.Write(NPCVoiceSet);
            // Список бафов
            bw.Write((short) 2);
            byte buffsNum = (byte) BuffList.Length;
            MonsterXfer.BuffEntry buff;
            bw.Write(buffsNum);
            for (int i = 0; i < buffsNum; i++)
            {
                buff = BuffList[i];
                bw.Write(buff.Name);
                bw.Write(buff.Power);
                bw.Write(buff.Duration);
                if (buff.Name == ENCHANT_SHIELD)
                    bw.Write(buff.ShieldHealth);
            }
            bw.Write(PoisonLevel);
            // byte array
            byte[] xfer = memStream.ToArray();
            bw.Close();
            obj.modbuf = xfer;
            obj.ReadRule1 = 0x3E;
        }
Beispiel #7
0
        protected void WriteSpells(NoxBinaryWriter wtr)
        {
            wtr.Write((long) 0);//save a spot for the length
            long startPos = wtr.BaseStream.Position;

            wtr.Write((short) 0x0003);//UNKNOWN, but always the same

            foreach (Spell spell in spellset)
            {
                wtr.Write((byte) spell.Flags);
                wtr.Write(spell.Name);
            }

            wtr.Write((byte) 0x00);//first byte of last entry is null
            wtr.Write((byte) ActiveSpellset);
            wtr.Write((byte) ActiveTrap);
            wtr.Write((byte) 0x04);//UNKNOWN, but constant

            //go back and write in the length
            long length = wtr.BaseStream.Position - startPos;
            wtr.Seek((int) startPos - 8, SeekOrigin.Begin);
            wtr.Write((long) length);
            wtr.Seek(0, SeekOrigin.End);
        }
Beispiel #8
0
        protected void WriteCharacterInfo(NoxBinaryWriter wtr)
        {
            wtr.Write((long) 0);//save a spot for the length
            long startPos = wtr.BaseStream.Position;

            wtr.Write((short) 0x000C);//UNKNOWN, but constant
            wtr.Write((int) 0x00000002);//UNKOWN, but constant

            wtr.Write((short) SavePath.Length);
            wtr.Write(SavePath.ToCharArray());
            wtr.Write((byte) 0x00);//extra terminator

            //TODO: allow user specified datetime?
            DateTime time = DateTime.Now;
            wtr.Write((short) time.Year);
            wtr.Write((short) time.Month);
            wtr.Write((short) time.DayOfWeek);
            wtr.Write((short) time.Day);
            wtr.Write((short) time.Hour);
            wtr.Write((short) time.Minute);
            wtr.Write((short) time.Second);
            wtr.Write((short) time.Millisecond);

            wtr.WriteColor(HairColor);
            wtr.WriteColor(SkinColor);
            wtr.WriteColor(MustacheColor);
            wtr.WriteColor(BeardColor);
            wtr.WriteColor(SideburnsColor);
            wtr.WriteUserColor(PantsColor);
            wtr.WriteUserColor(ShirtColor);
            wtr.WriteUserColor(ShirtTrimColor);
            wtr.WriteUserColor(ShoesColor);
            wtr.WriteUserColor(ShoesTrimColor);

            wtr.Write((byte) (Encoding.Unicode.GetByteCount(Name) / 2));
            wtr.Write(Encoding.Unicode.GetBytes(Name));
            wtr.Write((byte) Class);
            wtr.Write((short) 0x0A00);//UNKNOWN, but constant -- may be character level, but this is always reset to 10, so what's the point of storing it in the file?!
            wtr.Write(LastMapPlayed);
            wtr.Write((byte) 0x00);//null terminator not counted in stringlength

            //go back and write in the length
            long length = wtr.BaseStream.Position - startPos;
            wtr.Seek((int) startPos - 8, SeekOrigin.Begin);
            wtr.Write((long) length);
            wtr.Seek(0, SeekOrigin.End);
        }
Beispiel #9
0
        //precondition: all members are properly initialized
        public void WriteFile()
        {
            NoxBinaryWriter wtr = new NoxBinaryWriter(File.Open(filename, FileMode.Create), CryptApi.NoxCryptFormat.PLR);

            wtr.Write((long) FileType);
            switch (FileType)
            {
                case PlrFileType.MULTI:
                    WriteSpells(wtr);
                    wtr.Write((int) 0x00000001);//UNKOWN, constant
                    wtr.SkipToNextBoundary();

                    WriteCharacterInfo(wtr);
                    wtr.Write((int) 0x0000000c);//UNKNOWN, constant
                    wtr.SkipToNextBoundary();

                    //write the last short section
                    wtr.Write((long) 3);
                    wtr.Write((short) 0x000B);
                    wtr.Write((byte) 0x00);

                    wtr.SkipToNextBoundary();
                    break;
            }

            wtr.Close();
        }
Beispiel #10
0
        /// <summary>
        /// Преобразует структуру обратно в массив байтов, и сохраняет в Map.Object
        /// </summary>
        public void WriteToObjectMod(Map.Object obj)
        {
            ThingDb.Thing tt = ThingDb.thingdb.Things[obj.Name];
            MemoryStream memStream = new MemoryStream();
            NoxBinaryWriter bw = new NoxBinaryWriter(memStream, CryptApi.NoxCryptFormat.NONE);
            // Направление
            bw.Write((ulong) Direction);
            // Записываем обработчики
            for (int i = 0; i < 10; i++)
            {
                if (i == 2)
                    bw.Write(DetectEventTimeout);

                bw.WriteScriptEvent(ScriptEvents[i]);
            }
            bw.Write((int) 0);
            // Основная инфа
            bw.Write(ActionRoamPathFlag);
            bw.Write((uint) StatusFlags);
            bw.Write(HealthMultiplier);
            bw.Write(RetreatRatio);
            bw.Write(ResumeRatio);
            bw.Write(SightRange);
            bw.Write(Aggressiveness);
            bw.Write(EscortObjName);
            // Записываем заклинания
            int knownSpellsCount = KnownSpells.Count;
            bw.Write(knownSpellsCount);
            foreach (SpellEntry se in KnownSpells)
            {
                bw.Write(se.SpellName);
                bw.Write(se.UseFlags);
            }
            bw.Write(ReactionCastingDelayMin);
            bw.Write(ReactionCastingDelayMax);
            bw.Write(BuffCastingDelayMin);
            bw.Write(BuffCastingDelayMax);
            bw.Write(DebuffCastingDelayMin);
            bw.Write(DebuffCastingDelayMax);
            bw.Write(OffensiveCastingDelayMin);
            bw.Write(OffensiveCastingDelayMax);
            bw.Write(BlinkCastingDelayMin);
            bw.Write(BlinkCastingDelayMax);
            //
            bw.Write(LockPathDistance);
            bw.Write(SpellPowerLevel);
            bw.Write(AimSkillLevel);
            bw.Write(TrapSpell1);
            bw.Write(TrapSpell2);
            bw.Write(TrapSpell3);
            bw.Write(NoxEnums.AIActionStrings[DefaultAction]);
            // данные ИИ - пропускаем
            bw.Write((short) 4);
            bw.Write((byte) 0);
            // Бессмертие - в общем то bool
            bw.Write(Immortal);
            // Магазин
            if (tt.Subclass[(int) ThingDb.Thing.SubclassBitIndex.SHOPKEEPER])
            {
                bw.Write(ShopkeeperInfo.BuyValueMultiplier);
                bw.Write(ShopkeeperInfo.SellValueMultiplier);
                bw.Write(ShopkeeperInfo.ShopkeeperGreetingText);
                byte itemsCount = (byte) ShopkeeperInfo.ShopItems.Length;
                ShopItemInfo item;
                bw.Write(itemsCount);
                for (int i = 0; i < itemsCount; i++)
                {
                    item = ShopkeeperInfo.ShopItems[i];
                    bw.Write(item.Count);
                    bw.Write(item.Name);
                    bw.Write(item.SpellID);
                    bw.Write(item.Ench1);
                    bw.Write(item.Ench2);
                    bw.Write(item.Ench3);
                    bw.Write(item.Ench4);
                }
            }
            //
            bw.Write(MagicNumber);
            bw.Write(AddedSubclass);
            bw.Write(Health);
            bw.Write(SetDefaultResumeRatio);
            bw.Write(SetDefaultRetreatRatio);
            bw.Write(SetDefaultMonsterStatus);
            //
            bw.Write(LearnDefaultSpells);
            if (tt.Subclass[(int) ThingDb.Thing.SubclassBitIndex.FEMALE_NPC])
            {
                Color color;
                for (int i = 0; i < 6; i++)
                {
                    color = MaidenBodyColors[i];
                    bw.Write(color.R);
                    bw.Write(color.G);
                    bw.Write(color.B);
                }
                bw.Write(MaidenVoiceSet);
            }
            // Список бафов
            bw.Write((short) 2);
            byte buffsNum = (byte) BuffList.Length;
            BuffEntry buff;
            bw.Write(buffsNum);
            for (int i = 0; i < buffsNum; i++)
            {
                buff = BuffList[i];
                bw.Write(buff.Name);
                bw.Write(buff.Power);
                bw.Write(buff.Duration);
                if (buff.Name == ENCHANT_SHIELD)
                    bw.Write(buff.ShieldHealth);
            }
            //
            if (tt.Subclass[(int) ThingDb.Thing.SubclassBitIndex.WOUNDED_NPC])
                bw.Write(WoundedNPCVoiceSet);
            bw.Write(PoisonLevel);
            // Теперь нам нужен byte array
            byte[] xfer = memStream.ToArray();
            bw.Close();
            obj.modbuf = xfer;
            obj.ReadRule1 = 0x40;
        }
Beispiel #11
0
        public void WriteToObjectMod(Map.Object obj)
        {
            MemoryStream ms = new MemoryStream();
            NoxBinaryWriter bw = new NoxBinaryWriter(ms, CryptApi.NoxCryptFormat.NONE);

            bw.Write(SizeX);
            bw.Write(SizeY);
            bw.WriteColor(EdgeColor);
            bw.WriteColor(BackColor);
            bw.Write(UnkInt1);
            bw.WriteScriptEvent(ScriptOnPressed);
            bw.WriteScriptEvent(ScriptOnReleased);
            bw.WriteScriptEvent(ScriptOnCollided);
            bw.Write(AllowedObjClass);
            bw.Write(IgnoredObjClass);
            bw.Write(AllowedTeamID);
            bw.Write(IgnoredTeamID);
            bw.Write(TriggerState);
            bw.Write(Unk7);
            bw.Write(UnkInt2);
            bw.Flush();

            obj.modbuf = ms.ToArray();
            obj.ReadRule1 = 0x3D;
            bw.Close();
        }
        public void WriteToMapObject(Map.Object obj)
        {
            MemoryStream ms = new MemoryStream();
            NoxBinaryWriter bw = new NoxBinaryWriter(ms, CryptApi.NoxCryptFormat.NONE);

            bw.Write((uint) RewardType);
            bw.Write(Unknown1);
            bw.Write((short) Spells.Count);
            foreach (string spell in Spells)
                bw.Write(spell);
            bw.Write((short) Abilities.Count);
            foreach (string ability in Abilities)
                bw.Write(ability);
            bw.Write((short) Monsters.Count);
            foreach (string scroll in Monsters)
                bw.Write(scroll);
            bw.Write(Unknown2);
            bw.Write(Unknown3);
            bw.Write(Unknown4);
            bw.Write(Unknown5);
            bw.Write(Unknown6);
            bw.Write(ActivateChance);
            bw.Write(RareOrSpecial);

            obj.ReadRule1 = 0x3F;
            obj.modbuf = ms.ToArray();
            bw.Close();
        }