While nowadays we are able to define who is a merchant, and set some properties for them, we still have the fundamental problem that merchants require a profile (for face data, speech files, and other shenanigans). As the number of profiles is fairly limited (this might change in the future), and setting up a profile requires, well, face images, speech files etc., setting up new merchants is close to undoable.
However, there are many instances where more trade opportunities would be good:
When playing with the food feature, one surprisingly needs food. The main source of that is stores. This sucks if you're in a part of the country that doesn't have any.
On a smaller scale, at least in the very beginning, the AI carries almost no LBE. Stock 1.13 gear kits are very limited in that regard, which can leave you with gear, but no way to carry it. You need a way to buy at least basic LBE.
Quite often, there are very basic items (canteens, first aid kits, any kind of knife) that you'd reasonably expect to get very easy, but actually have no way of obtaining until the enemy cares to drop one.
In many maps, there are stores, with ware on display, and even counters - but there's nobody to trade with.
I've decided to change this. With this feature, we are now able to place civilians without a profile that nevertheless are fully functional merchants. This should ease the above problems tremendously.
These civilians are placed via lua, with the same (now expanded) function already used here in Scripts/strategicmap.lua in HandleSectorTacticalEntry():
-- this function is called whenever we enter a sector in tactical
function HandleSectorTacticalEntry( sSectorX, sSectorY, bSectorZ, fHasEverBeenPlayerControlled )
...
-- Flugente: if this sector has not yet been liberated by the player, there might be some civilian enemy personnel here
-- the idea is that these people are government employed, and won't stay around once you take the sector
-- parameters of CreateCivilian:
-- - tile where person should be created on the map
-- - civilian group they should belong to (see also CivGRoupNames.xml)
-- - number of the merchant the civilian should be (-1 for no merchant)
-- - bodytype
-- - vest colour (-1 for random)
-- - pants colour (-1 for random)
-- - hair colour (-1 for random)
-- - skin colour (-1 for random)
-- - optional item 1 (-1 for nothing)
-- - optional item 2 (-1 for nothing)
-- - optional item 3 (-1 for nothing)
-- - optional item 4 (-1 for nothing
...
elseif ( bSectorZ == 1 ) then
-- We spawn a rebel 'quartermaster' in the rebel basement. He doesn't have much to offer, and it isn't exactly quality ware, but better than nothing
if ( sSectorX == 10 and sSectorY == SectorY.MAP_ROW_A) then
CreateCivilian(11433, CivGroup.REBEL_CIV_GROUP, 40, Bodytype.CRIPPLECIV, Vest.BROWNVEST, Pants.GREENPANTS, Hair.WHITEHEAD, -1, 711, 545, 545, -1)
end
...
In this example, I've decided that while Miguel's rebels are in a dire situation, they must have some gear left, which you could buy for a modest price:
This isn't exactly high class stuff, but a chance to stock up on desperately needed resources.
There are quite a few other shops:
Drassen now has a general store. Not exactly fancy, but now you actually have a chance to get a knife in case you were unlucky earlier.
No there's a store in Alma too. Note that there are 2 staff inside - but both use the same shop inventory.
As there are pharmacies elsewhere, you don't have to fight through to Balime to get much needed medical supplies.
This Meduna store sells unneeded items for unreasonable prices. The people love it!
This San Mona store (controlled by Kingpin) sells hunting equipment - shotgun equipment and camo-related stuff (no military-grade weaponry. But you know where to get that in San Mona anyway.).
If you ever want to fortify a sector, this store will be tremendously useful. Fortification-based items are on sale here, which means you don't have to order everything from Bobby Rays all the time.
Of course, there are also completely different kinds of shops - a dealer has set up shop in the ruins of the university.
Shops can also be set up outside of towns. In this case, there's a small takeout at the Balime gas station.
Note that merchants refuse to trade with you during combat.
If a merchant doesn't trust you enough, they refuse to trade with you. This can be set for every individual merchant.
And this is how it works in action.
There is only one required ini setting in Ja2_Options.ini:
...
;------------------------------------------------------------------------------------------------------------------------------
; Default: FALSE
; Additional civilians can be placed in maps via Lua scripts, see Scripts/strategicmap.lua: HandleSectorTacticalEntry()
; It is also possible to place new merchants (that don't require a NPC profile) this way, see the same file
;------------------------------------------------------------------------------------------------------------------------------
ALLOW_EXTRA_CIVILIANS = FALSE
; Allow placing of new merchants
; Note: this requires ALLOW_EXTRA_CIVILIANS to be TRUE
ALLOW_EXTRA_MERCHANTS = FALSE
...
There is one new optional tag in Merchants.xml:
<MERCHANTSLIST>
<MERCHANT>
<uiIndex>0</uiIndex> <-- index of merchant
<szName>Tony</szName> <-- name of merchant (orientation purpose only ;-) )
<dBuyModifier>0.75</dBuyModifier> <-- buy cost modifier (speed modifier for repairguys)
<dSellModifier>1.25</dSellModifier> <-- sell cost modifier (repair cost modifier for repairguys)
<ubShopKeeperID>91</ubShopKeeperID> <-- ID of this NPC. Relevant values are on top of xml
<ubTypeOfArmsDealer>0</ubTypeOfArmsDealer> <-- 0: buy/sell 1: sell only 2: buy only 3: repair
<iInitialCash>15000</iInitialCash> <-- cash at begin of game
<uiFlags>1342177280</uiFlags> <-- behaviour flags, explanation below...
<dailyIncrement>15000</dailyIncrement> <-- add this amount of money every day
<dailyMaximum>15000</dailyMaximum> <-- maximum cash every day
<dailyRetained>0</dailyRetained> <-- we can carry this amount of money to the enxt day
<minCoolness>1</minCoolness> <-- min coolness for our stock
<maxCoolness>10</maxCoolness> <-- max coolness for our stock
<addToCoolness>1</addToCoolness>
<coolnessProgressRate>10</coolnessProgressRate>
<daysDelayMin>2</daysDelayMin>
<daysDelayMax>3</daysDelayMax>
<useBRSetting>0</useBRSetting> <-- use BR settings?
<allInventoryAlwaysAvailable>0</allInventoryAlwaysAvailable> <-- is all inventory always available?
<nonprofile_loyaltyrequired>30</nonprofile_loyaltyrequired> <-- required town loyalty if this is a non-profile based merchant (ubShopKeeperID 200) in a town
</MERCHANT>
...
</MERCHANTSLIST>
<loyaltyrequired> simply sets the required town loyalty, below that the merchant wont trade with you. However, spies can circumvent that check: As no sane arulcan merchant would ever refuse business with the army, anyone successfully disguised as a soldier can trade with them, town loyalty non-regarding. This effectively allows your spies to go on a shopping spree while infiltrating Meduna. Any operation that requires infiltrating an evil dictator's stronghold to buy a new overpriced wristwatch seems like a win to me.
If a merchant is killed, they drop their merchandise, but his/her shop closes indefinitely. Thereby you cannot kill the same store owner over and over to get more stuff.
Multiple merchants can be assigned to the same store,even in different maps. They share the inventory etc. Think of the person standing in the store merely being a 'mountpoint' to a store
This would also allow you to place, say, a merchant in your HQ that conveniently brings up another merchant's store.
That method also allows effectively creating an instant delivery system: Set up 2 merchants in 2 different towns for the same store, sell items in town A, instantly buy them back in town B. Not that I use that, but this is easily possible.
Apart from the entire store business, merchants are normal civilians. As seen in the above video, they can fight back (if properly equipped and set up).
If you want specific conditions for a merchant to appear, set them up in the lua file. For example, the stores in San Mona are all owned by Kingpin, and won't open if he's dead or hostile.
I've expanded the possible number of extra merchants from 20 to 60 (thus the huge number of files in TableData/NPCInventory. I also changed the loading routine - if a file is missing, the game won't crash anymore (the shop simply won't have anything).
The new merchants start at merchant slot 40, which refers to AdditionalDealer_21_Inventory.xml. slot 41 refers to AdditionalDealer_22_Inventory.xml and so on.
You can also set up a repair shop. Haven't done that in stock, but works like Perko, Arnie an Fredo do.
There are 28 new shops in Arulco. I'm not telling you where all of them are - have fun exploring (or just look it up in the xmls/lua script). Rule of thumb: if it looks like a shop, it probably is.
This feature can be turned on and off via ALLOW_EXTRA_CIVILIANS and ALLOW_EXTRA_MERCHANTS in Ja2_Options.ini and is set to be off by default.
This is savegame compatible.
This has been added to the trunk in r8212 & GameDir r2320. Using the new exe without the new GameDir is a silly thing. Why would you do that? WHY?
[Updated on: Sun, 15 May 2016 19:57]
I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.
If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.
Nice. Could the merchant character model be easily drawn at the portrait area in the trading interface aka Fallout 1/2 style?
No savegame (just before e bug occurs), no cure.
'Not everything that counts can b counted, n not everything that can b counted counts' - Albert Einstein
I may answer/reply in my old public posts & prefer PM over e former[FUDforum's PM suxx]
we only have those pictures (with all vest/pants/skin/hair combinations) for the merc bodytypes, not for the civilian ones. Which is bad, as quite a few traders use civilian bodytypes. I asked for those to be drawn years ago, but nobody wanted to.
I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.
If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.
Answer to relevant post from Slax, which somehow landed in the wrong thread (?):
Slax wrote on Sun, 15 May 2016 18:35
Wonderful indeed! Less need to wait for Mr. snack vendor to replenish his supplies.
Now I'm wondering if town influence/morale is going to come into play.
Town hates you =
Town's okay with you = Plain ol' inventory.
Town loves you = You get the good stuff.
Something like that.
This is easily possible in lua by doing this:
Town =
{
OMERTA = 1,
DRASSEN = 2,
ALMA = 3,
GRUMM = 4,
CAMBRIA = 6,
SANMONA = 7,
ESTONI = 8,
BALIME = 10,
MEDUNa = 11,
CHITZENA = 12,
}
...
-- Drassen
if ( sSectorX == 13 and sSectorY == SectorY.MAP_ROW_D) then
if ( GetTownLoyaltyRating(Town.DRASSEN) > 75 ) then
-- wine store
CreateCivilian(17198, 0, 55, Bodytype.REGFEMALE, -1, -1, -1, -1, -1, -1, -1, -1)
if ( GetTownLoyaltyRating(Town.DRASSEN) > 40 ) then
-- wine store
CreateCivilian(17198, 0, 56, Bodytype.REGFEMALE, -1, -1, -1, -1, -1, -1, -1, -1)
end
...
In this example, you'd get different stores (55 or 56) depending on town loyalty. Can easily be done by altering the script this way and setting up the merchants and inventories.
I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.
If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.
we only have those pictures (with all vest/pants/skin/hair combinations) for the merc bodytypes, not for the civilian ones. Which is bad, as quite a few traders use civilian bodytypes. I asked for those to be drawn years ago, but nobody wanted to.
I was thinking more along the lines of drawing a static character model portrait generated by reading from the values in-game.
- Then whoever that volunteer could skip the grunt work of doing up all the different combinations;
- All bodytypes could then benefit from the code to be easily shown. ;)
Not sure if it's doable though...
No savegame (just before e bug occurs), no cure.
'Not everything that counts can b counted, n not everything that can b counted counts' - Albert Einstein
I may answer/reply in my old public posts & prefer PM over e former[FUDforum's PM suxx]
Eeh... I don't understand what you are trying to say, to be honest.
I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.
If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.
The character model is drawn real-time on the tactical screen.
So is drawing a static front-facing character model in the trading screen easily doable?
No savegame (just before e bug occurs), no cure.
'Not everything that counts can b counted, n not everything that can b counted counts' - Albert Einstein
I may answer/reply in my old public posts & prefer PM over e former[FUDforum's PM suxx]
Hmmm. Knowing our graphics functions, would at least require absolutely horrible hacks and/or has the risk of bizarre sideeffects.
Probably still easier than hoping for anyone to actually make pictures.
I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.
If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.
As of r8392, we show an image of the nonprofile-merchant we are currently trading with in the interface. This could also easily be used in other places.
If the person to be displayed has no corresponding SOLDIERTYPE structure (= we make stuff up), this would require a bit of additional work - filling the shade tables properly, getting the correct animation offsets and so on - but still far from the dive into undocumented Assembler-code I was fearing.
I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.
If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.
Thanks Flugente, I finally had a chance to look at this and related features - I've managed to add a bartender to the Biker Bar from of original Urban Chaos screenshot fame in only a few minutes of work.
Also, my thanks concerning CivGroups 22 and 23 (I vaguely remember this conversation from a long time ago).