Thread: Tweaking chests
View Single Post
  #1  
Old 01-15-2011, 12:05 AM
DarkScythe DarkScythe is offline
Registered Member
 
Join Date: Jan 2011
Posts: 13
Default Tweaking chests

Hello everyone,

I'm currently enjoying my first King's Bounty game (or any HoMM-type game, for that matter) with AP/Crossworlds, as I went for the $8.74 deal on Steam a couple weeks ago.

I have to say it's a lot better than I expected it to be, and I'm having quite a bit of fun. I started out as a mage on Normal difficulty, and quickly ran into the "everything is lethal/invincible" problem on Scarlet Wind, which was kind of fun having to really try to figure out how to beat those armies to advance. Ultimately though, after reading on these forums, it seems "easy" is better for a first-timer until I understand how the game itself works, so I've restarted on easy (I'll hopefully get back to my normal game at some point.)

In either case, I'm wondering if there is a way to mod the treasure chests in some way.
I don't want to modify all of them, but rather just the ones that appear in-battle when I use the dragon's treasure searcher ability. My problem is it seems there is far too much gold being pulled up. I have to wonder why gold is a valuable currency if it's that easy to dig up. If possible, I want to modify the chests so that it would drop straight gold less often (combined with all the gold-filled chests already on the world map, this makes me not want to waste time in-battle to go treasure hunting) but increase the chances of something like crystals (which sounds like a reasonably expensive item for pirates to hoarde.)

Unfortunately, I'm not entirely sure how to do this, or if it's even possible.

From some posts I've found here, it looks like boxes.lua inside ses.kfs contains the code that generates the items in the chests. (Specifically, this thread.)

If I'm reading the code correctly, it seems to roll for a random number up to 100, then subtract some value to find the condition when it becomes negative, then apply the condition that it's matched with.

For the purposes of testing a "proof of concept," I selected crystals for modification. I set all the numbers to 0 so that they would hopefully not trigger, then set crystals to the following:

Code:
 K = K - 101
  if K < 0 then
    local r = Boxgen.rnd(113)

    if r < 100 then
      Boxgen.parcount( "crystals", "10" )
    elseif r < 110 then
      Boxgen.parcount( "crystals", "20" )
    else
      Boxgen.parcount( "crystals", "30" )
    end

    return true
  end
I set it to subtract 101, thinking if the maximum value being rolled is 100, this would always force a negative, and thus always force this condition to activate. I also increased the crystals substantially so that I would know if the modification was being applied successfully or if the game simply ignored this file and gave me crystals based on the stock file instead.

Of course, this did not work. I don't even know if the game is executing this file or not. I've placed my modified boxes.lua file into ./sessions/orcs/mods since that's where I've placed the camera mod, and I'm playing the Orcs on the March campaign of Crossworlds/AP. I launched the game, went into a battle, and immediately told my dragon to dig up a chest. I then casted haste on a squad of griffins to fly over and open the chest. The chest yielded some gold, and then the game crashed to desktop.

I'm not sure what I'm doing wrong, but if possible I'd like some help with this. If, on the other hand, what I'm trying to accomplish is impossible, please let me know as well. Ultimately, if I can get a proof of concept working, I'll tweak the values much more thoroughly so as to try to not completely break the game.

I apologize for the long first post, and appreciate any responses and help.

Thanks.
Reply With Quote