Looks very good to me for a first script
Quick question,isn't the script opening the door everytime it closes, even though it not required to have it open to reach other goblins?
You could change to logic to: (now only opens door when it has to attack a goblin which you can't reach)
Npc gob = getGoblin();
if(gob != nullç{
if(getmap().canReach(gob)){
//attack gob
}else{
getDoorhandler().handleNextobstacle(gob);
sleep(500,1000)
}
}
Someother things you can improve (Your code works fine aswell):
for(String actions: door.getDefinition().getActions()) {
if(actions.contains("Open")) {
}
}
Can be done by:
door.hasAction("Open");
Also check if the interaction was succeeded, don't just simply sleep after it without checking^^
goblin.interact("Attack");
sleep(random(100, 250));
AfterAttack();
Check if was succeeded.
if(goblin.interact("Attack")){
sleep(random(100, 250));
AfterAttack();
}else{
log("Failed attacking");
}
Kind regards
Khaleesi