Home » MODDING HQ 1.13 » Flugente's Magika Workshop » New feature: non-profile merchants
New feature: non-profile merchants[message #345526] Sun, 15 May 2016 19:50 Go to previous message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
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:
http://i.imgur.com/yhmDhtD.png
This isn't exactly high class stuff, but a chance to stock up on desperately needed resources.

There are quite a few other shops:

  • http://i.imgur.com/UuQ1O34.png
    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.
  • http://i.imgur.com/uJkmJaA.png
    No there's a store in Alma too. Note that there are 2 staff inside - but both use the same shop inventory.
  • http://i.imgur.com/GMA7xtb.png
    As there are pharmacies elsewhere, you don't have to fight through to Balime to get much needed medical supplies.
  • http://i.imgur.com/8qL3V8q.png
    This Meduna store sells unneeded items for unreasonable prices. The people love it!
  • http://i.imgur.com/W9In0x2.png
    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.).
  • http://i.imgur.com/xmrwZPW.png
    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.
  • http://i.imgur.com/UxW1dEu.png
    Of course, there are also completely different kinds of shops - a dealer has set up shop in the ruins of the university.
  • http://i.imgur.com/zyXSYhX.png
    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.
  • http://i.imgur.com/YsdvqSh.png
    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 happy
    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.

Report message to a moderator

Captain

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: New feature: profile-independent voicesets
Next Topic: New feature: anti-materiel ammo
Goto Forum:
  


Current Time: Sun Dec 01 09:14:20 GMT+2 2024

Total time taken to generate the page: 0.00768 seconds