Jump to content

Make a bot pray at an altar?[new]


Tom1759

Recommended Posts

Hey, I'm new to scripting and just wondering how I would make my bot pray at an altar every x seconds. Thanks. (example please)

why every x seconds? why not do it at prayer %?

 

for the interaction:

RS2Object ALTER = closestObjectForName("Alter");

if(/*Condition you want to pray at*/){
if(ALTER != null){

alter.interact("Pray-at", true, true);
sleep(random(300, 900)):

}

}

i think (sorry if im wrong i am very tired and just woke up XD )

edit: id also add an animation/moving check but i wasnt sure if you'd be standing at time before praying

Edited by Isolate
Link to comment
Share on other sites

Guest Apogee

Add that in the script outside of onLoop() : 

final int[] ALTAR_IDS = { ALTARIDHERE#, #, #, # }; // add the ID's there.

onLoop() :  

Entity altar = closestObject(ALTAR_IDS); // The reason i didn't get by name is due to the fact that he might want multiple altars.


if (altar.isVisible()) {
	if (!client.getMyPlayer().isMoving()) {
               if (!client.getMyPlayer().isAnimating()) {
               altar.interact("Pray-at"); //not sure what the actual right click option is
               sleep(random(1250, 2250));
               }
        }
}

As the the at x second thing, you REALLY shouldn't use that. You'd have to use a Timer class, (i have one if you want it.) And it wouldn't be as.. accurate. 

 

It would be much more efficient if you made the script go to the altar at a certain amount of remaining prayer points.

You can go to the API section at the top to find what the check prayer points method is. I personally do not know it.

Edited by Bitter
Link to comment
Share on other sites

Add that in the script outside of onLoop() : 

final int[] ALTAR_IDS = { ALTARIDHERE#, #, #, # }; // add the ID's there.

onLoop() :  

Entity altar = closestObject(ALTAR_IDS); // The reason i didn't get by name is due to the fact that he might want multiple altars.


if (altar.isVisible()) {
	if (!client.getMyPlayer().isMoving()) {
               if (!client.getMyPlayer().isAnimating()) {
               altar.interact("Pray-at"); //not sure what the actual right click option is
               sleep(random(1250, 2250));
               }
        }
}

As the the at x second thing, you REALLY shouldn't use that. You'd have to use a Timer class, (i have one if you want it.) And it wouldn't be as.. accurate. 

 

It would be much more efficient if you made the script go to the altar at a certain amount of remaining prayer points.

You can go to the API section at the top to find what the check prayer points method is. I personally do not know it.

 

Why visiblity check? Interact method will auto rotate camera and thus if you visibility check you may not pray when needed and maybe die if in combat

 

Link to comment
Share on other sites

why every x seconds? why not do it at prayer %?

 

for the interaction:

RS2Object ALTER = closestObjectForName("Alter");

if(/*Condition you want to pray at*/){
if(ALTER != null){

alter.interact("Pray-at", true, true);
sleep(random(300, 900)):

}

}

i think (sorry if im wrong i am very tired and just woke up XD )

edit: id also add an animation/moving check but i wasnt sure if you'd be standing at time before praying

How would I do the condition? Like if I wanted it to be if prayer percent is under 50?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...