Issue with AntiRandoms
Flight
2011-04-18 07:37:31
So I was testing my new gold bar-smelting script and I encountered the 'ScapeRune' random, the one were you're on an island and you must grab a fishing net and fish a certain fish to solve the event.
The problem is, in my script I always have a full inventory of ores, and as I watched Smart to try solve the event it ignored the fact I had a full inventory and tried grabbing a net on the ground, over and over… This is just one example, as there are 4 randoms that require obtaining items.
The solution:
Pretty simple actually, as far as I'm aware all 4 of these certain random events have deposit boxes (correct me if I'm wrong), so why not at the beginning of the random event (if it falls into the category of these 4) detect if your inventory is full, if so then 'Deposit All' with the exception of global 'tools' your character might have in their inventory (if any). Such as fishing tools/bait, pickaxes, hatchets, chisels, jewelry molds, knives, ect… There's probably more but those would be the majority. This way you free up room to solve the random, and when it's solved and returned to your previous location, you still have your tools in your inventory to carry on where you left off.
Maybe it's not been mentioned before because there's not too many scripts that require a full inventory, but for the scripts that do, it's a pretty big problem, luckily it's a very simple fix.
HarryJames
2011-04-18 07:43:49
Flight, instead of depositing all, why not have these items declared in the player form?
As cooked food might be from fighting, or from a cooker. The first one it's definately needed, but for the latter it's conveniant.
Just adding my 50p.
Flight
2011-04-18 07:52:19
Yeah cooked food would be another example, and it's not a tool. But then again you'd still have to deposit a certain amount of that food depending on the random event, so you could make the antirandom detect if you have a full inventory of just food, and deposit just a small amount rather than all. Defining items 'not' to deposit in such random events I think would be over-doing it, because tools you'd always want to keep, but everything else can just be deposited, the only exception to this is, like you said, food.
HarryJames
2011-04-18 07:55:21
Surely essence would count too, for a RC script?
Flight
2011-04-18 07:58:49
That's why fail-safes are so important and encouraged so much in all scripts.
if (R_CountItem(ItemID) < NumNeeded) then
ReturnToBank;
That's what gives our scripts long lasting endurance.
Yeah I think in some reflection solvers it actually tries to bank though. I was watching a scaperune random once and in the debug it attempted to bank but failed…
Harry
2011-04-18 14:36:55
Some bank, some don't. It's a tricky situation; "are the items you are banking required for script operation, or just raw materials you are planning on banking"?
From: Harry
Some bank, some don't. It's a tricky situation; "are the items you are banking required for script operation, or just raw materials you are planning on banking"?
I second the opinion that there should be an option in player form or somewhere else asking what to bank…
Flight
2011-04-18 21:18:55
Yeah if you read the previous posts we've already gone over possible solutions for this, player definitions is one of them.
Coh3n
2011-04-19 01:56:27
Yeah this has happened to me before. I think I reported it in the reflection randoms thread. I like the idea of having users set what items to deposit (or the scripter). I don't really see any other solution that would work like that. Perhaps have it deposit all if it's not set, so it will at least solve the random?
Flight
2011-04-19 02:00:21
Yeah by default it should deposit all, also if the player's defines aren't set. Like you said, solving the random is priority #1, because until it's solved your script is, as of that point, stopped, and it would probably throw up 'botting' flags.
Coh3n
2011-04-19 02:08:09
From: Flight
Yeah by default it should deposit all, also if the player's defines aren't set. Like you said, solving the random is priority #1, because until it's solved your script is, as of that point, stopped, and it would probably throw up 'botting' flags.
I think you can set SRL_Proc[srl_OnRandomsCall] to a procedure that handles this. It's just testing that will be difficult.
Smartzkid
2011-04-19 02:36:50
Rather than depositing all, you should just deposit the last row or two of the inv. Why? Most scripts keep tools at the top, and once the random is solved, the script should be able to finish whatever it was doing. Best of both worlds.
Flight
2011-04-19 02:43:45
That's a good idea, but I think just to be safe it should be the last inventory row + 1 extra item. (As you need 5 spaces available for the GraveYard random event).
WT-Fakawi
2011-04-19 03:04:35
If you have 27 ores in your invent, or 20 logs or 12 fish, you could easily drops those, no? Because I'd be very upset if a script would deposit all. It would screw my scripts bigtime, since I don't check if I still have my stuff.
Flight
2011-04-19 03:32:45
Yeah like I mentioned before, essential items should always be kept while depositing all. Infact, it might be a better approach to deposit just 1-5 items (depending on the random event) and keep as many with you as possible. Defining which items to keep as a player define, or whatever, would work just fine, would it not?
Edit: How about we count the items of each type when we enter the random event, and the item id that we have the most of will be deposited? (1-5, or all) This keeps the single important items, but the common items wouldn't have such an impact when deposited.
Is still think you should choose what to deposit. What if there was that one odd script that had cash and weapons on the bottom?
Or maybe it should deposit what it detects multiple of… Idk.
Coh3n
2011-04-19 14:25:56
From: Yago
Is still think you should choose what to deposit. What if there was that one odd script that had cash and weapons on the bottom?
Or maybe it should deposit what it detects multiple of… Idk.
Yeah it should be set. I think they were talking about what to do if the scipter/user didn't set which items to deposit.
Smartzkid
2011-04-19 15:20:30
I like Flight's idea. The scripter should be able to set items that are 'safe' to deposit. If this is not set, deposit the item that is most prevalent in the inventory.
Pretty safe way to go, IMO.
Flight
2011-05-08 06:00:05
I made this small function for getting a common item in your inventory. (Note: Reflection only ;))
{*******************************************************************************
Funtion R_GetCommonItemID
By: Flight
Description: Gets the item in your inventory with
a count higher or equal-to 'Amount',
returns the items ID.
*******************************************************************************}
Function R_GetCommonItemID(Amount: integer): integer;
var
i,ID : Integer;
begin
for i := 1 to 28 do
begin
if (R_ItemSlotExists(i)) then
begin
if (GetItemIDAt(i) > 0) then
begin
ID := GetItemIDAt(i);
if (R_CountItem(ID) >= Amount) then
Result := ID;
end;
end;
end;
end;
I tested it with "R_GetCommonItemID(5)", 5 being the largest number of spaces we need for any event, so it'd be wise to count somewhere around that number.
I figure at the beginning of a Random Event that requires inventory space, we check if our inventory is full, then use this to get out common item ID and deposit however many of that item we need to finish that Event and then go from there.
Any ideas on that?
From: Flight
I made this small function for getting a common item in your inventory. (Note: Reflection only ;))
{*******************************************************************************
Funtion R_GetCommonItemID
By: Flight
Description: Gets the item in your inventory with
a count higher or equal-to 'Amount',
returns the items ID.
*******************************************************************************}
Function R_GetCommonItemID(Amount: integer): integer;
var
i,ID : Integer;
begin
for i := 1 to 28 do
begin
if (R_ItemSlotExists(i)) then
begin
if (GetItemIDAt(i) > 0) then
begin
ID := GetItemIDAt(i);
if (R_CountItem(ID) >= Amount) then
Result := ID;
end;
end;
end;
end;
I tested it with "R_GetCommonItemID(5)", 5 being the largest number of spaces we need for any event, so it'd be wise to count somewhere around that number.
I figure at the beginning of a Random Event that requires inventory space, we check if our inventory is full, then use this to get out common item ID and deposit however many of that item we need to finish that Event and then go from there.
Any ideas on that?
Create function R_MostCommonItemInInventory :P
~Home
Flight
2011-05-08 07:01:10
I couldn't figure out how to sort each item by how many slots they appear in. Maybe it's still out of my ability. :(
Bixby Sayz
2011-05-08 11:17:48
From: Coh3n
I think you can set SRL_Proc[srl_OnRandomsCall] to a procedure that handles this. It's just testing that will be difficult.
I played around with this. Unfortunately it gets called
after the random solving attempt, not while you are in the random.
Coh3n
2011-05-08 11:36:08
From: Bixby Sayz
I played around with this. Unfortunately it gets called after the random solving attempt, not while you are in the random.
Could always add srl_Proc[OnRandomDetect] to be called when a random is detected. May not be necessary though if an alternative is made.