diff --git a/java/noppes/npcs/api/AbstractNpcAPI.java b/java/noppes/npcs/api/AbstractNpcAPI.java index b6d568b..f07dd98 100644 --- a/java/noppes/npcs/api/AbstractNpcAPI.java +++ b/java/noppes/npcs/api/AbstractNpcAPI.java @@ -16,6 +16,7 @@ import noppes.npcs.api.entity.ICustomNpc; import noppes.npcs.api.entity.IEntity; import noppes.npcs.api.entity.IPlayer; import noppes.npcs.api.gui.ICustomGui; +import noppes.npcs.api.handler.IAbilityHandler; import noppes.npcs.api.handler.IActionManager; import noppes.npcs.api.handler.IAnimationHandler; import noppes.npcs.api.handler.IAttributeHandler; @@ -173,6 +174,8 @@ public abstract class AbstractNpcAPI { */ public abstract IScriptHookHandler getScriptHooks(); + public abstract IAbilityHandler getAbilities(); + public abstract String[] getAllBiomeNames(); public abstract ICustomNpc createNPC(IWorld var1); diff --git a/java/noppes/npcs/api/ability/IAbility.java b/java/noppes/npcs/api/ability/IAbility.java new file mode 100644 index 0000000..9d9ac16 --- /dev/null +++ b/java/noppes/npcs/api/ability/IAbility.java @@ -0,0 +1,156 @@ +package noppes.npcs.api.ability; + +import noppes.npcs.api.INbt; + +/** + * Interface for NPC abilities. + * Abilities are special attacks or actions that NPCs can perform during combat. + */ +public interface IAbility { + + /** + * Get the unique ID of this ability instance. + */ + String getId(); + + /** + * Set the unique ID of this ability instance. + */ + void setId(String id); + + /** + * Get the display name of this ability. + */ + String getName(); + + /** + * Set the display name of this ability. + */ + void setName(String name); + + /** + * Get the type ID of this ability (e.g., "cnpc:slam", "cnpc:beam"). + */ + String getTypeId(); + + /** + * Check if this ability is enabled. + */ + boolean isEnabled(); + + /** + * Enable or disable this ability. + */ + void setEnabled(boolean enabled); + + /** + * Get the selection weight for random ability selection. + * Higher weight = more likely to be selected. + */ + int getWeight(); + + /** + * Set the selection weight. + */ + void setWeight(int weight); + + /** + * Get the minimum range at which this ability can be used. + */ + float getMinRange(); + + /** + * Set the minimum range. + */ + void setMinRange(float range); + + /** + * Get the maximum range at which this ability can be used. + */ + float getMaxRange(); + + /** + * Set the maximum range. + */ + void setMaxRange(float range); + + /** + * Get the cooldown time in ticks. + */ + int getCooldownTicks(); + + /** + * Set the cooldown time in ticks. + */ + void setCooldownTicks(int ticks); + + /** + * Get the wind-up time in ticks (telegraph phase). + */ + int getWindUpTicks(); + + /** + * Set the wind-up time in ticks. + */ + void setWindUpTicks(int ticks); + + /** + * Get the active duration in ticks. + */ + int getActiveTicks(); + + /** + * Set the active duration in ticks. + */ + void setActiveTicks(int ticks); + + /** + * Get the recovery time in ticks. + */ + int getRecoveryTicks(); + + /** + * Set the recovery time in ticks. + */ + void setRecoveryTicks(int ticks); + + /** + * Check if this ability can be interrupted by damage. + */ + boolean isInterruptible(); + + /** + * Set whether this ability can be interrupted. + */ + void setInterruptible(boolean interruptible); + + /** + * Check if this ability is currently being executed. + */ + boolean isExecuting(); + + /** + * Check if this ability is on cooldown. + */ + boolean isOnCooldown(); + + /** + * Get the current execution phase (0=IDLE, 1=WINDUP, 2=ACTIVE, 3=RECOVERY). + */ + int getPhaseInt(); + + /** + * Get the current tick within the current phase. + */ + int getCurrentTick(); + + /** + * Get this ability's data as NBT. + */ + INbt getNbt(); + + /** + * Set this ability's data from NBT. + */ + void setNbt(INbt nbt); +} diff --git a/java/noppes/npcs/api/ability/IAbilityHandler.java b/java/noppes/npcs/api/ability/IAbilityHandler.java new file mode 100644 index 0000000..56cf621 --- /dev/null +++ b/java/noppes/npcs/api/ability/IAbilityHandler.java @@ -0,0 +1,33 @@ +package noppes.npcs.api.ability; + +/** + * Handler for ability registration and creation. + * Use this to register custom ability types from external mods. + */ +public interface IAbilityHandler { + + /** + * Register a custom ability type. + * Call during FMLInitializationEvent. + * + * @param typeId The unique type ID (e.g., "mymod:custom_ability") + * @param abilityClass The class that implements the ability + */ + void registerType(String typeId, Class abilityClass); + + /** + * Check if an ability type is registered. + */ + boolean hasType(String typeId); + + /** + * Get all registered ability type IDs. + */ + String[] getTypes(); + + /** + * Create a new ability of the given type. + * Returns null if the type is not registered. + */ + IAbility create(String typeId); +} diff --git a/java/noppes/npcs/api/ability/IDataAbilities.java b/java/noppes/npcs/api/ability/IDataAbilities.java new file mode 100644 index 0000000..ff117b4 --- /dev/null +++ b/java/noppes/npcs/api/ability/IDataAbilities.java @@ -0,0 +1,78 @@ +package noppes.npcs.api.ability; + +/** + * Interface for an NPC's ability data manager. + * Provides access to the NPC's abilities and execution state. + */ +public interface IDataAbilities { + + /** + * Check if the ability system is enabled for this NPC. + */ + boolean isEnabled(); + + /** + * Enable or disable the ability system for this NPC. + */ + void setEnabled(boolean enabled); + + /** + * Get all abilities assigned to this NPC. + */ + IAbility[] getAbilities(); + + /** + * Add an ability to this NPC. + */ + void addAbility(IAbility ability); + + /** + * Remove an ability by ID. + */ + void removeAbility(String abilityId); + + /** + * Get an ability by ID. + */ + IAbility getAbility(String abilityId); + + /** + * Check if the NPC has an ability with the given ID. + */ + boolean hasAbility(String abilityId); + + /** + * Clear all abilities from this NPC. + */ + void clearAbilities(); + + /** + * Get the currently executing ability, or null if none. + */ + IAbility getCurrentAbility(); + + /** + * Check if any ability is currently executing. + */ + boolean isExecutingAbility(); + + /** + * Interrupt the current ability if one is executing. + */ + void interruptCurrentAbility(); + + /** + * Get the global cooldown timer in ticks. + */ + int getGlobalCooldown(); + + /** + * Set the global cooldown timer in ticks. + */ + void setGlobalCooldown(int ticks); + + /** + * Reset all ability cooldowns. + */ + void resetCooldowns(); +} diff --git a/java/noppes/npcs/api/event/IAbilityEvent.java b/java/noppes/npcs/api/event/IAbilityEvent.java new file mode 100644 index 0000000..57ab8e2 --- /dev/null +++ b/java/noppes/npcs/api/event/IAbilityEvent.java @@ -0,0 +1,120 @@ +package noppes.npcs.api.event; + +import cpw.mods.fml.common.eventhandler.Cancelable; +import noppes.npcs.api.IDamageSource; +import noppes.npcs.api.ability.IAbility; +import noppes.npcs.api.entity.ICustomNpc; +import noppes.npcs.api.entity.IEntityLivingBase; + +/** + * Events related to NPC ability execution. + * These events are fired during the ability lifecycle. + */ +public interface IAbilityEvent extends INpcEvent { + + /** + * Get the ability involved in this event. + */ + IAbility getAbility(); + + /** + * Get the target of the ability, or null if no target. + */ + IEntityLivingBase getTarget(); + + /** + * Fired when an ability starts executing (enters WINDUP phase). + * Canceling prevents the ability from starting. + */ + @Cancelable + interface StartEvent extends IAbilityEvent { + } + + /** + * Fired when an ability enters the ACTIVE phase and performs its effect. + * Canceling prevents the ability effect from occurring. + */ + @Cancelable + interface ExecuteEvent extends IAbilityEvent { + } + + /** + * Fired when an ability is interrupted by damage. + */ + interface InterruptEvent extends IAbilityEvent { + /** + * Get the damage source that caused the interruption. + */ + IDamageSource getDamageSource(); + + /** + * Get the amount of damage that caused the interruption. + */ + float getDamage(); + } + + /** + * Fired when an ability completes its full execution cycle. + */ + interface CompleteEvent extends IAbilityEvent { + } + + /** + * Fired when an ability hits an entity with damage. + * Canceling this event prevents the damage from being applied. + */ + @Cancelable + interface HitEvent extends IAbilityEvent { + /** + * Get the entity that was hit by the ability. + */ + IEntityLivingBase getHitEntity(); + + /** + * Get the damage amount. + */ + float getDamage(); + + /** + * Set the damage amount. Allows scripts to modify damage. + */ + void setDamage(float damage); + + /** + * Get the horizontal knockback amount. + */ + float getKnockback(); + + /** + * Set the horizontal knockback amount. + */ + void setKnockback(float knockback); + + /** + * Get the vertical knockback (upward force) amount. + */ + float getKnockbackUp(); + + /** + * Set the vertical knockback (upward force) amount. + */ + void setKnockbackUp(float knockbackUp); + } + + /** + * Fired every tick while an ability is executing. + * Provides the current phase and tick count. + */ + interface TickEvent extends IAbilityEvent { + /** + * Get the current phase of the ability. + * 0 = IDLE, 1 = WINDUP, 2 = ACTIVE, 3 = RECOVERY + */ + int getAbilityPhase(); + + /** + * Get the current tick count within the phase. + */ + int getTick(); + } +} diff --git a/java/noppes/npcs/api/handler/IAbilityHandler.java b/java/noppes/npcs/api/handler/IAbilityHandler.java new file mode 100644 index 0000000..fc873c2 --- /dev/null +++ b/java/noppes/npcs/api/handler/IAbilityHandler.java @@ -0,0 +1,49 @@ +package noppes.npcs.api.handler; + +/** + * Handler for ability presets. Allows scripts to save, load, and manage + * reusable ability templates. + * + * Access via API.getAbilities() + */ +public interface IAbilityHandler { + + /** + * Get all registered ability type IDs. + * These are the types that can be used to create new abilities. + * + * @return Array of type IDs (e.g., "cnpc:slam", "cnpc:charge") + */ + String[] getTypes(); + + /** + * Check if an ability type is registered. + * + * @param typeId The type ID to check + * @return true if the type exists + */ + boolean hasType(String typeId); + + /** + * Get all saved ability preset names. + * + * @return Array of saved ability names + */ + String[] getSavedNames(); + + /** + * Check if a saved ability preset exists. + * + * @param name The name of the ability + * @return true if the preset exists + */ + boolean has(String name); + + /** + * Delete a saved ability preset. + * + * @param name The name of the ability to delete + * @return true if deleted successfully + */ + boolean delete(String name); +}