SRL Archive - MSI Suggestions

LoadObjExperiences


Sir R. M8gic1an

2010-06-29 08:08:31

As I told Coh3n yesterday, I am currently unable to commit to the svn, (as I haven't yet set up everything I need for it on ubuntu).

So here's a little something to discuss / commit.


Function LoadObjExperiences(Objects: TIntegerArray): TExtendedArray;
var
i, e: integer;
begin
for i := 0 to High(Objects) do
begin

e := 0;
case Objects[i] of
{Trees}
OBJ_TREE_NORMAL : e := 25.0;
OBJ_TREE_OAK : e := 37.5;
OBJ_TREE_WILLOW : e := 67.5;
OBJ_TREE_MAPLE : e := 100.0;
OBJ_TREE_YEW : e := 175.0;
OBJ_TREE_MAGIC : e := 250.0;

{Rocks}
OBJ_ROCK_CLAY : e := 5.0;
OBJ_ROCK_TIN : e := 17.5;
OBJ_ROCK_COPPER : e := 17.5;
OBJ_ROCK_IRON : e := 35.0;
OBJ_ROCK_SILVER : e := 40.0;

else MSI_Debug('LoadObjExperiences', 'wrong object in ObjectConstants', DEBUG_FORCE);
end;

Result[i] := e;
end;
end;

function LoadItemNames(Items: TIntegerArray): TStringArray;
var
i: integer;
s: string;
begin
for i:= 0 to High(Items) do
begin

s := '';
case i of
ITEM_LOGS_NORMAL : s := 'Normal Logs';
ITEM_LOGS_OAK : s := 'Oak Logs';
ITEM_LOGS_WILLOW : s := 'Willow Logs';
ITEM_LOGS_MAPLE : s := 'Mapple Logs';
ITEM_LOGS_YEW : s := 'Yew Logs';

else MSI_Debug('LoadItemNames', 'wrong item in ItemConstants', DEBUG_FORCE);
end;

Result[i] := s;
end;
end;

I think we're better off having a centralized function, as it will allow for easier updating in the future, rather than going through all the script records and changing it.

And yes, I know that var e is not necessary there. Just looked better to me :p

This might need a change or two to work with everything else the way it currently is set up.

As for the string one, it forces consistency.

Basically, I find it 'stupid' that we'd be filling in the same thing over and over again, when we can just have a function do it for us.

~RM

Gu3st...

2010-06-29 16:30:19

FindXp.scar?

Sir R. M8gic1an

2010-06-29 19:48:00

From: Zyt3x
FindXp.scar?


Objects.scar?
Items.scar ?

~RM

i luffs yeww

2010-06-29 21:12:39

I think this would be fine. :) Good job.

Also, I haven't really thanked you for all the work you've been doing, so thanks a lot. :)

Coh3n

2010-06-29 22:06:44

Yeah I agree. When I was switching everything to script based I think I was trying to avoid adding functions, when I shouldn't have been. I'm glad you've looked through everything. :) Once I'm done work for this week, I'll be able to update everything and hopefully fix the weird bugs I've been having.

Having functions like this also would get rid of some issues I've had at the back of my mind, such as two skills that use the same item or something similar. This will also get rid of some attributes in our type records that don't necessarily fit (like the exp, for example).

marpis

2010-06-30 06:19:00

I don't think experience should be calculated with items/objects, but "actions performed".
Doesn't need script changes, but instead of thinking Integers[Logs] think Integers[Trees_cut]. This is a more logical approach when we have Integers[HighAlched], Integers[MapleLongsStrung], Integers[MudkipPouchesInfused].

How does that sound?

LoadObjExperiences -> LoadActionExperiences.
We could really use the same consts, like OBJ_TREE_OAK etc.

Coh3n

2010-06-30 06:21:26

From: marpis
I don't think experience should be calculated with items/objects, but "actions performed".
Doesn't need script changes, but instead of thinking Integers[Logs] think Integers[Trees_cut]. This is a more logical approach when we have Integers[HighAlched], Integers[MapleLongsStrung], Integers[MudkipPouchesInfused].

How does that sound?

LoadObjExperiences -> LoadActionExperiences.
We could really use the same consts, like OBJ_TREE_OAK etc.

So it'd be the exact same thing, just named differently? I know what you're saying though.

Coh3n

2010-07-03 22:46:26

Committed. :)

E: Oh, marpis, what I did was have it calculate the exp by item. Check out MSI_GetItemExperiences in ItemInfo.scar. It has a skill case to justify for fletching, woodcutting and firemaking for example.