kitchenrange
2011-02-02 13:06:13
I'm working on a script that constantly keeps track of its location for multiple reasons. I believe I have everything added correctly, but for some reason, TileInBox and MeInBox never return that I am in any of the Boxes that I have declared. Maybe I'm just doing something stupid, but if anyone has any suggestions, I'd love to hear them.
This is the procedure that declares the box bounds.
This is the function I'm trying to use to determine my location.
This function also returns 0 Monsters but I believe it is the same problem because I'm feeding it the same boxes as the other.
Does anyone see any mistakes?
E: I've corrected the mistakes in the bounds as far as I can tell with the same result. Threw up another function just to
get the juices flowing.
This is the procedure that declares the box bounds.
procedure CreateSurroundings;//BlockOne and BlockTwo must be a constant.
begin
BlockOne.HallOne.X1 := 3159;
BlockOne.HallOne.Y1 := 4268;
BlockOne.HallOne.X2 := 3166;
BlockOne.HallOne.Y2 := 4270;
BlockOne.HallTwo.X1 := 3157;
BlockOne.HallTwo.Y1 := 4257;
BlockOne.HallTwo.X2 := 3158;
BlockOne.HallTwo.Y2 := 4270;
BlockOne.HallThree.X1 := 3157;
BlockOne.HallThree.Y1 := 4249;
BlockOne.HallThree.X2 := 3166;
BlockOne.HallThree.Y2 := 4251;
BlockOne.LargeRoom.X1 := 3160;
BlockOne.LargeRoom.Y1 := 4253;
BlockOne.LargeRoom.X2 := 3166;
BlockOne.LargeRoom.Y2 := 4266;
BlockOne.RoomOne.X1 := 3160;
BlockOne.RoomOne.Y1 := 4258;
BlockOne.RoomOne.X2 := 3166;
BlockOne.RoomOne.Y2 := 4266;
BlockOne.RoomTwo.X1 := 3160;
BlockOne.RoomTwo.Y1 := 4258;
BlockOne.RoomTwo.X2 := 3166;
BlockOne.RoomTwo.Y2 := 4261;
BlockOne.RoomThree.X1 := 3160;
BlockOne.RoomThree.Y1 := 4253;
BlockOne.RoomThree.X2 := 3166;
BlockOne.RoomThree.Y2 := 4256;
BlockOne.Total.X1 := 3157;
BlockOne.Total.Y1 := 4249;
BlockOne.Total.X2 := 3166;
BlockOne.Total.Y2 := 4270;
BlockOne.South := MiddleTile(BlockOne.HallThree);
BlockOne.North := MiddleTile(BlockOne.RoomOne);
BlockOne.Middle := MiddleTile(BlockOne.LargeRoom);
BlockTwo.HallOne.X1 := 3159;
BlockTwo.HallOne.Y1 := 4244;
BlockTwo.HallOne.X2 := 3166;
BlockTwo.HallOne.Y2 := 4246;
BlockTwo.HallTwo.X1 := 3157;
BlockTwo.HallTwo.Y1 := 4233;
BlockTwo.HallTwo.X2 := 3158;
BlockTwo.HallTwo.Y2 := 4244;
BlockTwo.LargeRoom.X1 := 3160;
BlockTwo.LargeRoom.Y1 := 4228;
BlockTwo.LargeRoom.X2 := 3166;
BlockTwo.LargeRoom.Y2 := 4242;
BlockTwo.RoomOne.X1 := 3160;
BlockTwo.RoomOne.Y1 := 4239;
BlockTwo.RoomOne.X2 := 3166;
BlockTwo.RoomOne.Y2 := 4242;
BlockTwo.RoomTwo.X1 := 3160;
BlockTwo.RoomTwo.Y1 := 4234;
BlockTwo.RoomTwo.X2 := 3166;
BlockTwo.RoomTwo.Y2 := 4237;
BlockTwo.RoomThree.X1 := 3160;
BlockTwo.RoomThree.Y1 := 4228;
BlockTwo.RoomThree.X2 := 3166;
BlockTwo.RoomThree.Y2 := 4232;
BlockTwo.Total.X1 := 3157;
BlockTwo.Total.Y1 := 4228;
BlockTwo.Total.X2 := 3166;
BlockTwo.Total.Y2 := 4246;
BlockTwo.South := MiddleTile(BlockTwo.RoomThree);
BlockTwo.North := MiddleTile(BlockTwo.HallOne);
BlockTwo.Middle := MiddleTile(BlockTwo.LargeRoom);
end;This is the function I'm trying to use to determine my location.
function DetermineRoom : TBox;
var
Rooms : TBoxArray;
i,Top : integer;
begin
Rooms := [BlockOne.RoomOne,BlockOne.RoomTwo,BlockOne.RoomThree,BlockOne.HallOne,BlockOne.HallTwo,BlockOne.HallThree,BlockTwo.RoomOne,BlockTwo.RoomTwo,BlockTwo.RoomThree,BlockTwo.HallOne,BlockTwo.HallTwo];
Top := High(Rooms);
for i := 0 to Top do
begin
if MeInBox(Rooms[i]) then
begin
Result := Rooms[i];
WriteLn('We have found our room.');
Exit;
end else inc(i);
end;
WriteLn('We have not found our room.');
end; This function also returns 0 Monsters but I believe it is the same problem because I'm feeding it the same boxes as the other.
function MonstersInArea(Area : TBox) : TNPCArray;
var
Monsters,Res : TNPCArray;
i,p,q : integer;
begin
Monsters := ValidMonsters;
q := High(Monsters);
for i := 0 to q do
begin
if TileInBox(Area,Monsters[i].Tile) then
begin
WriteLn('adding a monster to the monstersinarea array');
SetLength(Res, Length(Res) + 1);
Res[p] := Monsters[i];
inc(p);
end;
inc(i);
end;
WriteLn('Monsters In are is resulting in '+IntToStr(Length(Res))+' monsters.');
Result := SortNpcs(Res);
end;Does anyone see any mistakes?
E: I've corrected the mistakes in the bounds as far as I can tell with the same result. Threw up another function just to
get the juices flowing.