[MOD] Improved (full rewrite) Engineer
Moderators: Scripting / Modding Moderators, Moderators for English X Forum
-
- Posts: 259
- Joined: Sat, 23. Nov 13, 09:48
[MOD] Improved (full rewrite) Engineer
http://xrebirth.nexusmods.com/mods/204/?
Finally, your boarded freighters / capitalship will be fixable even if they have no drones on board.
Complete rewrite of the engineer ai.
Include support for emergency repairs and repair using in flight drones, as well as engineer skills and morale.
Skills
Engineering is the most important one, affecting all things.
- amount repaired by iteration is affected 75% by engineering, 25% by science
- the time between repair iterations is affected 50% engineering, 25% management, 25% leadership
- the rate at which drones help with repair while docked is affected 25% by engineering, 50% by management, 25% by leadership
- the maximum repair the engineer is able to do without a shipyard is affected by 50% engineering, 20% management, 15% science, 15% navigation
base value for the maximum repairs are
50% on components (engines, shields etc)
10% on ship hull without docked drone support
50% on ship hull if docked construction drones are present (not busy repairing components)
Morale is essentially how tired your engineer get
the morale skill affect how slowly it drop and how quickly it recover.
This basically mean that an engineer efficiency will drop if hes constantly working , they are not machine
but the moral can also go above the normal and give a pretty substantial bonus for the first minute of a fight
You will received engineering reports if you are within 600m of the ship using the notification system (bottom right monitor) every 30seconds
if you go within 150m of the center of the ship, you will receive realtime reports of everything the engineer is doing.
This mod was made to fix engineer so that they would work in a functional and somewhat balanced fashion,
the repairs are balanced to be pretty slow if you have no drones and/or a low skill engineer, generally about a minute or 2 before the hull is repaired 1%
As opposed to the default engineer ai, this engineer also only repair one item at a time, it make no sense that an engineer is able to repair things on giant capital ship by instantly moving around !
the repair priorities are engine > jumpdrive > dronebay > shield > weapon > components > shiphull, but the engineer will also try to finish his current work before changing even if something else was more damaged. The longer he worked on something, the less likely he is to change components.
As far as performance goes, this rewrite should actually be much faster / lighter than the original engineer ai code due to the method i used to implement it.
Keep in mind that this is highly untested, it should work, but might not !
Feel free to dissect, modify, redistribute, include in your own mods whatever you want to do from the code, it would be appreciated if credits are given, but not required.
known issues:
- ship hull remain burned up after being heavily damaged, even if repaired back to 100%, need to find how to restore that.
- fire / smoke on broken component remain quite some time after the component was repaired but eventually go away
- the status panel for the ship refuse to update the engine status, even when the engines are fixed and the ship is moving, it still display 0m/s
Finally, your boarded freighters / capitalship will be fixable even if they have no drones on board.
Complete rewrite of the engineer ai.
Include support for emergency repairs and repair using in flight drones, as well as engineer skills and morale.
Skills
Engineering is the most important one, affecting all things.
- amount repaired by iteration is affected 75% by engineering, 25% by science
- the time between repair iterations is affected 50% engineering, 25% management, 25% leadership
- the rate at which drones help with repair while docked is affected 25% by engineering, 50% by management, 25% by leadership
- the maximum repair the engineer is able to do without a shipyard is affected by 50% engineering, 20% management, 15% science, 15% navigation
base value for the maximum repairs are
50% on components (engines, shields etc)
10% on ship hull without docked drone support
50% on ship hull if docked construction drones are present (not busy repairing components)
Morale is essentially how tired your engineer get
the morale skill affect how slowly it drop and how quickly it recover.
This basically mean that an engineer efficiency will drop if hes constantly working , they are not machine
but the moral can also go above the normal and give a pretty substantial bonus for the first minute of a fight
You will received engineering reports if you are within 600m of the ship using the notification system (bottom right monitor) every 30seconds
if you go within 150m of the center of the ship, you will receive realtime reports of everything the engineer is doing.
This mod was made to fix engineer so that they would work in a functional and somewhat balanced fashion,
the repairs are balanced to be pretty slow if you have no drones and/or a low skill engineer, generally about a minute or 2 before the hull is repaired 1%
As opposed to the default engineer ai, this engineer also only repair one item at a time, it make no sense that an engineer is able to repair things on giant capital ship by instantly moving around !
the repair priorities are engine > jumpdrive > dronebay > shield > weapon > components > shiphull, but the engineer will also try to finish his current work before changing even if something else was more damaged. The longer he worked on something, the less likely he is to change components.
As far as performance goes, this rewrite should actually be much faster / lighter than the original engineer ai code due to the method i used to implement it.
Keep in mind that this is highly untested, it should work, but might not !
Feel free to dissect, modify, redistribute, include in your own mods whatever you want to do from the code, it would be appreciated if credits are given, but not required.
known issues:
- ship hull remain burned up after being heavily damaged, even if repaired back to 100%, need to find how to restore that.
- fire / smoke on broken component remain quite some time after the component was repaired but eventually go away
- the status panel for the ship refuse to update the engine status, even when the engines are fixed and the ship is moving, it still display 0m/s
Last edited by Jey123456 on Sun, 24. Nov 13, 12:29, edited 7 times in total.
-
- Posts: 259
- Joined: Sat, 23. Nov 13, 09:48
Keep in mind this mod was built with the assumption repair drone in flight mode work. The mod will use them (untested but should work), but while they are in flight, their repairpower doesnt add to the engineer (since they arent inside to help him), so if the in flight repair doesnt actually work and is just visual, then ill have to implement that (could not find any code related to launch_repair_drone to check if it was implemented to work or not)
-
- Posts: 259
- Joined: Sat, 23. Nov 13, 09:48
Uploaded version 0.91... Forgot to remove my ultra accelerated repair hack for testing xD (everything repair in 1 iteration right now the time between itteration was not hacked so it still take some time to fully fix a ship, but from 1% to 100% on just about anything will happen in 1 iteration heh).
0.91 fix that and bring it to what i felt was balanced in the first place.
0.91 fix that and bring it to what i felt was balanced in the first place.
-
- Posts: 78
- Joined: Sat, 16. Sep 06, 05:38
found some little errors in your code i think
in this part :
i think you meant
in your
i don't know what are part of the weapon class, but you already set
you could maybe delete the weapon class check and set this to 25 to get away with one less (two less counting the wrecked parts part) elseif check
by the way :
it always did that as far as i can tell
maybe engineers like fires and working in depresurised parts ?
on the balancing part,
i never saw engineers with skills that good in the 5 fields you want, i almost think they only receive a boost in engineering and everything else is left in the 1 or 2 stars max (and randomness)
(i even wonder how skills are being created, still haven't found that)
maybe lower standards a bit on "having a good engineer" to compensate for that ?
well nice piece of code for all i can see
i'm just wondering, keeping values in a global "tab" is still possible in this engine ?
i'm wondering for the poor lads with slow processors here
in this part :
Code: Select all
<!-- Count our drones / score for repair and optimisation purposes (no point in launching drones if we have 0, and no point in checking while they are launched) -->
<set_value name="$welderdronesScore" exact="0"/> <!-- they only help internal repairs if they are not launched, so reset it to 0 everytime before checking it. If they are launched the check is skipped -->
<do_if value="($isDamaged) and ($welderdronesLaunched == 0)">
<do_all exact="unitcategory.welder.maxmk" counter="$i">
<set_value name="$welderdronesScore" operation="add" exact="this.container.units.{unitcategory.welder}.mk.{$i}.count * (1+$i)" /> <!-- they dont give too much bonus, since they actually have an outside repair mode. When used inside the hull, they are much less efficient -->
</do_all>
<set_value name="$welderdronesScore" exact="$skillbonusdrone * (75+$skillbonusdrone)/100"/> <!-- a good engineer in management will use drones most efficiently -->
</do_if>
Code: Select all
<set_value name="$welderdronesScore" exact="$welderdronesScore * (75+$skillbonusdrone)/100"/>
in your
Code: Select all
<!-- lets have a look at our status and decide on what to fix Priority order is engine > jumpdrive > dronebay > shield > weapon > anything else. It will only work on one piece at a time -->
<!-- first the damaged elements -->
[...]
<do_elseif value="$damagedelements.{$i}.isclass.weapon">
<set_value name="$thisRepairTargetValue" exact="25"/>
</do_elseif>
Code: Select all
<set_value name="$thisRepairTargetValue" exact="5"/>
by the way :
these are vanilla issues- fire / smoke on broken component remain quite some time after the component was repaired but eventually go away
- the status panel for the ship refuse to update the engine status, even when the engines are fixed and the ship is moving, it still display 0m/s
it always did that as far as i can tell
maybe engineers like fires and working in depresurised parts ?

on the balancing part,
i never saw engineers with skills that good in the 5 fields you want, i almost think they only receive a boost in engineering and everything else is left in the 1 or 2 stars max (and randomness)
(i even wonder how skills are being created, still haven't found that)
maybe lower standards a bit on "having a good engineer" to compensate for that ?
well nice piece of code for all i can see
i'm just wondering, keeping values in a global "tab" is still possible in this engine ?
i'm wondering for the poor lads with slow processors here

Last edited by seedee on Sun, 24. Nov 13, 05:42, edited 1 time in total.
-
- Posts: 259
- Joined: Sat, 23. Nov 13, 09:48
good catch on the drone one xD.
but for the selection score thing, its because there are other possible destructible than those listed (weapon is a non turret weapon on some ships)
i prefer the other things to be lower than said weapon hence the 5 score
I am not sure what you mean by "global tab" in that scenario, most variables are annoyingly global by default >< (or you mean something that would be shared between all instance of the object for the static constants ?)
While its true that it would be a slight improvement, the variables assignments in my test represent very little load, and most of the actual lag / cpu load come from the intterupt handlers.
the do_if checks are also a very minimal cpu load (i mean, its definitely a lot slower than a native assembly conditional jump but its hardly anything compared to the load of the game as a whole)
but for the selection score thing, its because there are other possible destructible than those listed (weapon is a non turret weapon on some ships)
i prefer the other things to be lower than said weapon hence the 5 score
I am not sure what you mean by "global tab" in that scenario, most variables are annoyingly global by default >< (or you mean something that would be shared between all instance of the object for the static constants ?)
While its true that it would be a slight improvement, the variables assignments in my test represent very little load, and most of the actual lag / cpu load come from the intterupt handlers.
the do_if checks are also a very minimal cpu load (i mean, its definitely a lot slower than a native assembly conditional jump but its hardly anything compared to the load of the game as a whole)
-
- Posts: 259
- Joined: Sat, 23. Nov 13, 09:48
my basic values and multiplier are set from ingame "pool" of engineer, i do not expect any to ever get close to 100% in all fields for sure xD.
I havent had enough time to actually play with them in game more than testings to really finetune the values but it looked pretty nice from the small tests i did.
I havent had enough time to actually play with them in game more than testings to really finetune the values but it looked pretty nice from the small tests i did.
-
- Posts: 78
- Joined: Sat, 16. Sep 06, 05:38
like in C langage and what we could do in X3 engine, keeping variables ad vitam to not have to reset them everytime and do calculations about their skills everytimeJey123456 wrote: I am not sure what you mean by "global tab" in that scenario, most variables are annoyingly global by default >< (or you mean something that would be shared between all instance of the object for the static constants ?)

and what i mean by "tab" (not english native, forgot the english name for that, but it's "tableau" in french)
is having :
thatship.thatengineer.thatthingaboutthatengineeronthatship
thatship.thatengineer.thatotherthingaboutthatengineeronthatship
thatship.thatengineer.thatotherotherthingaboutthatengineeronthatship
etc
(my computer engineering skills are far behind me, i've switched to another type of career, so don't remember the names of everything)
-
- Posts: 259
- Joined: Sat, 23. Nov 13, 09:48
You can keep them forever as well in XR script, i just chose not to so that the code is easier to read / edit the values that are made to be edited.
XR script actually go well beyond the normal "global" by saving everything for you and reloading them on game load on top of it !
As for table (array or vector depending on which language you prefer) they exist in the form of list (array / vector are the high performance storage of this type)
But the description you gave, seemed more like an indexed list or a map which are pretty slow compared to hardcoded nested if or switch xD (on small number of objects)
XR script actually go well beyond the normal "global" by saving everything for you and reloading them on game load on top of it !
As for table (array or vector depending on which language you prefer) they exist in the form of list (array / vector are the high performance storage of this type)
But the description you gave, seemed more like an indexed list or a map which are pretty slow compared to hardcoded nested if or switch xD (on small number of objects)
-
- Posts: 14
- Joined: Tue, 9. Feb 10, 04:42
-
- Posts: 259
- Joined: Sat, 23. Nov 13, 09:48
There is an issue right now that give you report for any ship (owned or not), altho if you go real close to the center of your ship, you should still get it.
I'm currently playtesting it / fixing bunch of small issues all around the place but its been calming down now, so ill make an update very soon (probably in the next 2 hours ish) that fix that along other things
I'm currently playtesting it / fixing bunch of small issues all around the place but its been calming down now, so ill make an update very soon (probably in the next 2 hours ish) that fix that along other things
-
- Posts: 78
- Joined: Sat, 16. Sep 06, 05:38
just did a small test run, it runs like a charm !
(i had a save where i was just beside one of my mining ship under attack by a couple a fighters)
i let them take down the hull, and i saw the builder drones make a building dance around the ship.
they seem to board the ship / re exit every 30sec or so, like what is to be expected
oh and yes, i was talking about arrays now that i know the term (again
)
(i had a save where i was just beside one of my mining ship under attack by a couple a fighters)
i let them take down the hull, and i saw the builder drones make a building dance around the ship.
they seem to board the ship / re exit every 30sec or so, like what is to be expected
oh and yes, i was talking about arrays now that i know the term (again

-
- Posts: 4
- Joined: Fri, 22. Nov 13, 14:09
-
- Posts: 259
- Joined: Sat, 23. Nov 13, 09:48
Ill see about that, altho its a bit lower priority, right now im doing bug hunting all around the game in freeplay. My goal is for the game to be playable for me, its only a free bonus that i make it available online heh.
Engineer were my first problem, since i couldnt use any capital ships i boarded, next will probably be the trading.
Altho if someone want to do the conversion to the language file be my guest, ill gladly put it in the release with your name in the credits.
Engineer were my first problem, since i couldnt use any capital ships i boarded, next will probably be the trading.
Altho if someone want to do the conversion to the language file be my guest, ill gladly put it in the release with your name in the credits.
-
- Posts: 486
- Joined: Thu, 22. Aug 13, 17:12
-
- Posts: 259
- Joined: Sat, 23. Nov 13, 09:48
there is none right now (hence the conversion to the language file)
currently the language is hardcoded to english in there. If someone want to change it so that it use a language file, i do not mind, but personally i rather work on getting things working first, i do not have much freetime to dedicate to that heh.
Once my game is in a state where i can enjoy all features without bugs/annoyance (that i can fix), then i will do lower priority things like cleaning up typos or actively supporting language files.
currently the language is hardcoded to english in there. If someone want to change it so that it use a language file, i do not mind, but personally i rather work on getting things working first, i do not have much freetime to dedicate to that heh.
Once my game is in a state where i can enjoy all features without bugs/annoyance (that i can fix), then i will do lower priority things like cleaning up typos or actively supporting language files.
-
- Posts: 172
- Joined: Wed, 6. Nov 02, 20:31
-
- Posts: 259
- Joined: Sat, 23. Nov 13, 09:48
Version 0.98 is out
It stops the engineers on ship you dont own from talking to you.
It also fix multiple runtimes error that could lockup the repairs (repair 1 piece up to 100% then keep trying to repair it)
The engineer wont bother you with the "everything is ok" message unless you go in "realtime engineering report" range (under 150m from the center of the ship)
It stops the engineers on ship you dont own from talking to you.
It also fix multiple runtimes error that could lockup the repairs (repair 1 piece up to 100% then keep trying to repair it)
The engineer wont bother you with the "everything is ok" message unless you go in "realtime engineering report" range (under 150m from the center of the ship)