public Creature(uint id, string name, Outfit outfit, Position position, Position spawnPosition,
                 ushort hitpoints, ushort maxHitpoints,
                 ushort mana, ushort maxMana, uint experience, byte level, byte magicLevel, ushort capacity, ushort speed,
                 CreatureFlags flags = CreatureFlags.None)
 {
     if (id == 0)
     {
         throw new ArgumentException("Id cannot be 0.", nameof(id));
     }
     Id            = id;
     Position      = position;
     SpawnPosition = spawnPosition;
     Name          = name;
     Outfit        = outfit;
     Hitpoints     = hitpoints;
     MaxHitpoints  = maxHitpoints;
     Mana          = mana;
     MaxMana       = maxMana;
     Experience    = experience;
     Level         = level;
     MagicLevel    = new Skill <byte>(magicLevel, 0);
     Capacity      = capacity;
     Flags         = flags;
     Speed         = new Skill <ushort>(speed, 110); // 110 is for level 1
     LightColor    = Outfit.LightColor;
     LightLevel    = Outfit.LightLevel;
     ZIndex        = 1;
 }
 /// <summary>
 /// Creates a placeholder creature with the given ArkId, which have to be imported
 /// </summary>
 /// <param name="arkId">ArkId from an imported source (no user input)</param>
 public Creature(long arkId)
 {
     ArkId         = arkId;
     ArkIdImported = true;
     guid          = Utils.ConvertArkIdToGuid(arkId);
     levelsWild    = new[] { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; // unknown wild levels
     flags         = CreatureFlags.Placeholder;
 }
 public CreatureBaseStats(CreatureFlags Flags, UInt16 Fatigue, UInt16 BarterGold, Int16 Level, UInt16 CalcMin, UInt16 CalcMax, UInt16 SpeedMultiplier, Single Karma, Int16 DispositionBase, ActorTemplateFlags TemplateFlags)
 {
     this.Flags           = Flags;
     this.Fatigue         = Fatigue;
     this.BarterGold      = BarterGold;
     this.Level           = Level;
     this.CalcMin         = CalcMin;
     this.CalcMax         = CalcMax;
     this.SpeedMultiplier = SpeedMultiplier;
     this.Karma           = Karma;
     this.DispositionBase = DispositionBase;
     this.TemplateFlags   = TemplateFlags;
 }
 public CreatureBaseStats(string Tag = null)
     : base(Tag)
 {
     Flags           = new CreatureFlags();
     Fatigue         = new UInt16();
     BarterGold      = new UInt16();
     Level           = new Int16();
     CalcMin         = new UInt16();
     CalcMax         = new UInt16();
     SpeedMultiplier = new UInt16();
     Karma           = new Single();
     DispositionBase = new Int16();
     TemplateFlags   = new ActorTemplateFlags();
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.CreatureCreatureFlags      = ((CreatureFlags)(binaryReader.ReadInt32()));
     this.DefaultTeam                = ((DefaultTeamEnum)(binaryReader.ReadInt16()));
     this.MotionSensorBlipSize       = ((MotionSensorBlipSizeEnum)(binaryReader.ReadInt16()));
     this.TurningVelocityMaximum     = binaryReader.ReadSingle();
     this.TurningAccelerationMaximum = binaryReader.ReadSingle();
     this.CasualTurningModifier      = binaryReader.ReadSingle();
     this.AutoaimWidth               = binaryReader.ReadSingle();
     pointerQueue               = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.Physics.ReadFields(binaryReader)));
     this.ImpactDamage          = binaryReader.ReadTagReference();
     this.ImpactShieldDamage    = binaryReader.ReadTagReference();
     this.DestroyAfterDeathTime = binaryReader.ReadRange();
     return(pointerQueue);
 }
Exemple #6
0
 public CreatureValues(Species species, string name, string owner, string tribe, Sex sex,
                       double[] statValues, int level, double tamingEffMin, double tamingEffMax, bool isTamed, bool isBred, double imprintingBonus, CreatureFlags flags,
                       Creature mother, Creature father)
 {
     this.Species         = species;
     this.name            = name;
     this.owner           = owner;
     this.tribe           = tribe;
     this.sex             = sex;
     this.statValues      = statValues;
     this.level           = level;
     this.tamingEffMin    = tamingEffMin;
     this.tamingEffMax    = tamingEffMax;
     this.isTamed         = isTamed;
     this.isBred          = isBred;
     this.imprintingBonus = imprintingBonus;
     this.flags           = flags;
     Mother = mother;
     Father = father;
 }
 public DB_Creature(int id, int loot, byte flags, int spell, float speed, int resource, ushort killCredit, float aRate, float bResist, float bArmor, float bDodge, float bPower,
                    float bHealth, float bEnergy, float bHPReg, float bEPReg, float bDMGMin, float bDMGMax)
 {
     ID           = id;
     LootID       = loot;
     Speed        = speed;
     SpellID      = spell;
     Resource     = resource;
     Base_Armor   = bArmor;
     Base_Dodge   = bDodge;
     Base_Power   = bPower;
     Attack_Rate  = aRate;
     Base_HP_Reg  = bHPReg;
     Base_EP_Reg  = bEPReg;
     Base_Health  = bHealth;
     Base_Energy  = bEnergy;
     Base_Dmg_Min = bDMGMin;
     Base_Dmg_Max = bDMGMax;
     Base_Resists = bResist;
     KillCredit   = killCredit;
     Flags        = (CreatureFlags)flags;
 }
Exemple #8
0
        /// <summary>
        /// Updates the list of set owners, servers, tribes and tags of all creatures.
        /// </summary>
        private void UpdateOwnerServerTagLists()
        {
            // status list
            var statusList = new CreatureFlags[]
            {
                CreatureFlags.Available,
                CreatureFlags.Unavailable,
                CreatureFlags.Dead,
                CreatureFlags.Obelisk,
                CreatureFlags.Cryopod,
                CreatureFlags.Mutated,
                CreatureFlags.Neutered,
                CreatureFlags.Female,
                CreatureFlags.Male,
            };

            _statusButtons = new List <Button>(statusList.Length);
            int statusButtonWidth = FlpStatus.Width - 6;

            foreach (var s in statusList)
            {
                ButtonState buttonState = ButtonState.Neutral;
                if ((Properties.Settings.Default.FilterFlagsOneNeeded & (int)s) != 0)
                {
                    buttonState = ButtonState.OneNeeded;
                }
                else if ((Properties.Settings.Default.FilterFlagsAllNeeded & (int)s) != 0)
                {
                    buttonState = ButtonState.AllNeeded;
                }
                else if ((Properties.Settings.Default.FilterFlagsExclude & (int)s) != 0)
                {
                    buttonState = ButtonState.Exclude;
                }

                var b = new Button()
                {
                    Text      = s.ToString(),
                    Tag       = (s, buttonState),
                    BackColor = ColorButtonState(buttonState),
                    Width     = statusButtonWidth
                };
                FlpStatus.Controls.Add(b);
                FlpStatus.SetFlowBreak(b, true);
                _statusButtons.Add(b);
                b.Click += BtStatusClicked;
            }

            //// lists with number of according creatures
            var ownerList   = new Dictionary <string, int>();
            var tribesList  = new Dictionary <string, int>();
            var serversList = new Dictionary <string, int>();
            var tagList     = new Dictionary <string, int>();

            // clear checkBoxLists
            ClbOwners.Items.Clear();
            ClbTribes.Items.Clear();
            ClbServers.Items.Clear();
            ClbTags.Items.Clear();

            //// check all creature for info
            var creaturesToCheck = _cc.creatures.Where(c => !c.flags.HasFlag(CreatureFlags.Placeholder)).ToArray();

            foreach (Creature c in creaturesToCheck)
            {
                SetListValue(c.owner, ownerList);
                SetListValue(c.tribe, tribesList);
                SetListValue(c.server, serversList);

                void SetListValue(string _value, Dictionary <string, int> _list)
                {
                    if (string.IsNullOrEmpty(_value))
                    {
                        if (!_list.ContainsKey(string.Empty))
                        {
                            _list.Add(string.Empty, 1);
                        }
                        else
                        {
                            _list[string.Empty]++;
                        }
                    }
                    else if (!_list.ContainsKey(_value))
                    {
                        _list.Add(_value, 1);
                    }
                    else
                    {
                        _list[_value]++;
                    }
                }

                // tags
                if (!(c.tags?.Any() ?? false))
                {
                    if (!tagList.ContainsKey(string.Empty))
                    {
                        tagList.Add(string.Empty, 1);
                    }
                    else
                    {
                        tagList[string.Empty]++;
                    }
                }
                else
                {
                    for (int t = 0; t < c.tags.Count; t++)
                    {
                        if (!tagList.ContainsKey(c.tags[t]))
                        {
                            tagList.Add(c.tags[t], 1);
                        }
                        else
                        {
                            tagList[c.tags[t]]++;
                        }
                    }
                }
            }

            CbOwnersAll.Checked  = CreateCheckboxes(ClbOwners, ownerList, Properties.Settings.Default.FilterHideOwners);
            CbTribesAll.Checked  = CreateCheckboxes(ClbTribes, tribesList, Properties.Settings.Default.FilterHideTribes);
            CbServersAll.Checked = CreateCheckboxes(ClbServers, serversList, Properties.Settings.Default.FilterHideServers);
            CbTagsAll.Checked    = CreateCheckboxes(ClbTags, tagList, Properties.Settings.Default.FilterHideTags);

            bool IsChecked(string[] list, string name) => list == null || !list.Contains(name);

            bool CreateCheckboxes(CheckedListBox clb, Dictionary <string, int> dict, string[] hiddenList)
            {
                bool allChecked = true;

                foreach (var entry in dict.OrderBy(o => o.Key))
                {
                    bool isChecked = IsChecked(hiddenList, entry.Key);
                    clb.Items.Add($"{entry.Key} ({entry.Value})", isChecked);
                    allChecked = allChecked && isChecked;
                }

                return(allChecked);
            }
        }
Exemple #9
0
        public static Creature SpawnRandomCreature(CreatureFlags flags, ActionNode node, WIGroup group)
        {
            Creature newCreature = null;

            return(newCreature);
        }
		public bool GetFlag( CreatureFlags flag )
		{
			return ( (m_Flags & flag) != 0 );
		}
		public void SetFlag( CreatureFlags flag, bool value )
		{
			if ( value )
				m_Flags |= flag;
			else
				m_Flags &= ~flag;
		}
		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();

			m_CurrentAI = (AIType)reader.ReadInt();
			m_DefaultAI = (AIType)reader.ReadInt();

			m_iRangePerception = reader.ReadInt();
			m_iRangeFight = reader.ReadInt();

			m_iTeam = reader.ReadInt();

			m_dActiveSpeed = reader.ReadDouble();
			m_dPassiveSpeed = reader.ReadDouble();
			m_dCurrentSpeed = reader.ReadDouble();

			double activeSpeed = m_dActiveSpeed;
			double passiveSpeed = m_dPassiveSpeed;

			//			SpeedInfo.GetSpeeds( this, ref activeSpeed, ref passiveSpeed );

			bool isStandardActive = false;
			for ( int i = 0; !isStandardActive && i < m_StandardActiveSpeeds.Length; ++i )
				isStandardActive = ( m_dActiveSpeed == m_StandardActiveSpeeds[i] );

			bool isStandardPassive = false;
			for ( int i = 0; !isStandardPassive && i < m_StandardPassiveSpeeds.Length; ++i )
				isStandardPassive = ( m_dPassiveSpeed == m_StandardPassiveSpeeds[i] );

			if ( isStandardActive && m_dCurrentSpeed == m_dActiveSpeed )
				m_dCurrentSpeed = activeSpeed;
			else if ( isStandardPassive && m_dCurrentSpeed == m_dPassiveSpeed )
				m_dCurrentSpeed = passiveSpeed;

			if ( isStandardActive )
				m_dActiveSpeed = activeSpeed;

			if ( isStandardPassive )
				m_dPassiveSpeed = passiveSpeed;

			if ( m_iRangePerception == OldRangePerception )
				m_iRangePerception = DefaultRangePerception;

			m_pHome.X = reader.ReadInt();
			m_pHome.Y = reader.ReadInt();
			m_pHome.Z = reader.ReadInt();

			if ( version >= 1 )
			{
				m_iRangeHome = reader.ReadInt();

				int i, iCount;

				iCount = reader.ReadInt();
				for ( i=0; i< iCount; i++ )
				{
					string str = reader.ReadString();
					Type type = Type.GetType( str );

					if ( type != null )
					{
						m_arSpellAttack.Add( type );
					}
				}

				iCount = reader.ReadInt();
				for ( i=0; i< iCount; i++ )
				{
					string str = reader.ReadString();
					Type type = Type.GetType( str );

					if ( type != null )
					{
						m_arSpellDefense.Add( type );
					}
				}
			}
			else
			{
				m_iRangeHome = 0;
			}

			if ( version >= 2 )
			{
				m_FightMode = ( FightMode )reader.ReadInt();

				m_bControled = reader.ReadBool();
				m_ControlMaster = reader.ReadMobile();
				m_ControlTarget = reader.ReadMobile();
				m_ControlDest = reader.ReadPoint3D();
				m_ControlOrder = (OrderType) reader.ReadInt();

				m_dMinTameSkill = reader.ReadDouble();

				if ( version < 9 )
					reader.ReadDouble();

				m_bTamable = reader.ReadBool();
				m_bSummoned = reader.ReadBool();

				if ( m_bSummoned )
				{
					m_SummonEnd = reader.ReadDeltaTime();
					new UnsummonTimer( m_ControlMaster, this, m_SummonEnd - DateTime.Now ).Start();
				}

				m_iControlSlots = reader.ReadInt();
			}
			else
			{
				m_FightMode = FightMode.All | FightMode.Closest;

				m_bControled = false;
				m_ControlMaster = null;
				m_ControlTarget = null;
				m_ControlOrder = OrderType.None;
			}

			if ( version >= 3 ) // loyalty redo
			{
				m_Loyalty = (PetLoyalty)reader.ReadInt();

				if (version < 23)
					m_Loyalty = (PetLoyalty)((int)m_Loyalty * 10);
			}
			else
				m_Loyalty = PetLoyalty.WonderfullyHappy;


			if ( version >= 4 )
				m_CurrentWayPoint = reader.ReadItem() as WayPoint;

			if ( version >= 5 )
				m_SummonMaster = reader.ReadMobile();

			if ( version >= 6 )
			{
				m_HitsMax = reader.ReadInt();
				m_StamMax = reader.ReadInt();
				m_ManaMax = reader.ReadInt();
				m_DamageMin = reader.ReadInt();
				m_DamageMax = reader.ReadInt();
			}

			if ( version >= 7 && version < 18) // Adam: eliminate crazy resistances ver. 18
			{
				int dummy;
				dummy = reader.ReadInt();	// PhysicalResistance
				dummy = reader.ReadInt();	// PhysicalDamage
				dummy = reader.ReadInt();	// FireResistance
				dummy = reader.ReadInt();	// FireDamage
				dummy = reader.ReadInt();	// ColdResistance
				dummy = reader.ReadInt();	// ColdDamage
				dummy = reader.ReadInt();	// PoisonResistance
				dummy = reader.ReadInt();	// PoisonDamage
				dummy = reader.ReadInt();	// EnergyResistance
				dummy = reader.ReadInt();	// EnergyDamage
			}

			//if ( version >= 7 && version >= 18) // Adam: eliminate crazy resistances ver. 18
			//{
			//	m_PhysicalResistance = reader.ReadInt();
			//	m_PhysicalDamage = reader.ReadInt();
			//}

			if ( version >= 8 )
				m_Owners = reader.ReadMobileList();
			else
				m_Owners = new ArrayList();

			if ( version >= 10 )
			{
				m_IsDeadPet = reader.ReadBool();
				m_IsBonded = reader.ReadBool();
				m_BondingBegin = reader.ReadDateTime();
				m_OwnerAbandonTime = reader.ReadDateTime();
			}

			if ( version >= 11 )
				m_HasGeneratedLoot = reader.ReadBool();
			else
				m_HasGeneratedLoot = true;

			if( version >= 12 )
			{
				m_StatLossTime = reader.ReadDateTime();
			}

			if( version >= 13 ) //Pigpen - Addition for IOB Sytem
			{
				m_IOBAlignment = (IOBAlignment)reader.ReadInt();
			}

			if( version >= 14 ) //Pix: IOBLeader/IOBFollower
			{
				m_IOBFollower = reader.ReadBool();
				m_IOBLeader = reader.ReadMobile();
			}

			if( version >= 15 ) //Pix: Spawner
			{
				m_Spawner = (Spawner)reader.ReadItem();
			}

			if( version >= 16 ) //Pix: Lifespan
			{
				m_lifespan = reader.ReadDeltaTime();
			}
			if( version >= 17 && version < 30 ) //Kit: preferred target ai
			{	// eliminated in version 30
				//m_preferred = reader.ReadBool();
				//m_preferredTargetType = reader.ReadMobile();
				//Sortby = (SortTypes)reader.ReadInt();
				reader.ReadBool();
				reader.ReadMobile();
				reader.ReadInt();
			}
			if( version >= 18 ) //Adam: eliminate stupid resistances
			{
				// see above - version 7
			}
			if( version >= 19 ) //Kit: NavStar
			{
				Destination = reader.ReadPoint3D();

				dest = (NavDestinations)reader.ReadInt();

				Nav = (NavBeacon)reader.ReadItem();
			}
			if( version >= 20 ) //Adam: convert BardImmune from an override to a property
			{
				m_bBardImmune = reader.ReadBool();
			}

			if(version >= 21 )
			{
				loyaltyfeed = reader.ReadDateTime();
			}

			if(version >= 22)
			{
				m_Flags = (CreatureFlags)reader.ReadInt();
			}

			if (version >= 24)
			{
				m_ControlSlotModifier = reader.ReadDouble();
				m_Patience = reader.ReadInt();
				m_Wisdom = reader.ReadInt();
				m_Temper = reader.ReadInt();
				m_MaxLoyalty = reader.ReadInt();
			}

            if (version >= 25)
            {
                m_HitsRegenGene = reader.ReadDouble();
                m_ManaRegenGene = reader.ReadDouble();
                m_StamRegenGene = reader.ReadDouble();
            }

            // note the LESS THAN symbol instead of GTE
            // this is an example of run-once deserialization code - every old critter will run this once.
            if (version < 26)
                InitializeGenes();

            // version 27
            if (version >= 27)
                m_LifespanMinutes = reader.ReadInt();

			// we need to reset this because reading the Flags will have turned it off
			//	the flags value will obnly be valid when version >= 28
			if (version < 28)
				IsScaredOfScaryThings = true;

			/*	versions < 29 get their FightMode upgraded to the new [Flags] version
			public enum FightMode
			{
				None,			// Never focus on others
				Aggressor,		// Only attack Aggressors
				Strongest,		// Attack the strongest
				Weakest,		// Attack the weakest
				Closest, 		// Attack the closest
				Evil,			// Only attack aggressor -or- negative karma
				Criminal,		// Attack the criminals
				Player
			}
			 */
			if (version < 29)
			{
				switch ((int)m_FightMode)
				{	// now outdated values
					case 0: m_FightMode = (FightMode)0x00; break;	/*None*/
					case 1: m_FightMode = (FightMode)0x01; break;	/*Aggressor*/
					case 2: m_FightMode = (FightMode)0x02; break;	/*Strongest*/
					case 3: m_FightMode = (FightMode)0x04; break;	/*Weakest*/
					case 4: m_FightMode = (FightMode)0x08; break;	/*Closest*/
					case 5: m_FightMode = (FightMode)0x10; break;	/*Evil*/
					case 6: m_FightMode = (FightMode)0x20; break;	/*Criminal*/
					case 7: m_FightMode = (FightMode)0x40; break;	/*Player*/
				}
			}

			/* versions < 30 get their FightMode upgraded to the new [Flags] version
			public enum FightMode
			{
				None		= 0x00,		// Never focus on others
				Aggressor	= 0x01,		// Only attack Aggressors
				Strongest	= 0x02,		// Attack the strongest
				Weakest		= 0x04,		// Attack the weakest
				Closest		= 0x08, 	// Attack the closest
				Evil		= 0x10,		// Only attack aggressor -or- negative karma
				Criminal	= 0x20,		// Attack the criminals
				Player		= 0x40		// Attack Players (Vampires for feeding on blood)
			}
			 */
			if (version < 30)
			{
				switch ((int)m_FightMode)
				{
					case 0x00 /*None*/		: m_FightMode = FightMode.None; break;
					case 0x01 /*Aggressor*/	: m_FightMode = FightMode.Aggressor; break;
					case 0x02 /*Strongest*/	: m_FightMode = FightMode.All | FightMode.Strongest; break;
					case 0x04 /*Weakest*/	: m_FightMode = FightMode.All | FightMode.Weakest; break;
					case 0x08 /*Closest*/	: m_FightMode = FightMode.All | FightMode.Closest; break;
					case 0x10 /*Evil*/		: m_FightMode = FightMode.Aggressor | FightMode.Evil; break;
					case 0x20 /*Criminal*/	: m_FightMode = FightMode.Aggressor | FightMode.Criminal; break;
					case 0x40 /*Player*/	: m_FightMode = FightMode.All | FightMode.Closest; break;
				}
			}

			// new Fight Style for enhanced AI
			if (version >= 31)
				m_FightStyle = (FightStyle)reader.ReadInt();

			// version 32, read in the AI data, but we must construct the AI object first
			ChangeAIType(m_CurrentAI);
			if (version >= 32)
			{
				if (AIObject != null)
					AIObject.Deserialize(reader);
			}

			if (version >= 33)
			{
				m_ConstantFocus = reader.ReadMobile();
			}

			// -------------------------------
			// After all the reading is done
			// -------------------------------
			RefreshLifespan();
			CheckStatTimers();
			AddFollowers();
		}
    public override void Initialize(System.IO.BinaryReader reader, RecordHeader header)
    {
        while (reader.BaseStream.Position < header.DataEndPos)
        {
            var type = (SubRecordType)reader.ReadInt32();
            var size = reader.ReadInt32();

            switch (type)
            {
            case SubRecordType.Id:
                name = reader.ReadString(size);
                break;

            case SubRecordType.Model:
                model = reader.ReadString(size);
                break;

            case SubRecordType.Name:
                fullName = reader.ReadString(size);
                break;

            case SubRecordType.Script:
                script = Script.Get(reader.ReadString(size));
                break;

            case SubRecordType.AiData:
                aiData = new AiData(reader);
                break;

            case SubRecordType.AiActivateData:
                activateData = new ActivateData(reader);
                break;

            case SubRecordType.AiEscortData:
                escortData = new EscortData(reader);
                break;

            case SubRecordType.AiFollowData:
                followData = new FollowData(reader);
                break;

            case SubRecordType.AiTravelData:
                travelData = new TravelData(reader);
                break;

            case SubRecordType.AiWanderData:
                wanderData = new WanderData(reader);
                break;

            case SubRecordType.CreatureName:
                soundGeneratorName = reader.ReadString(size);
                break;

            case SubRecordType.InventoryItem:
                items.Add(new InventoryItem(reader));
                break;

            case SubRecordType.NpcSpell:
                spells.Add(Record.GetRecord <SpellRecord>(reader.ReadString(size)));
                break;

            case SubRecordType.Scale:
                scale = reader.ReadSingle();
                break;

            case SubRecordType.NpcData:
                data = new CreatureData(reader);
                break;

            case SubRecordType.Flag:
                flags = (CreatureFlags)reader.ReadInt32();
                break;
            }
        }

        // Use the record id for sound generation if no SoundGeneratorName is specified
        if (soundGeneratorName == null)
        {
            soundGeneratorName = name;
        }
    }