SRL Archive - MSI Suggestions

DDTMs


Ejjman

2010-04-15 22:00:13

Also: See post #9, and #12


No idea if I'm doing this right, and you can change anything.

First of all, in DDTM.scar, there's two things I can switch up.

1: Have each item have one color in Globals.scar. Only one color.
2: Use the first color from MSI_Item[Item].Colors[0].

I show how you can replace it below. So it's up to RM's discression.

Ddtm.scar

function MSI_LoadDTM(Which : integer) : integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..4] of TDTMPointDef;
TempTDTM: TDTM;
TheColor : integer;
begin
case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING :
begin
case Which of //This whole thing can be deleted, if....
LOGS_NORMAL: TheColor := COLOR_LOG_NORMAL;
LOGS_OAK: TheColor := COLOR_LOG_OAK;
LOGS_WILLOW: TheColor := COLOR_LOG_WILLOW;
LOGS_MAPLE: TheColor := COLOR_LOG_MAPLE;
LOGS_YEW: TheColor := COLOR_LOG_YEW;
end;
dtmMainPoint.x := 1155;
dtmMainPoint.y := 290;
dtmMainPoint.AreaSize := 0;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := TheColor; //..place MSI_Item[Which].Colors[0]; instead of TheColor;
dtmMainPoint.Tolerance := LOG_TOLERANCE;

dtmSubPoints[0].x := 1155;
dtmSubPoints[0].y := 290;
dtmSubPoints[0].AreaSize := 0;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := TheColor; //..place MSI_Item[Which].Colors[0]; instead of TheColor;
dtmSubPoints[0].Tolerance := LOG_TOLERANCE;

dtmSubPoints[1].x := 1164;
dtmSubPoints[1].y := 281;
dtmSubPoints[1].AreaSize := 0;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := 131072;
dtmSubPoints[1].Tolerance := 0;

dtmSubPoints[2].x := 1164;
dtmSubPoints[2].y := 290;
dtmSubPoints[2].AreaSize := 0;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := 131072;
dtmSubPoints[2].Tolerance := 0;

dtmSubPoints[3].x := 1147;
dtmSubPoints[3].y := 294;
dtmSubPoints[3].AreaSize := 0;
dtmSubPoints[3].AreaShape := 0;
dtmSubPoints[3].Color := 131072;
dtmSubPoints[3].Tolerance := 0;

dtmSubPoints[4].x := 1143;
dtmSubPoints[4].y := 280;
dtmSubPoints[4].AreaSize := 0;
dtmSubPoints[4].AreaShape := 0;
dtmSubPoints[4].Color := 131072;
dtmSubPoints[4].Tolerance := 0;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;
//SKILL_MINING:
//New DDTM here
end;
end;



I'm not sure why you have an array of colors for some items. If you want to, I guess, keep that, then go with method 2.



Globals.scar. If you use the array of colors, then delete the first set of const.


const
COLOR_LOG_NORMAL = 2770782;
COLOR_LOG_OAK = 3760770;
COLOR_LOG_WILLOW = 1325891;
COLOR_LOG_MAPLE = 867162;
COLOR_LOG_YEW = 669258;

const
LOG_TOLERANCE = 7;


Setup.scar

{.include srl/srl/msi/ddtm.scar}


And ItemInfo.scar, change this for each log(for now) accordingly.

DTM := MSI_LoadDTM(LOGS_XXXX);



Tested and works.
The tolerance is not specific, and might need touching, but for now, its working.

Sir R. M8gic1an

2010-04-15 22:05:40

Oki, but it'll need to be more global. As you'll notice, the MSI Core is pretty much global throughout the script, and we'd probably benefit more from something like this:

MSI_LoadDTM(Which: integer):integer;

And we don't really use strings, we use constants. Reading through the MSI standards thread and the include might help :)

~RM

Ejjman

2010-04-15 22:08:02

From: Rasta Magician
Oki, but it'll need to be more global. As you'll notice, the MSI Core is pretty much global throughout the script, and we'd probably benefit more from something like this:

MSI_LoadDTM(Which: integer):integer;

And we don't really use strings, we use constants. Reading through the MSI standards thread and the include might help :)

~RM


Ok.

We're looking at a quite large function, mister.

NCDS

2010-04-15 22:12:21

From: Ejjman1
Ok.

We're looking at a quite large function, mister.


It's quite a large project ;)

You'll catch on more as to what were doing as you read through some of the other threads.

I believe the MSI standards thread is now visible to Members+ so have a look at that and it should help clear some things up.

[edit by RM : MSI Scripting Standards: http://villavu.com/forum/showthread.php?t=56132]

Sir R. M8gic1an

2010-04-15 22:12:34

From: Ejjman1
Ok.

We're looking at a quite large function, mister.


well, if it needs breaking down afterwards it's fine, but at least we'll have a middle tier, so only the middle tier will need updating


MSI sub-scripts —> MSI_LoadDTM —> MSI_LoadDTMWC

It'll just be easier to manage overall with the middle tier.

~RM

Coh3n

2010-04-15 22:16:09

Yes it'll be large, and it won't be the only one. ;)

E: Moved this from the other thread for people to catch up.


function MSI_LoadDDTM(which: Integer): Integer;
begin
//all the DDTM stuff here
end;


HATCHET_BRONZE : //Coh3n
with MSI_Item[HATCHET_BRONZE] do
begin
Name := 'Bronze Hatchet';
UpText := ['onze hat'];
ItemP := Point(0, 0);
Colors := [1649466, 1583415, 1715516];
Tol := 3;
Stackable := False;
DTM := MSI_LoadDDTM(HATCHET_BRONZE);

BMP := BitmapFromString(5, 5, 'beNoT5LbXl7bRlbL' +
'SlgSiMEEeCAOIzDUlgFwgicw1UhWFsIEoRJBbX1kEzg4BAL4aC8A=' + '');
end;

Ejjman

2010-04-15 22:19:58

reading through now..

Learning new things, can't wait :spot:

Ejjman

2010-04-16 18:37:46

See first post for updated one.

Coh3n

2010-04-17 12:24:13

Nice :)

This is something I just thought of and wrote up quickly. It would certainly shorten up the code significantly.


//gets the coords of the DTM points
function MSI_GetDTMInfo(which: Integer): TIntegerArray;
begin
case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING:
case which of
LOGS_NORMAL..LOGS_YEW:
Result := [ 1155, 290, 1164, 281, 1164, 290, 1147, 294, 1143, 280 ];

//Hathcet stuff here

else
MSI_Debug(...);
end;

else
MSI_Debug(...);
end;
end;

function MSI_LoadDTM(which : integer) : integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..4] of TDTMPointDef;
TempTDTM: TDTM;
pts: TIntegerArray;
item: TItem;
i: Integer;
begin
pts := MSI_GetDTMInfo(which);
item := MSI_GetItem(which);

with dtmMainPoint do
begin
x := pts[0];
y := pts[1];
AreaSize := 0;
AreaShape := 0;
Color := MSI_Item[item].Colors[0];
Tolerance := MSI_Item[item].Tol;
end;

for i := 0 to High(dtmSubPoints) do
with dtmSubPoints[i] do
begin
AreaSize := 0;
AreaShape := 0;

if (i > 0) then
Color := 131072 //or MSI_OUTLINE_BLACK?
else
Color := MSI_Item[item].Colors[0];

Tolerance := MSI_Item[item].Tol;
end;

dtmSubPoints[1].x := pts[0];
dtmSubPoints[1].y := pts[1];

dtmSubPoints[2].x := pts[2];
dtmSubPoints[2].y := pts[3];

dtmSubPoints[3].x := pts[4];
dtmSubPoints[3].y := pts[5];

dtmSubPoints[4].x := pts[6];
dtmSubPoints[4].y := pts[7];

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

We could edit the first function to make the DTMs more customizable if need be.

Thoughts?

Ejjman

2010-04-17 12:57:31

That is perfect! With some cleaned up standards :p

I didn't know there was MSI_OUTLINE_BLACK, so that is switchable.


Thanks :)

Coh3n

2010-04-17 14:08:02

From: Ejjman1
That is perfect! With some cleaned up standards :p

I didn't know there was MSI_OUTLINE_BLACK, so that is switchable.


Thanks :)

There isn't an MSI_OUTLINE_BLACK, I was suggesting we add it. :) Unless, the srl_Outline_Black is the same, in which case we may has well use that.

E: I just read the rest of the first post and I think this should be added to ItemInfo.scar. With the shortened version, it's not going to be very long, so there's no harm in keeping it in one file.

Ejjman

2010-04-17 14:24:18

That seems reasonable.

We will also be adding a few more, but I don't think the size should increase *too much.

function MSI_GetDTMInfo(which: Integer): TIntegerArray;
begin
case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING:
case which of
LOGS_NORMAL..LOGS_YEW:
Result := [ 1155, 290, 1164, 281, 1164, 290, 1147, 294, 1143, 280 ];

HATCHET_BRONZE..HATCHET_RUNE:
Result := [blahblah];
end;
SKILL_MINING:
case which of
ORES_TIN..ORES_ADDY:
Result := [blahblah];
PICKAXE_BRONZE..PICKAXE..RUNE:
Result := [blahblah];
end;


else
MSI_Debug(...);
end;

else
MSI_Debug(...);
end;
end;

I can't think of any skills that have same DTMs currently. So that is probably the largest it'll get.

Coh3n

2010-04-17 14:27:01

Perfect! :) Make sure you add spaces in the cases. I know it's a little thing, but we need to keep everything consistent.


function MSI_GetDTMInfo(which: Integer): TIntegerArray;
begin
case PlayerSkills[CurrentPlayer][CurrentSkill] of
SKILL_WOODCUTTING:
case which of
LOGS_NORMAL..LOGS_YEW:
Result := [ 1155, 290, 1164, 281, 1164, 290, 1147, 294, 1143, 280 ];

HATCHET_BRONZE..HATCHET_RUNE:
Result := [blahblah];
end;

SKILL_MINING:
case which of
ORES_TIN..ORES_ADDY:
Result := [blahblah];

PICKAXE_BRONZE..PICKAXE..RUNE:
Result := [blahblah];
end;


else
MSI_Debug(...);
end;

else
MSI_Debug(...);
end;
end;

Nava2

2010-04-17 14:59:45

I still think you guys should use pDTMs for this..

They make manipulation much easier and cleaner.

http://wizzup.org/static/simba/doc/ps_handbook/node33.html

Coh3n

2010-04-17 15:04:01

From: Nava2
I still think you guys should use pDTMs for this..

They make manipulation much easier and cleaner.

http://wizzup.org/static/simba/doc/ps_handbook/node33.html

Didn't RM say that would break the SCAR compatibility?

Sir R. M8gic1an

2010-04-18 06:34:18

From: Nava2
I still think you guys should use pDTMs for this..

They make manipulation much easier and cleaner.

http://wizzup.org/static/simba/doc/ps_handbook/node33.html


Actually we could maybe import the type…. (not sure, need to think on it some more)

~RM

Nava2

2010-04-18 11:09:26

Just use a define for the type in SCAR.

Its already in Simba, so you would just have to write a wrapper for conversion between them, which is far from hard. (Or copy it from the MML Sauce)

e:

;)

Credit Wizzup/Ray
function pDTMToTDTM(Const DTM: pDTM): TDTM;

Var
Temp: TDTMPointDef;
I: Integer;

Begin
For I := 0 To 0 Do
Begin
Temp.X := DTM.p[i].x;
Temp.Y := DTM.p[i].y;
Temp.AreaSize := DTM.asz[i];
Temp.AreaShape := DTM.ash[i];
Temp.Color := DTM.c[i];
Temp.Tolerance := DTM.t[i];
End;
Result.MainPoint := Temp;
SetLength(Result.SubPoints, Length(DTM.p) - 1);

For I := 1 To DTM.l-1 Do
Begin
Temp.X := 0; Temp.Y := 0; Temp.AreaSize := 0; Temp.AreaShape := 0; Temp.Color := 0; Temp.Tolerance := 0;
Temp.X := DTM.p[i].x;
Temp.Y := DTM.p[i].y;
Temp.AreaSize := DTM.asz[i];
Temp.AreaShape := DTM.ash[i];
Temp.Color := DTM.c[i];
Temp.Tolerance := DTM.t[i];
Result.SubPoints[I - 1] := Temp;
End;
End;

{/\
Converts a TDTM to a pDTM.
/\}

function tDTMTopDTM(Const DTM: TDTM): pDTM;
var
I: Integer;
begin
Result.l := Length(DTM.SubPoints) + 1; //The mainpoint is in a different structure
SetLength(Result.p, Result.l);
SetLength(Result.c, Result.l);
SetLength(Result.t, Result.l);
SetLength(Result.asz, Result.l);
SetLength(Result.ash, Result.l);
SetLength(Result.bp, Result.l);

Result.p[0].x := DTM.MainPoint.x;
Result.p[0].y := DTM.MainPoint.y;
Result.c[0] := DTM.MainPoint.Color;
Result.t[0] := DTM.MainPoint.Tolerance;
Result.asz[0] := DTM.MainPoint.AreaSize;
Result.ash[0] := DTM.MainPoint.AreaShape;

For I := 1 To Result.l - 1 Do // High + 1 = Length
Begin
Result.p[I].x := DTM.SubPoints[I - 1].x;
Result.p[I].y := DTM.SubPoints[I - 1].y;
Result.c[I] := DTM.SubPoints[I - 1].Color;
Result.t[I] := DTM.SubPoints[I - 1].Tolerance;
Result.asz[I] := DTM.SubPoints[I - 1].AreaSize;
Result.ash[I] := DTM.SubPoints[I - 1].AreaShape;
End;

setlength(result.bp, result.l);
for i := 0 to result.l -1 do
result.bp[i] := false;
end;

You *probably* only need the second one..

Coh3n

2010-04-18 12:17:48

Is there something wrong with the way we're doing it? Or are you just saying it would be better to use a pDTM? If the latter, how come? I'm just curious.

Nava2

2010-04-18 14:21:01

Much cleaner, shorter, faster in Simba since the DTM algorithms do the conversion between pDTM and TDTM anyways.

Coh3n

2010-04-18 14:22:33

From: Nava2
Much cleaner, shorter, faster in Simba since the DTM algorithms do the conversion between pDTM and TDTM anyways.

Are there really any disadvantages? :p

Nava2

2010-04-18 14:25:38

You have to do the conversion for SCAR…

And define a new type/function.

Sir R. M8gic1an

2010-04-19 12:30:30

From: Nava2
Much cleaner, shorter, faster in Simba since the DTM algorithms do the conversion between pDTM and TDTM anyways.


Meh, I say we stick to DDTMs for now, maybe we'll converto to pDTMs later.

Lets get this ball rolling.

~RM

Nava2

2010-04-19 13:46:53

From: Rasta Magician
Meh, I say we stick to DDTMs for now, maybe we'll converto to pDTMs later.

Lets get this ball rolling.

~RM


I apologize that I'm not really a participating member, yet passing judgement; but what is the point in waiting to do the conversion when you have a better solution already available. Not to mention that Simba compatibility is a major part of the todo list.

Sir R. M8gic1an

2010-04-19 14:03:52

From: Nava2
I apologize that I'm not really a participating member, yet passing judgement; but what is the point in waiting to do the conversion when you have a better solution already available. Not to mention that Simba compatibility is a major part of the todo list.


MSI already IS Simba compatible.
As far as I know, DDTMs are Simba compatible, no?
Well, pDTMs are not Scar Compatible.

Finally, Coh3n, the advantage of pDTMs are NOT Points. (points the DDTM will disregard)

Nava, with all due respect, who are you to say what is major and what isn't in MSI ? Last time I checked that was the SLs job >.<

~RM

Wizzup?

2010-04-19 14:14:21

From: Rasta Magician
Meh, I say we stick to DDTMs for now, maybe we'll converto to pDTMs later.

Lets get this ball rolling.

~RM


Yeah, stick with TDTM if you want to keep SCAR compatibility. You can't use NOT points anyway in SCAR.

Nava2

2010-04-19 18:38:56

From: Rasta Magician
Nava, with all due respect, who are you to say what is major and what isn't in MSI ? Last time I checked that was the SLs job >.<

~RM


There was a reason why I pointed it out..

I was saying they should be used in replacing DTMs because of the simplicity of loading them is far superior to that of using TDTMDefPoints etc. It would merely involve setting of arrays and then moving on from there.

Not too tough, significantly cleaner than writing:
with dtmMainPoint do
begin
x := pts[0];
y := pts[1];
AreaSize := 0;
AreaShape := 0;
Color := MSI_Item[item].Colors[0];
Tolerance := MSI_Item[item].Tol;
end;

for i := 0 to High(dtmSubPoints) do
with dtmSubPoints[i] do
begin
AreaSize := 0;
AreaShape := 0;

if (i > 0) then
Color := 131072 //or MSI_OUTLINE_BLACK?
else
Color := MSI_Item[item].Colors[0];

Tolerance := MSI_Item[item].Tol;
end;

dtmSubPoints[1].x := pts[0];
dtmSubPoints[1].y := pts[1];

dtmSubPoints[2].x := pts[2];
dtmSubPoints[2].y := pts[3];

dtmSubPoints[3].x := pts[4];
dtmSubPoints[3].y := pts[5];

dtmSubPoints[4].x := pts[6];
dtmSubPoints[4].y := pts[7];

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

e:
I should have pointed out before, the reason for moving to pDTMs wouldn't be for not points as of yet. Would be a nice touch though, later on.

Sir R. M8gic1an

2010-04-19 18:49:31


var index: integer;
begin
index := 0;

with dtmMainPoint do
begin
x := pts[0];
y := pts[1];
AreaSize := 0;
AreaShape := 0;
Color := MSI_Item[item].Colors[0];
Tolerance := MSI_Item[item].Tol;
end;

for i := 0 to High(dtmSubPoints) do
with dtmSubPoints[i] do
begin
AreaSize := 0;
AreaShape := 0;

if (i > 0) then
begin
Color := MSI_OUTLINE_BLACK;

dtmSubPoints[i].x := pts[index];
dtmSubPoints[i].y := pts[index + 1] ;

IncEx(index, 2);

end else
Color := MSI_Item[item].Colors[0];

Tolerance := MSI_Item[item].Tol;
end;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

Seems simple enough..

Anyway, main point for not using them is scar compatibility.

~RM

Coh3n

2010-04-28 15:52:57

Committed. :)