Wednesday, 8 June 2011

Dealing with obsessive campers - Part II advanced

IMPORTANT NOTE: This article is intended for advanced users who can edit the program code of a mod. If you don't feel comfortable using a text editor to edit a mod then don't try this!


I'm an old C programmer so while I don't know lua well enough to write a mod from scratch it is a simple language making it trivial to edit a mod to calculate prices differently. I use TSM (TradeSkillMaster) and I make 2 modifications in post.lua.

The first change is really simple. All it does is change the way TSM's "maximum price" setting percentage is used. It compares the current lowest buyout price to fallback price * maximum price percentage. Adjust the "maximum price" setting to determine what percentage you want to multiply fallback by.

If the current price is greater than than fallback * maximum then it posts at fallback * maximum.  If the current price is greater than fallback but less than fallback * maximum then it just posts at fallback.

This is extremely useful for quickly yanking prices back into a sane range when someone tries to buy it all out and jack prices up insanely high. Of course he'll be camping hardcore until prices get back to normal. This ensures they get back to normal quickly.

So for example if your fallback is 100g, maximum price is set at 200% and the current price is over 200g, it'll post at 200g, if the price is over 100g but 200g or less, it'll post at 100g. If the price is 100g or less it will calculate undercuts as normal.

Just after line 405 in post.lua you'll find a code snippet something like this

-- Check if we're posting something too high
if buyout > (fallback * TSMAuc.Config:GetConfigValue(itemID, "fallbackCap")) then
buyout = fallback
fallbackCap = true
end

Cut that code out and replace it with this.

-- Check if we're posting something too high
if buyout > (fallback * TSMAuc.Config:GetConfigValue(itemID, "fallbackCap")) then
buyout = (fallback * TSMAuc.Config:GetConfigValue(itemID, "fallbackCap"))
fallbackCap = true
elseif buyout > fallback then
buyout = fallback
fallbackCap = true
end


The second change doesn't replace any code, it simply adds a new bit of code that changes the price calculation. ANY undercut value of 50c or less is considered to be a PERCENTAGE. This bit of code calculates the difference between the current lowest price and your threshold, then undercuts by 1-50% of that. The higher the current price is the bigger the undercuts will be but they'll get progressively smaller and smaller as the price approaches threshold. Set the bid to 1-50c to adjust just how aggressively it undercuts and therefore how quickly it brings prices down. If you use this edit too, make sure it goes directly above the first edit or it won't work correctly.

Note: I don't recommend using the second change with a blacklist. If there are any names on your blacklist it could cause you to post extremely low since TSM ignores thresholds for blacklisted names.

  -- Do percentage undercuts as a percentage of the difference between the
  -- current lowest price and our threshold using undercut settings less than 50c as 1-50%
if lowestBuyout > threshold then
  local tempp = TSMAuc.Config:GetConfigValue(itemID, "undercut")
  if tempp <= 50 then
    -- consider an undercut of 0c to be 10% and prevent divide by 0 errors
    if tempp < 1 then
        tempp = 10
      end
      buyout = lowestBuyout - ((lowestBuyout - threshold)/(100/tempp))
  end
  -- do nothing, the undercut setting was a real undercut value not a percentage
  end

No comments:

Post a Comment