
NativeEvents.onEvent($LivingHurtEvent, event => {
    if (event.source.actual && !event.source.actual.isPlayer()) {
        let attacker = event.source.actual;
        let attackerType = attacker.type
        let modifier = damageModifiers.find(mod => mod.entity_type === attackerType);
        if (modifier) {
            event.amount = (event.amount + modifier.addition) * modifier.multiply;
        }
    }
});

//boss免疫禁疗相关buff
NativeEvents.onEvent($MobEffectEvent$Applicable, event => {
    let entity = event.entity
    if (!entity.isLiving()) return

    let effectInstance = event.getEffectInstance()
    let buff = effectInstance.getEffect().getDescriptionId();

    if (buff != 'effect.alexscaves.irradiated') return

    let entity_name = entity.type
    if (stage_boss_2_1.includes(entity_name) || stage_boss_2_2.includes(entity_name) || stage_boss_3.includes(entity_name)) {
        event.setResult(Event$Result.DENY)
    }
})
//撼地斯啦攻击给辐射buff
NativeEvents.onEvent($LivingHurtEvent, event => {
    if (event.source.actual && event.entity) {
        let attacker = event.source.actual;
        let attackerType = attacker.type
        if (attackerType == "alexscaves:tremorzilla") {
            event.entity.potionEffects.add('alexscaves:irradiated', 40, 0)
        }
    }
});
//磁控机兵,明路巨兽，镇山大王受到的伤害减少
NativeEvents.onEvent($LivingHurtEvent, event => {
    if (event.entity) {
        if (event.entity.type == 'jerotesvillage:tyrant_of_the_mountain_realm') {
            event.amount *= 0.2
        }
        if (event.entity.type == "jerotesvillage:bright_land_beast") {
            event.amount *= 0.02
        }
        if (event.entity.type == 'alexscaves:magnetron' ){
            event.amount *= 0.005
        }
    }
});
