[MOD] Smart miners [0.4 experimental]

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

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

felrasha
Posts: 37
Joined: Mon, 18. Nov 13, 14:55

[MOD] Smart miners [0.4 experimental]

Post by felrasha »

Author: Felrasha
Version: 0.4 Experimental
Date: 19-11-2013

If you feel this mod improves your gaming experience, endorse it on nexusmods

[ external image ]

Description

After reading through the aiscript for mining I was getting quite a headache. At the moment it seems like Egosoft is moving miningships towards the center of the zone, and then moving them a random distance between 1 and 10km in a random direction, in the hope of bumping into an asteroid. If not, they rinse and repeat until finally they just stop.

This mod adds some AI into the AISCRIPT, and adds an iterative scan for asteroids, up to a range of 40km. This is an experimental version, and might cause some weird behaviour.

This works for both NPC miners and your own. The initial version is for Capital asteroid miners only.


Version history

0.4
- fixed a probablem that could cause an infinite loop in the code, resulting in a game crash

0.3
- Fixed out-of-zone mining: The ship no longer checks if it's own zone is different from the player zone, if the player is within 60km
- Fixed some positioning problems
- Added more descriptive abort texts (translations needed)

0.2
- updated the scanning degree for ore miners from 60 degrees to 360 degrees for finding asteroids to mine
- updated the scanning degree for ore miners from 60 degrees to 360 degrees for finding pickups for drones
- fixed a bug where all mining ships will eventually stop mining, because it only has a turret on one side, and is too stupid to turn around...
- altered maximum scanning distance to 60km
- implemented the scanning method for medium miners, (might be buggy)


0.1
Initial Release

Todo list

- liquid miners
- medium miners
- mining drones
- improve AI
- remove the need for babysitting
Last edited by felrasha on Fri, 22. Nov 13, 13:46, edited 7 times in total.
skyler.g
Posts: 11
Joined: Wed, 25. Sep 13, 22:03
x4

Post by skyler.g »

Looks good! This is definitely one I will be following.
dez505
Posts: 172
Joined: Wed, 6. Nov 02, 20:31
x4

Re: [MOD] Smart miners [0.1 experimental]

Post by dez505 »

felrasha wrote:and might cause some weird behaviour.
You mean like they are already behaving vanilla lol.

Good work man!

I love mining and will follow this :P
dez505
Posts: 172
Joined: Wed, 6. Nov 02, 20:31
x4

Re: [MOD] Smart miners [0.1 experimental]

Post by dez505 »

felrasha wrote:and might cause some weird behaviour.
You mean like they are already behaving vanilla lol.

Good work man!

I love mining and will follow this :P
Deleted User

Post by Deleted User »

AI of miners, right? good job!
felrasha
Posts: 37
Joined: Mon, 18. Nov 13, 14:55

Re: [MOD] Smart miners [0.1 experimental]

Post by felrasha »

dez505 wrote:
felrasha wrote:and might cause some weird behaviour.
You mean like they are already behaving vanilla lol.

Good work man!

I love mining and will follow this :P
Yeah I know :P, could hardly make it worse. :)
Deleted User

Post by Deleted User »

liquid miners?
felrasha
Posts: 37
Joined: Mon, 18. Nov 13, 14:55

Post by felrasha »

gas miners I guess, they are labelled liquid miners in the code:

Code: Select all

		  <!-- gas mining -->
		  <do_if value="$ware.tags.indexof.{tag.liquid}">
EDIT: gas miners will have to wait. Drones are very wonky, and I'm going to try and fix those first.
Blakey47
Posts: 6
Joined: Sun, 17. Nov 13, 01:24
x3ap

Post by Blakey47 »

Thank you for jumping on this, looking at the code makes you wonder what was their thoughts on this... looking forward to this mod being fully developed. +1
GdVzSdRf
Posts: 34
Joined: Wed, 6. Nov 02, 20:31
x3tc

Post by GdVzSdRf »

Very good idea. Additionally I would be really great to have a better fine tuned control.

For example I want to be able to tell a mining ship to just mine in system A and just unload all in station B (player owned station). It seems the station manager send the ship anywhere around accidentally into dangerous systems. Setting a maximum amount at the target station not to exceed would be cool.

Mining more than one type of material would be nice as well (if supported by cargo/miner type). e.g. Ore and Silicon at the same time. Maybe another good option would be to tell the miner somehow the wanted volume in a station of all ores and change prefered type of material to mine by itself.

On top of that, the exisiting mining commands seem to sometimes left drones behind before leaving the system. I have a feeling the problem has something to do with mining over the maximum volume the ship can transport. All drones remaing should drop their load and return in any case the mining ship leaves the spot or gets other commands.
zone22
Posts: 55
Joined: Fri, 4. Aug 06, 05:24
x3tc

Post by zone22 »

I'm running into trouble with my mining ship after adding the mod. I tell it to gather resources and then collect ore. the ship moves are a few seconds then says:Paraphrasing; orders complete stopped collecting gas. The ship is neither club of quipped, or was ordered to collect gas.

Extensions
5kScanRange- edited so it only alters station points
BetterCockpit 0.5
ManualCommandExtension- possible conflict?
NESA
NPC_Bail_Increase
TastefulYishaArmour
felrasha
Posts: 37
Joined: Mon, 18. Nov 13, 14:55

Post by felrasha »

I'll check into that. As far as I'm aware no other mod has touched on this aiscript yet, so there should be no conflicts. I've seen this behaviour once, though only directly after a game loaded.

My first guess would be that there are no asteroids within 40km to mine. I might increase the max range on the scan and fix egosofts default 'stopped mining gas' notice

edit: to show how incomprehensible this stuff is:

Code: Select all

        <do_if value="not ($collectresult == 'aborted')">
          <run_script name="'player.interaction'" result="$result">
            <param name="Line" value="1210" comment="We stopped mining, sir. If you don't have new orders for us, we will follow you again." />
            <param name="UIText" value="{1015,24}" comment="Info: gas mining stopped" />
            <param name="ConversationParam" value="'g_gas_mining_stopped'" />
          </run_script>
          <debug_text text="'$result: ' + $result" chance="$debugchance" />
          <do_if value="$result" exact="'wait'">
            <wait />
          </do_if>
        </do_if>
This same script is called for both gas mining and ore mining, resulting in a notification that your ore miner stopped mining gas.
The weird part is that this code seems to be triggered by a result of anything BUT the collect script being aborted (hence the "not ($collectresult == 'aborted')"). I'll have to debug this tonight, but my first impression would be that this script is atm being called in incorrect conditions.
User avatar
mega|Doc
Posts: 324
Joined: Tue, 17. Feb 04, 00:09
x4

Post by mega|Doc »

sounds good, i will follow this mod. I really look forward to having your TO DO list completed
"Das Weltall ist ein Kreis, dessen Mittelpunkt überall, dessen Umfang nirgends ist."
Blaise Pascal (19.06.1623 - 19.08.1662)
foxtrot76
Posts: 75
Joined: Fri, 12. Mar 10, 21:44

Post by foxtrot76 »

Not sure if it's related to this mod. My miner started strange behaviour after installing this mod: I would fly to an asteroid field i want to mine and would tell the miner to fly to my position (with the custom commands) after this I would tell it to start mining which would activate your script. It's at this point that the miner decides to boost back to the sector and fly around. Tried a few other times and the result was the same with one exception. The miner would start mining while moving back to the sector and ignoring asteroids while the drones and mining laser where working as normal.

Here's the list of mods I use in case it helps:

5km scan range
better cockpits
ignore jumpdrive fuel
improved missiles
manual command extension
NESA
No traffic highways
NPC bail increase
osr auto target <--- I suspect a conflict with this one since noticed also drones behaving strangely since i installed it
upclose detailed monitor
felrasha
Posts: 37
Joined: Mon, 18. Nov 13, 14:55

Post by felrasha »

wow, I've not seen that happen yet. I've not seen anything in the osr auto target mod that would cause that. Can you tell me which mining it was?

I just noticed something I overlooked in the first version: not only were the ships programmed to fly around randomly in the hopes of bumping into an asteroid; they also only scan in a frontal 60 degree angle... which is kind of not working if you are flying next to an asteroidfield but not facing it.

The same also is true for picking targets for your drones to pick up, which would probably explain why drones run off in random directions while there is stuff to pick up right next to the ship.

I'll fix that tonight and see how it works.
Last edited by felrasha on Wed, 20. Nov 13, 16:03, edited 1 time in total.
zone22
Posts: 55
Joined: Fri, 4. Aug 06, 05:24
x3tc

Post by zone22 »

felrasha wrote:I'll check into that. As far as I'm aware no other mod has touched on this aiscript yet, so there should be no conflicts. I've seen this behaviour once, though only directly after a game loaded.

My first guess would be that there are no asteroids within 40km to mine. I might increase the max range on the scan and fix egosofts default 'stopped mining gas' notice

edit: to show how incomprehensible this stuff is:

Code: Select all

        <do_if value="not ($collectresult == 'aborted')">
          <run_script name="'player.interaction'" result="$result">
            <param name="Line" value="1210" comment="We stopped mining, sir. If you don't have new orders for us, we will follow you again." />
            <param name="UIText" value="{1015,24}" comment="Info: gas mining stopped" />
            <param name="ConversationParam" value="'g_gas_mining_stopped'" />
          </run_script>
          <debug_text text="'$result: ' + $result" chance="$debugchance" />
          <do_if value="$result" exact="'wait'">
            <wait />
          </do_if>
        </do_if>
This same script is called for both gas mining and ore mining, resulting in a notification that your ore miner stopped mining gas.
The weird part is that this code seems to be triggered by a result of anything BUT the collect script being aborted (hence the "not ($collectresult == 'aborted')"). I'll have to debug this tonight, but my first impression would be that this script is atm being called in incorrect conditions.
Thank you so much for improving mining!

Regarding "no asteroids within 40km to mine. " Well I know for fact that there was ore asteroids within 1km. I use the mining laser to bust them up. I used manual command extension to call the freighter to my location. Then proceeded to tell the start mining.

Unrelated but I have experienced the ming bug without your mod that you might want to look into. Often I get when trying to enable "mining mode" where you target an asteroid destroying the mining laser and it automatically tags the ore. When trying to enable that mode. It often says I have"no ships capable of doing that" . Only occasionally am I allowed to use mining mode, and there seems to be no rhyme or reason why I'm able to.

I suspect it has to do with what kind of orders your mining freighter ships are currently trying to carry out when trying to enable the mode. Although you'll have to look at the code.
foxtrot76
Posts: 75
Joined: Fri, 12. Mar 10, 21:44

Post by foxtrot76 »

felrasha wrote:wow, I've not seen that happen yet. I've not seen anything in the osr auto target mod that would cause that. Can you tell me which mining it was?

I just noticed something I overlooked in the first version: not only were the ships programmed to fly around randomly in the hopes of bumping into an asteroid; they also only scan in a frontal 60 degree angle... which is kind of not working if you are flying next to an asteroidfield but not facing it.

The same also is true for picking targets for your drones to pick up, which would probably explain why drones run off in random directions while there is stuff to pick up right next to the ship.

I'll fix that tonight and see how it works.
Gonna update all the mods i listed first and try again with a fresh start, just to make sure. Will let you know if it happens again.

Just to clarify the mentioned behavior I wanted to mine in an asteroid field outside a sector... and the miner would want to go back and mine in the closest sector.

On a side note any chance to let the miner give a feedback on what his current actions are such as: looking for asteroid; mining; moving to location etc? This might help debugging. Just an idea
felrasha
Posts: 37
Joined: Mon, 18. Nov 13, 14:55

Post by felrasha »

zone22 wrote:
felrasha wrote:I'll check into that. As far as I'm aware no other mod has touched on this aiscript yet, so there should be no conflicts. I've seen this behaviour once, though only directly after a game loaded.

My first guess would be that there are no asteroids within 40km to mine. I might increase the max range on the scan and fix egosofts default 'stopped mining gas' notice

edit: to show how incomprehensible this stuff is:

Code: Select all

        <do_if value="not ($collectresult == 'aborted')">
          <run_script name="'player.interaction'" result="$result">
            <param name="Line" value="1210" comment="We stopped mining, sir. If you don't have new orders for us, we will follow you again." />
            <param name="UIText" value="{1015,24}" comment="Info: gas mining stopped" />
            <param name="ConversationParam" value="'g_gas_mining_stopped'" />
          </run_script>
          <debug_text text="'$result: ' + $result" chance="$debugchance" />
          <do_if value="$result" exact="'wait'">
            <wait />
          </do_if>
        </do_if>
This same script is called for both gas mining and ore mining, resulting in a notification that your ore miner stopped mining gas.
The weird part is that this code seems to be triggered by a result of anything BUT the collect script being aborted (hence the "not ($collectresult == 'aborted')"). I'll have to debug this tonight, but my first impression would be that this script is atm being called in incorrect conditions.
Thank you so much for improving mining!

Regarding "no asteroids within 40km to mine. " Well I know for fact that there was ore asteroids within 1km. I use the mining laser to bust them up. I used manual command extension to call the freighter to my location. Then proceeded to tell the start mining.

Unrelated but I have experienced the ming bug without your mod that you might want to look into. Often I get when trying to enable "mining mode" where you target an asteroid destroying the mining laser and it automatically tags the ore. When trying to enable that mode. It often says I have"no ships capable of doing that" . Only occasionally am I allowed to use mining mode, and there seems to be no rhyme or reason why I'm able to.

I suspect it has to do with what kind of orders your mining freighter ships are currently trying to carry out when trying to enable the mode. Although you'll have to look at the code.
Maybe this has something to do with the 60 degree angle problem I mentioned above?

The assert to determine wether or not you can activate mining mode depends on the following things:
-You need a mining ship in your squad
-That mining ship needs collector drones
-That mining ship needs free cargospace
-That mining ship needs to be following you
if one of those is false, OR (and this is more likely) that check encounters a problem anywhere, you won't be able to enter mining mode.
-- This code keeps amazing me...
Zothen
Posts: 215
Joined: Wed, 6. Nov 02, 20:31

Post by Zothen »

If it is possible, I would maybe turn the waffle and let an asteroid attract a free miner instead. Could be less cpu overhang instead of constantly checking for asteroids?!
zone22
Posts: 55
Joined: Fri, 4. Aug 06, 05:24
x3tc

Post by zone22 »

Maybe this has something to do with the 60 degree angle problem I mentioned above?

The assert to determine wether or not you can activate mining mode depends on the following things:
-You need a mining ship in your squad
-That mining ship needs collector drones
-That mining ship needs free cargospace
-That mining ship needs to be following you
if one of those is false, OR (and this is more likely) that check encounters a problem anywhere, you won't be able to enter mining mode.
Can you elaborate a little bit on "-That mining ship needs to be following you"

Return to “X Rebirth - Scripts and Modding”