SRL Archive - SRL Suggestions

SetupPlayer instead of MakeCompass/SetRun/


Cstrike

2010-11-29 21:46:04


procedure SetupPlayer (Angle: Boolean; CompassDirection: TVariant; Run: Boolean);
begin
SetAngle(Angle);
MakeCompass (CompassDirection);
SetRun(Run);
end;

Is there a function for what I've proposed above? I seem to be on a hot-streak for recommending existent things :cartman:
Doesn't quite have to be called this and can be fail-safed of course.
Also, I do agree that this is uber minor. No need to remind me ;)

Frement

2010-11-29 21:57:50

This would save some time, and ease the setup. I say yes for this.

HyperSecret

2010-11-30 00:26:01

I don't see a use for it, honestly.

i luffs yeww

2010-11-30 00:36:54

No reason to add this to SRL, imo. Just have it in your script if you so please; things like this will eventually lead to "CookFish;" in SRL. :/

Frement

2010-11-30 00:38:08

From: i luffs yeww
No reason to add this to SRL, imo. Just have it in your script if you so please; things like this will eventually lead to "CookFish;" in SRL. :/


IMO totally different situation, this isnt skill specific.

i luffs yeww

2010-11-30 00:44:27

The idea is the same though.. package a bundle of different things to one function. CookFish would just be a FindFish, ClickFire, basically, and wait, so really I think it would lead to things like that.

Bad Boy JH

2010-11-30 01:46:17

think about this though, when you start your player, do move camera up, and then change the rotation? no, you do both at the same time. perhaps a function which does both at the same time?

Narcle

2010-11-30 02:15:02

From: Bad Boy JH
think about this though, when you start your player, do move camera up, and then change the rotation? no, you do both at the same time. perhaps a function which does both at the same time?


Now THAT would be useful. Actually I see great potential in this. All directional could be set with one function. I would leave SetRun separate though.

Edit: I made it, looks SOO much better doing both at same time:
Function SetCamera(CompassDirection: Variant; HighestAngle: Variant): Boolean;
var
StartAngle, Angle, DirectionDeg, i: Extended;
Left, SetCompass, SetAng, Highest, Set0, Set1: Boolean;
Mark, TimeOut: Integer;
Begin
Result := False;

if Not LoggedIn then
Exit;

if varType(HighestAngle) = varBoolean then
begin
SetAng := true;
Highest := HighestAngle;
end;

case VarType(CompassDirection) of
varInteger, varDouble: begin
StartAngle := (rs_GetCompassAngleDegrees);
DirectionDeg := FixD(CompassDirection + 0.0);
end;
varString: begin
StartAngle := (rs_GetCompassAngleDegrees);
i := StrToFloatDef(CompassDirection,-1337);
if i = -1337 then
begin
case LowerCase(CompassDirection) of
'n': DirectionDeg := 0;
'w': DirectionDeg := 270;
's': DirectionDeg := 180;
'e': DirectionDeg := 90;
'random', 'rand': DirectionDeg := RandomRange(0, 360);
end;
end else
DirectionDeg := FixD(i);
end;
end;

SetCompass := (StartAngle > -1) and (DirectionDeg > -1);

i := 0.0;
if (MinE(Abs(StartAngle - DirectionDeg), MinE(Abs(StartAngle - (DirectionDeg + 360)), Abs((StartAngle + 360) - DirectionDeg)))) <= 8.0 then
SetCompass := False;

Set0 := not SetCompass;
Set1 := not SetAng;

if SetCompass then
begin
Left := (Round((360 - StartAngle) + DirectionDeg) mod 360 <= Round((StartAngle + 360) - DirectionDeg) mod 360);
KeyDown((Integer(not Left) * 2) + 37);
end;

if SetAng then
begin
KeyDown((Integer(not Highest) * 2) + 38);
TimeOut := 1000 + Random(300);
end;

MarkTime(Mark);

repeat
wait(1);

if SetCompass then
begin
Angle:= rs_GetCompassAngleDegrees;
if ((TimeFromMark(Mark) > 6000) and (i < 1.0)) or
((TimeFromMark(Mark) > 10000) and (i < 2.0)) or
((TimeFromMark(Mark) > 14000) and (i < 3.0)) then
i := i + 1.0;
if ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
or (TimeFromMark(Mark) > 14000)
or (Angle < 0) then
begin
if Left then
KeyUp(VK_Left)
else
KeyUp(VK_Right);
Set0 := true;
end;
end;

if SetAng then
if (TimeFromMark(Mark) >= TimeOut) then
begin
KeyUp((Integer(not Highest) * 2) + 38);
Set1 := true;
end;

until (Set0 and Set1) or (TimeFromMark(Mark) > 14000);

if SetCompass then
Result := ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
else
Result := not SetCompass;
end;

Note HighestAngle is a variant this way you can put 0 or w/e besides a boolean so it doesn't try to set the Angle.

Frement

2010-11-30 04:08:14

Now thats the shit!

Bad Boy JH

2010-11-30 07:13:46

yes, yes it is, I am working on a cooker, and that would make it insanely human like…

Cstrike

2010-11-30 13:24:18

I officially want Narcle's suggestion instead of mine.

weezy

2010-11-30 13:36:36

Well I think SetAngle should be automatically initiated to true (not asked in the initialization function), that's about it, since I don't walk to put in a bunch of arguments for SRL setup when I don't even need them.

Boreas

2010-11-30 13:42:25

Is AngleDir still in SRL?

Narcle

2010-11-30 13:55:26

From: Boreas
Is AngleDir still in SRL?


I don't see it in there. I've improved my function a bit too:

Function SetCamera(CompassDirection: Variant; HighestAngle: Variant): Boolean;
var
StartAngle, Angle, DirectionDeg, i: Extended;
Left, SetCompass, SetHeight, Highest, Set0, Set1: Boolean;
Mark, TimeOut, k: Integer;
Begin
Result := False;
if not LoggedIn then
Exit;
if varType(HighestAngle) = varBoolean then
begin
SetHeight := true;
Highest := HighestAngle;
end;
case VarType(CompassDirection) of
varInteger, varDouble: begin
StartAngle := (rs_GetCompassAngleDegrees);
DirectionDeg := FixD(CompassDirection + 0.0);
end;
varString: begin
StartAngle := (rs_GetCompassAngleDegrees);
i := StrToFloatDef(CompassDirection,-1337);
if i = -1337 then
begin
case LowerCase(CompassDirection) of
'n': DirectionDeg := 0;
'w': DirectionDeg := 270;
's': DirectionDeg := 180;
'e': DirectionDeg := 90;
'random', 'rand': DirectionDeg := RandomRange(0, 360);
end;
end else
DirectionDeg := FixD(i);
end;
end;
SetCompass := (StartAngle > -1) and (DirectionDeg > -1);
if SetCompass then
if (MinE(Abs(StartAngle - DirectionDeg), MinE(Abs(StartAngle - (DirectionDeg + 360)), Abs((StartAngle + 360) - DirectionDeg)))) <= 8.0 then
SetCompass := False;
if SetCompass then
begin
i := 0.0;
Left := (Round((360 - StartAngle) + DirectionDeg) mod 360 <= Round((StartAngle + 360) - DirectionDeg) mod 360);
KeyDown((Integer(not Left) * 2) + 37);
end else
Set0 := true;//to break out of loop
if SetHeight then
begin
KeyDown((Integer(not Highest) * 2) + 38);
TimeOut := 1000 + Random(300);
end else
Set1 := true;
MarkTime(Mark);
repeat
wait(1);
if SetCompass and (not Set0) then
begin
Angle:= rs_GetCompassAngleDegrees;
if ((TimeFromMark(Mark) > 6000) and (i < 1.0)) or
((TimeFromMark(Mark) > 10000) and (i < 2.0)) or
((TimeFromMark(Mark) > 14000) and (i < 3.0)) then
i := i + 1.0;
if ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
or (TimeFromMark(Mark) > 14000)
or (Angle < 0) then
begin
KeyUp(Integer(not Left)*2+37);
Set0 := true;
end;
end;
if SetHeight and (not Set1) then
if (TimeFromMark(Mark) >= TimeOut) then
begin
KeyUp((Integer(not Highest) * 2) + 38);
Set1 := true;
end;
until (Set0 and Set1) or (TimeFromMark(Mark) > 14000);
for k := 37 to 40 do
begin
KeyDown(k);
KeyUp(k);
end;//sometimes doesn't release keys, this makes sure they are all reset
if SetCompass then
Result := ((MinE(Abs(Angle - DirectionDeg), MinE(Abs(Angle - (DirectionDeg + 360)), Abs((Angle + 360) - DirectionDeg)))) <= (7.0 + i))
else
Result := not SetCompass;
end;

Edit: Updated it again. For some reason the keys will stick randomly, so I added a loop to push and release them all at the end, this seems to solve it.

Sir R. M8gic1an

2010-11-30 20:42:23

That looks great Narcle o.O

~RM