private void BeforeDamageOnTrigger(EntityUid uid, MousetrapComponent component, BeforeDamageUserOnTriggerEvent args)
 {
     if (TryComp(args.Tripper, out PhysicsComponent? physics) && physics.Mass != 0)
     {
         // The idea here is inverse,
         // Small - big damage,
         // Large - small damage
         // yes i punched numbers into a calculator until the graph looked right
         var scaledDamage = -50 * Math.Atan(physics.Mass - component.MassBalance) + (25 * Math.PI);
         args.Damage *= scaledDamage;
     }
 }
Exemplo n.º 2
0
    private bool OnDamageTrigger(EntityUid source, EntityUid target, DamageUserOnTriggerComponent?component = null)
    {
        if (!Resolve(source, ref component))
        {
            return(false);
        }

        var damage = new DamageSpecifier(component.Damage);
        var ev     = new BeforeDamageUserOnTriggerEvent(damage, target);

        RaiseLocalEvent(source, ev);

        return(_damageableSystem.TryChangeDamage(target, ev.Damage, component.IgnoreResistances) is not null);
    }