Skip to content

Instantly share code, notes, and snippets.

@kindlich
Created October 19, 2018 22:41
Show Gist options
  • Save kindlich/0e19f18155ea0805ac0563c18b66b800 to your computer and use it in GitHub Desktop.
Save kindlich/0e19f18155ea0805ac0563c18b66b800 to your computer and use it in GitHub Desktop.
import mods.compatskills.TraitCreator;
static attackingPlayers as string[string] = {};
val myTrait = TraitCreator.createTrait("moreDamage", 4, 3, "reskillable:attack", 5, "reskillable:attack|3");
myTrait.onAttackMob = function(event as crafttweaker.event.EntityLivingHurtEvent) {
if(!event.entity.world.remote)
if(!didAlreadyAttack(event.damageSource.trueSource.displayName, event.entity.world.time)){
var player as crafttweaker.player.IPlayer = event.damageSource.trueSource;
event.entity.attackEntityFrom(createPlayerDamage(player), 3.0f);
}
};
myTrait.name = format.red("Packing a " + format.strikethrough("real") + " punch!");
function didAlreadyAttack(name as string, time as string) as bool {
val res = attackingPlayers[name];
val result = isNull(res) ? false : res == time;
attackingPlayers[name] = time;
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment