jpcsupplies / Economy_mod

Basic Economy System for Space Engineers
13 stars 12 forks source link

[enh] NPC conversations #148

Open jpcsupplies opened 7 years ago

jpcsupplies commented 7 years ago

Just noting this for reference.. a logical extension of being able to prevent chat messages showing in game (ie commands) is that it also allows players to converse with NPCs without the conversation being overheard by other players

could be handy for tiered commands (eg mission interface, show menu, player chooses an option - gets responce client side)

or talking to npcs (RPG game style) for missions

This has the advantage that if we support some datafile for such conversations - the file layout can be much simpler. Simply MUD style, text - possible answers, and what to load on getting such answer. the only complexity is a consequence function. (eg pay player, trigger a mission etc)

Example data. [Missionmenu] if making a menu system 0 "Menu: \n1: Do you wish to display current mission \n2: Do you wish to abandon current mission \nX: Exit menu",1=dialog 1,2=dialog 2,X=end 1 dialog "Displaying mission",Currentmission,end 2 dialog "Abandoning Mission",dropmission,end

[NPC 1] if using it for npc conversations 0 "Hello there, I am Izeikiel. How can i help you?\n1: I would like to buy a rifle\n2: I would like to buy ammo\n3: I want to sell my rifle\n4: Got any work?\n5: Nevermind",1=dialog 1, 2=dialog 2, 3=dialog 3,4=dialog 4, 5=end "Suit yourself.. I just talk to myself then.."

1 dialog "Sure you can have this one for 20 \n1: I'll take it\n2: Sorry I've changed my mind..",1=pay -20 give "rifle" end "Here you go - you be careful with that.. you know which end is dangerous I hope..", 2=end "Too rich for ye eh.. suit yourself"

2 dialog "Sure you can have 10 for 10/n1: Sold! /n2: Sorry i've changed my mind", 1=pay -10 give 10*"25mm ammo" end "Here you go..",2=end "changed your mind eh? ok then"

3 dialog "Ok hand it to me.. ill pay you 10 for it/n1: Here you go../n2: No Actually nevermind..", 1=take 1*"rifle" pay 10 end "Thanks here is your money..", 2=end "

4 dialog "Well, Can you pick me up a shipment of magnesium from my supplier for me?../n1:Sure where from?/n2:Wait.. you are paying me for this right?/n3:Sorry no thanks.",1=mission "Ok can you go over to 0,0,0 and grab me 1000 magnesium and bring it back here" target=0,0,0 collect 1000*"magnesium ore" return=here reward=pay 50 give 50 "uranium ingot" winmsg "Izeikiel pays you, and hands you a box of uranium fuel" failmsg "Izeikiel sends you a message that you took too darned long, and got someone else to do it" deadline=1 hour,Currentmission, end "Off you go then be back in an hour or i'll get someone else",2=dialog 5,3=end "pfft people these days no work ethic"

5 dialog "Of course I am paying, ill pay you 50 and throw in 50 uranium ingots too", dialog 4

Logical thoughts:

  1. On start of a NPC dialog - flip a flag that prevents all replies displaying in chat (effectively default false on gotmessage) probably with a timeout for ending if no reply given.
  2. Same flag redirects all chat processing through our NPC dialog engine instead
  3. the "end" tag flips this flag back again - this flag should not be persistent so a disconnect will reset it.
  4. Although in practice this will probably use xml files or some other friendly file format for admins to manually edit.. should we use comma delimited then; split on commas then spaces ""'s and = signs? Probably would need fine tuning a lot.. but once split properly it should be a simple case of a running a loop over an array of the splits and filter the contents of each element through a "select case" or "if" structure to display or process the conversation.
  5. Some dialogs would need a setting that recorded a player had already completed that task/discussion
  6. Mission conditions would simply be passed through to any existing mission processing routine... ie example:

missiontext="Ok can you go over to 0,0,0 and grab me 1000 magnesium and bring it back here" (this sets the start mission text and mission description for pop up)

target=0,0,0 (this sets the general location the player must travel too)

collect 1000*"magnesium ore" (this sets what item the player needs to obtain after arriving at target - and the item that needs to be in their inventory once they return to the mission competion location)

return=here (this says set the return location for the mission as the players present location useful if these npcs are roaming about.. but may require extra logic if the npc moves after the mission starts)

reward=pay 50 give 50 "uranium ingot" (reward= pay 50 money and give 50 items of uranium ingot - it should automatically remove the 1000 magnesium from the main mission system other wise it needs a take 1000 "magnesium ore" here mission should not complete if the ore is not present)

winmsg "Izeikiel pays you, and hands you a box of uranium fuel" (pop up message to show on beating mission)

failmsg "Izeikiel sends you a message that you took too darned long, and got someone else to do it" (pop up message to show on taking too long)

deadline=1 hour (how long until the misison auto fails, this could be worded as fail conditions which could work similarly to the win conditions list)

Currentmission (just tells the NPC chat engine to output the current mission details like it would typing /mission in the demo missions)

Closing thoughts - If we had some economy api working - this could be an external plugin, which simply takes advantage of the mission system/banking from economy