Facebook MobWars Helper

By Piotr P. Karwasz Last update Dec 23, 2008 — Installed 91,001 times.

Updates made to Mob Wars: The reason of the Inventory script problem

in
Subscribe to Updates made to Mob Wars: The reason of the Inventory script problem 8 posts, 6 voices



XxXavier User

Read a while ago on the Mob Wars main page about the following updates:

"==UPDATES==
11/18/2008.2
Launched drop items! Right now it's pretty hard to get them. I wanted to start out making them hard to get vs. easier to be safe. Will tweak as I watch the impact on the game.

11/18/2008.1
Phase 1: Launched changes to jobs page to accommodate drop items. Yes I know, no items are there yet!

11/16/2008
New updates coming this week: Drop Items... Drop items are special items that you'll only get a random % of the time. They won't be easy to get! Think missions to acquire special weapons to give you that extra edge in battle. These additions will bring jobs back into the game, and provide a more dynamic weapon set to fight with. This is going to be a BETA launch, so bear with any bugs or problems! I will launch as soon as you guys have gotten a chance to discuss this on the boards. Once I have the green light it will be launched!"

So it seems this is what is causing the script to go into error. Hope this can be of help so the script can be fixed.

 
TheDruidsKeeper Scriptwright

I've been looking extensively into the problem, but it looks like the changes that have been made are only part of the changes that will be done over the next few days / weeks. I made a fix that seems to work for now (although it is not a permanent fix), it will at least not have errors, and it will continue to do prep jobs. Here it is:

Look for this code:

result = str.match(/Energy: (\d+).*\(\+(\d+)\)/);
item.energy_per_unit = result[1] / result[2];

and change it to this:

result = str.match(/Energy: (\d+).*\(\+(\d+)\)/);
if (result != null)
item.energy_per_unit = result[1] / result[2];
else
item.energy_per_unit = 15;

Basically since it is not able to find the required energy for the prep jobs it has been giving errors, so with this fix it will set the prep job energy to 15 instead. Sorry this isn't a full fix, but I don't feel like doing one when I think it will change anyway.

Note: I changed a lot of things in this process, so if this doesn't fix it right I'll try and remember what else I did.

 
ThePCMan User

Nice one 'TheDruidsKeeper' that works fine for me. Looking forward to the real fix. This script is a godsend to as i'm away a lot.

 
Pea Cracker Scriptwright

As mentioned already, the drop items are being "looked through" by the script thinking that they are prep items, but not, though they share the item_## naming convention. Through my own level I can see 6 things being scanned through: item_57, item_58, item_59, item_39, item_35 and item_34; the first 3 are % drop items and the latter 3 are prep items. I think the root of our issue is that the current script relies on the naming convention to detect prep items, which gives false positives. I would recommend slicing the entire "app8743457343_content" div into two pieces, first piece being "The Job List" and second piece being "Job Prep", as the game already has tags and sections set up that way. Then dig ONLY through the second section for those with the item_## naming convention for calculating the item.energy_per_unit;

By the way, I believe result = str.match(/Energy: (\d+).*\(\+(\d+)\)/); attempts to get 2 values, 1 right after Energy:  and 1 inside a pair of parenthesis, together with & prefixed by a + -- this part of the codes is trying to calculate "energy per unit [of the item]", or shall we say, prep items.

However, from the data captures I got, it seems that the unit values of the prep items are a few levels deeper situated than those in the Job List. So the current codes are only able to find Energy for the prep items (while nothing for the non-prep items as they do not have either). And I'm not sure if that regex can match if the two values are positioned backward (unit first then energy)

In short, I recommend to list just prep items, dig thru correct level, & check the regex match.

 
TheDruidsKeeper Scriptwright

Here is the rest of the fix. They changed the layout of the prep items, so the script cant find how many of the prep items you have, which is why it doesn't seem to be doing the prep job before doing the actual job.

Look for this text: "Update the number of items that we have"
A few lines below that you will see this line:

var div = divs[i].parentNode.parentNode;

and insert these lines below it:

var isPrepJob = div.innerHTML.match(/dojob/);
if (Page.c_page == 'jobs' && isPrepJob == null) div = divs[i].parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;

 
Pea Cracker Scriptwright

I've posted my solutions to revise the script in a new thread: http://userscripts.org/topics/18142

 
Chrisos User

I've posted my fixed version of the script in a new thread: http://userscripts.org/topics/18139

 
Kemm User

looks like TheDruidsKeeper's solution works just fine for me at the moment. tweaked script from Chrisos seems to have a problem on my computer its always "resting". not sure what went wrong. i'm not an expert anyway ;) but thanks to TheDruidsKeeper and Chrisos and Pea Cracker and all the others for helping us out.

This is a great script.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel