コード例 #1
0
ファイル: ovr017.cs プロジェクト: stavrossk/coab
        internal static void import_char01(ref Player player, string arg_8)
        {
            Classes.File file;

            seg042.find_and_open_file(out file, false, Path.Combine(Config.GetSavePath(), arg_8));

            seg041.displayString("Loading...Please Wait", 0, 10, 0x18, 0);


            if (gbl.import_from == ImportSource.Curse)
            {
                byte[] data = new byte[Player.StructSize];
                seg051.BlockRead(Player.StructSize, data, file);
                seg051.Close(file);

                player = new Player(data, 0);
            }
            else if (gbl.import_from == ImportSource.Pool)
            {
                byte[] data = new byte[PoolRadPlayer.StructSize];
                seg051.BlockRead(PoolRadPlayer.StructSize, data, file);
                seg051.Close(file);

                PoolRadPlayer poolRadPlayer = new PoolRadPlayer(data);

                player = ConvertPoolRadPlayer(poolRadPlayer);
            }
            else if (gbl.import_from == ImportSource.Hillsfar)
            {
                byte[] data = new byte[HillsFarPlayer.StructSize];
                seg051.BlockRead(HillsFarPlayer.StructSize, data, file);
                seg051.Close(file);

                HillsFarPlayer var_1C4 = new HillsFarPlayer(data);

                player = ConvertHillsFarPlayer(var_1C4, arg_8);

                var_1C4 = null;
            }

            if (gbl.import_from == ImportSource.Curse)
            {
                arg_8 = System.IO.Path.GetFileNameWithoutExtension(arg_8);
            }
            else
            {
                arg_8 = seg042.clean_string(player.name);
            }

            string filename = Path.Combine(Config.GetSavePath(), arg_8 + ".swg");

            if (seg042.file_find(filename) == true)
            {
                byte[] data = new byte[Item.StructSize];

                seg042.find_and_open_file(out file, false, filename);

                while (true)
                {
                    if (seg051.BlockRead(Item.StructSize, data, file) == Item.StructSize)
                    {
                        player.items.Add(new Item(data, 0));
                    }
                    else
                    {
                        break;
                    }
                }

                seg051.Close(file);
            }

            filename = Path.Combine(Config.GetSavePath(), arg_8 + ".fx");
            if (seg042.file_find(filename) == true)
            {
                byte[] data = new byte[Affect.StructSize];
                seg042.find_and_open_file(out file, false, filename);

                while (true)
                {
                    if (seg051.BlockRead(Affect.StructSize, data, file) == Affect.StructSize)
                    {
                        Affect tmp_affect = new Affect(data, 0);

                        player.affects.Add(new Affect(data, 0));
                    }
                    else
                    {
                        break;
                    }
                }

                seg051.Close(file);
            }

            filename = Path.Combine(Config.GetSavePath(), arg_8 + ".spc");
            if (gbl.import_from == ImportSource.Pool)
            {
                if (seg042.file_find(filename) == true)
                {
                    byte[] data = new byte[Affect.StructSize];
                    seg042.find_and_open_file(out file, false, filename);

                    while (true)
                    {
                        if (seg051.BlockRead(Affect.StructSize, data, file) == Affect.StructSize)
                        {
                            if (asc_49280.MemberOf(data[0]) == true)
                            {
                                Affect tmpAffect = new Affect(data, 0);
                                player.affects.Add(tmpAffect);
                            }
                        }
                        else
                        {
                            break;
                        }
                    }

                    seg051.Close(file);
                }
            }

            seg043.clear_keyboard();
            ovr025.reclac_player_values(player);
            ovr026.ReclacClassBonuses(player);
        }
コード例 #2
0
ファイル: ovr017.cs プロジェクト: stavrossk/coab
        private static Player ConvertHillsFarPlayer(HillsFarPlayer hf_player, string arg_8)
        {
            Player player = new Player();

            Classes.File file;

            player.items   = new List <Item>();
            player.affects = new List <Affect>();
            player.actions = null;

            string fileExt = ".guy";

            if (PlayerFileExists(fileExt, hf_player.name) == true)
            {
                string savename = Path.Combine(Config.GetSavePath(), Path.ChangeExtension(arg_8, fileExt));

                seg042.find_and_open_file(out file, false, savename);

                byte[] data = new byte[Player.StructSize];

                seg051.BlockRead(Player.StructSize, data, file);
                seg051.Close(file);

                player = new Player(data, 0);

                Player PreviousSelectedPlayer = gbl.SelectedPlayer;
                gbl.SelectedPlayer = player;

                TransferHillsFarCharacter(hf_player, player, PreviousSelectedPlayer);

                if (hf_player.field_1D > 0)
                {
                    Item newItem = new Item(0, Affects.helpless, (Affects)hf_player.field_1D,
                                            (short)(hf_player.field_1D * 200), 0, 0,
                                            false, 0, false, 0, 0, 0x57, 0xa7, 0xa8, ItemType.Necklace, true);

                    player.items.Add(newItem);
                }

                if (hf_player.field_23 > 0)
                {
                    Item newItem = new Item(0, Affects.poison_plus_4, (Affects)hf_player.field_23,
                                            (short)(hf_player.field_23 * 0x15E), 0, 1,
                                            false, 0, false, 0, 1, 0x45, 0xa7, 0xce, ItemType.WandB, true);

                    player.items.Add(newItem);
                }

                if (hf_player.field_86 > 0)
                {
                    Item newItem = new Item(0, Affects.helpless, (Affects)hf_player.field_86,
                                            (short)(hf_player.field_86 * 0xc8), 0, 0,
                                            false, 0, false, 0, 0, 0x42, 0xa7, 0xa8, ItemType.RingInvis, true);

                    player.items.Add(newItem);
                }

                if (hf_player.field_87 > 0)
                {
                    Item newItem = new Item(0, Affects.highConRegen, (Affects)hf_player.field_87,
                                            (short)(hf_player.field_87 * 0x190), 0, (short)(hf_player.field_87 * 10),
                                            false, 0, false, 0, 0, 0x40, 0xa7, 0xb9, ItemType.Necklace, true);

                    player.items.Add(newItem);
                }
            }
            else
            {
                fileExt = ".cha";

                if (PlayerFileExists(fileExt, hf_player.name) == true)
                {
                    byte[] data = new byte[PoolRadPlayer.StructSize];

                    string savename = System.IO.Path.Combine(Config.GetSavePath(), Path.ChangeExtension(arg_8, fileExt));

                    seg042.find_and_open_file(out file, false, savename);

                    seg051.BlockRead(PoolRadPlayer.StructSize, data, file);
                    seg051.Close(file);

                    PoolRadPlayer poolRadPlayer = new PoolRadPlayer(data);

                    player = ConvertPoolRadPlayer(poolRadPlayer);

                    Player PreviousSelectedPlayer = gbl.SelectedPlayer;
                    gbl.SelectedPlayer = player;

                    TransferHillsFarCharacter(hf_player, player, PreviousSelectedPlayer);
                }
                else
                {
                    Player PreviousSelectedPlayer = gbl.SelectedPlayer;
                    gbl.SelectedPlayer = player;

                    for (int i = 0; i < 6; i++)
                    {
                        player.icon_colours[i] = (byte)(((gbl.default_icon_colours[i] + 8) << 4) + gbl.default_icon_colours[i]);
                    }

                    player.base_ac       = 50;
                    player.thac0         = 40;
                    player.health_status = Status.okey;
                    player.in_combat     = true;
                    player.field_13F     = 1;
                    player.field_140     = 1;
                    player.field_DE      = 1;

                    player.mod_id  = seg051.Random((byte)0xff);
                    player.icon_id = 0x0A;

                    player.attacksCount          = 2;
                    player.attack1_DiceCountBase = 1;
                    player.attack1_DiceSizeBase  = 2;
                    player.field_125             = 1;
                    player.base_movement         = 12;

                    player.name = hf_player.name;
                    player.stats2.Str.Load(hf_player.stat_str);
                    player.stats2.Str00.Load(hf_player.stat_str00);
                    player.stats2.Int.Load(hf_player.stat_int);
                    player.stats2.Wis.Load(hf_player.stat_wis);
                    player.stats2.Dex.Load(hf_player.stat_dex);
                    player.stats2.Con.Load(hf_player.stat_con);
                    player.stats2.Cha.Load(hf_player.stat_cha);

                    player.race = (Race)(hf_player.field_2D + 1);

                    if (player.race == Race.half_orc)
                    {
                        player.race = Race.human;
                    }

                    switch (player.race)
                    {
                    case Race.halfling:
                        player.icon_size = 1;
                        ovr024.add_affect(false, 0xff, 0, Affects.con_saving_bonus, player);
                        break;

                    case Race.dwarf:
                        player.icon_size = 1;
                        ovr024.add_affect(false, 0xff, 0, Affects.con_saving_bonus, player);
                        ovr024.add_affect(false, 0xff, 0, Affects.dwarf_vs_orc, player);
                        ovr024.add_affect(false, 0xff, 0, Affects.dwarf_and_gnome_vs_giants, player);
                        break;

                    case Race.gnome:
                        player.icon_size = 1;
                        ovr024.add_affect(false, 0xff, 0, Affects.con_saving_bonus, player);
                        ovr024.add_affect(false, 0xff, 0, Affects.gnome_vs_man_sized_giant, player);
                        ovr024.add_affect(false, 0xff, 0, Affects.dwarf_and_gnome_vs_giants, player);
                        ovr024.add_affect(false, 0xff, 0, Affects.affect_30, player);
                        break;

                    case Race.elf:
                        player.icon_size = 2;
                        ovr024.add_affect(false, 0xff, 0, Affects.elf_resist_sleep, player);
                        break;

                    case Race.half_elf:
                        player.icon_size = 2;
                        ovr024.add_affect(false, 0xff, 0, Affects.halfelf_resistance, player);
                        break;

                    default:
                        player.icon_size = 2;
                        break;
                    }

                    player._class = HillsFarClassMap[hf_player.field_35 & 0x0F];
                    player.age    = hf_player.age;

                    player.cleric_lvl     = (hf_player.field_B7 > 0) ? (byte)1 : (byte)0;
                    player.magic_user_lvl = (hf_player.field_B8 > 0) ? (byte)1 : (byte)0;
                    player.fighter_lvl    = (hf_player.field_B9 > 0) ? (byte)1 : (byte)0;
                    player.thief_lvl      = (hf_player.field_BA > 0) ? (byte)1 : (byte)0;
                    player.HitDice        = 1;
                    player.sex            = hf_player.field_2C;
                    player.alignment      = hf_player.alignment;
                    player.exp            = hf_player.field_2E;

                    if (player.magic_user_lvl > 0)
                    {
                        player.LearnSpell(Spells.detect_magic_MU);
                        player.LearnSpell(Spells.read_magic);
                        player.LearnSpell(Spells.shield);
                        player.LearnSpell(Spells.sleep);
                    }

                    SilentTrainPlayer();

                    ovr022.addPlayerGold(300);
                    gbl.SelectedPlayer       = PreviousSelectedPlayer;
                    player.hit_point_max     = hf_player.field_21;
                    player.hit_point_rolled  = (byte)(player.hit_point_max - ovr018.get_con_hp_adj(player));
                    player.hit_point_current = hf_player.field_20;
                }
            }

            return(player);
        }
コード例 #3
0
ファイル: ovr017.cs プロジェクト: stavrossk/coab
        internal static Player ConvertPoolRadPlayer(PoolRadPlayer bp_var_1C0)
        {
            /* nested function, arg_0 is BP */
            Player player = new Player();

            player.race = (Race)bp_var_1C0.race;
            player.sex  = bp_var_1C0.sex;

            player.name = bp_var_1C0.name;

            int race = (int)player.race;
            int sex  = player.sex;

            player.stats2.Str.Load(bp_var_1C0.stat_str);
            player.stats2.Str.EnforceRaceSexLimits(race, sex);

            player.stats2.Int.Load(bp_var_1C0.stat_int);
            player.stats2.Int.EnforceRaceSexLimits(race, sex);

            player.stats2.Wis.Load(bp_var_1C0.stat_wis);
            player.stats2.Wis.EnforceRaceSexLimits(race, sex);

            player.stats2.Dex.Load(bp_var_1C0.stat_dex);
            player.stats2.Dex.EnforceRaceSexLimits(race, sex);

            player.stats2.Con.Load(bp_var_1C0.stat_con);
            player.stats2.Con.EnforceRaceSexLimits(race, sex);

            player.stats2.Cha.Load(bp_var_1C0.stat_cha);
            player.stats2.Cha.EnforceRaceSexLimits(race, sex);

            player.stats2.Str00.Load(bp_var_1C0.stat_str00);
            player.stats2.Str00.EnforceRaceSexLimits(race, sex);

            player.thac0         = bp_var_1C0.thac0;
            player._class        = (ClassId)bp_var_1C0._class;
            player.age           = bp_var_1C0.age;
            player.hit_point_max = bp_var_1C0.hp_max;

            System.Array.Copy(bp_var_1C0.field_33, player.spellBook, 0x38);
            player.spellBook[(int)Spells.animate_dead - 1] = 0;

            player.attackLevel = bp_var_1C0.field_6B;
            player.field_DE    = bp_var_1C0.field_6C;

            System.Array.Copy(bp_var_1C0.saveVerse, player.saveVerse, 5);

            player.base_movement   = bp_var_1C0.field_72;
            player.HitDice         = bp_var_1C0.field_73;
            player.multiclassLevel = player.HitDice;
            player.lost_lvls       = bp_var_1C0.field_74;
            player.lost_hp         = bp_var_1C0.field_75;
            player.field_E9        = bp_var_1C0.field_76;

            System.Array.Copy(bp_var_1C0.field_77, player.thief_skills, 8);

            player.field_F6              = bp_var_1C0.field_83;
            player.control_morale        = bp_var_1C0.field_84;
            player.npcTreasureShareCount = bp_var_1C0.field_85;
            player.field_F9              = bp_var_1C0.field_86;
            player.field_FA              = bp_var_1C0.field_87;

            player.Money.SetCoins(Money.Platinum, 300);

            System.Array.Copy(bp_var_1C0.field_96, player.ClassLevel, 8);

            player.monsterType = (MonsterType)bp_var_1C0.field_9F;
            player.alignment   = bp_var_1C0.field_A0;

            player.attacksCount            = bp_var_1C0.field_A1;
            player.baseHalfMoves           = bp_var_1C0.field_A2;
            player.attack1_DiceCountBase   = bp_var_1C0.field_A3;
            player.attack2_DiceCountBase   = bp_var_1C0.field_A4;
            player.attack1_DiceSizeBase    = bp_var_1C0.field_A5;
            player.attack2_DiceSizeBase    = bp_var_1C0.field_A6;
            player.attack1_DamageBonusBase = bp_var_1C0.field_A7;
            player.attack2_DamageBonusBase = bp_var_1C0.field_A8;

            player.base_ac   = bp_var_1C0.field_A9;
            player.field_125 = bp_var_1C0.field_AA;
            player.mod_id    = bp_var_1C0.field_AB;

            player.exp              = bp_var_1C0.field_AC;
            player.classFlags       = bp_var_1C0.field_B0;
            player.hit_point_rolled = bp_var_1C0.field_B1;

            for (int var_2 = 1; var_2 <= 3; var_2++)
            {
                player.spellCastCount[0, var_2 - 1] = bp_var_1C0.field_B2[var_2 - 1];
                player.spellCastCount[2, var_2 - 1] = bp_var_1C0.field_B5[var_2 - 1];
            }

            player.field_13C = bp_var_1C0.field_B8;

            player.field_13E = bp_var_1C0.field_BA;
            player.field_13F = bp_var_1C0.field_BB;

            player.field_140   = bp_var_1C0.field_BC;
            player.head_icon   = bp_var_1C0.field_BD;
            player.weapon_icon = bp_var_1C0.field_BE;
            player.icon_size   = bp_var_1C0.field_C0;

            System.Array.Copy(bp_var_1C0.field_C1, player.icon_colours, 6);


            //player.field_14c = bp_var_1C0.field_C7; // Item count

            //mov	di, [bp+arg_0] // copy item pointers...
            //les	di, ss:[di-0x1C0]
            //add	di, 0x0CC
            //push	es
            //push	di
            //les	di, int ptr [bp+player.offset]
            //add	di, 0x151
            //push	es
            //push	di
            //mov	ax, 0x34
            //push	ax
            //call	Move(Any &,Any &,Word)

            player.weaponsHandsUsed = bp_var_1C0.field_100;
            player.field_186        = (sbyte)bp_var_1C0.field_101;
            player.weight           = bp_var_1C0.field_102;

            player.health_status = (Status)bp_var_1C0.field_10C;
            player.in_combat     = bp_var_1C0.field_10D != 0;
            player.combat_team   = (CombatTeam)bp_var_1C0.field_10E;
            player.hitBonus      = bp_var_1C0.field_110;

            player.ac        = bp_var_1C0.field_111;
            player.ac_behind = bp_var_1C0.field_112;

            player.attack1_AttacksLeft = bp_var_1C0.field_113;
            player.attack2_AttacksLeft = bp_var_1C0.field_114;

            player.attack1_DiceCount = bp_var_1C0.field_115;
            player.attack2_DiceCount = bp_var_1C0.field_116;

            player.attack1_DiceSize = bp_var_1C0.field_117;
            player.attack2_DiceSize = bp_var_1C0.field_118;

            player.attack1_DamageBonus = (sbyte)bp_var_1C0.field_119;
            player.attack2_DamageBonus = bp_var_1C0.field_11A;
            player.hit_point_current   = bp_var_1C0.field_11B;
            player.movement            = (byte)bp_var_1C0.field_11C;

            return(player);
        }