Home » MODDING HQ 1.13 » Flugente's Magika Workshop » New feature: Externalised Merchants
New feature: Externalised Merchants[message #313363] Thu, 20 December 2012 02:04 Go to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
More (and externalised) merchants

As recent features have increased the need to buy local Arulcan products dramatically :angel: , I have increased the number of merchants that Arulco has. There can now be up to 21 additional merchants (arbitrary number, it seems enough for the moment). I also externalised the merchant data.

Thus it is now possible, via xml, to define any NPC to be a merchant or repairguy. I figure modders might have a use for this happy

There are new xmls in TableData/NPCInventory. The most interesting one is Merchants.xml, which has the following entries (lets look at Tony's entries as an example):

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


The <uiFlags> is a flagmask. Only some of them are relevant to us at this point. They define the merchants' behaviour when dealing items:
#define		ARMS_DEALER_ONLY_USED_ITEMS			0x08000000	// 134217728
#define		ARMS_DEALER_GIVES_CHANGE			  0x10000000	// 268435456	//The arms dealer will give the required change when doing a transaction
#define		ARMS_DEALER_ACCEPTS_GIFTS			  0x20000000	// 536870912	//The arms dealer is the kind of person who will accept gifts
#define		ARMS_DEALER_SOME_USED_ITEMS			0x40000000	// 1073741824	//The arms dealer can have used items in his inventory
#define		ARMS_DEALER_HAS_NO_INVENTORY		0x80000000	// 2147483648	//The arms dealer does not carry any inventory


The xml has slots for all merchants, and template fields for 20 new ones, jsut fill them in however ou like. The Inventory of the new merchants is set in TableData/NPCInventory/Additional_Dealer_xxx_Inventory.xml.

Note that UB gets a slightly different Merchants.xml, due to the different merchants there.

Some of the existing ini settings might alter Tony and Devin in a few regards - I'll eventually erase them I guess.

Note that this xml includes all existing merchants and removes hardcoded values. So any change will influence your dealers.
You can now simply define your own dealers, just fill in the correct values. However, when defining a new merchant, it can take a few days for them to get stock - better do that before starting a new game.

Non-merchant NPCs have no fitting speechfiles, thus they might say odd things when selling stuff. A noble exception is Tina. Altough no code section anywhere indicates that she was intended to be a merchant, her ingame story and speechfiles suggest exactly that. For this reason, I made her sell clothes and LBE gear from now on.
http://i47.tinypic.com/29uss9v.jpg

http://i48.tinypic.com/r28aw3.jpg
A local woman sells food, seems normal...

http://i49.tinypic.com/2e3afkg.jpg
... but her son clearly has bad music taste, or watches a bit too much 2012 Anime. Or something.

http://i50.tinypic.com/xqfkhh.jpg
This guy repairs all their stuff.

http://i45.tinypic.com/2e65w92.jpg
Lets hope he's not on the manufacturing side as well.

@JMich: I'll pm you the exact datatypes for the editor later.

By the way... this breaks savegame compatibility. Playing with this requires a new game, no way around that.
This is in the trunk since r5744, and requires GameDir >= r1578.

Go shopping! Christmas shows its ugly head!

[Updated on: Sun, 15 May 2016 18:28]

Report message to a moderator

Captain

Re: New feature: Externalised Merchants[message #313376] Thu, 20 December 2012 11:26 Go to previous messageGo to next message
smeagol is currently offline smeagol

 
Messages:2705
Registered:June 2008
Location: Bremen, Germany
unfortunately too late to make it into aimnas xmas release.


very nice new addition!!!

Report message to a moderator

Lieutenant

Re: New feature: Externalised Merchants[message #313381] Thu, 20 December 2012 13:01 Go to previous messageGo to next message
Madd_Mugsy

 
Messages:634
Registered:July 2005
Location: Canada
Nice work!

Report message to a moderator

First Sergeant

Re: New feature: Externalised Merchants[message #313388] Thu, 20 December 2012 18:44 Go to previous messageGo to next message
Wil473

 
Messages:2815
Registered:September 2004
Location: Canada
Hmmm, Charlie's Hot Dog Emporium (UC) may have hot dogs... or not (in-game speech). This will make it into UC-1.13 v4.xx as it slowly creeps towards start of production.

Report message to a moderator

Lieutenant

Re: New feature: Externalised Merchants[message #313403] Fri, 21 December 2012 03:59 Go to previous messageGo to next message
Clarkew is currently offline Clarkew

 
Messages:75
Registered:May 2011
Location: East Texas, USA
Sounds like a great excuse to turn off ALT-LMB selling!

Report message to a moderator

Corporal
Re: New feature: Externalised Merchants[message #313410] Fri, 21 December 2012 19:10 Go to previous messageGo to next message
wanne (aka RoWa21) is currently offline wanne (aka RoWa21)

 
Messages:1961
Registered:October 2005
Location: Austria
very nice feature for the modders. awesome work Smile

Report message to a moderator

Sergeant Major

Re: New feature: Externalised Merchants[message #316708] Fri, 29 March 2013 07:41 Go to previous messageGo to next message
Clarkew is currently offline Clarkew

 
Messages:75
Registered:May 2011
Location: East Texas, USA
Too bad there's no way to turn off speech for individuals during the sales interface. Every time I buy some porn from Hans he threatens to kill me Smile

In my current game I'm going through and taking notes on all the merchants (or likely merchants) and tweaking their inventory as an aside to my Economy Balancing xml edits for 1.13.

I'm taking my sweet time and trying to set up stuff that makes sense but doesn't break the game. So far I've dumbed down the food a bit (bars sell bar food, clubs sell restaurant style food) added useless leather jackets, low chance revolver holster/regular holster to Angel and of course was thinking of Hans actually selling porn.

Anyway, again this is a great addition that I'm having fun just screwing around with.

Report message to a moderator

Corporal
Re: New feature: Externalised Merchants[message #341344 is a reply to message #316708] Thu, 04 June 2015 16:00 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
As or r7887 & GameDir r2251, Kyle finally takes over the San Mona leather shop once his quest is over (it always seemed a bit odd that he moved out of the tattoo parlour but never arrived in the leather shop - now he'll be there). He sells leather clothes (not that we have a wide selection of those) just like he said he would, plus all sorts of clothes. And a bit of kinky stuff, because gays in video games are always over-the-top kinky.
He also sells LBE MOLLE gear, so you now can get MOLLE in the country, if you do a quest beforehand. Quest reward or whatever.



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: Externalised Merchants[message #342220 is a reply to message #341344] Thu, 27 August 2015 19:21 Go to previous messageGo to next message
navaroe is currently offline navaroe

 
Messages:78
Registered:August 2012
Anyone seen Kyle actually appear in Angel's leather shop so far? I gave him the deed on day 39, on day 45 there is still no sign of him, checked throughout a day, especially between 9.-12. hour.

Report message to a moderator

Corporal
Re: New feature: Externalised Merchants[message #342221 is a reply to message #342220] Thu, 27 August 2015 19:55 Go to previous messageGo to next message
M16AMachinegun is currently offline M16AMachinegun

 
Messages:304
Registered:September 2013
I've played through the game throughout multiple builds and i've not seen Kyle in the shop, nope

Course, i've been playing AFS mods, so...

Report message to a moderator

Master Sergeant
Re: New feature: Externalised Merchants[message #342223 is a reply to message #342221] Thu, 27 August 2015 20:22 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
If the mod you are playing with does not use the altered scripts, no wonder.


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: Externalised Merchants[message #342228 is a reply to message #342223] Thu, 27 August 2015 21:59 Go to previous messageGo to next message
navaroe is currently offline navaroe

 
Messages:78
Registered:August 2012
Hm, unlike M16AM I play just plain 1.13.
I took look into lua scripts and found, that Kyle appears when proper if condion checks on gubQuest( Quests.QUEST_LEATHER_SHOP_DREAM ) == qStatus.QUESTNOTSTARTED. So game does not consider the quest even started. Probably nothing to do about that now...

But he still isn't considered a merchant - he does not have "buy/sell" in conversation options. Any ideas what's wrong?

Report message to a moderator

Corporal
Re: New feature: Externalised Merchants[message #342230 is a reply to message #342228] Fri, 28 August 2015 02:22 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
No. That is not what the script says. The script refers to the quest having the status qStatus.QUESTDONE. At that point, Kyle is moved to the shop and is allowed to be a shopkeeper (which of course requires xml shopkeeper settings).


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: Externalised Merchants[message #342238 is a reply to message #342230] Fri, 28 August 2015 16:38 Go to previous messageGo to next message
navaroe is currently offline navaroe

 
Messages:78
Registered:August 2012
I think you misunderstood - I finished the quest - Kyle has given me money for deed and went. But game still thinks that quest status is "not started", as evidenced by gubQuest( Quests.QUEST_LEATHER_SHOP_DREAM ) == qStatus.QUESTNOTSTARTED evaluating to true. Nevermind - I can cheat Kyle to appear by changing the lua script.

As for XML settings for Kyle being a merchant - I understand those are already in place since r7887 & GameDir r2251 and of course I have those. I checked Kyle is present in merchants.xml - <ubShopKeeperID>95</ubShopKeeperID> which is Kyle (according to comment enumarating NPCs in merchants.xml), tried to copy some other functioning merchant (Darrel's) settings over Kyle's - no effect, Kyle still can't make business. What am I missing?

If only proper entry in merchants.xml was enought for Kyle to be merchant, he would be merchant even in C5 sector before quest, right?

Report message to a moderator

Corporal
Re: New feature: Externalised Merchants[message #342242 is a reply to message #342238] Fri, 28 August 2015 22:22 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
Manny and Kyle can only be merchants once specific quests have been done. That is hardcoded, no way around that. If the quest is not considered finished by the game (for whatever reason), Kyle won't be a shopkeeper.


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: Externalised Merchants[message #342244 is a reply to message #342242] Sat, 29 August 2015 01:33 Go to previous messageGo to next message
navaroe is currently offline navaroe

 
Messages:78
Registered:August 2012
Aha, thanks.

So no flamboyant merchants for me :'{

Report message to a moderator

Corporal
Re: New feature: Externalised Merchants[message #351854 is a reply to message #342244] Sun, 31 December 2017 21:06 Go to previous messageGo to next message
88vs1984 is currently offline 88vs1984

 
Messages:15
Registered:August 2015
Location: Belarus
Flugente, what these tegs do?

<addToCoolness>1</addToCoolness>
<coolnessProgressRate>10</coolnessProgressRate>
<daysDelayMin>2</daysDelayMin>
<daysDelayMax>3</daysDelayMax>

Report message to a moderator

Private
Re: New feature: Externalised Merchants[message #351920 is a reply to message #351854] Fri, 05 January 2018 05:00 Go to previous messageGo to next message
todd0001 is currently offline todd0001

 
Messages:42
Registered:November 2017
Quote:
Flugente, what these tegs do?

<addToCoolness>1</addToCoolness>
<coolnessProgressRate>10</coolnessProgressRate>
<daysDelayMin>2</daysDelayMin>
<daysDelayMax>3</daysDelayMax>

Bump! Just learning this too!

Report message to a moderator

Corporal
Re: New feature: Externalised Merchants[message #357495 is a reply to message #313363] Tue, 04 June 2019 06:02 Go to previous messageGo to next message
Kitty

 
Messages:473
Registered:October 2017
Location: Germany
I'm struggling with adding merchants whose inventory should be allways completly available. The merchants shows up where it should, I can trade with him, but what's available seems to be random choice out of it's inventory (AdditionalDealerInventory 51 in this case).
Since placement and inventory seem to work I might have something wrong in merchants.xml. Anybody able to give me a hint why these setting didn't result in "allInventoryAllwaysAvailable" ? I tried it with 0 instead of 1 at this tag, too. Although I'm not sure what "addToCoolness" is refering to, I changed numbers from 0 to 10 but still... So, after numerous attempts with every combination I could think of, waiting for days and weeks inbetween next buying to allow restocking, liberating up to three cities before, etc. I never had a full inventory with all should-be-available items out of inventory. I don't get, what I'm possibly doing wrong.



<MERCHANT>
<uiIndex>70</uiIndex>
<szName>pharmacy Chitzena (A3)</szName>
<dBuyModifier>1.0</dBuyModifier>
<dSellModifier>1.3</dSellModifier>
<ubShopKeeperID>200</ubShopKeeperID>
<ubTypeOfArmsDealer>1</ubTypeOfArmsDealer>
<iInitialCash>1500</iInitialCash>
<uiFlags>268435456</uiFlags>
<dailyIncrement>1500</dailyIncrement>
<dailyMaximum>3000</dailyMaximum>
<dailyRetained>1500</dailyRetained>
<minCoolness>1</minCoolness>
<maxCoolness>10</maxCoolness>
<addToCoolness>10</addToCoolness>
<coolnessProgressRate>100</coolnessProgressRate>
<daysDelayMin>1</daysDelayMin>
<daysDelayMax>2</daysDelayMax>
<useBRSetting>0</useBRSetting>
<allInventoryAlwaysAvailable>1</allInventoryAlwaysAvailable>
<nonprofile_loyaltyrequired>5</nonprofile_loyaltyrequired>
</MERCHANT>

(It's for an AR-Map, that's why there is a paharmacy at A3)

Edit: The reason for the inventory not full is probably time. So, waiting a week or so helped.

[Updated on: Sat, 27 July 2019 16:58]




How to get: latest 1.13, 7609 and more | 7609 SCI (eng) | Compiling+SVN

I need more details. (Didi Hallervorden)

Report message to a moderator

Master Sergeant
Re: New feature: Externalised Merchants[message #357539 is a reply to message #357495] Fri, 14 June 2019 03:19 Go to previous messageGo to next message
fightcancer is currently offline fightcancer

 
Messages:214
Registered:February 2005
Location: USA
Wow! I really love the extra merchants!! Thank you so much!!

Report message to a moderator

Sergeant 1st Class
Re: New feature: Externalised Merchants[message #358673 is a reply to message #313363] Wed, 18 December 2019 02:37 Go to previous messageGo to next message
rotundrew is currently offline rotundrew
Messages:2
Registered:March 2016
is the merchant in a wheelchair that was in the rebel hideout removed, also the merchant in the middle sector of Drassen that has a store in her home. I played a SCI build a few months ago and they were present and the newest build they are not?

Report message to a moderator

Civilian
Re: New feature: Externalised Merchants[message #358797 is a reply to message #358673] Thu, 16 January 2020 02:37 Go to previous messageGo to next message
ZedJA2

 
Messages:202
Registered:January 2018
Don't forget that there is also an .ini file that needs to have the setting on for the Additional Merchants to be active. I believe the default is OFF so you will have to check your main .ini file to make sure it is on -- at least that was the way in the 8696 version EXE. Not certain if there were any changes to merchants since.


EDIT IN: The location is in JA2options.ini, around line 1019-1023. There are actually two lines that need to be set as TRUE, one pertains to Allow Extra Civilians, the other to Allow Extra Merchants:

<<

;----------------------------------------------------------------------------------------------------------------------- -------
; 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 = TRUE

; Allow placing of new merchants
; Note: this requires ALLOW_EXTRA_CIVILIANS to be TRUE
ALLOW_EXTRA_MERCHANTS = TRUE

>>

The other possibility would be that the LUA file that needs to have the script for inserting the Additional Merchants was either changed or is not where it should be. However, that is a less likely scenario.

For example, whenever you upgrade, if you copy over the .ini file, it may overwrite your previous selection.

One of the horrors of updating, is that most options are reset, some options are moved from one file to another location, some are moved to being a new in-game selectable option, and additional files from the directories may be required, but those overwrite previous customizations unless you do everything by hand. If you do it by hand, though, the chance for errors and the need for hours of hand work, makes it a bit of a pain in the neck.

[Updated on: Thu, 16 January 2020 02:44]

Report message to a moderator

Sergeant 1st Class
Re: New feature: Externalised Merchants[message #360373 is a reply to message #358797] Mon, 15 June 2020 12:02 Go to previous messageGo to next message
Vritran is currently offline Vritran

 
Messages:199
Registered:February 2020
Location: North East England
Hi Flugente,

Would it be possible to do a little bit of additional coding in respect to this feature so that the merchant can play a voice file (battlesnd?) when you click him and open the trade window. Such as "Take a look" or "I've got the best prices". Could even do a "Come back soon" voice file when you close the trade window?

I'm not a coder so I don't know how difficult that this would actually be to implement but it would be a nice addition to an already useful/good feature. I can scavenge the relevant voice files from various games if needs be so that isn't a problem.

Cheers, Vritran

Report message to a moderator

Staff Sergeant
Re: New feature: Externalised Merchants[message #360376 is a reply to message #360373] Mon, 15 June 2020 22:31 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
That's easy to do. What do you have in mind - generic sounds for all merchants, or specific sounds for each and every one?


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: Externalised Merchants[message #360377 is a reply to message #360376] Tue, 16 June 2020 00:14 Go to previous messageGo to next message
Vritran is currently offline Vritran

 
Messages:199
Registered:February 2020
Location: North East England
Well I was thinking about a dozen generic sounds that are played out similar to the BAD0_XXX, BAD1_XXX etc.

However, if you can make it individual we could potentially go nuts and tailor the merchant for the sector that they are in. (Unsavory drug dealers in San Mona, snobbish merchants in Balime etc.)

Report message to a moderator

Staff Sergeant
Re: New feature: Externalised Merchants[message #360378 is a reply to message #360377] Tue, 16 June 2020 01:22 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
At the very least we'd need to differentiate between genders I think.

Shopkeepers use the following quotes in the shopkeeper screen:
Toggle Spoiler

That is quite a bit to play with. I recall having a bit of trouble when I added Additional Dialogue for shopkeepers with displaying the text to the sound - the game really didn't like that - so I'm just playing the sound. But that sounds fine I think.
I'm still pondering where one would implement parts of it - whether to just build a sound file name in the code and search a specific location for a fitting file, or whether to script it in lua - but this shouldn't be too hard, apart from navigating the swamp that is shopkeeper stuff.

In a way this somewhat opens the door to having non-profile based people talk (apart from grunting when we shoot them in the face), but I see that more as a positive.

[Updated on: Tue, 16 June 2020 01:23]




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: Externalised Merchants[message #360379 is a reply to message #360378] Tue, 16 June 2020 02:00 Go to previous messageGo to next message
Kitty

 
Messages:473
Registered:October 2017
Location: Germany
Flugente wrote on Tue, 16 June 2020 01:22



I'm still pondering where one would implement parts of it - whether to just build a sound file name in the code and search a specific location for a fitting file, or whether to script it in lua - but this shouldn't be too hard, apart from navigating the swamp that is shopkeeper stuff.

In a way this somewhat opens the door to having non-profile based people talk (apart from grunting when we shoot them in the face), but I see that more as a positive.
Wouldn't using "PlaySound" instead of "PlayJA2Sample" be useful for this? Then Vritran wouldn't be restricted to a sample-array for sounds in code, since this would allow to take the sounds directly from a directory instead.

At least for ActionItems this seems to be working, I did this. Plays a sound directly from directory of choice.


if ActionID == 25 then
	
	PlaySound("Sounds\\Engine01.wav", SoundVolume.HIGHVOLUME, sGridNo)
		
end

[Updated on: Tue, 16 June 2020 02:14]




How to get: latest 1.13, 7609 and more | 7609 SCI (eng) | Compiling+SVN

I need more details. (Didi Hallervorden)

Report message to a moderator

Master Sergeant
Re: New feature: Externalised Merchants[message #360381 is a reply to message #360379] Tue, 16 June 2020 02:23 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
Uh, yes? But he still needs the number to know which sound to play, at which point one could easily define a file name pattern like "merchantID_shopkeepersoundID" and habe the game use that. Lua offers a lot more flexibility, true, but one also has to write that down, then.

Note that PlaySound does not use the third argument, so your sGridNo is actually unnecessary.



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: Externalised Merchants[message #360386 is a reply to message #360381] Tue, 16 June 2020 16:54 Go to previous messageGo to next message
Vritran is currently offline Vritran

 
Messages:199
Registered:February 2020
Location: North East England
Sounds good Flugente. I better start uncovering relevant merchant voice files from the bowels of my hard drive.

Report message to a moderator

Staff Sergeant
Re: New feature: Externalised Merchants[message #360388 is a reply to message #360386] Wed, 17 June 2020 01:06 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
As expected, it works fine. I'm using a lua function that looks like this:

-- functions used here:
-- 
-- path: path and name of soundfile we want to play (in .wav, .ogg or .mp3 format)
-- volume: optional sound volume (65: medium volume, 127: loud), default 65
-- PlaySound(path, volume)

-- handle
-- sSectorX, sSectorY and bSectorZ indicate the sector coordinates
-- ubMerchantID is the ID of the merchant for whom this is called
-- usQuoteNum is the event of the dialogue that is supposed to be called 
function HandleNPCMerchantQuote(sSectorX, sSectorY, bSectorZ, ubMerchantID, usQuoteNum )

        -- test sounds
	choicenr = math.random(1, 7)
			
	if ( choicenr == 1 ) then     	PlaySound("Sounds//Weapons//38//38 CALIBER.ogg")
	elseif ( choicenr == 2 ) then 	PlaySound("Sounds//Weapons//38//38SUPER PISTOL SINGLE SHOT.ogg")
	elseif ( choicenr == 3 ) then 	PlaySound("Sounds//Weapons//38//380 MAC11 BURST 5.ogg")
	elseif ( choicenr == 4 ) then 	PlaySound("Sounds//Weapons//RIFLE SILENCER BURST 5.ogg")
	elseif ( choicenr == 5 ) then 	PlaySound("Sounds//Weapons//PUMP-ACTION.ogg")
	elseif ( choicenr == 6 ) then 	PlaySound("Sounds//Weapons//BOLT-ACTION SPRINGFIELD.ogg")
	elseif ( choicenr == 7 ) then 	PlaySound("Sounds//Weapons//50CAL.WAV")
	end

end

As I assume the plan isn't to have the merchants double as firearms, this is where the sounds would go. ubMerchantID is the ID used when placing a merchant in HandleSectorTacticalEntry(...) in strategicmap.lua:

-- armour store (Skin Tight Fashions)
CreateCivilian(13010, CivGroup.KINGPIN_CIV_GROUP, 67, Bodytype.MINICIV, -1, -1, -1, -1, -1, -1, -1, -1)

so in this case it would be 67. usQuoteNum meanwhile is number of the quote that would be played if this were a profile-based merchant, which I posted earlier.

I could add extra arguments but am not that hopeful about it. Due to the way this lua function is accessed deep in the code, I'd prefer not having to drag in extra arguments, like stats of the merchant themself, though one should already know their bodytype and thus gender as we set that ourselves via CreateCivilian(...)

The only thing I'm unsure of is whether to add any sounds from movies/games/etc. you find to the GameDir trunk. That feels... unsafe, which is one of the reasons the mercs I made are not part of 1.13.
But even then nothing would stop one from simply packing the sounds as an addon.

[Updated on: Wed, 17 June 2020 01:09]




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: Externalised Merchants[message #360393 is a reply to message #360388] Wed, 17 June 2020 11:32 Go to previous messageGo to next message
Vritran is currently offline Vritran

 
Messages:199
Registered:February 2020
Location: North East England
Yeah the sounds shouldn't be in the v1.13 trunk. It should be a separate 'extension' Mod, to avoid any copyright issues, which can be copied and pasted into a new version of v1.13 if desired.

The only thing that needs to be in v1.13 trunk is the ability to add those sounds in.

Report message to a moderator

Staff Sergeant
Re: New feature: Externalised Merchants[message #360398 is a reply to message #360393] Wed, 17 June 2020 23:24 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
Well, as of r8821 & GameDir r2550, this is now a thing. I added the function to Overhead.lua, and also added the shopkeeper's bodytype as an argument, so we can determine the gender:

-- (relevant) bodytypes
Bodytype = 
{
	REGMALE = 0,
	BIGMALE = 1,
	STOCKYMALE = 2,
	REGFEMALE = 3,
	FATCIV = 11,
	MANCIV = 12,
	MINICIV = 13,
	DRESSCIV = 14,
	HATKIDCIV = 15,
	KIDCIV = 16,
	CRIPPLECIV = 17,
}

-- shopkeeper quotes while in the shop interface
Shopkeeperquote = 
{
	SK_QUOTES_DEALER_OFFERED_MONEY_AS_A_GIFT = 10,
	SK_QUOTES_PLAYER_FIRST_ENTERS_SKI = 11,
	SK_QUOTES_RANDOM_QUOTE_WHILE_PLAYER_DECIDING_1 = 12,
	SK_QUOTES_RANDOM_QUOTE_WHILE_PLAYER_DECIDING_2 = 13,
	SK_QUOTES_RANDOM_QUOTE_WHILE_ITEMS_CHOSEN_TO_TRADE = 14,
	SK_QUOTES_RANDOM_QUOTE_WHILE_ITEMS_CHOSEN_TO_SELL_OR_REPAIR = 15,
	SK_QUOTES_PLAYER_REQUESTED_EVALUATION = 16,
	SK_QUOTES_DURING_EVALUATION_STUFF_REJECTED = 17,
	SK_QUOTES_EVALUATION_RESULT_VALUE_OF_ZERO = 18,
	SK_QUOTES_EVALUATION_RESULT_SOME_REALLY_DAMAGED_ITEMS = 19,
	SK_QUOTES_EVALUATION_RESULT_NORMAL = 20,
	SK_QUOTES_EVAULATION_PLAYER_DOESNT_HAVE_ENOUGH_VALUE = 21,
	SK_QUOTES_PLAYER_HAS_EXACTLY_ENOUGH_MONEY_FOR_TRANSACTION = 22,
	SK_QUOTES_PLAYER_HAS_TOO_MUCH_MONEY_FOR_TRANSACTION = 23,
	SK_QUOTES_PRESSES_DONE_HAS_AT_LEAST_1_TRANSACTION = 24,
	SK_QUOTES_PRESSED_DONE_HASNT_MADE_TRANSACTION = 25,
	SK_QUOTES_PRESSED_DONE_STILL_HAS_STUFF_IN_OFFER_AREA = 26,
	SK_QUOTES_CANT_AFFORD_TO_BUY_OR_TOO_MUCH_TO_REPAIR = 27,
}

-- functions used here:
-- 
-- path: path and name of soundfile we want to play (in .wav, .ogg or .mp3 format)
-- volume: optional sound volume (65: medium volume, 127: loud), default 65
-- PlaySound(path, volume)

-- handle
-- sSectorX, sSectorY and bSectorZ indicate the sector coordinates
-- ubMerchantID is the ID of the merchant for whom this is called
-- ubBodyType is the character model the merchant uses
-- usQuoteNum is the event of the dialogue that is supposed to be called 
function HandleNPCMerchantQuote(sSectorX, sSectorY, bSectorZ, ubMerchantID, ubBodyType, usQuoteNum )

    -- do stuff here!

end

You should post what you come up with using this, btw.



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: Externalised Merchants[message #360442 is a reply to message #360398] Wed, 24 June 2020 20:17 Go to previous messageGo to next message
Vritran is currently offline Vritran

 
Messages:199
Registered:February 2020
Location: North East England
Hi Flugente,

I've downloaded the latest exe and game directory. Your modification shows in the Data/Scripts/Overhead.lua and Data-UB/Scripts/Overhead.lua but not in Data-1.13/Scripts/Overhead.lua. Is this intentional?

Cheers, Vritran

Report message to a moderator

Staff Sergeant
Re: New feature: Externalised Merchants[message #360446 is a reply to message #360442] Wed, 24 June 2020 22:53 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
Hu? It's in there, at the end of the file, it's just empty:

- functions used here:
-- 
-- path: path and name of soundfile we want to play (in .wav, .ogg or .mp3 format)
-- volume: optional sound volume (65: medium volume, 127: loud), default 65
-- PlaySound(path, volume)

-- handle
-- sSectorX, sSectorY and bSectorZ indicate the sector coordinates
-- ubMerchantID is the ID of the merchant for whom this is called
-- ubBodyType is the character model the merchant uses
-- usQuoteNum is the event of the dialogue that is supposed to be called 
function HandleNPCMerchantQuote(sSectorX, sSectorY, bSectorZ, ubMerchantID, ubBodyType, usQuoteNum )

	

end



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: Externalised Merchants[message #360449 is a reply to message #360446] Thu, 25 June 2020 11:00 Go to previous messageGo to next message
Vritran is currently offline Vritran

 
Messages:199
Registered:February 2020
Location: North East England
Ah yes it is. Going blind.

[Updated on: Thu, 25 June 2020 11:52]

Report message to a moderator

Staff Sergeant
Re: New feature: Externalised Merchants[message #360470 is a reply to message #360449] Mon, 29 June 2020 03:38 Go to previous messageGo to next message
Kitty

 
Messages:473
Registered:October 2017
Location: Germany
I'm no-way sure about this, but here is my assumption on how it probably should look like:


Either something like this:

if ( sSectorX == 6 and sSectorY == SectorY.MAP_ROW_C and bSectorZ == 0 and ubMerchantID == 63 and ubBodytype == 13 and usQuoteNum == 13 )then 

     PlaySound("Sounds//Merchant63//The price is right.ogg")

end

or something like this:


if ( sSectorX == 6 and sSectorY == SectorY.MAP_ROW_C and bSectorZ == 0 ) then 
    if ( ubMerchantID == 63 and ubBodytype == 13 and usQuoteNum == 13 ) then
	
	  PlaySound("Sounds//Merchant63//The price is right.ogg")
    end

end

or:

if ( sSectorX == 6 and sSectorY == SectorY.MAP_ROW_C and bSectorZ == 0 ) then 
    if ( ubMerchantID == 63 and ubBodytype == 13 ) then
        if (usQuoteNum == 13) then
	
	  PlaySound("Sounds//Merchant63//The price is right.ogg")
        

        elseif (usQuoteNum == 14) then

          PlaySound("Sounds//Merchant63//The price is tight.ogg")

        end
    end
end



If this is bull, I beg to be corrected.

[Updated on: Mon, 29 June 2020 03:55]




How to get: latest 1.13, 7609 and more | 7609 SCI (eng) | Compiling+SVN

I need more details. (Didi Hallervorden)

Report message to a moderator

Master Sergeant
Re: New feature: Externalised Merchants[message #360473 is a reply to message #360470] Mon, 29 June 2020 12:35 Go to previous messageGo to next message
Vritran is currently offline Vritran

 
Messages:199
Registered:February 2020
Location: North East England
Yeah I'm having trouble coding this correctly as well. I'm terrible at coding.

Report message to a moderator

Staff Sergeant
Re: New feature: Externalised Merchants[message #360474 is a reply to message #360473] Mon, 29 June 2020 22:33 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
That looks good to me. The third version would work best if you have several lines for the same merchant, and is what I would use.

Note that you don't need to use the sector coordinates or the bodytype etc., it's just there in case you need it. This might become necessary, depending on how one sets up the merchants. After all it is possible to have several civilians having the same merchant ID, even in different sectors. It is even possible to create an instant gear teleportation service this way big grin



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: Externalised Merchants[message #360476 is a reply to message #360474] Mon, 29 June 2020 23:33 Go to previous messageGo to next message
Kitty

 
Messages:473
Registered:October 2017
Location: Germany
I was wondering if this could be used for Kyle (Tatoo, not Shadow) as well. After the quest he becomes a merchant, but he allready has lines 1-22 in his edt. When trading with him, the game seems to take the lines from there.

Is it worth a try to use this externalised Merchants System on him, or is there a risk for conflicts because he has a Profile (and therefore existing quotes in some of those places)?

Or would it be better to use "handle replace quotes" for Profile-Merchants like him ?

Or worse, would this require to rewrite the edt and npc-records? (add lines for SKI in edt and re-adress stuff in records to ensure his standard behaviour)(plus adding matching stuff to his speech, which first has to be created out of existing lines)

[Updated on: Mon, 29 June 2020 23:36]




How to get: latest 1.13, 7609 and more | 7609 SCI (eng) | Compiling+SVN

I need more details. (Didi Hallervorden)

Report message to a moderator

Master Sergeant
Re: New feature: Externalised Merchants[message #360477 is a reply to message #360476] Tue, 30 June 2020 01:06 Go to previous messageGo to previous message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
Well, HandleNPCMerchantQuote(...) isn't going to be called for him as he has a profile.

HandleReplaceQuote(...) would be the best place. There are no changes for shopkeepers required then, a sector check will be enough as the shop is in a different sector than the tatoo parlour.



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

Previous Topic: New feature: Take prisoners, interrogate them
Next Topic: New Quest: a questline continues...
Goto Forum:
  


Current Time: Sun Dec 01 14:25:37 GMT+2 2024

Total time taken to generate the page: 0.02303 seconds