randomChance();
This is an easier way of having a certain chance of doing a task, saving a few lines every time you want to do something like this. randomChance(2) has a 50% chance of returning true, randomChance(3) has a 33% chance of returning, randomChance(4) is 25%, et cetera.
Edit: We both misunderstood how random(2) worked, so basically this function combines if "random(2) = 0 or 1 then" to "if randomChance(2) then"
Simba Code:
function randomChance(randomNumber: integer): boolean;
begin
if randomNumber and (random(1, randomNumber) = 1) then
result := true;
end;
Example Usage:
Simba Code:
if randomChance(10) then writeln('You won the lottery!');
rotateCamera();
This is a function that randomly moves the camera on both axes. It is more useful in OGL scripts when trying to search for objects that may have evaded view. Utilizes randomChance(); as described above. Also useful in color scripts when having north or aerial orientation isn't required.
Simba Code:
procedure rotateCamera;
const
KEYS_HORIZONTAL: TIntegerArray = [0, 37, 39];
KEYS_VERTICAL: TIntegerArray = [0, 38, 40];
var
pressKeyHorizontal, pressKeyVertical: integer;
begin
pressKeyHorizontal := KEYS_HORIZONTAL[random(0, 2)];
pressKeyVertical := KEYS_VERTICAL[random(0, 2)];
if randomChance(2) then
begin
if (pressKeyHorizontal > 0) then
keyDown(pressKeyHorizontal);
if (pressKeyVertical > 0) then
begin
if (pressKeyHorizontal > 0) then
wait(random(350));
keyDown(pressKeyVertical);
end;
end
else
begin
if (pressKeyVertical > 0) then
keyDown(pressKeyVertical);
if (pressKeyHorizontal > 0) then
begin
if (pressKeyVertical > 0) then
wait(random(350));
keyDown(pressKeyHorizontal);
end;
end;
if (pressKeyHorizontal > 0) or (pressKeyVertical > 0) then
wait(random(750));
if randomChance(2) then
begin
if (pressKeyHorizontal > 0) then
keyUp(pressKeyHorizontal);
if (pressKeyVertical > 0) then
begin
if (pressKeyHorizontal > 0) then
wait(random(350));
keyUp(pressKeyVertical);
end;
end
else
begin
if (pressKeyVertical > 0) then
keyUp(pressKeyVertical);
if (pressKeyHorizontal > 0) then
begin
if (pressKeyVertical > 0) then
wait(random(350));
keyUp(pressKeyHorizontal);
end;
end;
end;
Example Usage (on repeated loop):
A single usage is one of those camera nudges.
Credits to my buddy @Obscurity.