Coh3n
2010-07-27 20:20:43
Basically, he suggested using Procedure Pointers in our TScript records. This will make scripts more customizable and gives an object oriented programming (OOP) kind of feel to it as functions can be "overridden" using pointers. If you have no idea what I'm talking about, don't worry, I'll try to explain.
program new;
{$i srl/srl.scar}
type
TScript = record;
Name: string;
WalkToLoc: function(startLoc, endLoc: Integer): Boolean;
end;
function WalkToLocDefault(startLoc, endLoc): Boolean;
begin
end;
function WalkToLocWithGate(startLoc, endLoc): Boolean;
begin
end;
function LoadScript(Which: Integer): TScript;
begin
case Which of
EXAMPLE_1:
with Result do
begin
Name := 'Example_1';
WalkToLoc := @WalkToLocDefault(LOC_BANK, LOC_TREES);
end;
EXAMPLE_2:
with Result do
begin
Name := 'Example_2';
WalkToLoc := @WalkToLocWithGate(LOC_BANK, LOC_TREES); // If there's a gate in the path, we won't use the default walking function
end;
end;
end;
function MSI_WalkToLoc: Boolean; // This would be the function in Mainloop.scar
var
Script: TScript;
begin
Script := MSI_Scripts[MSI_Players[CurrentPlayer].Scripts[CurrentScript]];
if (Script.WalkToLoc <> nil) then // If .WalkToLoc has been set
Result := Script.WalkToLoc
else
Result := WalkToLocDefault(Script.StartLoc, Script.EndLoc);
end;
begin
end.
Similar strategies can be done with Object finding/location finding (when the relocator is developed), etc.
I wrote this quick, so if you don't understand, just ask. But anyway, I just want to discuss this for now, see what people think. :)[/INDENT]