/// <summary> /// Body or another living has been attacked. /// </summary> /// <param name="living"></param> /// <param name="attackData"></param> protected virtual void OnAttacked(AttackData attackData) { if (attackData == null) { return; } if (attackData.Target == Body) { if (Body.IsReturningToSpawnPoint) { Body.CancelWalkToSpawn(); } if (!attackData.IsMeleeAttack) { ISpellHandler spellhandler = attackData.SpellHandler; if (spellhandler != null && spellhandler is TauntSpellHandler) { OnTaunted(attackData); return; } } Aggression.Raise(attackData.Attacker, attackData.Damage); // TODO: Process attack data and change the amount of aggro // accordingly. } else { OnLivingAttacked(attackData.Target, attackData.Attacker); } }
/// <summary> /// The NPC has been taunted (spell). /// </summary> /// <param name="attackData"></param> protected virtual void OnTaunted(AttackData attackData) { GameLiving attacker = attackData.Attacker; if (attackData.Target == Body) { Aggression.Raise(attackData.Attacker, attackData.IsSpellResisted ? 0 : TauntAggressionAmount); } else { OnLivingAttacked(attackData.Target, attacker); } }
/// <summary> /// An enemy was healed. /// </summary> /// <param name="source"></param> /// <param name="amount"></param> protected virtual void OnEnemyHealed(GameObject source, int amount) { if (source == null) { return; } if (source is GameLiving && amount > 1) { Aggression.Raise(source as GameLiving, amount / 2); } // TODO: Track the source of the heal, e.g. if the heal originated // from an object, find out who the owner is. // Adjust amount of aggro generated. }
/// <summary> /// The NPC has nothing to do. /// </summary> protected virtual void OnIdle() { if (Body == null) { return; } foreach (GamePlayer player in Body.GetPlayersInRadius(AggressionRange)) { if (Util.Chance(GetChanceToAggroOn(player))) { Aggression.Raise(player, InternalAggression.Initial); return; } } }