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 next 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

Re: New feature: non-profile merchants[message #345540 is a reply to message #345526] Mon, 16 May 2016 04:38 Go to previous messageGo to next message
Buggler is currently offline Buggler

 
Messages:211
Registered:November 2009
Nice. Could the merchant character model be easily drawn at the portrait area in the trading interface aka Fallout 1/2 style? happy

https://1.bp.blogspot.com/-psdNEWkN19c/U5V1FdM4WHI/AAAAAAAAEzA/1KkPi2CF_lo/s1600/inventory.jpg



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]

Report message to a moderator

Sergeant 1st Class
Re: New feature: non-profile merchants[message #345547 is a reply to message #345540] Mon, 16 May 2016 13:35 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
While we could use pictures like this:
http://i.imgur.com/WJ6Xn9l.png
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.

Report message to a moderator

Captain

Re: New feature: non-profile merchants[message #345548 is a reply to message #345547] Mon, 16 May 2016 13:58 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
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.

Report message to a moderator

Captain

Re: New feature: non-profile merchants[message #345558 is a reply to message #345548] Tue, 17 May 2016 04:03 Go to previous messageGo to next message
Buggler is currently offline Buggler

 
Messages:211
Registered:November 2009
Quote:
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]

Report message to a moderator

Sergeant 1st Class
Re: New feature: non-profile merchants[message #345560 is a reply to message #345558] Tue, 17 May 2016 13:16 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
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.

Report message to a moderator

Captain

Re: New feature: non-profile merchants[message #345562 is a reply to message #345560] Tue, 17 May 2016 13:58 Go to previous messageGo to next message
Buggler is currently offline Buggler

 
Messages:211
Registered:November 2009
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]

Report message to a moderator

Sergeant 1st Class
Re: New feature: non-profile merchants[message #345574 is a reply to message #345562] Wed, 18 May 2016 01:38 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
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.

Report message to a moderator

Captain

Re: New feature: non-profile merchants[message #349182 is a reply to message #345574] Mon, 06 March 2017 21:23 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
Hu. That wasn't hard at all.
http://i.imgur.com/lnBkVbe.png
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.

Report message to a moderator

Captain

Re: New feature: non-profile merchants[message #349904 is a reply to message #349182] Sat, 27 May 2017 22:10 Go to previous message
Wil473

 
Messages:2815
Registered:September 2004
Location: Canada
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).

[Updated on: Sat, 27 May 2017 22:13]




More weapon features and upgrade options, via (mis)use of v1.13 for vanilla Arulco, Dedrianna Lives! and Urban Chaos campaigns.

Report message to a moderator

Lieutenant

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


Current Time: Thu Nov 28 17:54:41 GMT+2 2024

Total time taken to generate the page: 0.01202 seconds