Beispiel #1
0
 public Monster(int[] stats, int[] resists, MonsterFight mf, Classess monClass, int baseM, int basePh, string desc, char vis, ConsoleColor color)
 {
     _isPassable = false;
     _type = ObjectType.O_MONSTER;
     _monsterBehaviur = MonsterState.MS_IDLE;
     _pathAvaible = false;
     _route = new List<Point>();
     _movement = new List<Point>();
     _seen = false;
     _description = desc;
     _visual = vis;
     _color = color;
     _class = monClass;
     _primaryStats = new Dictionary<PrimaryStats, Stat>();
     _resists = new Dictionary<Resists, Stat>();
     _BaseResists = new Dictionary<ResistGroup, Stat>();
     _monsterWeapons = mf.ListOfWeapons;
     _monsterArmor = mf.monsterArmor;
     _weaponProficiencies = new int[mf.ListOfWeapons.GetLength(0)];
     _states = new bool[(int)PlayerStates.MAX_SIZE];
     changeState(PlayerStates.NORMAL);
     for (PrimaryStats i = PrimaryStats.VITALITY; i < PrimaryStats.MAX_SIZE; i++)
     {
         _primaryStats.Add(i, new Stat(stats[(int)i]));
     }
     for (Resists i = Resists.RESIST_1; i < Resists.MAX_SIZE; i++)
     {
         _resists.Add(i, new Stat(resists[(int)i]));
     }
     _BaseResists.Add(ResistGroup.MENTAL, new Stat(baseM));
     _BaseResists.Add(ResistGroup.PHYSICAL, new Stat(basePh));
     Level = 0;
     _Stamina = new Stat(_primaryStats[PrimaryStats.VITALITY].currentValue / 10 + _primaryStats[PrimaryStats.STRENGTH].currentValue / 10);
     //recalculate dex and spd based on armor limitation
     _primaryStats[PrimaryStats.DEXTERITY].actualValue /= _monsterArmor.Limitation[0];
     _primaryStats[PrimaryStats.SPEED].actualValue /= _monsterArmor.Limitation[1];
     //calculate defence without weapon
     _defence = new Stat(_monsterArmor.Defence + Convert.ToInt16(Math.Round((_primaryStats[PrimaryStats.DEXTERITY].actualValue / 10.0f))));
     _protection = new int[3];
     _protection[0] = _monsterArmor.Protection[0];
     _protection[1] = _monsterArmor.Protection[1];
     _protection[2] = _monsterArmor.Protection[2];
     //genereate weapon proficiency for all weapons
     for (int i = 0; i < _monsterWeapons.GetLength(0); i++)
     {
         int bonus = _monsterWeapons[i].ProfBonus;
         int prof = bonus + Data.PlayerClass.ClassProficiencyTable[_class][1] + Dice.Roll("d50");
         _weaponProficiencies[i] = prof;
     }
     _steps = 0;
     _exp = MonsterGenerator.CalcualteMonsterExp(this);
     //calcualte magic potential for future casters
     _MagicPotential = new Stat(0);
     CalculateMagicPotential();
 }
 public static Monster GenerateMonster(string monsterRace, int monsterLevel = 0, Classess monsterClass = Classess.MAX_SIZE)
 {
     int[] Stats = new int[11];
     int[] finalStats = new int[11];
     int[] Resists = new int[10];
     int[] finalResists = new int[10];
     int[] classBonusStats;
     int[] classBonusResists;
     //MonsterWeapon[] wList; //= new List<MonsterWeapon>();
     MonsterFight mf = new MonsterFight();
     Classess usedClass;
     mwList.Clear();
     Random rnd = new Random();
     //read monster file
     readFile(monsterRace);
     //populate tables
     Stats = parseTable(_stats);
     Resists = parseTable(_resists);
     //select class for monster
     //chosen class in on the list and it's not random
     if (_classes.Contains(monsterClass) && monsterClass != Classess.MAX_SIZE)
     {
         //use selected class
         usedClass = monsterClass;
     }
     //chosen class in on the list and it's random
     else if (_classes.Contains(monsterClass) && monsterClass == Classess.MAX_SIZE) 
     {
         //pick one at random from all available classes
         int size = (int)Classess.MAX_SIZE;
         usedClass = (Classess)rnd.Next(0, size);
     }
     //chosen class is not on the list
     else
     {
         //pick one at random from classes available for this race
         int size = _classes.Count();
         int index = rnd.Next(0, size);
         usedClass = _classes[index];
     }
     //generate stats
     //base + roll + classBonus
     classBonusStats = PlayerClass.ParseClassBonuses(usedClass);
     for (int i = 0; i < (int)PrimaryStats.MAX_SIZE; i++)
     {
         if (i == (int)PrimaryStats.VITALITY)
         {
             finalStats[i] = Stats[i] + classBonusStats[i];
         }
         else if (i == (int)PrimaryStats.NOTICE)
         {
             if (usedClass == Classess.PRIEST || usedClass == Classess.DRUID || usedClass == Classess.ASTROLOGER || usedClass == Classess.HALF_GOD)
             {
                 finalStats[i] = Stats[i] + Dice.Roll("d10") + classBonusStats[i];
             }
             else
             {
                 finalStats[i] = Stats[i] + Dice.Roll("d5") + classBonusStats[i];
             }
             
         }
         else
         {
             finalStats[i] = Stats[i] + Dice.Roll("d50") + classBonusStats[i];
         }
         
     }
     //generate base resists
     int baseMental = Dice.Roll("d10") + finalStats[(int)PrimaryStats.INTELLIGENCE] / 10 + finalStats[(int)PrimaryStats.WISDOM] / 10 + finalStats[(int)PrimaryStats.VITALITY] / 20;
     int basePhysical = Dice.Roll("d10") + finalStats[(int)PrimaryStats.VITALITY] / 10 + finalStats[(int)PrimaryStats.STRENGTH] / 10;
     //generate resist
     //base + racebonus + classBonus
     classBonusResists = PlayerClass.ParseClassResistsBonuses(usedClass);
     for (int i = 0; i < (int)Enums.Resists.MAX_SIZE; i++)
     {
         if (i <= (int)Enums.Resists.RESIST_5)
         {
             if (i == (int)Enums.Resists.RESIST_1)
             {
                 finalResists[i] = baseMental + Resists[i] + classBonusResists[i] + finalStats[(int)PrimaryStats.INTELLIGENCE] / 10;
             }
             else if (i == (int)Enums.Resists.RESIST_2)
             {
                 finalResists[i] = baseMental + Resists[i] + classBonusResists[i] + finalStats[(int)PrimaryStats.WISDOM] / 10;
             }
             else if (i == (int)Enums.Resists.RESIST_3)
             {
                 finalResists[i] = baseMental + Resists[i] + classBonusResists[i] + finalStats[(int)PrimaryStats.FAITH] / 10;
             }
             else
             {
                 finalResists[i] = baseMental + Resists[i] + classBonusResists[i];
             }
             
         }
         else
         {
             finalResists[i] = basePhysical + Resists[i] + classBonusResists[i];
         }
     }
     //set all fight details for monster
     mf.ListOfWeapons = new MonsterWeapon[mwList.Count];
     mwList.CopyTo(mf.ListOfWeapons, 0);
     mf.monsterArmor = ma;
     //level up monster
     if (monsterLevel == 0)
     {
         return new Monster(finalStats, finalResists, mf, usedClass, baseMental, basePhysical, _description, vis, color);
     }
     else
     {
         return levelMonster(monsterLevel, new Monster(finalStats, finalResists, mf, usedClass, baseMental, basePhysical, _description, vis, color));
     }
 }