#Ignoring entities' iframes

1 messages · Page 1 of 1 (latest)

abstract stratus
#
let dmgnum = 0;

world.afterEvents.entityHurt.subscribe(({damage, damageSource, hurtEntity}) => {
    const player = damageSource.damagingEntity;
    const hitbox = hurtEntity;
    if (hitbox.typeId == "dungeonscombat:hitbox" && player.typeId == "minecraft:player" && damageSource.cause == EntityDamageCause.entityAttack ) {
        dmgnum = damage;
        let nearbyEntities = player.dimension.getEntities({
            maxDistance: 4,
            closest: 1,
            excludeTypes: ['player', 'item', 'xp_orb'],
            excludeFamilies: ['dchitbox', 'dchitboxride'],
            location: player.location
        });
        for (const entity of nearbyEntities) {
            entity.applyDamage(dmgnum,{cause: EntityDamageCause.entityAttack, damagingEntity: player});
        }
    world.sendMessage(`damage is ${dmgnum}`);
    }
});

the code checks the damage done to dummy entity by the player, and then it applies damage to nearby closest mob with the same damage done to the dummy entity

but theres a limit where dummy entity gets into iframes on hit, making applyDamage to run inconsistently because the code runs if the dummy entity is damaged

using entityHitEntity event partially works but it doesnt track the number of damage done reliably since entityHurt fires only when the entity gets damaged

is there any workaround for this?

abstract stratus
#

what do you mean by "this works?"

stray spire
#

like it bypasses iframes?

abstract stratus
#

no

stray spire
#

oh

#

well i was just actually working on something

#

that does

#

but idk how its gonna work

abstract stratus
#

well that code runs when the player damages the dummy entity

#

so its all about the dummy entity

stray spire
#

well u can do it in vanilla

#

you just have to ```js
/damage @s 0 override

#

it always attacks

#

but idk how im gonna use it

abstract stratus
#

uh

#

im not sure if this really works

#

at all

stray spire
#

wait yours or mine?

abstract stratus
stray spire
#

it does

#

i tested it

#

put it in a repeat command block

abstract stratus
#

i mean sure it does ignore the iframes

#

but like i said above

stray spire
#

yeah it does

abstract stratus
#

the code uses dummy entity's damage

stray spire
#

ik

abstract stratus
#

and since player has to hit the entity

#

directly

#

my code wouldnt be consistent because the iframes would trigger

stray spire
#

thats why im tryna work on it so it does work

abstract stratus
#

im not sure what to do with that command though

stray spire
#

wait i made a system

#

that works

#

lemme cip it

abstract stratus
stray spire
#

yeah

#

but u could prob set a variable

abstract stratus
#

yeah thats the issue sadly

#

i need the game to track the damage without variables

stray spire
#

but u kinda gotta recode the entire damage system lol

abstract stratus
#

yeah i noticed there was no crit in the vid

stray spire
#

yeah u cant crit either

abstract stratus
#

though it sounds simple

#

using isFalling

stray spire
#

ill send code

abstract stratus
#

and then multiplying the damage by 1.2

stray spire
#
world.afterEvents.entityHitEntity.subscribe(({damagingEntity, hitEntity}) => {
    if (damagingEntity.typeId == "minecraft:player" && hitEntity.typeId == "minecraft:player") {
    hitEntity.applyDamage(0.00005, {cause:EntityDamageCause.override,damagingEntity:damagingEntity})
    }
})```
#

ok

abstract stratus
#

what is override cause actually

#

is it any different than entityAttack

#

other than ignoring iframes

stray spire
#

idk if it is

abstract stratus
#

hmm

#

so it basically sets the hp

#

that means it ignores armor

stray spire
#

yeah

#

gotta recode armor too

#

lmao

#

ok i added crits

abstract stratus
#

ok so

#

i just thought of the

#

most ridiculous one that might work

#

when you damage a mob thats in iframe state with damage higher than previous damage

#

itll damage the entity again

#

but it caps to the highest damage done

stray spire
#

wait what

abstract stratus
#

yeah its a vanilla thing

#

try it

#

im sending a vid

stray spire
abstract stratus
#

an attack without a weapon does 1 damage but crit multiplies the damage by 1.2

stray spire
#

oh

abstract stratus
#

so if you attack midair and then attack while falling

#

itll do extra damage to fit the highest damage done

#

in that case itll be 1.2 damage in total

stray spire
#

ok

abstract stratus
#

so my thoughts here

#

is to multiply the damage by twice (excluding the crit multiplier) in interval

stray spire
#

it aint working for me tho

abstract stratus
#

i think this might need an hour of work (for me at least) to get it work

#

since there are many instances lol

stray spire
#

wait

stray spire
#

this is cool

#
system.afterEvents.scriptEventReceive.subscribe(({id, sourceEntity, message}) => {
    if (id == "traye:cooldown") {
        function applyDamageWithDelay(entity, initialDamage, increment, iterations, delay) {
            function applyDamageStep(currentIteration) {
                if (currentIteration >= iterations) return;
        
                const damage = initialDamage + (currentIteration * increment);
                if (message) entity.applyDamage(damage, {cause:"entityAttack",damagingEntity:world.getPlayers({name:`${message}`})[0]});
                else entity.applyDamage(damage)
        
                system.runTimeout(() => {
                    applyDamageStep(currentIteration + 1);
                }, delay);
            }
        
            applyDamageStep(0);
        }
        
        applyDamageWithDelay(sourceEntity, 1, 0.0001, 100, 2);
    }
})```
abstract stratus
stray spire
abstract stratus
#

not yet

abstract stratus
#

imma start making this to work now

#

though im not sure how to properly get the damage done to the entity, because entityHitEntity and entityHurt hates each other when it comes to damage part

#

there could be some issues like the game not fetching the damage properly (such as quickly swapping from diamond swrod to fists, making fists do 8 damage)

abstract stratus
stray spire
#

nice

abstract stratus
#

you can make it pvp friendly by removing player on excludeType and if hitEntity & hurtEntity

#

never tested it but it could hit self too so beware