Activate() public method

public Activate ( CreatureStates state ) : void
state CreatureStates
return void
Exemplo n.º 1
0
Arquivo: Rest.cs Projeto: xKamuna/aura
		/// <summary>
		/// Starts rest skill.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="dict"></param>
		/// <returns></returns>
		public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict)
		{
			creature.StopMove();

			creature.IsInBattleStance = false;
			creature.AttemptingAttack = false;

			var chairItemEntityId = dict.GetLong("ITEMID");

			if (chairItemEntityId != 0)
				this.SetUpChair(creature, chairItemEntityId);

			creature.Activate(CreatureStates.SitDown);
			if (skill.Info.Rank >= SkillRank.R9)
				creature.Activate(CreatureStatesEx.RestR9);

			Send.SitDown(creature);

			// Get bonuses if meditation isn't active.
			if (!creature.Conditions.Has(ConditionsE.Meditation))
			{
				ApplyRestBonus(creature, skill, chairItemEntityId);
			}
			else
			{
				RestCampfireBonus(creature, skill, chairItemEntityId);
			}

			// Add bonus from campfire
			// TODO: Check for disappearing of campfire? (OnDisappears+Recheck)
			var campfires = creature.Region.GetProps(a => a.Info.Id == 203 && a.GetPosition().InRange(creature.GetPosition(), 500));
			if (campfires.Count > 0)
			{
				Send.Notice(creature, Localization.Get("The fire feels very warm."));
			}

			if (skill.Info.Rank == SkillRank.Novice) skill.Train(1); // Use Rest.

			return StartStopResult.Okay;
		}
Exemplo n.º 2
0
        public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict)
        {
            creature.StopMove();

            var chairItemEntityId = dict.GetLong("ITEMID");

            if (chairItemEntityId != 0)
                this.SetUpChair(creature, chairItemEntityId);

            creature.Activate(CreatureStates.SitDown);
            Send.SitDown(creature);

            creature.Regens.Add("Rest", Stat.Life, (0.12f * ((skill.RankData.Var1 - 100) / 100)), creature.LifeMax);
            creature.Regens.Add("Rest", Stat.Stamina, (0.4f * ((skill.RankData.Var2 - 100) / 100)), creature.StaminaMax);
            creature.Regens.Add("Rest", Stat.LifeInjured, skill.RankData.Var3, creature.LifeMax);

            if (skill.Info.Rank == SkillRank.Novice) skill.Train(1); // Use Rest.

            return StartStopResult.Okay;
        }
Exemplo n.º 3
0
		/// <summary>
		/// Adds creature to region, sends EntityAppears.
		/// </summary>
		public void AddCreature(Creature creature)
		{
			//if (creature.Region != Region.Limbo)
			//	creature.Region.RemoveCreature(creature);

			_creaturesRWLS.EnterWriteLock();
			try
			{
				if (_creatures.ContainsKey(creature.EntityId))
					throw new ArgumentException("A creature with id '" + creature.EntityId.ToString("X16") + "' already exists.");

				_creatures.Add(creature.EntityId, creature);
			}
			finally
			{
				_creaturesRWLS.ExitWriteLock();
			}

			creature.Region = this;
			creature.Activate(CreatureStates.EverEnteredWorld);

			// Save reference to client if it's mainly controlling this creature.
			if (creature.Client.Controlling == creature)
			{
				lock (_clients)
					_clients.Add(creature.Client);
			}

			// Send appear packets, so there's no delay.
			Send.EntityAppears(creature);

			// Remove Spawned state, so effect only plays the first time.
			// This probably only works because of the EntityAppears above,
			// otherwise the state would be gone by the time LookAround
			// kicks in. Maybe we need a better solution.
			creature.State &= ~CreatureStates.Spawned;

			//if (creature.EntityId < MabiId.Npcs)
			//	Log.Status("Creatures currently in region {0}: {1}", this.Id, _creatures.Count);

			if (creature.IsPlayer)
			{
				ChannelServer.Instance.Events.OnPlayerEntersRegion(creature);
				this.PlayerEnters.Raise(creature);
			}
		}
Exemplo n.º 4
0
		/// <summary>
		/// Starts rest skill.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="dict"></param>
		/// <returns></returns>
		public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict)
		{
			creature.StopMove();

			var chairItemEntityId = dict.GetLong("ITEMID");

			if (chairItemEntityId != 0)
				this.SetUpChair(creature, chairItemEntityId);
			else
			{
				// Find all nearby sittable props and sit on closest one
				var crpos = creature.GetPosition();
				var props = creature.Region.GetProps(prop => prop.HasTag("/sittable/")
					&& (!prop.HasXml || prop.Xml.Attribute("SITCHAR") == null || prop.Xml.Attribute("SITCHAR").Value == "0")
					&& prop.GetPosition().GetDistance(crpos) < 125);
				if (props.Count > 0)
				{
					int nearest = 0;
					int minDist = 125;
					for (int i = 0; i < props.Count; i++)
					{
						var dist = crpos.GetDistance(props[i].GetPosition());
						if(dist < minDist)
						{
							nearest = i;
							minDist = dist;
						}
					}
					this.SitOnProp(creature, props[nearest]);
				}
			}

			creature.Activate(CreatureStates.SitDown);
			if (skill.Info.Rank >= SkillRank.R9)
				creature.Activate(CreatureStatesEx.RestR9);

			Send.SitDown(creature);

			// Get base bonuses
			var bonusLife = ((skill.RankData.Var1 - 100) / 100);
			var bonusStamina = ((skill.RankData.Var2 - 100) / 100);
			var bonusInjury = skill.RankData.Var3;

			// Add bonus from campfire
			// TODO: Check for disappearing of campfire? (OnDisappears+Recheck)
			var campfires = creature.Region.GetProps(a => a.Info.Id == 203 && a.GetPosition().InRange(creature.GetPosition(), 500));
			if (campfires.Count > 0)
			{
				// Add bonus if no chair?
				if (chairItemEntityId == 0)
				{
					// TODO: Select nearest? Random?
					var campfire = campfires[0];

					var multi = (campfire.Temp.CampfireSkillRank != null ? campfire.Temp.CampfireSkillRank.Var1 / 100f : 1);

					// Add bonus for better wood.
					// Amounts unofficial.
					if (campfire.Temp.CampfireFirewood != null)
					{
						if (campfire.Temp.CampfireFirewood.HasTag("/firewood01/"))
							multi += 0.1f;
						else if (campfire.Temp.CampfireFirewood.HasTag("/firewood02/"))
							multi += 0.2f;
						else if (campfire.Temp.CampfireFirewood.HasTag("/firewood03/"))
							multi += 0.3f;
					}

					// Apply multiplicator
					bonusLife *= multi;
					bonusStamina *= multi;
					bonusInjury *= multi;
				}

				Send.Notice(creature, Localization.Get("The fire feels very warm"));
			}

			creature.Regens.Add("Rest", Stat.Life, (0.12f * bonusLife), creature.LifeMax);
			creature.Regens.Add("Rest", Stat.Stamina, (0.4f * bonusStamina), creature.StaminaMax);
			creature.Regens.Add("Rest", Stat.LifeInjured, bonusInjury, creature.LifeMax); // TODO: Test if LifeInjured = Injuries

			if (skill.Info.Rank == SkillRank.Novice) skill.Train(1); // Use Rest.

			return StartStopResult.Okay;
		}
Exemplo n.º 5
0
		/// <summary>
		/// Starts rest skill.
		/// </summary>
		/// <param name="creature"></param>
		/// <param name="skill"></param>
		/// <param name="dict"></param>
		/// <returns></returns>
		public override StartStopResult Start(Creature creature, Skill skill, MabiDictionary dict)
		{
			creature.StopMove();

			var chairItemEntityId = dict.GetLong("ITEMID");

			if (chairItemEntityId != 0)
				this.SetUpChair(creature, chairItemEntityId);

			creature.Activate(CreatureStates.SitDown);
			if (skill.Info.Rank >= SkillRank.R9)
				creature.Activate(CreatureStatesEx.RestR9);

			Send.SitDown(creature);

			// Get base bonuses
			var bonusLife = ((skill.RankData.Var1 - 100) / 100);
			var bonusStamina = ((skill.RankData.Var2 - 100) / 100);
			var bonusInjury = skill.RankData.Var3;

			// Add bonus from campfire
			// TODO: Check for disappearing of campfire? (OnDisappears+Recheck)
			var campfires = creature.Region.GetProps(a => a.Info.Id == 203 && a.GetPosition().InRange(creature.GetPosition(), 500));
			if (campfires.Count > 0)
			{
				// Add bonus if no chair?
				if (chairItemEntityId == 0)
				{
					// TODO: Select nearest? Random?
					var campfire = campfires[0];

					var multi = (campfire.Temp.CampfireSkillRank != null ? campfire.Temp.CampfireSkillRank.Var1 / 100f : 1);

					// Add bonus for better wood.
					// Amounts unofficial.
					if (campfire.Temp.CampfireFirewood != null)
					{
						if (campfire.Temp.CampfireFirewood.HasTag("/firewood01/"))
							multi += 0.1f;
						else if (campfire.Temp.CampfireFirewood.HasTag("/firewood02/"))
							multi += 0.2f;
						else if (campfire.Temp.CampfireFirewood.HasTag("/firewood03/"))
							multi += 0.3f;
					}

					// Apply multiplicator
					bonusLife *= multi;
					bonusStamina *= multi;
					bonusInjury *= multi;
				}

				Send.Notice(creature, Localization.Get("The fire feels very warm"));
			}

			creature.Regens.Add("Rest", Stat.Life, (0.12f * bonusLife), creature.LifeMax);
			creature.Regens.Add("Rest", Stat.Stamina, (0.4f * bonusStamina), creature.StaminaMax);
			creature.Regens.Add("Rest", Stat.LifeInjured, bonusInjury, creature.LifeMax); // TODO: Test if LifeInjured = Injuries

			if (skill.Info.Rank == SkillRank.Novice) skill.Train(1); // Use Rest.

			return StartStopResult.Okay;
		}