Post by Darth Maul on Aug 24, 2017 10:34:44 GMT
This was originally posted by me on the noxiousot forum, several years ago. The original thread can be found here: www.noxiousot.com/index.php?subtopic=forum&action=show_thread&id=15490
The original question that was asked was..
Problem:
Basically I want to use SD if there are no monsters 3sqm (avalanche distance) around my current target and use Avalanche if there is 2 or more monster 3sqm around my current target. Also, I dont want it to use an avalanche if there is a "Human Player" 5sqm around my current target.
In-depth response:
An avalanche rune will look something like this after throwing it on your target.
Now let's break down the script I gave you.
auto 100 | dontlist | foreach 'floorplayers' $p {if [$p.posx >= ($target.posx-3) && $p.posx <= ($target.posx+3) && $p.posy >= ($target.posy-3) && $p.posy <= ($target.posy+3)] {set $canava 'false'} | else {set $canava 'true'}
auto 100 - Makes the bot use the script every .1 second. [1000 == 1second]
dontlist - unlist the script from your HUD. Alternatively you could use listas 'NAME' if you wanted to see it displayed in your HUD.
foreach 'floorplayers' $p - It loops through all the players that's on your screen.
This is usually followed by 'if' statements to check something about the players. If they match the if statement usually an action takes place.
The foreach command allows you to search through these: (allcreatures, allplayers, allmonsters, floorcreatures, floorplayers, floormonsters, screencreatures, screenplayers, screenmonsters, shootablecreatures, shootableplayers, shootablemonsters).
The script I gave you has 4 if statements. These statements check around your current target to see if a player is within it's "borders".
The statements are as followed:
1 - $p.posx >= [$target.posx - 3]
2 - $p.posx <= [$target.posx + 3]
3 - $p.posy >= [$target.posy - 3]
4 - $p.posy <= [$target.posy + 3]
$p - $p refers to the player. The player is identified through it's server ID.
$target - $target refers to your current target. Just like the players, the target is identified through it's server ID.
.posx or .posy - These refer to the players X position, and the players Y position in-game.
These statements are all contained within the one 'if' to reduce the scripts length and neaten the script up. This is usually done by linking them with '&&'.
The image below shows how these statements work in accordance to the monster.
In essence, the script is taking the monsters position and either adding, or taking away, 3 tiles from it. Through 'if' statements we check all four sides, this then gives you the range in-which a player cannot be located in.
If a player is found within this range we set a variable to false, in this case we use the variable "$canava". If no player is found, we set it to true.
{set $canava 'false'} | else {set $canava 'true'}
By itself, setting this variable to false, or true, does nothing. This would then need to be followed up by a second script which checks what state this variable is in and attacks accordingly.
Something like this:
auto 100 | dontlist | if [$canava == 'true'] {useoncreature 3161 target} | else {sd target}
Solution:
Step one: Checking whether a player is within range.
Step two: Checking whether a monster is within range.
Step three: Changing your attack mode.
Step four: Attack.
The three steps would look something like this:
Step one: (Checking if a player is within range.)
Step Two: (Checking whether another monster is within range.)
Step three: (Changing your attack mode.)
Step four: (Attack.)
Paste the first 3 steps into your persistent hotkeys, and use the fourth step as your actual attacking hotkey/shortkey.
How to paste into your persistent hotkeys.
The original question that was asked was..
Problem:
Basically I want to use SD if there are no monsters 3sqm (avalanche distance) around my current target and use Avalanche if there is 2 or more monster 3sqm around my current target. Also, I dont want it to use an avalanche if there is a "Human Player" 5sqm around my current target.
In-depth response:
- Imagine you are standing on the blue star and
- Your current target is standing on the red star.
- From the blue star, these are all the squares that are in your view.
- The yellow tiles are the tiles you want your bot to start targeting monsters from, so that you're able to see all around your target.
- The gray tiles are still in your view, however you don't want to target any monster on those tiles.
An avalanche rune will look something like this after throwing it on your target.
Now let's break down the script I gave you.
auto 100 | dontlist | foreach 'floorplayers' $p {if [$p.posx >= ($target.posx-3) && $p.posx <= ($target.posx+3) && $p.posy >= ($target.posy-3) && $p.posy <= ($target.posy+3)] {set $canava 'false'} | else {set $canava 'true'}
auto 100 - Makes the bot use the script every .1 second. [1000 == 1second]
dontlist - unlist the script from your HUD. Alternatively you could use listas 'NAME' if you wanted to see it displayed in your HUD.
foreach 'floorplayers' $p - It loops through all the players that's on your screen.
This is usually followed by 'if' statements to check something about the players. If they match the if statement usually an action takes place.
The foreach command allows you to search through these: (allcreatures, allplayers, allmonsters, floorcreatures, floorplayers, floormonsters, screencreatures, screenplayers, screenmonsters, shootablecreatures, shootableplayers, shootablemonsters).
The script I gave you has 4 if statements. These statements check around your current target to see if a player is within it's "borders".
The statements are as followed:
1 - $p.posx >= [$target.posx - 3]
2 - $p.posx <= [$target.posx + 3]
3 - $p.posy >= [$target.posy - 3]
4 - $p.posy <= [$target.posy + 3]
$p - $p refers to the player. The player is identified through it's server ID.
$target - $target refers to your current target. Just like the players, the target is identified through it's server ID.
.posx or .posy - These refer to the players X position, and the players Y position in-game.
These statements are all contained within the one 'if' to reduce the scripts length and neaten the script up. This is usually done by linking them with '&&'.
The image below shows how these statements work in accordance to the monster.
In essence, the script is taking the monsters position and either adding, or taking away, 3 tiles from it. Through 'if' statements we check all four sides, this then gives you the range in-which a player cannot be located in.
If a player is found within this range we set a variable to false, in this case we use the variable "$canava". If no player is found, we set it to true.
{set $canava 'false'} | else {set $canava 'true'}
By itself, setting this variable to false, or true, does nothing. This would then need to be followed up by a second script which checks what state this variable is in and attacks accordingly.
Something like this:
auto 100 | dontlist | if [$canava == 'true'] {useoncreature 3161 target} | else {sd target}
Solution:
Step one: Checking whether a player is within range.
Step two: Checking whether a monster is within range.
Step three: Changing your attack mode.
Step four: Attack.
The three steps would look something like this:
Step one: (Checking if a player is within range.)
auto 100 | dontlist | foreach 'floorplayers' $p {if [$p.posx >= ($target.posx-3) && $p.posx <= ($target.posx+3) && $p.posy >= ($target.posy-3) && $p.posy <= ($target.posy+3)] if [$playersaround.9 >= '1'] {set $noplayer '0'}
auto 100 | dontlist | foreach 'floorplayers' $p {ifnot [$p.posx >= ($target.posx-3) && $p.posx <= ($target.posx+3) && $p.posy >= ($target.posy-3) && $p.posy <= ($target.posy+3)] {set $noplayer '1'}
Step Two: (Checking whether another monster is within range.)
auto 100 | dontlist | foreach 'floorcreatures' $m {if [$m.posx >= ($target.posx-3) && $m.posx <= ($target.posx+3) && $m.posy >= ($target.posy-3) && $m.posy <= ($target.posy+3)] if [$monstersaround.9 >= '2'] {set $monstercount '1'}
auto 100 | dontlist | foreach 'floorcreatures' $m {ifnot [$m.posx >= ($target.posx-3) && $m.posx <= ($target.posx+3) && $m.posy >= ($target.posy-3) && $m.posy <= ($target.posy+3)] {set $monstercount '0'}
Step three: (Changing your attack mode.)
auto 100 | dontlist | if [$noplayer == '1' && $monstercount == '1'] {set $attacktype 'ava'} | else {set $attacktype 'sd'}
Step four: (Attack.)
auto 200 | listas 'Avalanche or SD' | if [$attacktype == 'ava'] {useoncreature 3161 target | wait 700 | end} | else {useoncreature 3155 target | wait 700 | end}
Paste the first 3 steps into your persistent hotkeys, and use the fourth step as your actual attacking hotkey/shortkey.
How to paste into your persistent hotkeys.