api-tutorials/Examples
At this point I will demonstrate the usage of my API by some examples.
I will use skeletons to demonstrate the possible behavior, but you can use any other mob (according to the compatibility table).
Movement
Stay around doing nothing
ControllableMob<Skeleton> controlledSkeleton = ControllableMobs.assign(skeleton, true); // this will make the skeleton controllable and remove the AI.
Move to the given location
ControllableMob<Skeleton> controlledSkeleton = ControllableMobs.assign(skeleton, true); controlledSkeleton.getActions().moveTo(new Location(myWorld, 60, 54, 78)); // the skeleton will immediately start to move to the location // afterwards, it will do nothing
Move to a given location and explore the area
ControllableMob<Skeleton> controlledSkeleton = ControllableMobs.assign(skeleton, true, new AIRandomStroll()); // add an AI behavior to automatically move around controlledSkeleton.getActions().moveTo(new Location(myWorld, 60, 4, 78)); // the skeleton will immediately start to move to the location, overriding the added AI behavior // afterwards, it will start to randomly move around (AI behavior comes into effect)
Attacking
Move to a given location, kill an entity and behave normal afterwards
ControllableMob<Skeleton> controlledSkeleton = ControllableMobs.assign(skeleton); controlledSkeleton.getActions().moveTo(new Location(myWorld, 60, 4, 78)); // the skeleton will immediately start to move to the location, overriding the normal AI behavior controlledSkeleton.getActions().target(skeletonsEnemy, true); // set the new target the skeleton will attack. Because "true" is specified as the second parameter, the action is queued and executed after the skeleton reached the previously specified location. // afterwards, it will behave like a normal skeleton again (we did not remove the default behavior in the .assing()-method)
Attack the 2 targets with a custom attack type
ControllableMob<Skeleton> controlledSkeleton = ControllableMobs.assign(skeleton, true, new AIAttackMelee()); // add a melee attack as an attack type (targets will be hunted and attacked at close range). controlledSkeleton.getActions().target(skeletonsEnemy1); // set the first target the skeleton will attack. controlledSkeleton.getActions().target(skeletonsEnemy2, true); // set the second target the skeleton will attack. Because "true" is specified as the second parameter, the action is queued and executed after the first target has been killed. // afterwards, the skeleton will do nothing
Now that you have seen some examples, learn what else beside the demonstrated behaviors are possible - by studying the API's javadoc!
plz write Examples of speed mobs