Turn off Friendly Fire

The place to discuss scripting and game modifications for X Rebirth.

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

Post Reply
BoostHungry
Posts: 122
Joined: Sat, 23. Nov 13, 20:33

Turn off Friendly Fire

Post by BoostHungry » Mon, 4. Jul 16, 08:15

Due to the extreme and awesome nature of CWIR, it's not uncommon for friendly capital ships to get into a drunken brawl with nearby allies. This brings up the need to turn off friendly fire, probably with some sort of limitations.

BoostHungry
Posts: 122
Joined: Sat, 23. Nov 13, 20:33

Post by BoostHungry » Mon, 4. Jul 16, 08:16

posts from the CWIR thread:
BoostHungry wrote:I know this has been mentioned before, but I just witnessed 6 of my capitals start a brawl with 6 RoC capitals in Fervid Corona where both fleets were defending the jump point from Reivers. I was at 29-30 relations with RoC so it's sad to see things turn so ugly resulting in me forced to pull all of my ships out of the zone for a while.

+1 to any idea of how to handle this. Is it possible to have friendly fire simply be ignored if relations are at least 20? Or maybe an ability to purchase a Non Aggression Pact for like 40 million as long as relations are at least a certain point which would turn off friendly fire between the factions.

Do we know if there is a certain AIScript or MD file that handles reactions to to being shot at? I can at least try to write something if I can at least find the right file to mod. There has to be some file somewhere that identifies which ship started the fight in order to change the state of the fleets so they begin fighting each other.

*edit* took a quick look and immediately found an interrupt.attacked.xml AI Script. Though this script specifically doesn't handle Cap Ships and instead lets the DO handle responses, but this is a good first start, will keep looking into it tomorrow.

Code: Select all

<!-- Attack respond -->
<check_all>
    <check_value value="not this.defensible.isplayerowned" comment="not engage player owned ships" />
    <check_value value="not this.defensible.isclass.[class.ship_l, class.ship_xl]" comment="if this is a capship, let the Deffence Officer handle it" />
    <check_value value="(not event.param.isclass.{class.station}) and ((this.ship.primarypurpose == objectpurpose.fight) or (this.ship.dps.all gt event.param.dps.all))" />
    <set_value name="$attackrespond" exact="true" />
</check_all>
[/b]
w.evans wrote:
BoostHungry wrote:Do we know if there is a certain AIScript or MD file that handles reactions to to being shot at?
If I remember correctly, the reaction to being attacked is in interrupt.attacked. The mechanism for lowering individual ship relations to enable them to retaliate is in several AI scripts. Example from move.escort.capital:

Code: Select all

<do_if value="not this.mayattack.{$enemy}">
  <add_relation_boost object="this" otherobject="$enemy" value="-0.1" decay="1" delay="10min" silent="true" />
</do_if>
edit: thought a relation check could be added to interrupt.attacked but there already is one:

<check_value value="event.param.isoperational and this.mayattack.{event.param}" />

think relations are lowered for ships that retaliate before they get to the interrupt.

BoostHungry
Posts: 122
Joined: Sat, 23. Nov 13, 20:33

Post by BoostHungry » Mon, 4. Jul 16, 08:23

It looks like fight.defend.capital doesn't actually do any fighting but instead passes off to fight.attack.object.capital when criteria are met.

At first glance, fight.attack.object.capital has some logic for adding a list of "attackers" to a list of "enemies" that it will target.

Code: Select all

<!-- include attackers -->
<do_all exact="$attackers.count" counter="$i">
    <do_if value="not $enemies.indexof.{$attackers.{$i}} and this.ship.mayattack.{$attackers.{$i}}">
        <append_to_list name="$enemies" exact="$attackers.{$i}" />
    </do_if>
</do_all>
<clear_group group="$attackers"/>
Think it could be as simple as updating the relations check here to not add attackers to the enemies list based on relations?

I'm fine with the relations drop occurring, it's only the returning of fire that I don't appreciate.

Ezarkal
Posts: 1610
Joined: Wed, 22. Apr 15, 02:27
x4

Post by Ezarkal » Mon, 4. Jul 16, 14:13

I'm no modder, and definitively no coder, but what seems odd to me in rebirth is that the "fight relations" are set by the ship being attacked rather than the ship doing the attack. So the ship being friendly fired on are turning against their allies. It's a good approach for the skunk, as it forces the player to be careful and prevents him from being too "liberal" with the stray shots. But it's crap for any ships that you don't control.

I think for player/NPC assets, the friend/enemy behavior should be set by the ship that attacks rather than by the ship that receives the hit. That way, in a fight, a friendly capship could get hit by a few allied stray shots, but as long as he's the target he won't turn against you (or allied NPC). And, since he's not the target, chances for him to die off only a few stray shots are, let's be honest, zero.

And since I already had a discussion about it, I'll add it right away. No, it doesn't add realism that any allied ship fired upon suddenly turns enemy because "he fired at me" and stuff. If your ship is standing near the line of fire between an allie and an enemy, and you're currently both trying to get rid of said enemy, then you're bound to get a few scratches. I personally would be more mad at my allie for not helping out than for accidentally putting a few scratches on my ship.
Humans are deuterostomes, which means that when they develop in the womb the first opening they develop is the anus.
This means that at one point you were nothing but an asshole.

Some people never develop beyond this stage.

BoostHungry
Posts: 122
Joined: Sat, 23. Nov 13, 20:33

Post by BoostHungry » Mon, 4. Jul 16, 18:20

General modding question, how do I see all the methods available on an object?

IE: In fight.defend.capital there's an $attacker variable which seems to be the object of the ship that attacked. How do I know what methods are available on this object?

In this case I'm trying to identify the faction of the ship that attacked.

Also, it looks like there are both properties and methods available. How do I find more information on methods like:
defensible.isclass.{class.station}

This looks like the equivalent in java as defensible.isClass(Class.STATION)
Last edited by BoostHungry on Mon, 4. Jul 16, 18:28, edited 1 time in total.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Mon, 4. Jul 16, 18:28

open the file Scriptproperties.html in a Browser and just type $ and the Var Type in the Top (for example "$ship." ) and you see all available properties it has - and if you continue typing also sub-properties of it.
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

BoostHungry
Posts: 122
Joined: Sat, 23. Nov 13, 20:33

Post by BoostHungry » Mon, 4. Jul 16, 18:30

UniTrader wrote:open the file Scriptproperties.html in a Browser and just type $ and the Var Type in the Top (for example "$ship." ) and you see all available properties it has - and if you continue typing also sub-properties of it.
Ahhhhh thank you so much, that's awesome :)

*edit*
Anyway to identify what type a parameter is? I should be able to figure it out by deduction, but would be nice if there was a way to figure it out. Can I log a property on every object and it will tell me its type in case I can't figure it out?

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Mon, 4. Jul 16, 18:45

just look in the second row of the scriptproperties...
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Mon, 4. Jul 16, 19:30

Ezarkal wrote:I think for player/NPC assets, the friend/enemy behavior should be set by the ship that attacks rather than by the ship that receives the hit.
Problem is the crew of the ship that got hit doesn't know whether it's being attacked or not. Just knows that it got hit, and if that hit hurt. (Speaking script-wise, but think it kind of makes sense in-game as well. Of course, what you're suggesting could be done, but would essentially amount to an attacking ship telling its target that it is being attacked.)

Another possible solution would be to set the threshold as some fraction of the attacking ship's dps rather than just damage incurred over time. So:

I'm hit,
that hurt,
well, he's big and that ship could've done a LOT more damage,
probably unintentional.
noo-nee-noo
BoostHungry wrote:General modding question, how do I see all the methods available on an object?
I also tend to use scriptproperties.xml as a reference, although i'm told that that's a rather unorthodox use of the file. So, for example, a ship is a:

destructible, defensible, container, controllable, object, and, well, a ship.

(There are some hierarchies in there, but for the purpose of looking something up, i find that it's usually enough to know that it belongs to those classes.) So the properties you can look up for any particular designated ship are all of those listed under those datatypes.

edit: sorry, forgot. if a ship's relation with another ship are such that they cannot fight back,

this.ship.mayattack.{$attackers.{$i}}

will resolve false. So it's the relation change that makes it possible in the first place.

BoostHungry
Posts: 122
Joined: Sat, 23. Nov 13, 20:33

Post by BoostHungry » Mon, 4. Jul 16, 22:24

So I've tracked down that the cue TempRelationDropped in notification.xml is what notifies when relations are changed. It doesn't handle the change itself, but is maybe a place where we can reset the change back.

There's another cue PlayerAttacks in the notification.xml which actually handles the temp reputation drop, but this seems to only apply to the player itself, not other ships the player owns.

I've tried finding a way to simply reset the relation change after it occurs by plugging into the TempRelationDropped cue, but can't get it working. <set_faction_relation> doesn't seem to work because we're dealing with objects not factions.

<add_relation_boost> seems to be what sets the negative boost with a decay rate, so I'm thinking I could just call this again to negate the effects. It seems to be called with two objects which is good and I have access to the object for the ship that was attacked, but any idea how I can get access to the ship the did the attacking in this TempRelationDropped cue?

<change_relation_on_attack> seems promising by name, but not exactly sure how I would call it. There's an example in the PlayerAttacks cue, but again this requires access to the object that did the attacking.

<reset_relation_boost> seems the most appropriate, but it doesn't seem to work if I pass it the attacked object and faction.player. My debug logs show that the attacked object resets relations to the player, but it stays red in the game and returns fire to my ship.

Not sure my approach of trying to reset relations after they're set is best. I think trying to prevent the relations from being set in the first place is best.

I tried a few things like plugging into fight.attack.object and fight.defend.capital with no luck.

User avatar
Nick 031287
Posts: 1175
Joined: Wed, 26. Jan 05, 21:30
x3tc

Post by Nick 031287 » Fri, 13. Oct 17, 18:38

i love CWIR but its got to a point where i can only observe my battles by spreadsheets....

if i try to personally intervenue war WILL break out with my allies, the centerans. just a strey shot here and there and all out war... EVERY time.... every sinngle time...

Post Reply

Return to “X Rebirth - Scripts and Modding”