How to assign and start conversation from inventory item

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
ramon.dexter
Posts: 1520
Joined: Tue Oct 20, 2015 12:50 pm
Graphics Processor: nVidia with Vulkan support
Location: Kozolupy, Bohemia

How to assign and start conversation from inventory item

Post by ramon.dexter »

I have a delicate problem. I want to make some sort of a shop powered by Strife Conversation - the ZSDF. I have no problem setting up a shop in a .wad map. That's okay. I just write the conversation, set the ConvID to some actor and everything works as expexted.
Problems come when I dont that map - let's say I want to make a gameplay mod, where player will collect gold/money/bones/stuff from enemies and later will use this collected stuff to buy ammunition/health/powerups/etc. The only possible way to me is to make a menu powered by the conversation script, that will act as a shop. I can write the menu, but I really dont know how to call it without an map actor, that has assigned a Tag and a ConversationID. Problem is, that when I have a map, I can hack an inventory item to start conversation without walking to an actor and pressing USE. The point is that I build an sector outside the map area and place some actor there that acts as a dummy for script. Then I assign Tag and ConversationID to that actor. The conversation itself is called by script with "StartConversation(tag)", where "tag" is the tag of the dummy actor. The sript is called from an inventory item.

Problem is, when I want to make an gameplay mod, I cannt make the sector with dummy actor. So I need to know how to solve this. How can I call conversation from an inventory item? Is it even possible? Or do I need to use other way?

Assigning the conversation this way:

Code: Select all

Conversation
{
	actor = "journal_item";	
	
	Page//1
	{
		Name = "TEST SHOP";
		Dialog = "IT WORKS!!";
		Goodbye = "\c[red][ EXIT ]";
	}
}
Is tested and doesn't work. Assigning ConversationID in MAPINFO is tested and doesn't work.
User avatar
Virathas
Posts: 249
Joined: Thu Aug 10, 2017 9:38 am

Re: How to assign and start conversation from inventory item

Post by Virathas »

I strongly advice to use something else than Strife Conversation system. Don't get me wrong, what you want to do is fully doable in it, but moving it to ACS/DECORATE will make it far more flexible, and more compatible (I know, i made a shopkeep system in it, and had problems with Strife compatiblity). I know, ZScript is probably the way to go, but I simply don't know it yet.

However, if the only problem is spawning a dummy actor on map start, it is easy:

ACS:

Code: Select all

script "WorldOpening" OPEN
{
	SpawnForced("VendorDummyActor",0,0,0,123456,0);
}


This will create the dummy actor and assign the Tag to it (or at least it should, you can easily reference it though). You can then try starting the conversation as you should.

To be frank, i am not sure this will fully work, if you'd prefer to use an ACS/DECORAT combo to do something similar, you can look at the shop in my Fusion Weaver mod. You'd be mostly interested in the ACS scripts "WorldOpening" and "ShopInventory"

In short, Worldopening creates a dummy actor and afterwards adds inventory to the shop (randomized)
ShopInventory does the bulk of everything, gives a full HUD of the shop, takes care of menu navigation and the purchase of items (I'd rather you not copy this purchase part, as it's dirty, large, and unoptimized).

Note that the way it works for a player - a player uses an item that spawns a shopkeeper. That shopkeeper creates an aura, that allows the user to "Enter Shop" (by the use of a keybind that runs a script)
As long as any player is still in the aura of the shopkeeper, he persists. If no players are around, he disappears leaving a vendor spawning beacon.

Hope this can at least somewhat help!
Post Reply

Return to “Scripting”