public override void OnDamage(Creature attacker, uint damage) { if (attacker != null) { if (!ThreatInfo.ContainsThreat(attacker)) { ThreatInfo.AddNewThreat(attacker, damage); } else { ThreatInfo.IncreaseThreat(attacker, damage); } } Condition.Asleep = false; IsHostile = true; ShouldWander = false; // FIXME: in the glorious future, run asynchronously with locking InitScript(); if (Script != null) { Script.SetGlobalValue("damage", damage); Script.ExecuteFunction("OnDamage", this, attacker); } }
public Monster(Xml.Creature creature, Xml.Spawn spawn, int map, Loot loot = null) { _actionQueue = new ConcurrentQueue <MobAction>(); _spawn = spawn; var buffed = Rng.Next() > 50; if (buffed) { _variance = (Rng.NextDouble() * _spawn.Variance) + 1; } else { _variance = 1 - (Rng.NextDouble() * _spawn.Variance); } Name = creature.Name; Sprite = creature.Sprite; World = Game.World; Map = Game.World.WorldData.Get <Map>(map); Stats.Level = spawn.Stats.Level; Stats.BaseHp = VariantHp; Stats.Hp = VariantHp; Stats.BaseMp = VariantMp; Stats.Mp = VariantMp; DisplayText = creature.Description; Stats.BaseStr = VariantStr; Stats.BaseInt = VariantInt; Stats.BaseWis = VariantWis; Stats.BaseCon = VariantCon; Stats.BaseDex = VariantDex; _castables = spawn.Castables; Stats.BaseDefensiveElement = spawn.GetDefensiveElement(); Stats.BaseDefensiveElement = spawn.GetOffensiveElement(); _loot = loot; if (spawn.Flags.HasFlag(Xml.SpawnFlags.AiDisabled)) { IsHostile = false; } else { IsHostile = _random.Next(0, 8) < 2; } if (spawn.Flags.HasFlag(Xml.SpawnFlags.MovementDisabled)) { ShouldWander = false; } else { ShouldWander = IsHostile == false; } ThreatInfo = new ThreatInfo(); DeathProcessed = false; }