Simba Code:
program BlitzFighter;
{$i oglib/lib/core/core.simba}
{BlitzFighter v0.01}
{SCRIPT SETTINGS}
const
SHOW_PAINT = false;
{END OF SETTINGS}
const
scriptVersion = '0.01';
type tMobID = record
ID: glModelArray;
end;
type MOB = record
Name,
attackOption: String;
mobID: tMobID;
minWait,
maxWait: integer;
thresholds,
selfRegen: boolean;
end;
var
fightFail,
scriptPaintBMP: integer;
clientCenter: TPoint;
playerID: uInt32;
Goblin: mob;
{PROCEDURE -- Debug
Purpose: Custom console debugging procedure.
Comments: By Clarity.}
procedure Debug(message: string);
begin
writeln('BlitzFighter v' + scriptVersion + ' || ' + toStr(getTimeRunning) + ' || ' + message);
end;
{PROCEDURE -- doNothing()
Purpose: Scan React.
Comments: None.}
procedure doNothing();
begin
end;
{PROCEDURE -- rotateCamera()
Purpose: rotates Camera.
Comments: None.}
procedure rotateCamera();
begin
minimap.setDegrees(minimap.getDegrees()+random(-45,45));
end;
{PROCEDURE -- shortWait()
Purpose: Cuz I'm lazy and want to type less.
Comments: None.}
procedure shortWait();
begin
wait(randomRange(600,1800));
end;
{FUNCTION -- canFight(): boolean
Purpose: Detects if we are already in combat and capable of fighting.
Comments: None.}
function canFight(): boolean;
begin
if not (combat.hasTarget()) then
result:= true;
end;
{PROCEDURE -- mob.Init()
Purpose: For mob records.
Comments: None.}
procedure MOB.Init(_Name: String; _mobID: tMobID; _attackOption: String; _minWait: integer; _maxWait: integer; _thresholds: boolean; _selfRegen: boolean);
begin
Self.Name := _Name;
Self.mobID := _mobID;
Self.attackOption := _attackOption;
Self.minWait := _minWait;
Self.maxWait := _maxWait;
Self.thresholds := _thresholds;
Self.selfRegen := _selfRegen;
end;
{PROCEDURE -- tMobID.Init()
Purpose: For mob records.
Comments: None.}
procedure tMobID.Init(_mobArray: glModelArray);
begin
Self.ID := _mobArray;
end;
{PROCEDURE -- loadMobs()
Purpose: Loads mob data.
Comments: None.}
procedure loadMobs();
begin
Goblin.Init('Goblin', ogl.getModels[1496395506, 163684431, 1574583763, 3748622621, 3626760128, 2071972491], 'ttack Gobl', 1000, 3000, true, true);
end;
{PROCEDURE -- safeEscape()
Purpose: Fight logic.
Comments: None.}
procedure safeEscape();
begin
end;
{PROCEDURE -- useThresholds()
Purpose: Strategic use of thresholds.
Comments: None.}
procedure useThresholds();
begin
end;
{PROCEDURE -- mob.Attack()
Purpose: Fight logic.
Comments: None.}
procedure mob.Attack();
var
mobIDArray: glModelArray;
mobTPA: TPointArray;
nextFight: tCountDown;
begin
if fightFail > 5 then
safeEscape();
if canFight() and nextFight.isFinished() then
begin
if ogl.getModels(Self.mobID) then
begin
if (mobIDArray := ogl.getModels(Self.mobID)).indexes then
begin
mobTPA:= ogl.getClientMidPoint().closest(mobIDArray).toPointArray;
if not mobTPA[0].adjustPosition(0, -30).isVisible() then
begin
rotateCamera();
shortWait();
end;
Case random(4) of
1: mouse.rightClickOption(mobTPA[0].adjustPosition(0, -30).randomizePointEllipse(30), [Self.attackOption],600);
2: mouse.click(mobTPA[0].adjustPosition(0, -10).randomizePointEllipse(30));
3: mouse.click(mobTPA[0].adjustPosition(0, -20).randomizePointEllipse(40));
4: mouse.rightClickOption(mobTPA[0].adjustPosition(0, -20).randomizePointEllipse(40), [Self.attackOption],600);
end;
end;
nextFight.setTime(normalRandom(Self.minWait, Self.maxWait));
if actionBar.getAdrenaline() >=50 and combat.hasTarget() and Self.thresholds = true then
useThresholds();
if actionBar.getAdrenaline() >=1 and (not (combat.hasTarget())) and Self.selfRegen = true then
begin
if actionBar.getLifePoints() <80 then
begin
actionBar.setRegenerate(true);
while actionBar.getAdrenaline >=1 do
shortWait();
end;
end;
end;
end
else
begin
inc(fightFail);
exit;
end;
end;
{PROCEDURE -- mainLoop()
Purpose: Script main loop.
Comments: None.}
procedure mainLoop();
var
reaction: procedure() = @doNothing;
begin
if canFight() then
Goblin.Attack()
else
reaction();
end;
{PROCEDURE -- autoUpdateMe
Purpose: Autoupdates the script.
Comments: By Shuttleu, modified by Ashaman88 and Clarity}
procedure autoUpdateMe;
var
Neifile: Integer;
OnlineVersion, NewScript, NeiFeilNennen: string;
begin
Debug('Checking for script updates...');
OnlineVersion := GetPage('http://pastebin.com/raw/fSG5AKXw');
Debug('Online Script Version: ' + OnlineVersion);
Debug('Local Script Version: ' + ScriptVersion) if (trim(OnlineVersion) > ScriptVersion) then
begin
Debug('New script version online!');
Debug('Autoupdating to newer version.');
NewScript := GetPage('http://pastebin.com/raw/cryBF3SQ');
NeiFeilNennen := ScriptPath + 'BlitzKrieger v' + OnlineVersion + '.simba';
Neifile := Rewritefile(NeiFeilNennen, true);
try
WriteFileString(Neifile, NewScript);
except
begin
Debug('Fatal error writing to ' + NeiFeilNennen + '!');
Terminatescript;
end;
end;
CloseFile(Neifile);
Debug('New script downloaded to ' + NeiFeilNennen + '! Terminating old script, please use the new version.');
writeln('New script downloaded to ' + NeiFeilNennen + '! Terminating old script, please use the new version.');
TerminateScript;
end
else
Debug('You have the latest version of the script!');
end;
{PROCEDURE -- checkForFiles
Purpose: Checks to see if file downloading is required.
Comments: By Kevin, modified by Clarity}
procedure checkForFiles(filePath, message, link: string);
var
progFile: longInt;
fileName: string;
begin
fileName := AppPath + filePath;
try
if not fileExists(fileName) then
begin
Debug('-- INSTALLATION STATUS: ' + message + ' does not exist - Downloading now.');
progFile := createFile(fileName);
end
else
begin
Debug('-- INSTALLATION STATUS: ' + message + ' exists.');
exit;
end;
closeFile(progFile);
progFile := rewriteFile(fileName, false);
writeFileString(progFile, getPage(link));
Debug('-- INSTALLATION STATUS: ' + message + ' has been downloaded.');
finally
if (progFile > 0) then
closeFile(progFile);
end;
end;
{PROCEDURE -- installAssets
Purpose: Determines whether files exist and dictates their installation.
Comments: By Clarity}
procedure installAssets;
begin
Debug('Please wait...now installing BlitzKrieger image assets to your computer...');
if not directoryExists(appPath + 'scripts/BlitzKrieger/Images/') then
begin
try
createDirectory(appPath + 'scripts/BlitzKrieger/Images/');
Debug('Created a new folder in Simba/Scripts/');
except
end;
end;
checkForFiles('scripts/BlitzKrieger/Images/BlitzFighter.png', 'BlitzFighter', 'imgur path');
end;
procedure initialize();
begin
autoUpdateMe;
//installAssets();
loadMobs();
if SHOW_PAINT then
begin
scriptPaintBMP := loadBitmap(appPath + 'Scripts\BlitzKrieger\Images\BlitzFighter.png');
fastReplaceColor(scriptPaintBMP, 0, 1);
end;
clientCenter:=ogl.getClientMidPoint();
end;
begin
clearDebug();
ogl.setup(1200, 800);
ogl.setCacheTime(120);
ogl.setColourTolerance(2);
ogl.setDebugMode('m');
initialize();
repeat
//writeln(ogl.getTextures(117810));
mainLoop;
until false;
end;