mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 01:05:12 +00:00
Counter, Dodge, Guard Abilities
This commit is contained in:
1 parent
fc71fb5a33
commit
b49316d9bb
7 files changed
+99
-4
No files matched your search
@@ -6,6 +6,9 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import kamkeel.npcs.addon.DBCAddon;
|
||||
import kamkeel.npcs.controllers.data.ability.type.AbilityCounter;
|
||||
import kamkeel.npcs.controllers.data.ability.type.AbilityDefend;
|
||||
import kamkeel.npcs.controllers.data.ability.type.AbilityDodge;
|
||||
import kamkeel.npcs.addon.client.DBCClient;
|
||||
import kamkeel.npcs.network.PacketHandler;
|
||||
import kamkeel.npcs.network.enums.EnumSoundOperation;
|
||||
@@ -709,6 +712,21 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
// Resistances
|
||||
i = stats.resistances.applyResistance(damagesource, i);
|
||||
|
||||
// Defend abilities
|
||||
AbilityDefend defend = this.abilities != null ? this.abilities.getActiveDefend() : null;
|
||||
if (defend != null) {
|
||||
// Dodge & Counter: cancel attack entirely
|
||||
if (defend instanceof AbilityDodge || defend instanceof AbilityCounter) {
|
||||
float result = defend.onDefend(attackingEntity, damagesource, i);
|
||||
if (result != i) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// Guard: reduce damage
|
||||
i = defend.onDefend(attackingEntity, damagesource, i);
|
||||
}
|
||||
}
|
||||
|
||||
NpcEvent.DamagedEvent event = new NpcEvent.DamagedEvent(this.wrappedNPC, attackingEntity, i, damagesource);
|
||||
if (EventHooks.onNPCDamaged(this, event) || isKilled())
|
||||
return false;
|
||||
|
||||
Reference in new issue
Block a user