I need help getting Zulrah to loop through 9+ spawn locations in order. At the moment, it just spawns randomly between 3 different coordinates.
I don't mind the tedious process of messing with the coordinates until I get them right myself, but I just can't get it to cycle through each set of coordinates in order.
This is the array used to store the coordinates (found in Zulrah.java)
Code:
/**
* Zulrah's spawn locations
*/
private Location[] LOCATIONS = { new Location(2266, 3072, getOwner().getZ()), new Location(2276, 3074, getOwner().getZ()), new Location(2273, 3064, getOwner().getZ()) };
This is the method that handles spawning around the map (found in Zulrah.java)
I've pointed to the specific "teleport" method used to move Zulrah with a comment
The Utility.randomElement uses the "LOCATIONS" array mentioned above
Code:
/**
* Handles Zulrah moving around the map
**/
private void move() {
setCanAttack(false);
getOwner().setHitZulrah(false);
getOwner().getCombat().reset();
TaskQueue.queue(new Task(1) {
@Override
public void execute() {
getUpdateFlags().sendAnimation(new Animation(5072));
getOwner().send(new SendMessage("Zulrah dives into the swamp..."));
getUpdateFlags().isUpdateRequired();
stop();
}
@Override
public void onStop() {
}
});
TaskQueue.queue(new Task(3) {
@Override
public void execute() {
transform(getNextForm());
teleport(Utility.randomElement(LOCATIONS)); // ********* <---- I am struggling trying to get this method to loop through the coordinates instead of using Utility.randomElement()
getUpdateFlags().isUpdateRequired();
getUpdateFlags().sendAnimation(new Animation(5071));
getUpdateFlags().faceEntity(getOwner().getIndex());
getUpdateFlags().isUpdateRequired();
stop();
}
@Override
public void onStop() {
getCombat().setAttack(getOwner());
setCanAttack(true);
getOwner().setHitZulrah(true);
}
});
}
This is the teleport method that's called from Mob.java
Code:
/**
* Teleports the mob to a new location
*
* @param p
* The location to teleport the mob too
*/
public void teleport(Location p) {
Walking.setNpcOnTile(this, false);
getMovementHandler().getLastLocation().setAs(new Location(p.getX(), p.getY() + 1));
getLocation().setAs(p);
Walking.setNpcOnTile(this, true);
placement = true;
getMovementHandler().resetMoveDirections();
}
This is less important than getting the spawns locations to cycle, but I was also wondering if there's a similar way to loop through specific attack styles in order "e.g. Spawn 1 is range zulrah, Spawn 2 is melee, Spawn 3 is mage, etc."
This is the method used to set Zulrah's attack style (found in Zulrah.java)
Code:
private int getNextForm() {
List<Integer> possible = new ArrayList<>();
possible.addAll(Arrays.asList(2042, 2043, 2044));
possible.remove(Integer.valueOf(getId()));
return Utility.randomElement(possible); // <-- This part returns a random attack style
}
2042 = Green Zulrah
2043 = Red Zulrah
2044 = Blue Zulrah
I really don't care about having it change between 4 different rotations like it does in OSRS or even having it restart the same rotation. I don't mind restarting the fight each time or editing the code to create a new rotation; this is really just for personal use.
However this might be helpful for anyone trying to customize Zulrah rotations for his/her server.
I'm pretty embarrassed to admit that I've been struggling with this for hours, so I'd really appreciate any help you guys could give me.
Thanks in advance!