#Re: axe with ramping damage at lower health
13 messages · Page 1 of 1 (latest)
/**
*
* @param {Internal.AttackEntityEvent} event
* @returns
*/
global.playerattack = event => {
const { entity, entity: { mainHandItem } } = event;
// Check if the entity is a player
if (entity.getType() !== 'minecraft:player') return
// Check if the player is wielding a weapon
if (mainHandItem.id === 'kubejs:blood_hunter_axe') {
let healthRatio = entity?.health / entity?.maxHealth;
let damageIncrease = (1 - healthRatio) * 10 //Adjust this number to scale up as much as you need
entity.modifyAttribute('minecraft:generic.attack_damage', "-123924,5555,155221", `${damageIncrease}`, "addition");
}
};```
(code made by nʎdoᴉl) So this was the code, the issue I have seen with it in my testing is that it causes the game to crash when spam-attacking an enemy, and it doesnt seem to be linked to the weapon itself, as it seems to do this with any attack, and it also seems to be more frequent on lower end pc's as i have had multiple people help me test it out. Besides that the effect itself works perfectly, and when i check logs it seems to always bring up the first line of the code as a potential root cause.
i think we fixed this in the ticket right?
sec
is this the latest version of the script?
I remember there being one fix you did for it that caused it to crash after every 4th hit. This is indeed the latest last i checked, but ill double check to make sure.
dante said he made a syntax error and that this one apparently worked #1178756379381596190 message
thats what he said in vc anyways
ah, he just sent me a bit of the code and told me that it "should work" lol, so i may have been lacking all the details
let me try that one out
ah ok
alright, it worked lmao. Ill need to clown on Dante later, but thanks again for your help.
Ticket closed!