So I'm currently working on a pathfinding algorithm to streamline my scripts when i get round to making some (I actually saw similar objects runemate which gave me the idea to do it this way), but I've run into some issues:
The plan is to use Dijkstra's algorithm to filter through a number of different points which can be reached across the rs world. So obviously these points have to be connected in order for a path to be found, so i've set up a number of different records to store these vertices.
Anyway, the issue is, short of making a single record to store all my data ( and therefore take up a bunch more memory and everything) is there any way I can make it so that I can store a number of different vertices in and array of my RSVertexRSEdge record, and still be able to call the sub-record specific values (like CoOrdinateVertexCoOrdinateEdge.path).
Thanks for any help
I've attached my work so far so anyone giving input can get an idea of what i might be wanting to achieve.
Simba Code:type
EdgeMethod = (telePath,itemPath,objectPath,npcPath);
EdgeDir = (directed, bidirectional);
levelReq = record
skill: byte;
level: byte;
end
EdgeReq = record
items: TIntegerArray;
skills: array of levelReq;
quests: TStringArray;
end
RSEdge = record
method:EdgeMethod;
direction: EdgeDir;
origin: TPoint;
target: TPoint;
req :EdgeReq;
cost:integer;
end
TeleEdge = record(RSEdge)
spell:string;
spellbook:string;
end
ItemEdge = record(RSEdge)
item:integer;
options:TStringArray;
end
NPCEdge = record(RSEdge)
options:TStringArray;
end
ObjectEdge = record(RSEdge)
id:integer;
options:TStringArray;
end
CoOrdinateEdge = record(RSEdge)
path:TPointArray;
end
function RSEdge.isUseable:Boolean; //should calculate if player meets requirements
begin
//self.reqs.items
//self.reqs.levels
//self.reqs.quests
end
function CoOrdinateEdge.calcCost:integer;
var
temp:extended;
i:integer;
begin
temp := 0;
for i:= 1 to high(self.path) do
temp := temp+hypot(self.path[i].X-self.path[i-1].X,self.path[i].Y-self.path[i-1].Y);
result := round(temp);
self.cost := round(temp);
end


Reply With Quote


