Log in

View Full Version : Act only if 2 conditions are true & act only once whenever a condition is true



weeper
05-07-2007, 10:01
After reading this tutorial you will be able to make conditional events with the following characteristics:
Make something happen only if 2 conditions are true.
Make something happen only once when a condition is true and only can happen again after the condition becomes false and true again.
Combination of both

Events that require 2 conditions to be true.

The following example will make a ding ONLY if the last msg is "hi" and was sent by "John"


1
#number=#
1
0
300
0
exiva _var = 0
$lastsender$
#string=#
John
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$lastmsg$
#string=#
hi
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
300
0
exiva testding


Basically we set 4 conditional events here.
1. This event is always true (1=1). This one sets the custom variable $_var$ to "0".
2. This is actually the first condition that triggers our action. If the variable $lastsender$ returns "John" it will add +1 to our custom variable $_var$.
3. This is our second condition for the action to get done. If the variable $lastmsg$ returns "hi" it will add +1 to our custom variable $_var$.
4. This final event checks the current value of our custom variable called $_var$. If the value is "2" (both conditions were true, so each one added +1 to the variable) then it executes the action we want to get done. Which in this case is to make a ding using exiva testding.

Note: In this one as long as the 2 conditions keep being true it will spam dings. Later on this post I will explain how to avoid this.

Events that only are true once and can only be true again after they became false

The following example will ding ONLY ONCE whenever you get a message saying "hi". It can only ding again if you get a message different than "hi" and then "hi" again.



$lastmsg$
#string<>#
hi
0
300
0
exiva _variable = 0
$lastmsg$
#string=#
hi
0
500
0
exiva _variable = $numericalexp:{$_variable$}+1$
$_variable$
#number=#
1
0
300
0
exiva testding
$_variable$
#number>=#
500
0
300
0
exiva _variable = 2



We set four conditional events here too, but actually the last one is not totally necessary.
1. If the variable $lastmsg$ is something DIFFERENT than "hi" then it will set our custom variable "$_variable$" to "0".
2. If the variable $lastmsg$ is the same as "hi". It will add +1 to a custom variable called $_variable$.
3. If our custom variable is equal to 1. Then it will ding.
4. This is not actually necessary but if the variable $lastmsg$ keeps being "hi". The count can go very high so to avoid this, we set this event that checks if the custom variable called $_variable$ has reached 500. If so, it will make it go back to 2. I chose 2 because it must be a number that's after the one that we set to make the action (in this case 1) so the condition number 3 keeps being false.

Combination of both types of events.

Now that you know how to make this 2 types of events. You may have already figured out by yourself how to combine them.

The following example combined the 2 types we have seen.


$lastsender$
#string<>#
John
0
300
0
exiva _var = 0
$lastmsg$
#string<>#
hi
0
300
0
exiva _var = 0
$lastsender$
#string=#
John
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$lastmsg$
#string=#
hi
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
300
0
exiva testding
$_var$
#number>=#
500
0
300
0
exiva _var = 3



1. If the variable $lastsender$ returns something different than "John" then it will set custom variable $_var$ to 0.
2. If the variable $lastmsg$ returns something different than "hi" then it will set custom variable $_var$ to 0.
3. If variable $lastsender$ returns "John" it will add +1 to custom variable $_var$.
4. If variable $lastmsg$ returns "hi" it will add +1 to custom variable $_var$.
5. If custom variable $_var$ is equal to 2, then it will ding using "exiva testding"
6. If custom variable went too high (500) because both conditions kept being true for a long time, then it will reset it back to 3. (Must be a number above 2 so that condition number 5 keeps being false.)

I hope that with this little tutorial you are able to make more complex conditional events that suit your needs.

EDIT: 30 views and no comment? I would like to state that feedback is greatly appreciated.

Fanaticuser
05-08-2007, 00:03
extremely useful for me ty!!!


one question what do i have to do then if i want to use the spell exura gran when i have 150 hp or less and also 40 or more mana and if i have less than 40 mana when i have 150hp or less to drink a mana fluid

weeper
05-08-2007, 07:25
I would use the Runemaker for the mana fluid's and the cheats section for healing. It's way easier.

Goodfellow
05-08-2007, 08:35
yeeee....now I want fucking 2 variables:

1. $playeronscreen:name$ < that would check if player with certain name is in battle list. Just think, you could do auto sd combo on him or auto shoot paralyze as soon as this is possible

2. Possibility of shooting paralyze rune on target with exiva(trust me, that's really useful)

weeper
05-08-2007, 18:37
You don't need to have 2 conditions to be true for this, neither you need them to have them done just once. so maybe your post belongs to the variable proposal thread.

Goodfellow
05-12-2007, 22:38
I wanted to make an event which change SSA non-stop after my mana is below 200 and amulet slot is empty. It doesn't work because it's changing amulet even if there is an aol in the slot. Can you tell me what's wrong with that?

1
#number=#
1
0
300
0
exiva _var = 0
$mymana$
#number<=#
200
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$hex-equiped-item:02$
#number=#
0
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
300
0
exiva #09 0C 02

weeper
05-13-2007, 22:48
1
#number=#
1
0
300
0
exiva _var = 0
$mymana$
#number<=#
200
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$hex-equiped-item:02$
#string=#
00 00
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
300
0
exiva #09 0C 02


Try this one.

Goodfellow
05-14-2007, 09:52
Thanks ! It's working. I find this script very interesting during battles (for sorcerers, If my mana below 1k and amulet slot empty put SSA)

This one would rox for paladins: (change ssa if hp drops under 60% and no amulet in slot)


1
#number=#
1
0
300
0
exiva _var = 0
$myhppercent$
#number<=#
60
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$hex-equiped-item:02$
#string=#
00 00
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
300
0
exiva #09 0C 02

weeper
05-14-2007, 10:04
Yes it is, enjoy!
There are lots of uses for this kind of cond. events.
Any other feedback? Has anybody used it?

sequelado
07-13-2007, 13:00
hello weeper
can u check my thread on script requests about a cond, even that give u an alarm when trapped
=]


ty!

Jack
07-13-2007, 13:56
hello weeper
can u check my thread on script requests about a cond, even that give u an alarm when trapped
=]


ty!

theirs a feature in the cavebot called "OnTrapGiveAlarm" just use that in ur script

Fintarn
07-18-2007, 07:01
How about puttin a life ring up when you got a certain amount of hp/mana and taking of when you've got a certain amount of hp/mana? I tried doing one pretty quick, but it ended up switching rings as I had more than one life ring in the bp, and that wastes the mins like a mafaka. Anyway so, I'm going to read that tutorial tomorrow and try to do one myself. I'm too tired now >;p But anyway I'd appriciate if you made one aswell :)

Ninus
07-20-2007, 17:31
I've made a paralize cond, that uses exura only if I have 25 mana or more, thanks to this guide. This way I don't puff alot when I'm paralized and have no mana, which slows moving speed by alot.

Thanks

Meryn
09-26-2007, 15:29
Is it possible to set an alarm if a player pops-up in your vip list? or even better, logg out if the players pops-up in vip? If so, HOW? :D

jugglypiff
10-28-2007, 10:04
Hi, I find these conditions very interesting. But I have a problem with a situation which I am trying to adapt this to:

What I want is a script that puts on a life ring whenever my hp is below 90% of my maximum, and when it's above 95% of my maximum it will put on a crystal ring.

Now the problem is, I have this script already, but what it does, is constantly change the life ring whenever my hp if below 90%, so is cycles through all my life rings, causing lags and waste of packets. This is where the "only once" condition would be nice.

HOWEVER; When I try to use this condition with it, it puts on the life ring when it goes below 90%hp, but if the life ring ends before the hp gets above 95%, then the script will NEVER put on a new life ring, since the condition won't get false and true again.

Can you guys think of a solution to this?
Maybe a condition like "if ring slot is empty => equip lifering" or something would fix it. But I dont know how to do that.

Cheers, Jigglypuff

weeper
10-28-2007, 20:14
I suggest to use the first one "Act only if 2 conditions are true" instead of using the "act only once".

Make your first condition be: $myhppercent$ < 90

and second condition to be: $hex-equiped-item:09$ String<> (life ring ID)

That way it will ONLY equip the life ring, if your hp is < 90% AND you have something in your ring slot that is NOT a life ring.

Farsa
10-29-2007, 03:45
i think this will fit jugglypiff's request

$myhppercent$
#number>=#
95
0
0
0
exiva _hp = 3
$hex-equiped-item:09$
#string=#
ID OF LIFE RING WHEN EQUIPED
0
0
0
exiva _hp = $numericalexp:{$_hp$}+1$
$_hp$
#number>=#
4
0
0
0
exiva #BF 0B 09
$myhppercent$
#number<#
90
0
0
0
exiva _hp = 2
$hex-equiped-item:09$
#string=#
BF 0B
0
0
0
exiva _hp = $numericalexp:{$_hp$}-1$
$_hp$
#number<=#
1
0
0
0
exiva #EC 0B 09
$hex-equiped-item:09$
#string=#
00 00
0
0
0
exiva #BF 0B 09

jakoeb
11-03-2007, 11:31
If I D/L a cond event where should I put the .txt file?

weeper
11-03-2007, 21:34
In the "conds" folder that is inside the bot's folder.
Default is c:/program files/blackd tools/blackd proxy/conds

Oxm
11-04-2007, 09:49
Hello. I want only one take off exura from message alarm.

Oxm
11-04-2007, 13:00
It is good script to conditional events to take off exura from message alarm ???? :


$lastmsg$
#string<>#
exura
0
300
0
exiva _variable = 0
$lastmsg$
#string=#
exura
0
500
0
exiva _variable = $numericalexp:{$_variable$}+1$
$_variable$
#number=#
1
0
300
0
exiva _variable = 0
$_variable$
#number>=#
500
0
300
0
exiva _variable = 2

educorgozinho
04-27-2008, 21:53
Combination of both types of events.

Now that you know how to make this 2 types of events. You may have already figured out by yourself how to combine them.

The following example combined the 2 types we have seen.


$lastsender$
#string<>#
John
0
300
0
exiva _var = 0
$lastmsg$
#string<>#
hi
0
300
0
exiva _var = 0
$lastsender$
#string=#
John
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$lastmsg$
#string=#
hi
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
300
0
exiva testding
$_var$
#number>=#
500
0
300
0
exiva _var = 3



1. If the variable $lastsender$ returns something different than "John" then it will set custom variable $_var$ to 0.
2. If the variable $lastmsg$ returns something different than "hi" then it will set custom variable $_var$ to 0.
3. If variable $lastsender$ returns "John" it will add +1 to custom variable $_var$.
4. If variable $lastmsg$ returns "hi" it will add +1 to custom variable $_var$.
5. If custom variable $_var$ is equal to 2, then it will ding using "exiva testding"
6. If custom variable went too high (500) because both conditions kept being true for a long time, then it will reset it back to 3. (Must be a number above 2 so that condition number 5 keeps being false.)

I dont understand why you make reset to 3 instead of reset to 0. Becauese if you reset to 3 the $_var$ will never result equal to 2 again, then you will never testding to John+hi again...


Edited: nvm, I did read it again and now unterstand why reset to 3

Xamxu
10-07-2008, 01:54
I've tried to search on the forums for some kind of a cap alert, but I can't find one..
Anyone knows a good one to share? :D

Wojtek19
10-12-2008, 09:58
I try edit to avoid spam script ...
I dont know why this script dont change orther than energy mystic blade weapon to Mystic if last attacked monster is ghost.
Colored text is part of script added by me. Say me please what is wrong and fix it. I change it with reading Weeper tutorial.

Here is link to thead
http://www.blackdtools.net/showthread.php?t=28529

or here code:



1
#number=#
1
0
300
0
exiva _bs = 0
$hex-lastattackedid$
#string<>#
$hex-idofname:ghost$
0
300
0
exiva _bs = $numericalexp:{$_bs$}+1$
$hex-lastattackedid$
#string<>#
$hex-idofname:dragon$
0
300
0
exiva _bs = $numericalexp:{$_bs$}+1$
$hex-equiped-item:06$
#string<>#
$hex-idofname:DF 0C$
0
300
0
exiva _bs = $numericalexp:{$_bs$}+1$
$_bs$
#number=#
3
0
300
0
exiva #DF 0C 06
1
#number=#
1
0
300
0
exiva _MB = 0
$hex-lastattackedid$
#string=#
$hex-idofname:ghost$
0
300
0
exiva _MB = $numericalexp:{$_MB$}+1$
$hex-equiped-item:06$
#string<>#
$hex-idofname:1C 03$
0
300
0
exiva _MB = $numericalexp:{$_MB$}+1$
$_MB$
#number=#
2
0
300
0
exiva #1C 03 06
1
#number=#
1
0
300
0
exiva _ammo = 0
$hex-lastattackedid$
#string=#
$hex-idofname:dragon$
0
500
0
exiva _ammo = $numericalexp:{$_ammo$}+1$
$hex-equiped-item:0A$
#string=#
$hex-idofname:00 00$
0
300
0
exiva _ammo = $numericalexp:{$_ammo$}+1$
$_ammo$
#number=#
2
0
300
0
exiva > 78 FF FF 05 00 00 61 0D 00 FF FF 0A 00 00 01
1
#number=#
1
0
300
0
exiva _2h sword = 0
$hex-lastattackedid$
#string=#
$hex-idofname:dragon$
200
500
0
exiva _2h sword = $numericalexp:{$_2h sword$}+1$
$hex-equiped-item:06$
#string<>#
$hex-idofname:D6 1C$
0
300
0
exiva _2h sword = $numericalexp:{$_2h sword$}+1$
$_2h sword$
#number=#
2
0
300
0
exiva #D6 1C 06
1
#number=#
1
0
300
0
exiva _shield = 0
$hex-equiped-item:05$
#string=#
$hex-idofname:00 00$
0
300
0
exiva _shield = $numericalexp:{$_shield$}+1$
$hex-lastattackedid$
#string<>#
$hex-idofname:dragon$
0
300
0
exiva _shield = $numericalexp:{$_shield$}+1$
$_shield$
#number=#
2
0
300
0
exiva > 78 FF FF 0A 00 00 61 0D 00 FF FF 05 00 00 01


Thanks a lot.

h0tlines
03-09-2009, 18:05
I found this tutorial very useful weeper. I used it to make my first own conditional event, and I thought I should post it here since it might be useful. What it does is that it sounds the danger alarm whenever a player is on the screen only if you are on the 8th level. I use it when hunting in larva caves with a depositer so that the alarm won't go off on the way to the bank.



1
#number=#
1
0
300
0
exiva _var = 0
$pksonrelativefloor:0$
#number<>#
0
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$myz$
#number=#
8
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
10000
0
exiva testsound

Godlyyo
10-09-2009, 17:44
im sorry i have no idea how to use black d, could you explain in detail for a noob with computers/bots how to do this..

so the elf bot has something called "immortal" basically when someones hp drops below 60% or so it puts on a mana ring (death ring on my OT server) and takes it off when its above 60% again

i was wondering how to do this with black d? someone told me to record the hex of me doing it then set the conditions to when my hp is below 60% but i dont know how to record the hex or whatever... any help please?

schizzo
02-20-2017, 18:35
hey guys
can someone try to help me make a condition that turns the blueaura on if more than x monsters on screen / battle and turns it back off if there are 2 left ?