mirror of
https://github.com/KAMKEEL/CustomNPC-Plus-API.git
synced 2026-11-16 14:14:48 +00:00
Added Scheduled Tasks system for NPC scripting.
Allows for scripting the scheduling of runnable methods in sequence within the NPC's AI An example sequence of tasks: 1. Dashes towards player (might take 3-5 seconds, doesn't matter, task durations are dynamic so it can take as long as it needs). 2. Punches player away 3. Waits 10 ticks - Fires a ki blast 4. Teleports behind player 5. Knocks player out
This commit is contained in:
1 parent
3cfe8be056
commit
e13c6762f3
3 files changed
+127
No files matched your search
@@ -0,0 +1,69 @@
|
||||
package noppes.npcs.api;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public interface IAction {
|
||||
|
||||
/**
|
||||
* @return number of times the function passed has been called upon
|
||||
*/
|
||||
int getCount();
|
||||
|
||||
/**
|
||||
* @return number of ticks since action starting
|
||||
*/
|
||||
int getDuration();
|
||||
|
||||
String getName();
|
||||
|
||||
int getMaxDuration();
|
||||
|
||||
/**
|
||||
* @param done set to true to end action
|
||||
*/
|
||||
void setDone(boolean done);
|
||||
|
||||
boolean isDone();
|
||||
|
||||
/**
|
||||
* Allows the storage of objects that might be needed within the action.
|
||||
* Equivalent to npc.getTempData().
|
||||
* All data deleted on action ending
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
void addData(String key, Object value);
|
||||
|
||||
Object getData(String key);
|
||||
|
||||
int getUpdateEveryXTick();
|
||||
|
||||
/**
|
||||
* @param X calls upon the function passed every X ticks
|
||||
*/
|
||||
void setUpdateEveryXTick(int X);
|
||||
|
||||
/**
|
||||
* @return number of ticks to elapse before starting action
|
||||
*/
|
||||
int getStartAfterTicks();
|
||||
|
||||
/**
|
||||
* Creates a new IAction. allows for instant daisy-chaining without having to go through npc.getActionManager() again
|
||||
*
|
||||
* @param name
|
||||
* @param maxDuration
|
||||
* @param startAfterTicks
|
||||
* @param action
|
||||
* @return
|
||||
*/
|
||||
IAction create(String name, int maxDuration, int startAfterTicks, Consumer<IAction> action);
|
||||
|
||||
/**
|
||||
* Schedules newAction right after this one, skipping the line of everything after
|
||||
*
|
||||
* @param newAction
|
||||
*/
|
||||
void scheduleAfter(IAction newAction);
|
||||
}
|
||||
Reference in new issue
Block a user