예제 #1
0
 public EnemyData(EnemyData other)
 {
     name     = other.name;
     raceId   = new RaceID(other.raceId);
     aiParams = new AiParameters(other.aiParams);
     items    = new List <ItemData>(other.items);
 }
예제 #2
0
        public override void TileProc(int aX, int aY, ref bool refContinue)
        {
            NWField f = Field;

            Step(aX, aY);

            if (f.IsBarrier(aX, aY))
            {
                refContinue = false;
            }
            else
            {
                NWCreature c = (NWCreature)f.FindCreature(aX, aY);
                if (c != null && c.HasAffect(EffectID.eid_Death))
                {
                    RaceID race = c.Entry.Race;
                    if (race == RaceID.crDefault || race == RaceID.crHuman)
                    {
                        if (c.IsPlayer)
                        {
                            c.Death(BaseLocale.GetStr(RS.rs_KilledByDeathRay), null);
                        }
                        else
                        {
                            c.Death(BaseLocale.Format(RS.rs_TheXIsDestroyed, new object[] { c.Name }), null);
                        }
                    }
                }
            }
        }
예제 #3
0
 public void CorrectInvalidData()
 {
     if (raceId == null)
     {
         Debug.LogWarning("Race ID is null, changing to \"Human\"");
         raceId = new RaceID("Human");
     }
 }
예제 #4
0
        private void PrepareEnemy()
        {
            try {
                NWCreature self = (NWCreature)fSelf;

                // search nearest enemy
                NWCreature enemy = self.FindEnemy();

                if (enemy != null)
                {
                    if (IsShipSail)
                    {
                        PrepareChase(enemy, AttackRisk.Wary, false);
                        return;
                    }

                    AttackRisk ar;

                    RaceID race = self.Entry.Race;
                    if (GlobalVars.Debug_Fury || race == RaceID.crAesir || race == RaceID.crEvilGod || race == RaceID.crDaemon)
                    {
                        ar = AttackRisk.Immediately;
                    }
                    else
                    {
                        bool vent = self.Effects.FindEffectByID(EffectID.eid_Ventriloquism) != null;
                        if (vent)
                        {
                            ar = AttackRisk.Wait;
                        }
                        else
                        {
                            float arVal = self.GetAttackRate(enemy, Kinsfolks.Count);
                            ar = GetRiskKind(arVal);
                        }
                    }

                    switch (ar)
                    {
                    case AttackRisk.RunAway:
                    case AttackRisk.Evade:
                        PrepareEvade(enemy, ar, true);
                        break;

                    case AttackRisk.Wait:
                        // dummy
                        break;

                    case AttackRisk.Wary:
                    case AttackRisk.Immediately:
                        PrepareChase(enemy, ar, true);
                        break;
                    }
                }
            } catch (Exception ex) {
                Logger.Write("BeastBrain.prepareEnemy(): " + ex.Message);
            }
        }
예제 #5
0
    public virtual void CreateCharacter(RaceID race)
    {
        UpdateDefence(DefenceID.ArmorClass);
        UpdateDefence(DefenceID.Fortitude);
        UpdateDefence(DefenceID.Reflex);
        UpdateDefence(DefenceID.Will);
        UpdateMaxHealth();
        _currentHealth = _maxHealth;

        return;
    }
예제 #6
0
        public override void TileProc(int aX, int aY, ref bool aContinue)
        {
            NWField fld  = Field;
            NWTile  tile = (NWTile)fld.GetTile(aX, aY);

            Step(aX, aY);

            if (tile == null)
            {
                aContinue = false;
            }
            else
            {
                int fgp = tile.ForeBase;

                switch (fgp)
                {
                case PlaceID.pid_Undefined:
                    break;

                case PlaceID.pid_Mountain:
                case PlaceID.pid_Vulcan:
                    aContinue = false;
                    break;

                case PlaceID.pid_Vortex:
                case PlaceID.pid_StairsDown:
                case PlaceID.pid_StairsUp:
                case PlaceID.pid_GStairsDown:
                case PlaceID.pid_GStairsUp:
                case PlaceID.pid_HoleDown:
                case PlaceID.pid_HoleUp:
                    break;

                default:
                    tile.Foreground = PlaceID.pid_Rubble;
                    break;
                }

                NWCreature c = (NWCreature)fld.FindCreature(aX, aY);
                if (c != null)
                {
                    RaceID race = c.Entry.Race;
                    if (race == RaceID.crDefault || race == RaceID.crHuman)
                    {
                        c.Death("", null);
                    }
                }
            }
        }
예제 #7
0
    public void CreateNewHero(string name, RaceID raceId)
    {
        if (CurrentHeroData != null && !CurrentHeroData.IsEmpty)
        {
            ErrorHandler.ReportError("Cannot create a new hero - slot already taken");
            return;
        }

        if (Main.StaticData.Game.Races.GetValue(raceId) == null)
        {
            ErrorHandler.ReportError("Cannot create a new hero - invalid race ID");
            return;
        }

        heroes[currentHeroId] = new HeroData(name, raceId);
        HeroChangedEvent?.Invoke();
    }
예제 #8
0
 public HeroData(HeroData other)
 {
     isEmpty              = other.isEmpty;
     characterName        = other.characterName;
     raceId               = other.raceId;
     xp                   = other.xp;
     level                = other.level;
     rankPoints           = other.rankPoints;
     totalAttributePoints = other.totalAttributePoints;
     spentAttributePoints = other.spentAttributePoints;
     skillTreeSlots       = other.skillTreeSlots.DeepCopy();
     skills               = other.skills.DeepCopy();
     primarySkill         = new SkillID(other.primarySkill);
     secondarySkills      = other.secondarySkills.DeepCopy();
     unitData             = new UnitData(other.unitData);
     teleportData         = new TeleportData(other.teleportData);
 }
예제 #9
0
    public void Init(string name, RaceID raceId)
    {
        isEmpty       = false;
        characterName = name;
        this.raceId   = raceId;
        xp            = 0;
        level         = 1;
        rankPoints    = 0;
        Utils.InitWithNew(ref skillTreeSlots, StartingSkillSlotsCount);

        unitData        = Main.StaticData.Game.Races.GetValue(raceId).BaseStats;
        skills          = unitData.Skills;
        primarySkill    = unitData.MainAttack;
        secondarySkills = new List <SkillID>(StartingSecondarySkillsCount);

        teleportData = new TeleportData();
    }
예제 #10
0
    private Collider FindExistingCollider()
    {
        Collider result = null;

        result = unit.GetComponent <Collider>();
        if (result != null)
        {
            return(result);
        }

        RaceID raceId = new RaceID(unit.UnitData.RaceName);

        result = Main.StaticData.Game.Races.GetValue(raceId).Graphics.Collider;
        if (result != null)
        {
            return(gameObject.AddCopyOfComponent(result));
        }

        //the collider must be in the same gameObject as the rigidbody, so if we find one in a child object, we move it up
        Collider childCollider = unit.GetComponentInChildren <Collider>();

        if (childCollider is BoxCollider)
        {
            result = gameObject.AddCopyOfComponent(childCollider as BoxCollider);
        }
        if (childCollider is SphereCollider)
        {
            result = gameObject.AddCopyOfComponent(childCollider as SphereCollider);
        }
        if (childCollider is CapsuleCollider)
        {
            result = gameObject.AddCopyOfComponent(childCollider as CapsuleCollider);
        }
        if (childCollider is MeshCollider)
        {
            result = gameObject.AddCopyOfComponent(childCollider as MeshCollider);
        }

        Destroy(childCollider);
        return(result);
    }
예제 #11
0
        public override void TileProc(int aX, int aY, ref bool aContinue)
        {
            NWField f = Field;

            Step(aX, aY);
            if (f.IsBarrier(aX, aY))
            {
                aContinue = false;
            }
            else
            {
                NWCreature c = (NWCreature)f.FindCreature(aX, aY);
                if (c != null)
                {
                    RaceID race = c.Entry.Race;
                    if (race == RaceID.crDefault || race == RaceID.crHuman)
                    {
                        c.ClearAbilities();
                        c.ClearSkills();
                    }
                }
            }
        }
        public override void Execute()
        {
            NWCreature self  = (NWCreature)Self;
            NWCreature enemy = (NWCreature)Enemy;

            bool   ex   = ((NWField)self.CurrentMap).Creatures.IndexOf(enemy) >= 0;
            RaceID race = self.Entry.Race;
            bool   los  = (race == RaceID.crDefault || race == RaceID.crHuman);

            IsComplete = (!ex || enemy.State == CreatureState.csDead || !self.IsAvailable(enemy, los));
            if (!IsComplete)
            {
                if (!CanMove)
                {
                    Brain.Attack(enemy, true);
                }
                else
                {
                    Brain.Attack(enemy, Risk == AttackRisk.ar_Wary);
                }

                IsComplete = (enemy.State == CreatureState.csDead);
            }
        }
예제 #13
0
 public Race GetRace(RaceID raceId)
 {
     return(GetRace(raceId.Name));
 }
예제 #14
0
        public override void LoadXML(XmlNode element, FileVersion version)
        {
            try {
                base.LoadXML(element, version);

                Race = (RaceID)Enum.Parse(typeof(RaceID), ReadElement(element, "Race"));
                Gfx  = ReadElement(element, "gfx");
                Sfx  = ReadElement(element, "sfx");

                string signs = ReadElement(element, "Signs");
                Flags = new CreatureFlags(signs);
                if (!signs.Equals(Flags.Signature))
                {
                    throw new Exception("CreatureSigns not equals " + Convert.ToString(GUID));
                }

                MinHP        = Convert.ToInt16(ReadElement(element, "minHP"));
                MaxHP        = Convert.ToInt16(ReadElement(element, "maxHP"));
                AC           = Convert.ToInt16(ReadElement(element, "AC"));
                Speed        = Convert.ToSByte(ReadElement(element, "Speed"));
                ToHit        = Convert.ToInt16(ReadElement(element, "ToHit"));
                Attacks      = Convert.ToSByte(ReadElement(element, "Attacks"));
                Constitution = Convert.ToInt16(ReadElement(element, "Constitution"));
                Strength     = Convert.ToInt16(ReadElement(element, "Strength"));
                MinDB        = Convert.ToInt16(ReadElement(element, "minDB"));
                MaxDB        = Convert.ToInt16(ReadElement(element, "maxDB"));
                Survey       = Convert.ToByte(ReadElement(element, "Survey"));
                Level        = Convert.ToSByte(ReadElement(element, "Level"));
                Alignment    = (Alignment)Enum.Parse(typeof(Alignment), ReadElement(element, "Alignment"));
                Weight       = (float)ConvertHelper.ParseFloat(ReadElement(element, "Weight"), 0.0f, true);
                Sex          = StaticData.GetSexBySign(ReadElement(element, "Sex"));

                FleshEffect  = Convert.ToInt32(ReadElement(element, "FleshEffect"));
                FleshSatiety = Convert.ToInt16(ReadElement(element, "FleshSatiety"));

                string sym = ReadElement(element, "Symbol");
                Symbol      = (string.IsNullOrEmpty(sym) ? '?' : sym[0]);
                Extinctable = Convert.ToBoolean(ReadElement(element, "Extinctable"));
                Dexterity   = Convert.ToUInt16(ReadElement(element, "Dexterity"));
                Hear        = Convert.ToByte(ReadElement(element, "Hear"));
                Smell       = Convert.ToByte(ReadElement(element, "Smell"));
                FramesCount = Convert.ToByte(ReadElement(element, "FramesCount"));

                XmlNodeList nl = element.SelectSingleNode("Lands").ChildNodes;
                Lands = new string[nl.Count];
                for (int i = 0; i < nl.Count; i++)
                {
                    XmlNode n = nl[i];
                    Lands[i] = n.Attributes["ID"].InnerText;
                }

                nl = element.SelectSingleNode("Abilities").ChildNodes;
                for (int i = 0; i < nl.Count; i++)
                {
                    XmlNode   n   = nl[i];
                    AbilityID ab  = (AbilityID)Enum.Parse(typeof(AbilityID), n.Attributes["ID"].InnerText);
                    int       val = Convert.ToInt32(n.Attributes["Value"].InnerText);
                    Abilities.Add((int)ab, val);
                }

                nl = element.SelectSingleNode("Skills").ChildNodes;
                for (int i = 0; i < nl.Count; i++)
                {
                    XmlNode n   = nl[i];
                    SkillID sk  = (SkillID)Enum.Parse(typeof(SkillID), n.Attributes["ID"].InnerText);
                    int     val = Convert.ToInt32(n.Attributes["Value"].InnerText);
                    Skills.Add((int)sk, val);
                }

                nl        = element.SelectSingleNode("Inventory").ChildNodes;
                Inventory = new InventoryEntry[nl.Count];
                for (int i = 0; i < nl.Count; i++)
                {
                    XmlNode n = nl[i];

                    InventoryEntry invEntry = new InventoryEntry();
                    Inventory[i]      = invEntry;
                    invEntry.ItemSign = n.Attributes["ID"].InnerText;
                    invEntry.CountMin = Convert.ToInt32(n.Attributes["CountMin"].InnerText);
                    invEntry.CountMax = Convert.ToInt32(n.Attributes["CountMax"].InnerText);

                    XmlAttribute stat = n.Attributes["Status"];
                    if (stat != null)
                    {
                        ParseStatus(invEntry, stat.InnerText);
                    }
                }

                XmlNodeList dnl = element.SelectNodes("Dialog");
                if (dnl.Count > 0)
                {
                    XmlNode dialogXmlNode = (XmlNode)dnl[0];
                    Dialog.LoadXML(dialogXmlNode, version, true);
                }
            } catch (Exception ex) {
                Logger.Write("CreatureEntry.loadXML(): " + ex.Message);
                throw ex;
            }
        }
예제 #15
0
 public HeroData(string name, RaceID raceId)
 {
     Init(name, raceId);
 }
        public RaceSkillConditionalFeat SaveRaceSkillConditionalFeat()
        {
            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "InsertUpdate_RaceSkillConditionalFeat";
                command.Parameters.Add(dbconn.GenerateParameterObj("@RaceID", SqlDbType.Int, RaceID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@SkillID", SqlDbType.Int, SkillID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ConditionalFeatID", SqlDbType.Int, ConditionalFeatID.ToString(), 0));

                result = command.ExecuteReader();

                result.Read();
                SetReaderToObject(ref result);
            }
            catch
            {
                Exception e = new Exception();
                this._insertUpdateOK = false;
                this._insertUpdateMessage.Append(e.Message.ToString());
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this);
        }
예제 #17
0
        /// <summary>
        /// Saves the force power descriptor.
        /// </summary>
        /// <returns>Race Object</returns>
        public Race SaveRace()
        {
            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "InsertUpdate_Race";

                command.Parameters.Add(dbconn.GenerateParameterObj("@RaceID", SqlDbType.Int, RaceID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@RaceName", SqlDbType.VarChar, RaceName.ToString(), 50));
                command.Parameters.Add(dbconn.GenerateParameterObj("@RaceDescription", SqlDbType.VarChar, RaceDescription.ToString(), 1000));
                command.Parameters.Add(dbconn.GenerateParameterObj("@OtherDescription", SqlDbType.VarChar, OtherDescription.ToString(), 1000));
                command.Parameters.Add(dbconn.GenerateParameterObj("@SizeID", SqlDbType.Int, SizeID.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Sex", SqlDbType.Char, Sex.ToString(), 1));
                command.Parameters.Add(dbconn.GenerateParameterObj("@RageAbility", SqlDbType.Bit, RageAbility.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@ShapeShiftAbility", SqlDbType.Bit, ShapeShiftAbility.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@Primitive", SqlDbType.Bit, Primitive.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@BonusSkill", SqlDbType.Bit, BonusSkill.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@BonusFeat", SqlDbType.Bit, BonusFeat.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@AverageHeight", SqlDbType.Decimal, AverageHeight.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@AverageWeight", SqlDbType.Decimal, AverageWeight.ToString(), 0));
                command.Parameters.Add(dbconn.GenerateParameterObj("@SpeedID", SqlDbType.Int, SpeedID.ToString(), 0));

                result = command.ExecuteReader();

                result.Read();
                SetReaderToObject(ref result);
            }
            catch
            {
                Exception e = new Exception();
                this._insertUpdateOK = false;
                this._insertUpdateMessage.Append(e.Message + "                     Inner Exception= " + e.InnerException);
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this);
        }
예제 #18
0
        /// <summary>
        /// Deletes the extra class item.
        /// </summary>
        /// <returns>Boolean</returns>
        public bool DeleteRace()
        {
            SqlDataReader      result;
            DatabaseConnection dbconn     = new DatabaseConnection();
            SqlCommand         command    = new SqlCommand();
            SqlConnection      connection = new SqlConnection(dbconn.SQLSEVERConnString);

            try
            {
                connection.Open();
                command.Connection  = connection;
                command.CommandType = CommandType.StoredProcedure;
                command.CommandText = "Delete_Race";
                command.Parameters.Add(dbconn.GenerateParameterObj("@RaceID", SqlDbType.Int, RaceID.ToString(), 0));
                result = command.ExecuteReader();
            }
            catch
            {
                Exception e = new Exception();
                this._deleteOK = false;
                this._deletionMessage.Append(e.Message + "                     Inner Exception= " + e.InnerException);
                throw e;
            }
            finally
            {
                command.Dispose();
                connection.Close();
            }
            return(this.DeleteOK);
        }
예제 #19
0
 public string GetModelId()
 {
     return(RaceID.ToString());
 }
예제 #20
0
    public override void CreateCharacter(RaceID race)
    {
        _characterName = "Lost Vagabond";

        //Ability Scores
        int[] stats = { -1, -1, -1, -1, -1, -1 };
        int[] values = { 16, 14, 13, 12, 11, 10 };
        int   tempNum = 0;
        int   roundKill = 0;
        int   trained1 = -1, trained2 = -1, trained3 = -1;

        for (int i = 0; i < 6;)
        {
            tempNum = Random.Range(0, 6);
            if (System.Array.Exists(stats, stat => stat == tempNum) == false)
            {
                stats[i] = tempNum;
                i++;
            }

            roundKill++;
            if (roundKill >= 500)
            {
                Debug.LogError("BAD RNG, KILLED");
                break;
            }
        }

        for (int i = 0; i < 6; i++)
        {
            SetAbilityScore((AbilityID)stats[i], values[i]);
        }

        for (int i = 0; i < 3;)
        {
            switch (i)
            {
            case 0:
                trained1 = Random.Range(1, 17);
                i++;
                break;

            case 1:
                trained2 = Random.Range(1, 17);
                if (trained2 == trained1)
                {
                    trained2 = -1;
                }
                else
                {
                    i++;
                }
                break;

            case 2:
                trained3 = Random.Range(1, 17);
                if (trained3 == trained1 || trained3 == trained2)
                {
                    trained3 = -1;
                }
                else
                {
                    i++;
                }
                break;
            }
        }

        _trainedSkills[trained1] = true;
        _trainedSkills[trained2] = true;
        _trainedSkills[trained3] = true;
        _trainedSkills[0]        = true;

        base.CreateCharacter(race);
    }