[MOD] AutoCrew

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

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

pref
Posts: 5606
Joined: Sat, 10. Nov 12, 17:55
x4

Post by pref » Fri, 22. Jan 16, 01:07

Thanks!

Could this work in fight.defend.capital for ex for DO without any performance impact?

Code: Select all

    <handler>
      <conditions>
        <event_object_destroyed object="$attacker" />
        <check_value value="this.ship.owner == faction.player" />
        <check_value value="event.object.isclass.ship and (not event.object.isclass.ship_xs)" />
        <check_value value="event.object.owner != faction.player" />
        <check_value value="event.param == this.ship" />
      </conditions>
      <actions>
        <set_value name="$IncChance" exact="0" />
        <do_if value="@$attacker.isclass.ship_xl">
          <set_value name="$IncChance" exact="25" />
        </do_if>
        <do_if value="@$attacker.isclass.ship_l">
          <set_value name="$IncChance" exact="10" />
        </do_if>
        <do_if value="@$attacker.isclass.ship_m">
          <set_value name="$IncChance" exact="2" />
        </do_if>
        <do_if value="@$attacker.isclass.ship_s">
          <set_value name="$IncChance" exact="1" />
        </do_if>
        <do_if value="true" chance="$incChance">
          <do_any>
            <do_if value="this.skills.combat lt 5" weight="40">
              <set_value name="this.skill.combat" operation="add" />
            </do_if>
            <do_if value="this.skills.leadership lt 5" weight="30">
              <set_value name="this.skill.leadership" operation="add" />
            </do_if>
            <do_if value="this.skills.morale lt 5" weight="30">
              <set_value name="this.skill.morale" operation="add" />
            </do_if>
          </do_any>
        </do_if>
      </actions>
    </handler>
Or i just wish it was so simple? :D
$attacker is just a local that doesnt even exist usually.

Captain could be in move.generic only perhaps, when target is reached (before the <break />) with a 1% chance or so.

Engineer when any component is repaired to max allowed hp.

CommanderTM
Posts: 567
Joined: Mon, 20. May 13, 09:18
xr

Post by CommanderTM » Fri, 22. Jan 16, 12:29

Sounds like an interesting mod! Will try it out. Is it safe to remove after trying??

pref
Posts: 5606
Joined: Sat, 10. Nov 12, 17:55
x4

Post by pref » Fri, 22. Jan 16, 13:02

Your employees that were generated by the mod will stay, and will keep their skills even after removing the mod.

Otherwise it has no effect on your games, so if you can live with that it's save safe.

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

Post by w.evans » Fri, 22. Jan 16, 21:16

Sorry haven't replied, pref. To be honest, I'm not familiar with fight.defend.capital, but it looks like it should work. If I read that right, it'll fire once whenever a DO kills something, and what it'll do isn't all that resource-intensive, so should be fine.

A couple of changes I would suggest:

instead of that series of do_if nodes, would change that to a simple do_if do_elseif ... do_else block. If you already know that an xl ship was killed, no need to evaluate whether or not it's also an s ship.

not sure if "weight" in that context will work. Not saying it won't. It might. Replacing them with "chance" would do something similar, but then there'd be a chance that more than one skill at a time would be incremented.

Oh, missed your do_any.

edit: no need to evaluate... rather than no way
Last edited by w.evans on Fri, 22. Jan 16, 21:42, edited 1 time in total.

pref
Posts: 5606
Joined: Sat, 10. Nov 12, 17:55
x4

Post by pref » Fri, 22. Jan 16, 21:31

Thanks!

Almost there - though noone will use it i think but it wont let me go now until i finish it...

It gets confused because the destruct event object ($attacker) doesnt exist always.

No idea how to tell it to skip an interrupt check if the object variable is null.

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

Post by w.evans » Fri, 22. Jan 16, 21:40

pref wrote:No idea how to tell it to skip an interrupt check if the object variable is null.

Code: Select all

<check_value value="event.object != null"/>
?
Won't skip the interrupt check, but at least won't go past the conditions.

pref
Posts: 5606
Joined: Sat, 10. Nov 12, 17:55
x4

Post by pref » Fri, 22. Jan 16, 21:43

The first node has to be the event condition (if there is an event condition).
So all check_value-s will be evaluated after the event, and it whines that the value ($attacker in this case) is null.

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

Post by w.evans » Fri, 22. Jan 16, 21:47

Hm. Sounds like by the time the interrupt is triggered, $attacker's already dead. Which makes sense, I guess, because it was triggered by $attacker dying. Which begs the question: what's that event for in the first place?

ps. looked to me like valgusepoiss wanted to volunteer.

edit: is the error about the event? or the nodes in <actions> ? If it's the stuff in actions, might just mean that you shouldn't refer to the attacker after the event had already fired. (Because $attacker wouldn't exist anymore.)

pref
Posts: 5606
Joined: Sat, 10. Nov 12, 17:55
x4

Post by pref » Fri, 22. Jan 16, 21:50

$attacker is just a local that might not exist for whatever else reason.
When the game loads it does not exist for ex (resulting in this event spamming the log).

I could make a copy of that variable, and add a fake target in the init section when $attacker is null, but that sounds really dirty.

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

Post by w.evans » Fri, 22. Jan 16, 22:03

Finally got my ass around to actually opening the file. Sorry took so long. Now I see. $attacker is set by the other interrupt handlers. It's whatever the ship is commanded to attack, or whatever is attacking the ship. As long as those other events do not fire, $attacker is indeed not set. You could set it yourself, but that could break stuff that depend on it not being set.

You might be better off following the trail on to fight.attack.object after all since that DOES require a target. If I remember correctly, DO scripts only proceed there if there is an active target, and if there isn't one, exit back to whichever script led to it. It is also the funnel through which the DO, pilot, and captain combat scripts are routed on. Pretty sure your existing code will work, just change $attacker to $target.

Also, I think fight.defend.capital would only work if the DO were set to "Defend"

If you opt to go this route, better make sure that this.ship isn't a drone. Those go through fight.attack.object too.

pref
Posts: 5606
Joined: Sat, 10. Nov 12, 17:55
x4

Post by pref » Fri, 22. Jan 16, 22:20

Unfortunately there are no parameters for the DO script, no target either.
It gets the target from player direct order, or from a wait interrupt when attacked if in defence mode.

Maybe i just have to make a general cue to check for any killed ship?
Without a target object if thats even possible. Not sure about performance though.

pref
Posts: 5606
Joined: Sat, 10. Nov 12, 17:55
x4

Post by pref » Mon, 25. Jan 16, 02:43

Quick update: add architects to CVs.

jojorne
Posts: 834
Joined: Sun, 17. Nov 13, 17:25
x4

Post by jojorne » Thu, 3. Mar 16, 07:39

so if i buy a ship i'll get new crew members

now what this mean:

Your marine officer also got promoted, and now has to take care of
employee selection and hiring process for all the ships you borrow.

pref
Posts: 5606
Joined: Sat, 10. Nov 12, 17:55
x4

Post by pref » Thu, 3. Mar 16, 12:21

jojorne: In this game you can board and steal ships, and when you do so the ship will be manned automatically - the same way as when you buy ships.

jojorne
Posts: 834
Joined: Sun, 17. Nov 13, 17:25
x4

Post by jojorne » Thu, 3. Mar 16, 13:46

ah... thanks!

FunkDooBiesT
Posts: 13
Joined: Thu, 3. May 12, 14:01
x4

Post by FunkDooBiesT » Tue, 15. Mar 16, 06:46

Hi, I play with combat bail out mod and was wondering if it would be possible to get crew for those ships via Autocrew. There was a command in another mod that you would tell Yisha to find you some crew for the abandoned ships. Would be a big time saver bonus cheat for me.

Thanks for the mod!

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

Post by BoostHungry » Sat, 9. Apr 16, 21:58

Trying to get AutoCrew to work with the CWIR Fleet Boarding Options (where you can have capital ships in your squad assist with boarding essentially giving you access to more than 50 marines, and used for boarding stations).

I tried to figure this out myself but I'm stuck. CWIR introduced a new md file: boarding_playerfleet.xml (internally named: Boarding_PlayerFleet -- I haven't figured out if case matters yet). I tried adding a new AutoCrew md file to patch CWIR's new file, but I can't get it to work.

I've reduced down to just trying to get a simple test to work, but it's not working:
My test AutoCrew boarding_playerfleet.xml:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?> 
<diff> 
	
    <add sel="//cue[@name='Start']/actions" pos="prepend">
	
        <show_notification caption="'== AutoCrew Added - Fleet =='" details="'AutoCrew Notification'" timeout="12s" queued="true" priority="8" />
								
        <write_to_logbook category="general" text="'== AutoCrew Added - Fleet =='"/>
						
    </add>

</diff>
The same type of test added to the Boarding.xml for Solo Boarding does work.

Note: I also added a dependency on CWIR in the context.xml

My thought is because the boarding_playerfleet.xml added by CWIR is a new md file and is not patching a base game file. I think I might have read that new/replacement md files are loaded on game load while patches are applied on initial game start (to menu screen).

Thoughts on getting AutoCrew to function correctly with the new CWIR Fleet Boarding?

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

Post by UniTrader » Sat, 9. Apr 16, 22:00

did you put your patch file in a extensions-directory inside your extension?
(like extensions/YourExtension/extensions/CWIR/md )
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 » Sat, 9. Apr 16, 23:13

OMG, Thank You! Thank You! Thank You!

Yes, moving the script to an extension folder within the extension folder worked! It makes sense now that you mention it, but I wouldn't have considered it.

In case anyone wanted to do the same, I added a new file:
AutoCrew/extensions/cwir/md/boarding_playerfleet.xml:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<diff>
  <add sel="//cue[@name='Success']/actions/do_else/cease_fire[@object='$target']" pos="after">
    <do_if value="$target.isclass.ship_l or $target.isclass.ship_xl and $target.owner == faction.player">
      <create_cue_actor cue="this" group="argon.pilot">
        <skills>
          <skill type="boarding" min="1" max="3"/>
          <skill type="combat" min="5" max="5"/>
          <skill type="engineering" min="1" max="5"/>
          <skill type="leadership" min="5" max="5"/>
          <skill type="management" min="1" max="4"/>
          <skill type="morale" min="5" max="5"/>
          <skill type="navigation" min="5" max="5"/>
          <skill type="science" min="1" max="3"/>
        </skills>
      </create_cue_actor>
      <find_dock_location name="$target_dock" container="$target" size="tag.dock_p"/>
      <add_actor_to_platform actor="this.actor" dockingbay="$target_dock.component"/>
      <set_owner object="this.actor" faction="faction.player"/>
      <do_if value="$target.isclass.ship_l or $target.isclass.ship_xl">
        <set_entity_type entity="this.actor" type="entitytype.commander"/>
      </do_if>
      <do_else>
        <set_entity_type entity="this.actor" type="entitytype.pilot"/>
      </do_else>
      <assign_pilot object="$target" actor="this.actor"/>
      <start_script object="this.actor" name="'player.default'"/>
      <set_value name="$target.controlentity.$config_autorefuel" exact="1"/>
      <!-- NH: Engi -->
      <create_platform_actor name="$NHEngineer" type="entitytype.engineer" dockingbay="$target_dock.component" ref="engineer_omicron_lyrae_random">
        <owner exact="faction.player"/>
        <skills>
          <skill type="boarding" min="1" max="3"/>
          <skill type="combat" min="1" max="3"/>
          <skill type="engineering" min="5" max="5"/>
          <skill type="leadership" min="1" max="3"/>
          <skill type="management" min="1" max="4"/>
          <skill type="morale" min="1" max="5"/>
          <skill type="navigation" min="1" max="5"/>
          <skill type="science" min="1" max="3"/>
        </skills>
      </create_platform_actor>
      <assign_engineer actor="$NHEngineer" object="$target"/>
      <start_script object="$NHEngineer" name="'engineer.ai'"/>
      <!-- NH: DO -->
      <create_platform_actor name="$NHDefenceNPC" type="entitytype.defencecontrol" dockingbay="$target_dock.component" ref="fighter_omicron_lyrae_random">
        <owner exact="faction.player"/>
        <skills>
          <skill type="boarding" min="1" max="3"/>
          <skill type="combat" min="5" max="5"/>
          <skill type="engineering" min="1" max="5"/>
          <skill type="leadership" min="5" max="5"/>
          <skill type="management" min="1" max="4"/>
          <skill type="morale" min="5" max="5"/>
          <skill type="navigation" min="1" max="5"/>
          <skill type="science" min="1" max="3"/>
        </skills>
      </create_platform_actor>
      <assign_defence_manager actor="$NHDefenceNPC" object="$target"/>
      <start_script object="$NHDefenceNPC" name="'fight.defend.capital'"/>
      <!-- NH: Architect -->
      <do_if value="$target.primarypurpose == objectpurpose.build and $target.isclass.ship_xl">
        <create_platform_actor name="$NHArchi" type="entitytype.architect" dockingbay="$target_dock.component" ref="architect_omicron_lyrae_random">
          <owner exact="faction.player"/>
          <skills>
            <skill type="boarding" min="1" max="3"/>
            <skill type="combat" min="1" max="3"/>
            <skill type="engineering" min="5" max="5"/>
            <skill type="leadership" min="1" max="3"/>
            <skill type="management" min="5" max="5"/>
            <skill type="morale" min="1" max="3"/>
            <skill type="navigation" min="5" max="5"/>
            <skill type="science" min="1" max="3"/>
          </skills>
        </create_platform_actor>
        <assign_architect actor="$NHArchi" object="$target"/>
        <set_actor_account actor="$NHArchi"/>
      </do_if>
    </do_if>
  </add>
</diff>

I also did a similar thing for AutoTrain, which goes and modifies the above values.

pref
Posts: 5606
Joined: Sat, 10. Nov 12, 17:55
x4

Post by pref » Thu, 14. Apr 16, 19:54

If BlackRain and Rubini are finished with station boarding entirely i can include a compatibility fix for CWIR. Last we spoke they were really close.

I cannot handle this the official way, as that only allows dependencies for workshop mods ( :s ).
I can only provide a non steam version for this reason.

It would be the same thing BoostHungry did, so im not sure if its even necessary to make a new package for this.

Post Reply

Return to “X Rebirth - Scripts and Modding”