Beispiel #1
0
    public void ProcessDamageEvent(IEntity damager, ICombatant damaged, int damage)
    {
        bool resolve_after = !resolving_stack && !attack_happening;

        AfterDamageTakenTriggerInfo info       = new AfterDamageTakenTriggerInfo(damager, damaged, damage);
        AfterDamageDealtTriggerInfo dealt_info = new AfterDamageDealtTriggerInfo(damager, damaged, damage);

        Creature creature = damager as Creature;

        if (creature != null)
        {
            AddTriggersToStack(creature.abilities.GetLocalTriggers(dealt_info));
        }
        AddTriggersToStack(trigger_manager.GetTriggers(dealt_info));

        creature = damaged as Creature;
        if (creature != null)
        {
            AddTriggersToStack(creature.abilities.GetLocalTriggers(info));
        }
        AddTriggersToStack(trigger_manager.GetTriggers(info));

        if (resolve_after)
        {
            ResolveStack();
        }
    }
    public override bool TriggersFrom(TriggerInfo info)
    {
        if (info.type != type)
        {
            return(false);
        }

        AfterDamageDealtTriggerInfo damage_info = info as AfterDamageDealtTriggerInfo;

        if (damage_info == null)
        {
            return(false);
        }

        if (damage_info.damager.entity_type == EntityType.player && !players)
        {
            return(false);
        }

        if (damage_info.damager as Creature != null && !creatures)
        {
            return(false);
        }

        return(damage_info.damage >= damage_needed_to_trigger);
    }
    public override void Resolve(TriggerInfo info)
    {
        base.Resolve(info);

        if (info.type == TriggerType.damage_dealt)
        {
            AfterDamageDealtTriggerInfo damage_info = info as AfterDamageDealtTriggerInfo;

            if (damage_info.damaged != null)
            {
                foreach (TargetedEffect te in effects_targeting_damaged)
                {
                    te.SetTarget(damage_info.damaged);
                    te.Resolve(source);
                }
            }
        }
    }