Jump to content

I need help with my script


th3gos

Recommended Posts

I want to add in my script the option that when you reach a specific level in "Attack, force or defense" change the attack form to start uploading another melee skill
Ex: reach level 30 of attack and I want to change to the mode of "Block" so that it raises defense and later that it changes to "Stab" to raise force when it reaches certain levels.

Can you help me with that?

 

if (getSkills().getStatic(Skill.DEFENCE) < 30) {
        }
        else if (getSkills().getStatic(Skill.DEFENCE) >=30) {
            log ("Defence level es 30.");
                this.stop (false);
        }

I have this code but the only thing it can do is when it reaches level 30 of Defense it stops and I want it to change from Defense to Attack or Force ... to keep reaching melee levels.

Quote

@H0rn said: 
For your example you would do the following:
If you are using the defensive attack style and your attack is over the desired level, change the attack style to strength?

If I have already tried to think about that and I have searched the API for hours but I can not get anything.

Please help guys!

Edited by th3gos
Link to comment
Share on other sites

else if (getSkills().getStatic(Skill.DEFENCE) >=30) {
            log ("Defence level es 30.");
                this.stop (false);

If you have read the api under https://osbot.org/api/org/osbot/rs07/script/Script.html

The method stop(), will stop the script and will logout the accounts.

What you want to do is to change the style of attack if defence reaches a certain level. In order to change attack styles, you can either use config values or through widget ids.

Link to comment
Share on other sites

One way to do it is by widgets and configs.

Check if the config isn't the same as you want it to be (to stop a loop) && a check if its above 30 defence, then do some NPE checks for the widget, then interact.

 

 private int getdefLevel(){
        return api.getSkills().getStatic(Skill.DEFENCE);
    }
 private int defConfig = 2; //Not right config

        RS2Widget defence = api.getWidgets().get(1,1 ); //not the right widget ids, dont use this method btw, use filters
        if(getdefLevel() >= 30 && api.getConfigs().get(43) != defConfig){
            api.log("Defence is 30, attempting to switch attack styles");
            if(defence != null){
                if(defence.isVisible()){
                    if(defence.interact("change")){
                        api.log("Switched attack styles");
                    }
                }else{
                    if(api.getTabs().open(Tab.ATTACK)){
                        api.log("Successfully opened attack tab");
                    }
                }
            }
        }

That by no means will work at all, just remember the npe checks and to get widgets by filters (eg: text, actions etc.)

edit: Dont forget to check if the widget is visible, if not, youll have to open the tab first.

Edited by blogans
Link to comment
Share on other sites

On 22/3/2018 at 8:21 AM, Alek said:

You do know that if defence is not less than 30, that means its greater than or equal to 30? If you have specific weapons you are using, then the easiest would be to search for widgets with actions/messages with the nomenclature for "controlled", "defence", etc.

I do not understand you very well, I have to modify it to work ...

On 22/3/2018 at 8:11 AM, blogans said:

private int getdefLevel(){ return api.getSkills().getStatic(Skill.DEFENCE); } private int defConfig = 2; //Not right config RS2Widget defence = api.getWidgets().get(1,1 ); //not the right widget ids, dont use this method btw, use filters if(getdefLevel() >= 30 && api.getConfigs().get(43) != defConfig){ api.log("Defence is 30, attempting to switch attack styles"); if(defence != null){ if(defence.isVisible()){ if(defence.interact("change")){ api.log("Switched attack styles"); } }else{ if(api.getTabs().open(Tab.ATTACK)){ api.log("Successfully opened attack tab"); } } } }

The script is personal, I just want you to do what I said

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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