Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help
#5
Edited:
There are 3 versions of this macro, and last one, on the bottom, done by BMega is shortest, but most complex.


Just remember to use bbot 82.4 or higher for this

[macro]100 {stopnear} IDtostop:=8503 V0:=0 Xw:=Sub(:X, 1) Xe:=Add(:X, 1) Yn:=Sub(:Y, 1) Ys:=Add(:Y, 1) v:=Map.HasID(!IDtostop, !Xw, !Yn, :Z) VarAdd(V0, !v) v:=Map.HasID(!IDtostop, :X, !Yn, :Z) VarAdd(V0, !v) v:=Map.HasID(!IDtostop, !Xe, !Yn, :Z) VarAdd(V0, !v) v:=Map.HasID(!IDtostop, !Xe, :Y, :Z) VarAdd(V0, !v) v:=Map.HasID(!IDtostop, !Xe, !Ys, :Z) VarAdd(V0, !v) v:=Map.HasID(!IDtostop, :X, !Ys, :Z) VarAdd(V0, !v) v:=Map.HasID(!IDtostop, !Xw, !Ys, :Z) VarAdd(V0, !v) v:=Map.HasID(!IDtostop, !Xw, :Y, :Z) VarAdd(V0, !v) !V0>=1 Cavebot.Stop() [/macro]
Code:
IDtostop:=8503
V0:=0
Xw:=Sub(:X, 1)
Xe:=Add(:X, 1)
Yn:=Sub(:Y, 1)
Ys:=Add(:Y, 1)
v:=Map.HasID(!IDtostop, !Xw, !Yn, :Z)
VarAdd(V0, !v)
v:=Map.HasID(!IDtostop, :X, !Yn, :Z)
VarAdd(V0, !v)
v:=Map.HasID(!IDtostop, !Xe, !Yn, :Z)
VarAdd(V0, !v)
v:=Map.HasID(!IDtostop, !Xe, :Y, :Z)
VarAdd(V0, !v)
v:=Map.HasID(!IDtostop, !Xe, !Ys, :Z)
VarAdd(V0, !v)
v:=Map.HasID(!IDtostop, :X, !Ys, :Z)
VarAdd(V0, !v)
v:=Map.HasID(!IDtostop, !Xw, !Ys, :Z)
VarAdd(V0, !v)
v:=Map.HasID(!IDtostop, !Xw, :Y, :Z)
VarAdd(V0, !v)
!V0>=1
Cavebot.Stop()

under spoiler was my first version of macro, but then Mega reminded me of even shorter one which is above
[spoiler]
[macro]100 {stopnear} IDtostop:=8503 Xw:=Sub(:X, 1) Xe:=Add(:X, 1) Yn:=Sub(:Y, 1) Ys:=Add(:Y, 1) v1:=Map.HasID(!IDtostop, !Xw, !Yn, :Z) v2:=Map.HasID(!IDtostop, :X, !Yn, :Z) v3:=Map.HasID(!IDtostop, !Xe, !Yn, :Z) v4:=Map.HasID(!IDtostop, !Xe, :Y, :Z) v5:=Map.HasID(!IDtostop, !Xe, !Ys, :Z) v6:=Map.HasID(!IDtostop, :X, !Ys, :Z) v7:=Map.HasID(!IDtostop, !Xw, !Ys, :Z) v8:=Map.HasID(!IDtostop, !Xw, :Y, :Z) va:=Add(!v1, !v2) vb:=Add(!v3, !v4) vc:=Add(!v5, !v6) vd:=Add(!v7, !v8) vA:=Add(!va, !vb) vB:=Add(!vc, !vd) V0:=Add(!vA, !vB) !V0>=1 Cavebot.Stop() [/macro]


Code:
IDtostop:=8503
Xw:=Sub(:X, 1)
Xe:=Add(:X, 1)
Yn:=Sub(:Y, 1)
Ys:=Add(:Y, 1)
v1:=Map.HasID(!IDtostop, !Xw, !Yn, :Z)
v2:=Map.HasID(!IDtostop, :X, !Yn, :Z)
v3:=Map.HasID(!IDtostop, !Xe, !Yn, :Z)
v4:=Map.HasID(!IDtostop, !Xe, :Y, :Z)
v5:=Map.HasID(!IDtostop, !Xe, !Ys, :Z)
v6:=Map.HasID(!IDtostop, :X, !Ys, :Z)
v7:=Map.HasID(!IDtostop, !Xw, !Ys, :Z)
v8:=Map.HasID(!IDtostop, !Xw, :Y, :Z)
va:=Add(!v1, !v2)
vb:=Add(!v3, !v4)
vc:=Add(!v5, !v6)
vd:=Add(!v7, !v8)
vA:=Add(!va, !vb)
vB:=Add(!vc, !vd)
V0:=Add(!vA, !vB)
!V0>=1
Cavebot.Stop()
[/spoiler]









Okay, we had a talk with Mega about even a shorter version of this macro. And what he created it is dope.


[macro]100 {stopnear} IDtostop:=8503 Xi:=-1 Yi:=-1 {CheckAgain} X:=Add(:X, !Xi) Y:=Add(:Y, !Yi) Map.HasID(!IDtostop, !X, !Y, :Z)==1 [Continue] Cavebot.Stop() exit() {Continue} VarAdd(Xi, 1) !Xi==2 [CheckAgain] Xi:=-1 VarAdd(Yi, 1) !Yi==2 [CheckAgain] Exit()[/macro]
[spoiler]
Code:
IDtostop:=8503
Xi:=-1
Yi:=-1
{CheckAgain}
X:=Add(:X, !Xi)
Y:=Add(:Y, !Yi)
Map.HasID(!IDtostop, !X, !Y, :Z)==1 [Continue]
Cavebot.Stop()
exit()
{Continue}
VarAdd(Xi, 1)
!Xi==2 [CheckAgain]
Xi:=-1
VarAdd(Yi, 1)
!Yi==2 [CheckAgain]
Exit()
[/spoiler]
In single run of this macro, it checks every position in 1sqm radius from the character, including underneath.

loop with exit
Reply


Messages In This Thread
Help - by lukasze - 05-23-2017, 02:12 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)