Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$DEFINE SRL_USE_REMOTEINPUt}
- {$I SRL/osr.simba}
- function TRSWalker.GetMyPos_Barber(): TPoint;
- var
- TPA: TPointArray;
- err,me,anchor_mean,m: TPoint;
- r: TRectangle;
- anchor: TPoint = [3758, 2494];
- b: TBox;
- begin
- me := Self.GetMyPos();
- // 1. covert `anchor` to minimap
- m := Self.WorldToMM(me, anchor, minimap.GetCompassAngle(False));
- // 2. covert `anchor` to world location (and then some for finding)
- r := Minimap.PointToMsRect(m, 1.5,1.5); //scan larger than tile for object
- // limit to mainscreen exit if not in sight
- b := r.Bounds();
- b.LimitTo(MainScreen.Bounds);
- if b.Area = 0 then Exit(p);
- // find the object - I use a red chair that is in which the mean is about 2 units high
- srl.FindColors(TPA, CTS2(661620, 15, 0.16, 1.11), b);
- RSClient.Image.Clear(); // can be removed
- // Mean of anchor, height of it (in my example 2)
- // subtract it from whatever it was, call result err (error)
- anchor_mean := TPA.Cluster(3).Biggest().Mean();
- RSClient.Image.DrawCircle(anchor_mean, 5, $00FF00); // can be removed
- RSClient.Image.DrawRect(r, 255); // can be removed
- // this is how much wrong RSW was in world pixels:
- err := anchor-Self.MSToWorld(anchor_mean, 2);
- WriteLn('RSW was: ', err, ' wrong');
- // add the error to RSW position `p` and return that shit
- Result := me+err;
- // show corrected tile (can be removed):
- m := Self.WorldToMM(Result, match, minimap.GetCompassAngle(False));
- r := Minimap.PointToMsRect(m, 1,1);
- RSClient.Image.DrawRect(r, $00FF00);
- end;
- var
- RSW: TRSWalker;
- begin
- RSW.Setup();
- MM2MS.ZoomLevel := 25;
- while True do
- begin
- WriteLn('Before: ', RSW.GetMyPos());
- WriteLn('After : ', RSW.GetMyPos_barber());
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement