Coh3n
2010-04-28 16:00:29
I've got it working and everything. Not sure how I feel about how the colors are declared and I have a sneaking feeling RM is going to say something like "No hard-coded values in MSI!" or something like that. :p
I will switch them all the constants if need be.
In the public thread we talked about using MSI_GetItem to get the item's colors, but that doesn't work because MSI_GetItem calls MSI_LoadDTM, which calls MSI_GetItem, etc., etc., thus causing a mass amount of lag, not to mention it not working. :p
Naum also mentioned using a TIntegerArray for the colors, but I thought this was more readable, etc. Please update if there's a better method. :)
I will switch them all the constants if need be.
{******************************************************************************}
{ function MSI_GetDTMInfo(which: Integer): TIntegerArray; }
{ By: Coh3n }
{ Description: Gets the coodinates for the DTM points }
{******************************************************************************}
function MSI_GetDTMInfo(which: Integer): TIntegerArray;
begin
case which of
HATCHET_BRONZE..HATCHET_RUNE:
Result := [ 921, 515, 909, 534, 908, 525, 915, 512, 925, 519 ];
LOGS_NORMAL..LOGS_YEW:
Result := [ 1155, 290, 1164, 281, 1164, 290, 1147, 294, 1143, 280 ];
else
MSI_Debug('MSI_GetDTMInfo', 'Invalid item constant!', DEBUG_FUNCTIONS);
end;
end;
{******************************************************************************}
{ function MSI_LoadDTM(which: Integer): Integer; }
{ By: Coh3n and Ejjman1 }
{ Description: Loads the DTM specified by 'which' }
{******************************************************************************}
function MSI_LoadDTM(which: Integer): Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..4] of TDTMPointDef;
TempTDTM: TDTM;
pts: TIntegerArray;
clr, i: Integer;
begin
pts := MSI_GetDTMInfo(which);
case which of
HATCHET_BRONZE: clr := 1649466;
HATCHET_IRON: clr := 3618618;
HATCHET_STEEL: clr := 5855581;
HATCHET_MITHRIL: clr := 4599598;
HATCHET_ADAMANT: clr := 3291698;
HATCHET_RUNE: clr := 4932921;
LOGS_NORMAL: clr := 2704989;
LOGS_OAK: clr := 3760771;
LOGS_WILLOW: clr := 1325634;
LOGS_MAPLE: clr := 800853;
LOGS_YEW: clr := 668228;
end;
with dtmMainPoint do
begin
x := pts[DTM_X1];
y := pts[DTM_Y1];
AreaSize := 0;
AreaShape := 0;
Color := clr;
Tolerance := DTM_TOLERANCE;
end;
for i := 0 to High(dtmSubPoints) do
with dtmSubPoints[i] do
begin
AreaSize := 0;
AreaShape := 0;
if (i > 0) then
begin
Color := SRL_OUTLINE_BLACK
Tolerance := 0;
end else begin
Color := clr;
Tolerance := DTM_TOLERANCE;
end;
end;
dtmSubPoints[0].x := pts[DTM_X1];
dtmSubPoints[0].y := pts[DTM_Y1];
dtmSubPoints[1].x := pts[DTM_X2];
dtmSubPoints[1].y := pts[DTM_Y2];
dtmSubPoints[2].x := pts[DTM_X3];
dtmSubPoints[2].y := pts[DTM_Y3];
dtmSubPoints[3].x := pts[DTM_X4];
dtmSubPoints[3].y := pts[DTM_Y4];
dtmSubPoints[4].x := pts[DTM_X5];
dtmSubPoints[4].y := pts[DTM_Y5];
TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;
In the public thread we talked about using MSI_GetItem to get the item's colors, but that doesn't work because MSI_GetItem calls MSI_LoadDTM, which calls MSI_GetItem, etc., etc., thus causing a mass amount of lag, not to mention it not working. :p
Naum also mentioned using a TIntegerArray for the colors, but I thought this was more readable, etc. Please update if there's a better method. :)