[MOD] BetterTurrets. Updated 20.12.2014

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

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

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

Post by w.evans » Sat, 20. Dec 14, 23:35

Thanks! And sounds cool!

Small request though: could you maybe please bump the "neutral/friendly cap NPC's" up to just friendlies? Maybe 10+ relations? Less than that, and it doesn't make sense that they'd care whether I'm boarding or not. Unless we count in humanitarian reasons. That would be valid, maybe. A Universe-wide interdict on firing on ships with non-hostile personnel on board?

edit: meant in your next version! Not now!

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Sun, 21. Dec 14, 01:03

Just wanted to get this one "out the door" before leaving on holiday trip for a couple of weeks, so might need some more balancing.
For the impatient - both NPC "friendliness" and hullpercentage trigger can be tweaked in fight.attack.object.capital.xml, line 104 :)

Changing this from:

Code: Select all

<do_if value="@$enemies.{$i}.boarder and @this.ship.relationto.{$enemies.{$i}.boarder} ge 0.0 and $enemies.{$i}.hullpercentage le 50">
to:

Code: Select all

<do_if value="@$enemies.{$i}.boarder and @this.ship.relationto.{$enemies.{$i}.boarder} ge 0.0032 and $enemies.{$i}.hullpercentage le 50">
..should do what you ask (if i remember the relation weight correctly) :)

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

Post by w.evans » Sun, 21. Dec 14, 01:05

thanks! Enjoy your vacation! And merry christmas!

wanglewis
Posts: 37
Joined: Thu, 24. Sep 09, 09:59
x4

Post by wanglewis » Wed, 24. Dec 14, 23:59

Small request though: could you maybe please bump the "neutral/friendly cap NPC's" up to just friendlies? Maybe 10+ relations? Less than that, and it doesn't make sense that they'd care whether I'm boarding or not. Unless we count in humanitarian reasons. That would be valid, maybe. A Universe-wide interdict on firing on ships with non-hostile personnel on board?

I'm not totally agree with that. It's not just humanitarian reasons. For two factions(consider player as a faction), attack the ship which i have marines on that will cause deplomatical problem. The attack action appears to be a hostile action, not neutral.

wanglewis
Posts: 37
Joined: Thu, 24. Sep 09, 09:59
x4

Post by wanglewis » Thu, 25. Dec 14, 00:22

As i read through the recode of the fight.attack.object.captial, your script can be separate into two parts,

the first part you can use a code

Code: Select all

  <add sel="/aiscript[@name='fight.attack.object.capital']/attention[@min='visible']/actions/do_if[@value='$enemies.count']" pos="before">
to add the presetting of DObaseskill and drones swarmsize.

the second part you can use code

Code: Select all

 	<replace sel="/aiscript[@name='fight.attack.object.capital']/attention[@min='visible']/actions/do_if[@value='$enemies.count']">
to replace the whole do_if function to your own, because you only changed the code in it.

This will be more compatible to other mods instead of replace the whole <attention>

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

Post by w.evans » Thu, 25. Dec 14, 00:33

wanglewis wrote:attack the ship which i have marines on that will cause deplomatical problem. The attack action appears to be a hostile action, not neutral.
makes a lot of sense.

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Thu, 25. Dec 14, 02:05

@wanglewis
Don't forget the changes in the drone launch bit as well ;)
Patching the entire attention node is a bit "first mod noobness legacy"/"play safe and patch like CDOAIO" + to help with readability of the code.
Was considering splitting the code up at a later stage (that is partly why those commented <!--****Modified code start** etc. sections), but later reconsidered since patching the entire node has the benefit that it's a bit more futureproof if ego only does a small "cosmetic" change which makes the xpath fail + somewhat securing that it's not run with a conflicting mod which also patches the DO IZ code - which would most likely end badly.

It's about 50 lines of vanilla "padding" at the beginning and end in there now, but if requested it's a quick job to split this one into 3-4 patch segments instead in the next version :)
Do you have a specific mod in mind here when it comes to compatibility?

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

Post by w.evans » Thu, 25. Dec 14, 10:59

You're back! Merry Christmas!

I think that wanglewis just meant compatibility in general going forward. I don't think that there are any other mods at the moment that alter the fight.attack.object.capital.xml script.

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

Post by w.evans » Thu, 25. Dec 14, 12:01

Hi cicero111,

Way off topic, but if you have some time to spare, could you please take a look at this question? Copied and pasted from the XML Tutorial. Wasn't getting an answer, possibly because nobody's following it anymore (and possibly because it really is a dumb question)

Probably a dumb question, but if I started with this:

Code: Select all

<root>
  <bar>
    <foo a="1"/>
    <foo a="2"/>
  </bar>
</root>
and wrote this:

Code: Select all

<diff>
  <replace sel="//bar">

  </replace>
</diff>
would it output this?

Code: Select all

<root>
  <bar>
  </bar>
</root>
or this?

Code: Select all

<root>
  <bar>
    <foo a="1"/>
    <foo a="2"/>
  </bar>
</root>

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Thu, 25. Dec 14, 14:17

Merry Xmas :)
In this example you are replacing the <bar> node with a empty line, so I guess you would end up with something like this:

Code: Select all

<root>

</root>
Another example:

Code: Select all

<diff> 
  <replace sel="//bar"> 
    <bar>
      <!--vanilla bits-->
      <!--new stuff here-->
      <!--vanilla bits-->
    </bar> 
  </replace> 
</diff>
Should result in this:

Code: Select all

<root> 
  <bar>
    <!--vanilla bits-->
    <!--new stuff here-->
    <!--vanilla bits-->
  </bar> 
</root>
..which is in a way relevant to the discussion where I replace the entire attention node here :)

wanglewis
Posts: 37
Joined: Thu, 24. Sep 09, 09:59
x4

Post by wanglewis » Thu, 25. Dec 14, 14:26

@cicero111

it's the automated emergency jump mod, which changed the <wait> code inside the do_if. I dont know if these two mods can use together, i dont have a debuglog to prove it, whether these two are compatible. but according to the patch logic it's difficult for the game to find out which one is first

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Thu, 25. Dec 14, 15:00

@wanglewis
Ah - that one :) Had an old extracted version lying at my home server and took a quick peek. It does replace the wait before enemy scan goto/cease fire which I've not changed (other than backported the interrupts which were added in vanilla 3.0). They should be compatible, but depending on the patch load order it will either be appended or overwritten - which is not good..
I'm in on the do a less intrusive patching suggestion, I'll do a rewrite after the holidays :)

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

Post by w.evans » Thu, 25. Dec 14, 15:13

Thanks for taking the time to answer! Sorry, forgot the <bar></bar> in the example. So I can just put my changes in replace flags, and it will change the data in the nodes that match, and append the rest?

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Thu, 25. Dec 14, 15:42

Yup, it will only replace/add/remove the nodes which is specified in the xpath, and use vanilla for the rest :)
The xpath stuff was a bit hard to wrap my head around at first, but looking at similar mods + some trial and error was a good way to learn how to do it. And of course watching the debug.log + adding some debug output in the code to verify it behaves as expected.
If you run with a lot of mods it can get a bit noisy in there, so I recommend for example LogExpert to be able to do some filtering to only see the output you're interested in.

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

Post by w.evans » Thu, 25. Dec 14, 15:53

Thanks! Off to add some debug output to my scratch copies then to make sure my mods are so far working as intended then. It all looks like it's working in-game, but wanted to be sure.

antoniut
Posts: 198
Joined: Sat, 4. Oct 14, 13:07
xr

Post by antoniut » Sat, 10. Jan 15, 19:01

It would be posible that do not launch drones against a big enemy cap and only launch drones to fight against other drones or wingmen?(Maybe only xl's)

I was watching a battle between a leviathan (supertransport) against xenon K (leviathan wins) but K was empty of drones and no wingmen. Leviathan launched drones but was a total massacre without hurting K

Thanks

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Thu, 22. Jan 15, 18:42

@antoniut
Sorry for the late reply - It's quite possible, and in the early versions the mod only launced drones to XS/S/M ships. I changed back to vanilla behavior to not neuter the suls - who are a bit helpless against caps without their drones.
If you want to experiment, remove the lines 187-189:

Code: Select all

<do_if value="this.ship.distanceto.{$enemies.{$i}} lt 10000m">
  <add_to_group groupname="$dronetargets" object="$enemies.{$i}" />
</do_if>
This bit is where the caps are added as valid drone targets.

antoniut
Posts: 198
Joined: Sat, 4. Oct 14, 13:07
xr

Post by antoniut » Fri, 23. Jan 15, 01:50

Thanks! I'll mess with it

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

Post by w.evans » Mon, 26. Jan 15, 13:57

Hi cicero111,

thought that this might be of interest to you. Was playing around with the drone launch settings to make carriers more viable.

Premises:
carriers, or at least the Arawn, can carry 300 drones.
combinedskill outputs a number from 20-100

So changed the drone swarm size calculation to this:

Code: Select all

<set_value name="$droneswarmsize"  exact="this.combinedskill * (1 + (this.combinedskill * 2) / 100)" />
for carriers, and this:

Code: Select all

<set_value name="$droneswarmsize"  exact="this.combinedskill * ((1 + (this.combinedskill * 2) / 100) / 10)" />
for non-carriers.
Should allow carriers to launch from 28 to 300 drones, and non-carriers to launch from 2 to 30 drones.
Also doubled the range at which ships launch offensive drones.

I don't know if they'll all be able to get back home though since the drones' go home script appears to be flaky.

edit: Arawn launched 224 drones against a Titurel, and they all made it back. Took a while for all of them to get back though. Maybe some threat analysis? do_if dps gt x?

cicero111
Posts: 108
Joined: Sat, 13. Aug 11, 14:30
x4

Post by cicero111 » Tue, 27. Jan 15, 22:16

Thanks for the tip - did notice the combinedskill parameter was introduced in one of the the later betas but did not do much testing on the output.
The code could probably do good with a less "old school" approach of skill calculations, I'll look in to it and do a less hackish approach on the launch delay as well :)
Have found a better way to get ship classifications for carriers btw? Ship specific "this.ship.macro.ismacro.{macro.units_size_xl_capital_destroyer_1_macro}" (it just roll off the tounge :P ) stuff is not very expansion friendly.

Post Reply

Return to “X Rebirth - Scripts and Modding”