View Full Version : Quick Question About Inventory Management
skidude6200
03-01-2012, 04:39 PM
Hey everyone,
I'm in the beginning stages of scripting and need to know a bit about inventory management. I'm currently working on an impling catcher that works within the confines of the Al-Kharid resource dungeon.
Lets say that I wanted to be able to loot the less valuable jars within the dungeon and drop whatever was inside (you can't just release the imp without getting the drop as this results in destroying the jar) to prolong trips. The only way I can think of to make this work is to create 100+ DTMs, one for each possible loot in the lower-level jars. Other than being rather time consuming, would this actually work? Alternatively, is there a way to drop everything in the inventory that doesn't match one of my pre-defined DTMs?
Any help you can give would be great.
masterBB
03-01-2012, 04:42 PM
Hey everyone,
I'm in the beginning stages of scripting and need to know a bit about inventory management. I'm currently working on an impling catcher that works within the confines of the Al-Kharid resource dungeon.
Lets say that I wanted to be able to loot the less valuable jars within the dungeon and drop whatever was inside (you can't just release the imp without getting the drop as this results in destroying the jar) to prolong trips. The only way I can think of to make this work is to create 100+ DTMs, one for each possible loot in the lower-level jars. Other than being rather time consuming, would this actually work? Alternatively, is there a way to drop everything in the inventory that doesn't match one of my pre-defined DTMs?
Any help you can give would be great.
Yes that is possible, you can also do a uptext check of every item in your inventory. But if you want to use DTMs, just loop through your inventory, slot by slot, and if not recognized drop it.
Kyle Undefined
03-01-2012, 04:52 PM
No need for that many DTMs, just create one for the Jar and loop through the slots, if the jar isn't in that slot and there's an item in there, drop it. Much easier.
skidude6200
03-01-2012, 04:53 PM
The reason I was thinking of doing individual DTMs is that it would recognize junk without the need for constant inventory cycling. Could I have 100 DTMs set without performance issues? If I used individual functions for each type of jar I'd only need to search for about 10-20 in the same procedure if that makes a difference.
Kyle Undefined
03-01-2012, 04:56 PM
You would only need to check the inventory after you loot the jar, so it wouldn't be constant, and 100 DTMs is way too many.
skidude6200
03-01-2012, 04:58 PM
I guess that does make more sense. I know that with uptext cycling the mouse would actually be engaged going slot to slot... If the client was searching for an item that wasn't a jar it could do so without mouse movement correct?
masterBB
03-01-2012, 04:59 PM
I'm writing an example.
Kyle Undefined
03-01-2012, 05:03 PM
It would work like so:
procedure ScanInv();
var
i, x, y, DTM : Integer;
invB : TBox;
begin
DTM := DTMFromString('');
for i := 1 to 28 do
begin
invB := InvBox(i);
if(ExistsItem(i))then
begin
if(not(FindDTM(DTM, x, y, invB.X1, invB.Y1, invB.X2, invB.Y2)))then
DropItem(i);
end;
end;
FreeDTM(DTM);
end;
skidude6200
03-01-2012, 05:06 PM
Awesome, thanks a lot :)
masterBB
03-01-2012, 05:06 PM
function loadAllTheDTMs:Array of Integer;
begin
setLength(Result,3);
Result[0] := DTMFromString('aegaaeg');
Result[1] := DTMFromString('aegaaeg');
Result[2] := DTMFromString('aegaaeg');
end;
procedure freeAllTheDtms(AllTheDTMs:Array of Integer);
var
i,hi:Integer;
begin
hi := High(AllTheDTMs);
for i := 0 to hi do
FreeDTM(AllTheDTMs[i]);
end;
procedure CheckInv;
var
i,x,y:Integer;
AllTheDTMs:Array of Integer;
begin
loadAllTheDTMs;
for i := 1 to 28 do
begin
invB := InvBox(i);
if(ExistsItem(i))then
begin
if(not(FindDTM(AllTheDTMs[i], x, y, invB.X1, invB.Y1, invB.X2, invB.Y2)))then
DropItem(i);
end;
end;
freeAllTheDtms;
end;
skidude6200
03-01-2012, 05:07 PM
Hah, master's code answered my next question before I could ask it ;)
Thanks again guys.
Kyle Undefined
03-01-2012, 05:09 PM
Haha, master, our code is almost the same :p
masterBB
03-01-2012, 05:09 PM
Hah, master's code answered my next question before I could ask it ;)
Thanks again guys.
I can watch in the future :P.
But I posted wrong code, fixed:
program CheckForThoseJars;
function loadAllTheDTMs:Array of Integer;
begin
setLength(Result,3);
Result[0] := DTMFromString('aegaaeg');
Result[1] := DTMFromString('aegaaeg');
Result[2] := DTMFromString('aegaaeg');
end;
procedure freeAllTheDtms(AllTheDTMs:Array of Integer);
var
i,hi:Integer;
begin
hi := High(AllTheDTMs);
for i := 0 to hi do
FreeDTM(AllTheDTMs[i]);
end;
procedure CheckInv;
var
i,j,x,y,hi:Integer;
AllTheDTMs:Array of Integer;
begin
AllTheDTMs := loadAllTheDTMs;
hi := High(AllTheDTMs);
for i := 1 to 28 do
begin
invB := InvBox(i);
if(ExistsItem(i))then
begin
for j := 0 to hi do
if(not(FindDTM(AllTheDTMs[j], x, y, invB.X1, invB.Y1, invB.X2, invB.Y2)))then
DropItem(i);
end;
end;
freeAllTheDtms(AllTheDTMs);
end;
Kyle Undefined
03-01-2012, 05:11 PM
master, you forgot something ;)
AllTheDTMs := loadAllTheDTMs;
hi := High(AllTheDTMs);
masterBB
03-01-2012, 05:11 PM
master, you forgot something ;)
AllTheDTMs := loadAllTheDTMs;
hi := High(AllTheDTMs);
Let's hope no one sees it :P
I'm sleeping :P
Kyle Undefined
03-01-2012, 05:13 PM
Haha, one more thing :p
freeAllTheDtms(AllTheDTMs);
masterBB
03-01-2012, 05:14 PM
Haha, one more thing :p
freeAllTheDtms(AllTheDTMs);
I ninja'd you, check the last edit time :P
Kyle Undefined
03-01-2012, 05:15 PM
Haha, nice. :D
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.