Carpet

Carpet

2M Downloads

A way to create and send custom damage events

James103 opened this issue ยท 3 comments

commented

Currently (Carpet Mod 1.3.19 and 1.3.20 in MC 1.15.2), even though you can directly set a player's health, you are unable to specify a damage source type and entity, both of which default to null. A new function modify(e, 'damage', amount, source, source_entity) should be added that allows dealing arbitrary amounts of damage from a given source and source entity to the target entity. Alternatively, two extra optional parameters can be added to the modify(e, 'health') function to specify a damage source and source entity. Either way, this damage would be processed as if it was a real damage event, so armor, effects, etc are taken into account.

Example: Being in hot biomes deals fire damage (modify(p, 'damage', 1, 'inFire', null)), jumping deals fall damage (modify(p, 'damage', 1, 'fall', null)), being in water deals drowning damage (modify(p, 'damage', 1, 'drown', null)), and/or a way to make pigs attack you (modify(p, 'damage', 1, 'mob', pig); inventory_remove(p, 'carrot', 1)).

Assuming this allows specifying and sending non-vanilla damage sources, this plus the damage event handler could be used to create custom damage sources that range from "a direct health loss" to "you lose XP, items, or food instead of HP" or even "knockback-only damage, no HP loss".

commented

Firstly, are you still working on this?

Secondly, if a player is killed by a custom damage source, the death message for translation purposes would be death.attack.<source> if source_entity is null, or death.attack.<source>.player if source_entity is a valid entity. %1$s would be the target entity and %2$s would be the source entity. Is that correct?

commented

damage has been on my mind for a while. Will do at some point

commented

Moved to #649