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.