Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- usePortal: function (area, owner, unit) {
- var i, tick, portal,
- preArea = me.area;
- if (unit) {
- portal = unit;
- } else {
- portal = this.getPortal(area, owner);
- }
- if (!portal) {
- return false;
- }
- if (getDistance(me, portal) > 3) {
- this.moveToUnit(portal);
- }
- for (i = 0; i < 3; i += 1) {
- portal.interact();
- tick = getTickCount();
- while (getTickCount() - tick < 1000) {
- if (me.area !== preArea) {
- delay(750);
- return true;
- }
- delay(10);
- }
- }
- return false;
- },
- /*
- Without using blue portal check there's only 2 scenarios where the bot would take player's own blue portal to the area instead of a red one:
- - Secret Cow Level portal
- - Nihlathak's Temple
- However, I don't see a reason to go out with a blue portal and go back through a red one, so the check won't be added for now.
- */
- getPortal: function (area, owner) {
- var portal = getUnit(2, getLocaleString(3308)); // "Portal"
- if (!owner) {
- owner = me.name;
- }
- if (portal) {
- do {
- /* Portal is good in following cases:
- - if portal's area matches area argument OR there's no area argument specified (null)
- - there's no Parent (red portals) OR Parent matches owner argument
- - player is the Parent (own portal)
- - Parent is in player's party (someone else's portal)
- */
- if ((!area || portal.objtype === area) && ((owner === me.name || NTC_InMyParty(owner)) && portal.getParent() === owner || !portal.getParent())) { // TODO: Replace party check
- return copyUnit(portal);
- }
- } while (portal.getNext());
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement