[mod] NPC reactions

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

[mod] NPC reactions

Post by kuertee » Tue, 12. May 20, 03:37

NPC reactions
https://www.nexusmods.com/x4foundations/mods/497
(previously named Rumour topics)
by kuertee

Update:
=======
v1.1.1, 23 May 2020:
-The random chance of a meaningful rumour in the previous version was always 100%.

v1.1.0, 22 May 2020:
-Added this rumour topic: (Chat about politics): Increases your relation with the NPC's faction. 15% chance.
-Conversing with an NPC from the same race gives a 2.5% bonus to the chance of a meaningful rumour.
-Conversing with an NPC from a friendly faction, another 2.5% bonus.
-Conversing with an NPC from a friendly faction while in an enemy sector, a further 2.5% bonus.
-An NPC can offer only one meaningful rumour per hour.
-Generic missions are categorised as: combat, economic, engineering. The type of mission offered will be based on the NPC's profession and/or role.
-Your 'conversation skill' degrades by 0.25% every hour you don't have at least one direct (i.e. face-to-face) conversation. This should be negated by your day-to-day activities like: checking with traders for argnu beef, picking up passengers, talking to faction representatives, etc.
-Extension options support: Customise the penalties and bonuses above. Read below for more info.

Mod effects:
============
-Conversations with NPCs may produce one of these meaningful rumours: a generic mission, a lockbox location, an anomaly location, a data vault location.
-The chance a conversation produces in a meaningful rumour increases at every conversation.

Full read-me in the 2nd post below.
Last edited by kuertee on Sun, 24. May 20, 15:02, edited 3 times in total.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [mod] NPC reactions

Post by kuertee » Tue, 12. May 20, 03:39

NPC reactions
https://www.nexusmods.com/x4foundations/mods/497
(previously named Rumour topics)
by kuertee

Update:
=======
v1.1.0, 22 May 2020:
-Added this rumour topic: (Chat about politics): Increases your relation with the NPC's faction. 15% chance.
-Conversing with an NPC from the same race gives a 2.5% bonus to the chance of a meaningful rumour.
-Conversing with an NPC from a friendly faction, another 2.5% bonus.
-Conversing with an NPC from a friendly faction while in an enemy sector, a further 2.5% bonus.
-An NPC can offer only one meaningful rumour per hour.
-Generic missions are categorised as: combat, economic, engineering. The type of mission offered will be based on the NPC's profession and/or role.
-Your 'conversation skill' degrades by 0.25% every hour you don't have at least one direct (i.e. face-to-face) conversation. This should be negated by your day-to-day activities like: checking with traders for argnu beef, picking up passengers, talking to faction representatives, etc.
-Extension options support: Customise the penalties and bonuses above. Read below for more info.

Mod effects:
============
-Conversations with NPCs may produce one of these meaningful rumours: a generic mission, a lockbox location, an anomaly location, a data vault location.
-The chance a conversation produces in a meaningful rumour increases at every conversation.

How the mod works:
==================
Clicking on an NPC or contacting an NPC via the Comm command initiates a conversation.

The chance a conversation produces a meaningful rumour increases by 1% at every new conversation.
Conversing with an NPC of the same race gives a 2.5% bonus to this chance.
Conversing with an NPC from a friendly faction, another 2.5% bonus.
Conversing with an NPC from a friendly faction while in an enemy sector, a further 2.5% bonus.
These bonuses can be customised in the mod's Extension Options.

If a conversation produces a meaningful rumour, one of these conversation topics becomes available:
-(Chat about the wars/life in space/science/the galaxy): A generic mission based on the NPC's profession and/or role. There is a 60% chance for this type of rumour.
-(Chat about politics): Increases your relation with the NPC's faction. 15% chance.
-(Chat about lockboxes): The location of a lockbox. 15% chance.
-(Chat about anomalies): The location of an anomaly. 5% chance.
-(Chat about data vaults): The location of a data vault. 5% chance.
An NPC can offer only one meaningful rumour per hour.

When a conversation produces a meaningful rumour, the chance for the next meaningful rumour is reset to 0%.
However, a base chance is increased by 1%.
This can be considered to be a 'conversation skill', 'speech skil', 'charisma attribute', etc.
This 'conversation skill' is added to the chance for the next meaningful rumour.
This 'conversation skill' starts at 10% and is capped at 50%.

This 'conversation skill' degrades by 0.25% every hour you don't have at least one direct (i.e. face-to-face) conversation.
This should be negated by your day-to-day activities like: checking with traders for argnu beef, picking up passengers, talking to faction representatives, etc.
This penalty can be customised in the mod's Extension Options.

Generic missions:
=================
Depending on the NPC's profession and/or role, the generic mission offered will be one of following:
-(Chat about the wars): This will produce combat-type missions. NPC's who are marines, officers, pilots, or similar professions offer these types of missions.
-(Chat about life in space): Economic-type missions. Offered by any other NPC.
-(Chat about science): Engineering-type missions. Offered by any other NPC.
-(Chat about the galaxy): Any of the three above. Offered by faction representatives and black marketeers.

Extension options support:
==========================
This is an optional feature that is available when SirNukes Mod Support APIs mod (https://www.nexusmods.com/x4foundations/mods/503) is installed.

When installed, these mod options can be customised:
-No direct conversation penalty
-Same race bonus
-Friendly faction bonus
-Friendly faction in enemy sector bonus

Install:
========
-Unzip to 'X4 Foundations/extensions/kuertee_npc_reactions/'.
-Make sure the sub-folders and files are in 'X4 Foundations/extensions/kuertee_npc_reactions/' and not in 'X4 Foundations/extensions/kuertee_npc_reactions/kuertee_npc_reactions/'.
-If 'X4 Foundations/extensions/' is inaccessible, try 'Documents/Egosoft/X4/XXXXXXXX/extensions/kuertee_npc_reactions/' - where XXXXXXXX is a number that is specific to your computer.

Uninstall:
==========
-Delete the mod folder.
Last edited by kuertee on Sun, 24. May 20, 15:02, edited 1 time in total.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [mod] NPC reactions

Post by kuertee » Fri, 22. May 20, 18:12

I've updated this mod

NPC reactions
https://www.nexusmods.com/x4foundations/mods/497
(previously named Rumour topics)
by kuertee

Update:
=======
v1.1.0, 22 May 2020:
-Conversing with an NPC from the same race gives a 2.5% bonus to the chance of a meaningful rumour.
-Conversing with an NPC from a friendly faction, another 2.5% bonus.
-Conversing with an NPC from a friendly faction while in an enemy sector, a further 2.5% bonus.
-An NPC can offer only one meaningful rumour per hour.
-Generic missions are categorised as: combat, economic, engineering. The type of mission offered will be based on the NPC's profession and/or role.
-Your 'conversation skill' degrades by 0.25% every hour you don't have at least one direct (i.e. face-to-face) conversation. This should be negated by your day-to-day activities like: checking with traders for argnu beef, picking up passengers, talking to faction representatives, etc.
-Extension options support: Customise the penalties and bonuses above.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

Mycu
Posts: 410
Joined: Fri, 28. Sep 12, 08:30
x4

Re: [mod] NPC reactions

Post by Mycu » Sat, 23. May 20, 09:24

Thank you for a considerable update containing 'conversation skill' degradation mechanism.
Also it's nice to have configuration through SirNukes Extension Options menu.
X3 AP 3.1 + XRM
X3 AP 3.1 + LU

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [mod] NPC reactions

Post by kuertee » Sat, 23. May 20, 17:49

No, thank you for your suggestions.

I would have left my mod at v1, otherwise.

And I changed the name of the mod to follow my other mods of other games. (E.g. Skyrim's NPC Reactions).

I now have other ideas, from my work on the update, that relate to NPCs. I'm not sure yet if they're all possible. But some of those ideas, definitely are.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [mod] NPC reactions

Post by kuertee » Sat, 23. May 20, 17:55

And ... I just found a bug. The random chance of a meaningful rumour is always successful.

Update within the next hour.

EDIT: This bug-fix update is now available on Nexus.
v1.1.1, 23 May 2020:
-The random chance of a meaningful rumour in the previous version was always 100%.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

hxsgame
Posts: 210
Joined: Thu, 4. Oct 18, 16:54
x4

Re: [mod] NPC reactions

Post by hxsgame » Mon, 15. Jun 20, 16:40

Hello, I really like this mod. provides missions In this way it's very natural.

and I learned a lot by reading your mod, thank you very much.


In this part I don’t understand that, in:

Code: Select all

<remove_value name="$MissionSetUpCue" />
and

Code: Select all

<signal_cue_instantly cue="$MissionSetUpCue" param="table[……
In both places have "$MissionSetUpCue", They don't look the same mean.

Maybe you can give a brief explanation of them and the meaning of this <cue>, thank you very much.

Code: Select all

<cue name="GenerateMission">
	<actions>
		<debug_text text="GenerateMission" chance="md.kuertee_npc_reactions.NPCReactions.$DebugChance" />
		<set_value name="$GenerateMissionCount" exact="$GenerateMissionCount + 1" />
		<debug_text text="'$GenerateMissionCount: ' + $GenerateMissionCount" chance="md.kuertee_npc_reactions.NPCReactions.$DebugChance" />
		<remove_value name="$MissionSetUpCue" />
		<do_if value="not @$MissionSetUpCue">
			<do_if value="$genericMissionType == 'any'">
				<include_actions ref="GetAnyTypeMission" />
			</do_if>
			<do_elseif value="$genericMissionType == 'combat'">
				<include_actions ref="GetCombatTypeMission" />
			</do_elseif>
			<do_elseif value="$genericMissionType == 'economic'">
				<include_actions ref="GetEconomicTypeMission" />
			</do_elseif>
			<do_elseif value="$genericMissionType == 'engineering'">
				<include_actions ref="GetEngineeringTypeMission" />
			</do_elseif>
		</do_if>
		<do_if value="not @$Client and $isNPCInstanced">
			<do_any>
				<set_value name="$Client" exact="$npc" />
				<set_value name="$Client" exact="null" />
			</do_any>
		</do_if>
		<signal_cue_instantly cue="$MissionSetUpCue" param="table[
			$Sector = $Sector,
			$ReportSignalCue = OnGenerateMission,
			$RemoveOnSectorChange = false,
			$Client = $Client,
			$DebugChance = md.kuertee_npc_reactions.NPCReactions.$DebugChance
			]" />
		<set_value name="$MissionCue" exact="null" />
		<set_value name="$OnRumourMissionGalaxyGenerateFail" exact="CleanRumourMissionGalaxy" />
		<set_value name="$OnRumourMissionGalaxyComplete" exact="CleanRumourMissionGalaxy" />
	</actions>
</cue>

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [mod] NPC reactions

Post by kuertee » Tue, 16. Jun 20, 04:11

Hi hxsgame,

I'm simply resetting $MissionSetUpCue to empty with "remove_value".
I could have easily used "set_value name='$MissionSetUpCue" exact="null" or something like that.

The "include_actions" (e.g. include_actions ref='GetCombatTypeMission') randomly sets $MissionSetUpCue to one of the generic missions in the base game.
These generic missions are in the folder "md" (once you extract the files) and their filenames are prefixed with "gm_" (e.g. "gm_achievecoverage.xml").

The "<signal_cue_instantly cue="$MissionSetUpCue" param="table[ ..." simply calls whatever $MissionSetUpCue was chosen with a set of mission parameters (e.g. $Sector).
I also set the callback "$ReportSignalCue" cue to "OnGenerateMission".
This is triggered in the mission (from the base game) that was chosen when it succeeds or fails in setting itself up.
(E.g. it fails when no suitable mission target is found/created).

When OnGenerateMission is triggered, it receives data from the md in regards to the mission set-up.
If the mission set-up failed (i.e. no valid mission), I let my mod try to regenerate another random mission for up to 25 times.
You can see the re-do of GenerateMission in this bit of code in the "OnGenerateMission" cue:

Code: Select all

<do_elseif value="$GenerateMissionCount lt 25">
	<!-- generate another mission -->
	<reset_cue cue="GenerateMission" />
</do_elseif>




This whole sequence is basically a copy of the mission generator in the base game's "md/genericmissions.xml" script.
Although what you see in my mod is a trimmed/cleaned-up version and with more callbacks for the purposes of my mod.

Did that answer your question?
And I hope that helps you in creating your own story mod.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

hxsgame
Posts: 210
Joined: Thu, 4. Oct 18, 16:54
x4

Re: [mod] NPC reactions

Post by hxsgame » Tue, 16. Jun 20, 06:55

kuertee wrote:
Tue, 16. Jun 20, 04:11
Hi hxsgame,

I'm simply resetting $MissionSetUpCue to empty with "remove_value".
I could have easily used "set_value name='$MissionSetUpCue" exact="null" or something like that.

The "include_actions" (e.g. include_actions ref='GetCombatTypeMission') randomly sets $MissionSetUpCue to one of the generic missions in the base game.
These generic missions are in the folder "md" (once you extract the files) and their filenames are prefixed with "gm_" (e.g. "gm_achievecoverage.xml").

The "<signal_cue_instantly cue="$MissionSetUpCue" param="table[ ..." simply calls whatever $MissionSetUpCue was chosen with a set of mission parameters (e.g. $Sector).
I also set the callback "$ReportSignalCue" cue to "OnGenerateMission".
This is triggered in the mission (from the base game) that was chosen when it succeeds or fails in setting itself up.
(E.g. it fails when no suitable mission target is found/created).

When OnGenerateMission is triggered, it receives data from the md in regards to the mission set-up.
If the mission set-up failed (i.e. no valid mission), I let my mod try to regenerate another random mission for up to 25 times.
You can see the re-do of GenerateMission in this bit of code in the "OnGenerateMission" cue:

Code: Select all

<do_elseif value="$GenerateMissionCount lt 25">
	<!-- generate another mission -->
	<reset_cue cue="GenerateMission" />
</do_elseif>




This whole sequence is basically a copy of the mission generator in the base game's "md/genericmissions.xml" script.
Although what you see in my mod is a trimmed/cleaned-up version and with more callbacks for the purposes of my mod.

Did that answer your question?
And I hope that helps you in creating your own story mod.
Glad to get your answer kuertee.
Now, I find that my focus is not only on not understanding $MissionSetUpCue(Now I know After reading your explanation, it's helpful), but not familiar with the mechanism of md.

Thank you for your wishes, I will proceed.

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [mod] NPC reactions

Post by kuertee » Tue, 16. Jun 20, 08:24

hxsgame wrote:
Tue, 16. Jun 20, 06:55
Glad to get your answer kuertee.
Now, I find that my focus is not only on not understanding $MissionSetUpCue(Now I know After reading your explanation, it's helpful), but not familiar with the mechanism of md.

Thank you for your wishes, I will proceed.
The whole generic mission generator sequence in my mod and in the base game (genericmissions.xml) can get very confusing.

For a simpler NPC conversation > mission > fail/success callback, I suggest you look at the missions for finding lockboxes (or data vaults, or anomalies) in NPC Reactions.
That mission structure is simply: (1) get mission from conversation, (2) create a lockbox in space, (3) set-up the mission for it.
Also, if you do a debug_trace on the cue variable names, e.g. $MissionSetUpCue, etc., you'll see that they simply point to <cue>s.
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

Cedric_FP
Posts: 189
Joined: Thu, 13. Apr 06, 17:56
x4

Re: [mod] NPC reactions

Post by Cedric_FP » Wed, 17. Jun 20, 02:03

Would you mind listing out the various mission types NPCs can spawn? For example, can they spawn a build station or assemble fleet mission?

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [mod] NPC reactions

Post by kuertee » Wed, 17. Jun 20, 04:08

All but one of the generic missions that can pop into your BBS as you fly over stations can be offered by NPCs in my mod.
Here's my list:
Spoiler
Show

Code: Select all

				<library name="GetAnyTypeMission">
					<actions>
						<debug_text text="GetAnyTypeMission" chance="md.kuertee_npc_reactions.NPCReactions.$DebugChance" />
						<do_any>
							<set_value name="$MissionSetUpCue" exact="md.GM_Assassinate.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_DeployInPlace.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_Destroy_Objects.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_Find_Resources.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_Rescue_Ship.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_RepairObject.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_Transport_Passengers.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_Scan.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_SupplyFactory.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_GetExactCrew.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_BringItems.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_RetrieveItem.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_FindObject.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_BuildStation.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_KillMasstraffic.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_RepairSignalLeaks.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_TrackShip.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_BoardShip.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_Patrol.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GM_Destroy_RarelyOnSight.GenerateGenericMission" />
							<set_value name="$MissionSetUpCue" exact="md.GMC_Assisted_Task.GenerateGenericMission" />
						</do_any>
					</actions>
				</library>
And here is the base game's list:
Spoiler
Show

Code: Select all

                  <do_any>
                    <set_value name="$Cue" exact="md.GM_Assassinate.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_DeployInPlace.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_Destroy_Objects.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_Find_Resources.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_Rescue_Ship.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_RepairObject.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_Transport_Passengers.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_Scan.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_SupplyFactory.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_GetExactCrew.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_BringItems.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_RetrieveItem.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_FindObject.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_BuildStation.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_KillMasstraffic.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_RepairSignalLeaks.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_TrackShip.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_BoardShip.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_Patrol.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GM_Destroy_RarelyOnSight.GenerateGenericMission"/>
                    <set_value name="$Cue" exact="md.GMC_Assisted_Task.GenerateGenericMission"/>
                    <do_all weight="if Manager.$SignalledMissions.indexof.{md.GM_LargeSupply.GenerateGenericMission} then 0 else 1" comment="Only signal once">
                      <set_value name="$Cue" exact="md.GM_LargeSupply.GenerateGenericMission"/>
                    </do_all>
                  </do_any>
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

hxsgame
Posts: 210
Joined: Thu, 4. Oct 18, 16:54
x4

Re: [mod] NPC reactions

Post by hxsgame » Wed, 17. Jun 20, 06:52

kuertee wrote:
Tue, 16. Jun 20, 08:24
hxsgame wrote:
Tue, 16. Jun 20, 06:55
Glad to get your answer kuertee.
Now, I find that my focus is not only on not understanding $MissionSetUpCue(Now I know After reading your explanation, it's helpful), but not familiar with the mechanism of md.

Thank you for your wishes, I will proceed.
The whole generic mission generator sequence in my mod and in the base game (genericmissions.xml) can get very confusing.

For a simpler NPC conversation > mission > fail/success callback, I suggest you look at the missions for finding lockboxes (or data vaults, or anomalies) in NPC Reactions.
That mission structure is simply: (1) get mission from conversation, (2) create a lockbox in space, (3) set-up the mission for it.
Also, if you do a debug_trace on the cue variable names, e.g. $MissionSetUpCue, etc., you'll see that they simply point to <cue>s.
yes, it's really confusing in started.
But after insisting for 2 days now I slowly understanding.
"finding lockboxes"mission structure is indeed simpler. it's my Next learning objective. :wink:

hxsgame
Posts: 210
Joined: Thu, 4. Oct 18, 16:54
x4

Re: [mod] NPC reactions

Post by hxsgame » Wed, 17. Jun 20, 13:06

I extracted the main part of the "mission" part of the mod.
hoping to help more commander who like this mod to learn.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="kuertee_npc_reactions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
	<cues>
		<cue name="NPCReactions" namespace="this" version="2">
			<delay exact="5s" />
			<cues>
				<cue name="OnConversationStarted">
					<conditions>
						<event_conversation_started conversation="default" />
					</conditions>
					<actions>
						<do_all>
							<set_value name="$npc" exact="event.object" />
							<do_if value="@$npc.count gt 1">
								<set_value name="$isNPCInstanced" exact="false" />
							</do_if>
							<do_else>
								<set_value name="$isNPCInstanced" exact="true" />
								<set_value name="$npcSector" exact="$npc.sector" />
								<set_value name="$npcStation" exact="$npc.station" />
								<set_value name="$npcOwner" exact="$npc.owner" />
								<set_value name="$isRumourSelected" exact="false" />
							</do_else>
						</do_all>
					</actions>
					<cues>
						<cue name="ContinueOnConversationStarted">
							<actions>
								<signal_cue cue="AddRumourTopics" />
							</actions>
						</cue>
						<cue name="AddRumourTopics">
							<conditions>
								<check_all>
									<check_any>
										<event_cue_signalled />
										<event_conversation_returned_to_section section="default" />
									</check_any>
									<check_value value="not $isRumourSelected" />
								</check_all>
							</conditions>
							<actions>
									<do_all>
										<set_value name="$choiceText" exact="{1416318,688845}" />
										<do_if value="@$choiceText">
											<add_player_choice text="'(' + $choiceText + ')'" section="rumour_topic_galaxy" />
										</do_if>
										<do_else>
											<add_player_choice text="'(Chat about the galaxy)'" section="rumour_topic_galaxy" />
										</do_else>
									</do_all>
								<reset_cue cue="this" />
							</actions>
						</cue>
						<cue name="OnConversationNextSectionRumourTopic">
							<conditions>
								<event_conversation_next_section sectionprefix="rumour_" />
							</conditions>
							<actions>
								<set_value name="$isRumourSelected" exact="true" />
								<do_if value="event.param == 'rumour_topic_galaxy'">
									<signal_cue cue="RumourTopicGalaxyCue" />
								</do_if>
								<reset_cue cue="this" />
							</actions>
						</cue>
						<cue name="RumourTopicGalaxyCue">
							<conditions>
								<event_cue_signalled />
							</conditions>
							<actions>
								<do_all>
									<signal_cue cue="RumourMissionGalaxy" />
									<reset_cue cue="this" />
								</do_all>
							</actions>
						</cue>
						<cue name="OnConversationFinished">
							<conditions>
								<check_any>
									<event_cue_signalled />
									<event_conversation_finished actor="$npc" />
								</check_any>
							</conditions>
							<actions>
								<reset_cue cue="parent" />
							</actions>
						</cue>
					</cues>
				</cue>
				<cue name="RumourMissionGalaxy" instantiate="true" namespace="this">
					<conditions>
						<event_cue_signalled />
					</conditions>
					<actions>
						<do_all>
							<set_value name="$npc" exact="md.kuertee_npc_reactions.NPCReactions.$npc" />
							<set_value name="$isNPCInstanced" exact="md.kuertee_npc_reactions.NPCReactions.$isNPCInstanced" />
							<set_value name="$npcSector" exact="md.kuertee_npc_reactions.NPCReactions.$npcSector" />
						</do_all>
					</actions>
					<cues>
						<cue name="GenerateMission">
							<actions>
								<do_all>
									<remove_value name="$MissionSetUpCue" />
									<do_if value="not @$MissionSetUpCue">
										<include_actions ref="GetAnyTypeMission" />
									</do_if>
								
									<signal_cue_instantly cue="$MissionSetUpCue" param="table[$Sector = $npcSector]" />
								</do_all>
							</actions>
						</cue>
					</cues>
				</cue>
				<library name="GetAnyTypeMission">
					<actions>
						<set_value name="$MissionSetUpCue" exact="md.GM_BuildStation.GenerateGenericMission" />
					</actions>
				</library>
			</cues>
		</cue>
	</cues>
</mdscript>
Last edited by hxsgame on Wed, 17. Jun 20, 16:36, edited 1 time in total.

hxsgame
Posts: 210
Joined: Thu, 4. Oct 18, 16:54
x4

Re: [mod] NPC reactions

Post by hxsgame » Wed, 17. Jun 20, 16:31

hxsgame wrote:
Wed, 17. Jun 20, 13:06
I extracted the main part of the "mission" part of the mod.
hoping to help more commander who like this mod to learn.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="kuertee_npc_reactions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
	<cues>
		<cue name="NPCReactions" namespace="this" version="2">
			<delay exact="5s" />
			<cues>
				<cue name="OnConversationStarted">
					<conditions>
						<event_conversation_started conversation="default" />
					</conditions>
					<actions>
						<do_all>
							<set_value name="$npc" exact="event.object" />
							<do_if value="@$npc.count gt 1">
								<set_value name="$isNPCInstanced" exact="false" />
							</do_if>
							<do_else>
								<set_value name="$isNPCInstanced" exact="true" />
								<set_value name="$npcSector" exact="$npc.sector" />
								<set_value name="$npcStation" exact="$npc.station" />
								<set_value name="$npcOwner" exact="$npc.owner" />
								<set_value name="$isRumourSelected" exact="false" />
							</do_else>
						</do_all>
					</actions>
					<cues>
						<cue name="ContinueOnConversationStarted">
							<actions>
								<signal_cue cue="AddRumourTopics" />
							</actions>
						</cue>
						<cue name="AddRumourTopics">
							<conditions>
								<check_all>
									<check_any>
										<event_cue_signalled />
										<event_conversation_returned_to_section section="default" />
									</check_any>
									<check_value value="not $isRumourSelected" />
								</check_all>
							</conditions>
							<actions>
									<do_all>
										<set_value name="$choiceText" exact="{1416318,688845}" />
										<do_if value="@$choiceText">
											<add_player_choice text="'(' + $choiceText + ')'" section="rumour_topic_galaxy" />
										</do_if>
										<do_else>
											<add_player_choice text="'(Chat about the galaxy)'" section="rumour_topic_galaxy" />
										</do_else>
									</do_all>
								<reset_cue cue="this" />
							</actions>
						</cue>
						<cue name="OnConversationNextSectionRumourTopic">
							<conditions>
								<event_conversation_next_section sectionprefix="rumour_" />
							</conditions>
							<actions>
								<set_value name="$isRumourSelected" exact="true" />
								<do_if value="event.param == 'rumour_topic_galaxy'">
									<signal_cue cue="RumourTopicGalaxyCue" />
								</do_if>
								<reset_cue cue="this" />
							</actions>
						</cue>
						<cue name="RumourTopicGalaxyCue">
							<conditions>
								<event_cue_signalled />
							</conditions>
							<actions>
								<do_all>
									<signal_cue cue="RumourMissionGalaxy" />
									<reset_cue cue="this" />
								</do_all>
							</actions>
						</cue>
						<cue name="OnConversationFinished">
							<conditions>
								<check_any>
									<event_cue_signalled />
									<event_conversation_finished actor="$npc" />
								</check_any>
							</conditions>
							<actions>
								<reset_cue cue="parent" />
							</actions>
						</cue>
					</cues>
				</cue>
				<cue name="RumourMissionGalaxy" instantiate="true" namespace="this">
					<conditions>
						<event_cue_signalled />
					</conditions>
					<actions>
						<do_all>
							<set_value name="$npc" exact="md.kuertee_npc_reactions.NPCReactions.$npc" />
							<set_value name="$isNPCInstanced" exact="md.kuertee_npc_reactions.NPCReactions.$isNPCInstanced" />
							<set_value name="$npcSector" exact="md.kuertee_npc_reactions.NPCReactions.$npcSector" />
						</do_all>
					</actions>
					<cues>
						<cue name="GenerateMission">
							<actions>
								<do_all>
									<remove_value name="$MissionSetUpCue" />
									<do_if value="not @$MissionSetUpCue">
										<include_actions ref="GetAnyTypeMission" />
									</do_if>
								
									<signal_cue_instantly cue="$MissionSetUpCue" param="table[$Sector = $npcSector]" />
								</do_all>
							</actions>
						</cue>
					</cues>
				</cue>
				<library name="GetAnyTypeMission">
					<actions>
						<set_value name="$MissionSetUpCue" exact="md.GM_BuildStation.GenerateGenericMission" />
					</actions>
				</library>
			</cues>
		</cue>
	</cues>
</mdscript>

kuertee
EGOSOFT
EGOSOFT
Posts: 789
Joined: Sun, 14. Dec 03, 13:05
x4

Re: [mod] NPC reactions

Post by kuertee » Thu, 18. Jun 20, 16:30

hxsgame wrote:
Wed, 17. Jun 20, 13:06
I extracted the main part of the "mission" part of the mod.
hoping to help more commander who like this mod to learn.
... snipped ...
I reckon keep the clean-up routines that gets called when:
(1) the mission fails to be created (e.g. no valid mission target created. i.e. code: "static.$FeedbackValue.$ID == '$MISSION_NO_VARIANT"),
OR when:
(2) the mission ends with either success, failure, or abortion (i.e. code: "@static.$EndFeedbackValue")

If the mission cue is not cleaned up properly, they'll like be stored in the save game as "dead" data until the mod is uninstalled.

Here's your trimmed version of my code with the housekeeping call-backs added back in:
Spoiler
Show

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="kuertee_npc_reactions" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
	<cues>
		<cue name="NPCReactions" namespace="this" version="2">
			<delay exact="5s" />
			<cues>
				<cue name="OnConversationStarted">
					<conditions>
						<event_conversation_started conversation="default" />
					</conditions>
					<actions>
						<do_all>
							<set_value name="$npc" exact="event.object" />
							<do_if value="@$npc.count gt 1">
								<set_value name="$isNPCInstanced" exact="false" />
							</do_if>
							<do_else>
								<set_value name="$isNPCInstanced" exact="true" />
								<set_value name="$npcSector" exact="$npc.sector" />
								<set_value name="$npcStation" exact="$npc.station" />
								<set_value name="$npcOwner" exact="$npc.owner" />
								<set_value name="$isRumourSelected" exact="false" />
							</do_else>
						</do_all>
					</actions>
					<cues>
						<cue name="ContinueOnConversationStarted">
							<actions>
								<signal_cue cue="AddRumourTopics" />
							</actions>
						</cue>
						<cue name="AddRumourTopics">
							<conditions>
								<check_all>
									<check_any>
										<event_cue_signalled />
										<event_conversation_returned_to_section section="default" />
									</check_any>
									<check_value value="not $isRumourSelected" />
								</check_all>
							</conditions>
							<actions>
									<do_all>
										<set_value name="$choiceText" exact="{1416318,688845}" />
										<do_if value="@$choiceText">
											<add_player_choice text="'(' + $choiceText + ')'" section="rumour_topic_galaxy" />
										</do_if>
										<do_else>
											<add_player_choice text="'(Chat about the galaxy)'" section="rumour_topic_galaxy" />
										</do_else>
									</do_all>
								<reset_cue cue="this" />
							</actions>
						</cue>
						<cue name="OnConversationNextSectionRumourTopic">
							<conditions>
								<event_conversation_next_section sectionprefix="rumour_" />
							</conditions>
							<actions>
								<set_value name="$isRumourSelected" exact="true" />
								<do_if value="event.param == 'rumour_topic_galaxy'">
									<signal_cue cue="RumourTopicGalaxyCue" />
								</do_if>
								<reset_cue cue="this" />
							</actions>
						</cue>
						<cue name="RumourTopicGalaxyCue">
							<conditions>
								<event_cue_signalled />
							</conditions>
							<actions>
								<do_all>
									<signal_cue cue="RumourMissionGalaxy" />
									<reset_cue cue="this" />
								</do_all>
							</actions>
						</cue>
						<cue name="OnConversationFinished">
							<conditions>
								<check_any>
									<event_cue_signalled />
									<event_conversation_finished actor="$npc" />
								</check_any>
							</conditions>
							<actions>
								<reset_cue cue="parent" />
							</actions>
						</cue>
					</cues>
				</cue>
				<cue name="RumourMissionGalaxy" instantiate="true" namespace="this">
					<conditions>
						<event_cue_signalled />
					</conditions>
					<actions>
						<do_all>
							<set_value name="$npc" exact="md.kuertee_npc_reactions.NPCReactions.$npc" />
							<set_value name="$isNPCInstanced" exact="md.kuertee_npc_reactions.NPCReactions.$isNPCInstanced" />
							<set_value name="$npcSector" exact="md.kuertee_npc_reactions.NPCReactions.$npcSector" />
						</do_all>
					</actions>
					<cues>
						<cue name="GenerateMission">
							<actions>
								<do_all>
									<remove_value name="$MissionSetUpCue" />
									<do_if value="not @$MissionSetUpCue">
										<include_actions ref="GetAnyTypeMission" />
									</do_if>
									<signal_cue_instantly cue="$MissionSetUpCue" param="table[$Sector = $npcSector, $ReportSignalCue = OnGenerateMission]" />
									<set_value name="$OnRumourMissionGalaxyGenerateFail" exact="CleanRumourMissionGalaxy" />
									<set_value name="$OnRumourMissionGalaxyComplete" exact="CleanRumourMissionGalaxy" />
								</do_all>
							</actions>
						</cue>
						<cue name="OnGenerateMission" instantiate="true">
							<!-- notes: -->
							<!-- $GM_Wrapper = $MissionSetUpCue = md.*.GenerateGenericMission -->
							<!-- $MissionCue = event.param.$Cue = md.*.Start = used in MissionBriefingMenu -->
							<conditions>
								<event_cue_signalled/>
							</conditions>
							<actions>
								<do_if value="@static.$EndFeedbackValue" comment="Evaluate return-value of GM (success/failure)">
									<set_value name="$IsMissionFinished" exact="true" />
									<cancel_cue cue="static.$GM_Wrapper" />
									<do_if value="$MissionCue">
										<!-- mission was generated, clean -->
										<do_if value="@$OnRumourMissionGalaxyComplete">
											<signal_cue cue="$OnRumourMissionGalaxyComplete" />
										</do_if>
									</do_if>
									<do_else>
										<do_if value="@$OnRumourMissionGalaxyGenerateFail">
											<signal_cue cue="$OnRumourMissionGalaxyGenerateFail" />
										</do_if>
									</do_else>
								</do_if>
								<do_elseif value="@static.$FeedbackValue">
									<do_if value="static.$FeedbackValue.$ID == '$MISSION_ACCEPTED'">
										<set_value name="$IsMissionAccepted" exact="true" />
									</do_if>
									<do_if value="static.$FeedbackValue.$ID == '$MISSION_GENERATED'">
										<set_value name="$MissionCue" exact="event.param.$Cue" />
										<open_conversation_menu menu="MissionBriefingMenu" param="[0, 0, $MissionCue, true]" />
									</do_if>
									<do_elseif value="static.$FeedbackValue.$ID == '$MISSION_NO_VARIANT'">
										<do_if value="@$OnRumourMissionGalaxyGenerateFail">
											<signal_cue cue="$OnRumourMissionGalaxyGenerateFail" />
										</do_if>
									</do_elseif>
								</do_elseif>
							</actions>
						</cue>
						<cue name="CleanRumourMissionGalaxy" instantiate="true">
							<conditions>
								<check_any>
									<event_cue_signalled/>
									<event_conversation_finished />
								</check_any>
							</conditions>
							<actions>
								<do_if value="@$MissionCue">
									<remove_offer cue="$MissionCue" />
								</do_if>
								<do_if value="(not $IsMissionAccepted) or $IsMissionFinished">
									<do_if value="@$MissionCue">
										<cancel_cue cue="$MissionCue" />
									</do_if>
									<do_if value="@static.$GM_Wrapper">
										<cancel_cue cue="static.$GM_Wrapper" />
									</do_if>
									<cancel_cue cue="namespace" />
								</do_if>
							</actions>
						</cue>
					</cues>
				</cue>
				<library name="GetAnyTypeMission">
					<actions>
						<set_value name="$MissionSetUpCue" exact="md.GM_BuildStation.GenerateGenericMission" />
					</actions>
				</library>
			</cues>
		</cue>
	</cues>
</mdscript>
Mods: RPG: Reputations and Professions, Social Standings and Citizenships, Crime has Consequences, Alternatives to Death. Missions/NPCs: Emergent Missions, NPC Reactions, Mod Parts Trader, High-sec Rooms are Locked, Hacking Outcomes, More Generic Missions, Waypoint Fields for Deployment. Others: Auto-cam, Friendly Fire Tweaks, Teleport From Transporter Room, Wear and Tear. QoL: Trade Analytics, Loot Mining, Ship Scanner, Signal Leak Hunter, Station Scanner, Surface Element Targeting, etc.

Post Reply

Return to “X4: Foundations - Scripts and Modding”