[mod test] Friendly Fire Tweaks test request

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 test] Friendly Fire Tweaks test request

Post by kuertee » Tue, 27. Apr 21, 06:48

Can someone help me do a quick test of this mod?
My ship is in Xenon space, so I can't test it properly.

I have tested in regards to the Xenon NOT ignoring friendly fire from your turrets.
But I've not tested it on actual friendlies.
Otherwise, I'll be able to test it properly in a couple of days.
And I'll do a proper release to Nexus after.
Thank you.

Friendly fire from the player's turrets are ignored by the NPC except when:
(1) their shields are less than 25%, or
(2) their relationship is less than neutral,
(3) they are targeted.
https://drive.google.com/file/d/1ecIRa8 ... sp=sharing



EDIT:
And for those who check the logs, they should see these two types of lines:
On new target:

Code: Select all

[Scripts] 155008.97 *** Context:md.Notifications.kFFT_NewTarget: kuertee kFFT_NewTarget $kFFT_target: 0x4ce9d (XEN Raiding Party M)
When friendly fire is NOT ignored. When it is ignored, then no lines will be logged.

Code: Select all

[Scripts] 155020.33 *** Context:md.Notifications.PlayerAttacks<inst:e459f>: kuertee PlayerAttacks event.param: 0x4ce9d (XEN Raiding Party M) friendly fire not ignored
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.

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: [mod test] Friendly Fire Tweaks test request

Post by Alkeena » Tue, 27. Apr 21, 08:56

kuertee wrote:
Tue, 27. Apr 21, 06:48
Can someone help me do a quick test of this mod?
My ship is in Xenon space, so I can't test it properly.

I have tested in regards to the Xenon NOT ignoring friendly fire from your turrets.
But I've not tested it on actual friendlies.
Otherwise, I'll be able to test it properly in a couple of days.
And I'll do a proper release to Nexus after.
Thank you.

Friendly fire from the player's turrets are ignored by the NPC except when:
(1) their shields are less than 25%, or
(2) their relationship is less than neutral,
(3) they are targeted.
https://drive.google.com/file/d/1ecIRa8 ... sp=sharing



EDIT:
And for those who check the logs, they should see these two types of lines:
On new target:

Code: Select all

[Scripts] 155008.97 *** Context:md.Notifications.kFFT_NewTarget: kuertee kFFT_NewTarget $kFFT_target: 0x4ce9d (XEN Raiding Party M)
When friendly fire is NOT ignored. When it is ignored, then no lines will be logged.

Code: Select all

[Scripts] 155020.33 *** Context:md.Notifications.PlayerAttacks<inst:e459f>: kuertee PlayerAttacks event.param: 0x4ce9d (XEN Raiding Party M) friendly fire not ignored
I also won't be in a position to test anything for a few days, but did want to say thanks for looking into it, and good luck!

I would suggest dropping the first condition or you'll still get a bunch of frustrating false positives in big battles. For Ai controlled player ships I think you can just rely on temporary standings since they won't attack (intentionally) without setting something explicitly hostile. Player ship is a bit trickier of course--but since there's only one in the game it might be worth the performance overhead to track how much damage the player has actually done and only trigger a relation change after passing a certain threshold. Better kill credit probably has a good example on how to do it.

Godspeed!

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

Re: [mod test] Friendly Fire Tweaks test request

Post by kuertee » Tue, 27. Apr 21, 11:09

Alkeena wrote:
Tue, 27. Apr 21, 08:56
...I also won't be in a position to test anything for a few days, but did want to say thanks for looking into it, and good luck!

I would suggest dropping the first condition or you'll still get a bunch of frustrating false positives in big battles. For Ai controlled player ships I think you can just rely on temporary standings since they won't attack (intentionally) without setting something explicitly hostile. Player ship is a bit trickier of course--but since there's only one in the game it might be worth the performance overhead to track how much damage the player has actually done and only trigger a relation change after passing a certain threshold. Better kill credit probably has a good example on how to do it.

Godspeed!
Thanks, Alkeena!

I'm only adding these new conditions to the MD cue that Egosoft uses to (1) warn the player of friendly fire then (2) engage the player if the warning is ignored.

Instead of that cue executing at every player attack (which is the case in the base game and which is the case in big battles), my mod will add its three additional conditions - throttling false positives further.
Also, I don't want to remove the penalty to friendly fire completely. Hene, if their shields are low, Egosoft's cue will function normally. I.e.: warn the player, engage if ignored.

It's the same cue that my other mod, Crime has consequences (CHC), uses to determine if the fines stick (warning on attack ignored by the player) or not. So, CHC will be automatically compatible with this.
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.

Max Bain
Posts: 1461
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [mod test] Friendly Fire Tweaks test request

Post by Max Bain » Wed, 28. Apr 21, 23:41

Hi, thank you for this mod.
I have removed the first and second condition so that I only will be punished when the fire is intended. I hope it works :)
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

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

Re: [mod test] Friendly Fire Tweaks test request

Post by kuertee » Thu, 29. Apr 21, 04:04

Max Bain wrote:
Wed, 28. Apr 21, 23:41
Hi, thank you for this mod.
I have removed the first and second condition so that I only will be punished when the fire is intended. I hope it works :)
thankx, max! let us know if it works.
I'm still trying to rid tharkas cascade 15 of xenon.
but the one time I hopped into the split sector north of tc15 (to check if there were xenon stations there), and a xenon raiding party attacked me near a split station, the split didn't complain about my turrets.
it's likely that I didn't hit the station with my turrets. i was in a corvette.
but its also likely that I did hit their station and the mod worked.
so ... i don't know yet if my diffs works or not.
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.

Berni
Posts: 515
Joined: Sun, 15. Feb 04, 13:52
x4

Re: [mod test] Friendly Fire Tweaks test request

Post by Berni » Thu, 29. Apr 21, 09:27

Hello kuertee, your mod looks very promising.

One question, is it maybe possible to combine this mod with some kind of "unauthorized attack" (or kill) check? (Or even better disable this mechanic)
It is very frustrating losing reputation because of some of my ships defended themself against pirates or attacking one of my enemies.

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

Re: [mod test] Friendly Fire Tweaks test request

Post by kuertee » Fri, 30. Apr 21, 03:16

Berni wrote:
Thu, 29. Apr 21, 09:27
Hello kuertee, your mod looks very promising.
thank you.
One question, is it maybe possible to combine this mod with some kind of "unauthorized attack" (or kill) check? (Or even better disable this mechanic)
It is very frustrating losing reputation because of some of my ships defended themself against pirates or attacking one of my enemies.
Friendly fire penalties (e.g. that temporary relationship penalty and then friendlies turning red) only occur on player-controlled ships. your AI pilots never get penalised for friendly fire (as far as I can tell from Egosoft's code).

Your AI pilots will certainly engage friendlies - but only if their AI dictates that they should. But penalties caused by friendly fire from your AI pilots simply doesn't happen.
Last edited by kuertee on Fri, 30. Apr 21, 03:19, 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 test] Friendly Fire Tweaks test request

Post by kuertee » Fri, 30. Apr 21, 03:18

NOTE: I've still not tested this properly, because I'm still in Xenon space. (Only 3 Xenon stations left in that sector.)
So if anyone has managed to try this out and found it work, please let me know, and I'll release it publicly.
Thank you.
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.

Alkeena
Posts: 603
Joined: Tue, 15. May 07, 20:43
x4

Re: [mod test] Friendly Fire Tweaks test request

Post by Alkeena » Tue, 4. May 21, 03:31

Hey, I went to SirNukes github to reference some of his API docs and noticed this just hanging out from like a year ago:

https://github.com/bvbohnen/x4-projects ... dlier_fire

Maybe worth perusing for ideas and/or following up with SN?

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

Re: [mod test] Friendly Fire Tweaks test request

Post by kuertee » Tue, 4. May 21, 04:25

Cool!

I had a look at his code. His code listens for changes to the player's relationship with the faction and then counteracts it if his code detects that its from friendly fire.

My mod is more direct. My mod prevents Egosoft's penalties for friendly fire by stopping Egosoft's actual code for friendly fire penalties that (1) detects friendly fire then (2) warns the player of friendly fire and (3) applies the relationship penalty and engages the player if the warning is ignored. Egosoft's code for all this is in "md\notifications.xml" in the "PlayerAttacks" cue. And these are the conditions that I add to it:
Spoiler
Show

Code: Select all

<add sel="//cue[@name=&quot;PlayerAttacks&quot;]/conditions">
		<check_any>
			<!-- weapon is not a turret -->
			<check_value value="not @player.ship.turrets.operational.list.indexof.{event.param3.{2}}" />
			<!-- shield < 25 -->
			<check_value value="@event.param.shieldpercentage le 25" />
			<!-- relationship is less than neutral -->
			<check_value value="not @event.param.owner.relation.neutral.min" />
			<check_value value="event.param.relationto.{faction.player} lt @event.param.owner.relation.neutral.min" />
			<!-- targeted -->
			<check_value value="event.param == @kFFT_target" />
		</check_any>
	</add>
	<add sel="//cue[@name=&quot;PlayerAttacks&quot;]/actions">
		<debug_text text="'kuertee PlayerAttacks event.param: ' + @event.param + ' (' + @event.param.knownname + ', ' + @event.param3.{2}.name + ') friendly fire not ignored'" />
	</add>
kFFT_target is the player's target (event_player_changed_target) that I set elsewhere in my diff.
Unfortunately, I've not tested this fully yet. I've not yet been in a situation to be able to.
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.

Berni
Posts: 515
Joined: Sun, 15. Feb 04, 13:52
x4

Re: [mod test] Friendly Fire Tweaks test request

Post by Berni » Tue, 4. May 21, 05:50

Hello kuertee, from what i have observed so far, your mod seems to be working fine for the player. Until now, i have had no more warnings to stop firing if i was defending a station or battleship.
The mod doesn't seem to work for my AI captains because several NPCs have managed to turn an allied station red when they were near it and the towers are set to "attack all enemies".

EDIT: like Max Bain i've removed the first and second condition^^

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

Re: [mod test] Friendly Fire Tweaks test request

Post by kuertee » Tue, 4. May 21, 07:12

Berni wrote:
Tue, 4. May 21, 05:50
Hello kuertee, from what i have observed so far, your mod seems to be working fine for the player. Until now, i have had no more warnings to stop firing if i was defending a station or battleship.
The mod doesn't seem to work for my AI captains because several NPCs have managed to turn an allied station red when they were near it and the towers are set to "attack all enemies".

EDIT: like Max Bain i've removed the first and second condition^^
npc turning friendlies red may either be (1) another cue or (2) hard coded. It’s definitely not in the notifications PlayerAttacks cue that I describe above. I’ll have a look for it.

Thanks, Berni.
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”