[Weidu noob] Can this be done in Weidu and maybe code?
Vortaka
Member Posts: 173
Hi everyone! Been playing BGEE game (and all before, BG1, BG2, BGtutu) and I've messed with Near Infinity (took forever) so next time, I'd like to Weidu it!!! So, here's what I want to do!
Situation: Price of everything in my game is about 150% (rough time) and as I added items so that money is hard to come by... So I though of adding treasures (low gen) to all empty chests/crates/etc... To make it less grindy...
In BGEE, there are random item generators (RNDTRE01/etc) and I'd added then (took forever in NI) to each and every empty container... Next time, I want to Weidu it (lot faster). So, what I wanna do:
Weidu checks each and every ARE file... In those file, he checks if they have containers... If the containers are empty, it puts RNDTRE01 or RNDTRE02 in them (maybe a 50/50 chance?), then saves...
Can it be done? (By the way, I can "tweak" Weidu coding but I can't really code it... I mean, I'm like a weidu noob as stated in the title!)
Thanks for reading! If any questions (things you don't understand in my "unclear" message) just reply!
Thanks!!!
Vortaka
@Arunsun thanks! P.S. If you read this before posting, could you add some info the code? (I mean // things... So that I can understand a little more... I'm a tech but not that great of a modder I fear!)
Situation: Price of everything in my game is about 150% (rough time) and as I added items so that money is hard to come by... So I though of adding treasures (low gen) to all empty chests/crates/etc... To make it less grindy...
In BGEE, there are random item generators (RNDTRE01/etc) and I'd added then (took forever in NI) to each and every empty container... Next time, I want to Weidu it (lot faster). So, what I wanna do:
Weidu checks each and every ARE file... In those file, he checks if they have containers... If the containers are empty, it puts RNDTRE01 or RNDTRE02 in them (maybe a 50/50 chance?), then saves...
Can it be done? (By the way, I can "tweak" Weidu coding but I can't really code it... I mean, I'm like a weidu noob as stated in the title!)
Thanks for reading! If any questions (things you don't understand in my "unclear" message) just reply!
Thanks!!!
Vortaka
@Arunsun thanks! P.S. If you read this before posting, could you add some info the code? (I mean // things... So that I can understand a little more... I'm a tech but not that great of a modder I fear!)
Post edited by Vortaka on
0
Comments
COPY_EXISTING_REGEXP ~.*\.ARE~ ~override~ READ_BYTE 0x74 "#containers" READ_LONG 0x70 "containeroffset" WHILE ("%#containers%" > 0) BEGIN READ_BYTE ("%containeroffset%" + ("%#containers%" - 1) * 0xC0 + 0x44) "#items" SET "rand" = RANDOM( 1 2 ) PATCH_IF ( ("%#items%" = 0) AND ("%rand%" = 1) ) BEGIN LPF ADD_AREA_ITEM INT_VAR container_to_add_to = "%#containers%" STR_VAR item_to_add = RNDTRE01 END END PATCH_IF ( ("%#items%" = 0) AND ("%rand%" = 2) ) BEGIN LPF ADD_AREA_ITEM INT_VAR container_to_add_to = "%#containers%" STR_VAR item_to_add = RNDTRE02 END END SET "#containers"= ("%#containers%" - 1) END IF_EVAL ("%#containers%" > 0)
Code explanation:
[spoiler]
I'll take the code line by line here so that you may understand how to solve the problem:
This will copy every area that needs patching to the override folder, but only if their number of containers is above 0.
For each area we will need the number of containers within them, as well as the hexadecimal offset of the containers.
This loop is where everything happens. We'll go through each container here starting with the last one. We ensure that next time we enter the loop we will check the next container, and that the loop will end by decrementing the #containers variable everytime we get through one instance of the loop We want to check the number of items in the container we are currently inspecting. This can be found at
("%containeroffset%" + ("%#containers%" - 1) * 0xC0 + 0x44)
The first term is where the containers block begins.
The second term is the length of a container block times the number of the container we are currently inspecting.
The last term is the internal offset of the number of items, within a container block.
Lastly, this is where the actual patch happens:
We set a variable to a random value that's either 1 or 2, and then either the number of items is not 0 and then both PATCH_IF blocks are ignored, or it is 0 and then one of the two blocks is executed and the other is ignored, based on the random value that was determined earlier.
Within each PATCH_IF block is a patch function that adds an item to a container.
[/spoiler]
I'll probably release it as a mod (or if you wanna do it, go ahead) when I have the time to do it! It works great!
P.S. You'll have special thanks in it, of course! It will be called (my folder is already ready) RNDNEC (Random Nomore Empty Containers). I think I'll work on all EE games (cannot test) so I might put it in General Modding...
P.P.S. I know, it should be "No More", but it doesn't look good enough!!!
(UUrrgg... I've just looked at my override folder and it seems it originally took me about 3 hours time to mod it manually... I think 30 seconds or even 1 minute is ok, mind you! Think, I even made a AutoHotKey script so that instead of taking me 1 minutes or so a file, I could do 3 files a minute... Weidu is great, is it not?)