Jump to content

[Mod] Captined ship salvage command


Nexus

Recommended Posts

I originally posted this on the steam forums, thought I would post this here as well, incase anyone else finds it useful.

 

This is a small mod I made that adds a salvage mode for ships with captains in them.

 

I should note that as with mining, when told to salvage the ship is literally told to 'attack' the wreck it has targeted. It does this without checking what weapons it has equipped. As such to avoid any issues, it's best to have a dedicated salvaging ship use the commands.

 

The mod adds two commands, Salvage and Clean Sector.

 

The Salvage command works as intended, it will only salvage wrecks that have a listed resource content and value. Which not all pieces have so some will be missed.

 

The Clean sector command no longer cares if the wreckage has a resource content of value. It will mine away ALL wrecks.

 

Go to your install directory, using steam right click on the game and to go Properties->Local Files->Browse Local files

 

And place the data folder in the zip file inside that directory that pops up. Then run the game

Salvage_Command.zip

Link to comment
Share on other sites

Would there be a way to get similar from salvage fighters? As (AFAIK) they currently only go for something that is directly ordered and usually cut it into parts that they then ignore.

 

I'm currently working on a version that should hopefully add a 'Carrier Command Menu' to ships with hangers. Simply put it attaches the lua to the deployed fighter rather than the ship itself. This would allow the fighter to automatically detect and go after salvage targets like a captained ship can.

 

But there are some technical hurdles to overcome for me. I has been years since i have touched lua, so I'm about as rusty as a car left in a barn to rot for about 20-30 years...oh and the barn had no roof the whole time lol.

 

I have some of the scripts made, but not tested, I'm still trying to decide how I want the fighters to be assigned their targets. Do I want the carrier to assign them? or do I want the fighters to figure it out themselves? And how should I handle the fighters when there finished? Oh and don't forget the fun one, How the hell do I know I'm applying this to a salvage fighter and not a attack fighter?

 

Also this last patch has thrown me another curve ball, before the patch I almost never had sp server crash issues...now its happening all the time. And no log to show what happens, it just cuts off after posting a timestamp...makes me wonder if its a logging action itself that's making it crash *shrug*

 

But ill see how much of it I can get done tomorrow. I really want to start testing the scripts, knowing my luck I'll spend all day tomorrow attempting to apply a script to a fighter and fail miserably. =P

 

The script itself is quite nice, but I've found there is such a thing as too big of an automated salvage ship, cause of how AI ships fly, combined with knife fight range of salvage turrets.

 

Yes..build small, also try to put the turrets around the 'root' block, im staring to notice that the salvaging turrets seems to have an issue tracking targets while the salvaging ship is moving around....it is in some cases just completely missing the part by a long shot. Seems to be more of an issue the further away the salvaging laser is from the root block, and the scale of the ship seems to effect it as well.

 

 

Link to comment
Share on other sites

Thank you so much!  Someone linked me this on Reddit, so I immediately installed it and am now watching my salvage ship go nuts on a map.  Least I can do with all my new found free time is say thanks!!

 

Your welcome, A new version of the mod will pop up shortly that addresses salvage fighters, its not perfect but its a major improvement.

Link to comment
Share on other sites

well i tryed to combine it with the safe mining mode ... and no luck still cant see the buttons ,,,

what i am missing ?

 

local splitter = UIHorizontalMultiSplitter(Rect(window.size), 10, 10, 8)

    window:createButton(splitter:partition(0), "Idle"%_t, "onIdleButtonPressed")
    window:createButton(splitter:partition(1), "Passive"%_t, "onPassiveButtonPressed")
    window:createButton(splitter:partition(2), "Guard This Position"%_t, "onGuardButtonPressed")
    window:createButton(splitter:partition(3), "Patrol Sector"%_t, "onPatrolButtonPressed")
    window:createButton(splitter:partition(4), "Escort Me"%_t, "onEscortMeButtonPressed")
    window:createButton(splitter:partition(5), "Attack Enemies"%_t, "onAttackEnemiesButtonPressed")
    window:createButton(splitter:partition(6), "Mine"%_t, "onSafeMiningButtonPressed")
window:createButton(splitter:partition(7), "Salvage"%_t, "onSalvageButtonPressed")
window:createButton(splitter:partition(8), "Clean Sector"%_t, "onSalvageAllButtonPressed")

 

i see untill "mine" in game ...

Link to comment
Share on other sites

well i tryed to combine it with the safe mining mode ... and no luck still cant see the buttons ,,,

what i am missing ?

 

local splitter = UIHorizontalMultiSplitter(Rect(window.size), 10, 10, 8)

    window:createButton(splitter:partition(0), "Idle"%_t, "onIdleButtonPressed")
    window:createButton(splitter:partition(1), "Passive"%_t, "onPassiveButtonPressed")
    window:createButton(splitter:partition(2), "Guard This Position"%_t, "onGuardButtonPressed")
    window:createButton(splitter:partition(3), "Patrol Sector"%_t, "onPatrolButtonPressed")
    window:createButton(splitter:partition(4), "Escort Me"%_t, "onEscortMeButtonPressed")
    window:createButton(splitter:partition(5), "Attack Enemies"%_t, "onAttackEnemiesButtonPressed")
    window:createButton(splitter:partition(6), "Mine"%_t, "onSafeMiningButtonPressed")
window:createButton(splitter:partition(7), "Salvage"%_t, "onSalvageButtonPressed")
window:createButton(splitter:partition(8), "Clean Sector"%_t, "onSalvageAllButtonPressed")

 

i see untill "mine" in game ...

 

Did you also add the two functions onSalvageButtonPressed and onSalvageAllButtonPressed that are later in the file?

Link to comment
Share on other sites

yes i think so ...

i just got this mod also http://www.avorion.net/forum/index.php/topic,1196.0.html

maybe they not going good together ?

 

or i scrued something in the craftorders.lua

 

---

 

function initUI()

    local res = getResolution()
    local size = vec2(250, 290)

    local menu = ScriptUI()
    local window = menu:createWindow(Rect(res * 0.5 - size * 0.5, res * 0.5 + size * 0.5))
    menu:registerWindow(window, "Orders"%_t)

    window.caption = "Craft Orders"%_t
    window.showCloseButton = 1
    window.moveable = 1

    local splitter = UIHorizontalMultiSplitter(Rect(window.size), 10, 10, 8)

    window:createButton(splitter:partition(0), "Idle"%_t, "onIdleButtonPressed")
    window:createButton(splitter:partition(1), "Passive"%_t, "onPassiveButtonPressed")
    window:createButton(splitter:partition(2), "Guard This Position"%_t, "onGuardButtonPressed")
    window:createButton(splitter:partition(3), "Patrol Sector"%_t, "onPatrolButtonPressed")
    window:createButton(splitter:partition(4), "Escort Me"%_t, "onEscortMeButtonPressed")
    window:createButton(splitter:partition(5), "Attack Enemies"%_t, "onAttackEnemiesButtonPressed")
    window:createButton(splitter:partition(6), "Mine"%_t, "onSafeMiningButtonPressed")
window:createButton(splitter:partition(7), "Salvage"%_t, "onSalvageButtonPressed")
window:createButton(splitter:partition(8), "Clean Sector"%_t, "onSalvageAllButtonPressed")
    --window:createButton(Rect(10, 250, 230 + 10, 30 + 250), "Attack My Targets", "onWingmanButtonPressed")

end

 

function onMineButtonPressed()
    if onClient() then
        invokeServerFunction("onMineButtonPressed")
        ScriptUI():stopInteraction()
        return
    end

    if checkCaptain() then
        removeSpecialOrders()
        Entity():addScript("ai/mine.lua")
    end
end

function onSafeMiningButtonPressed()
    if onClient() then
        invokeServerFunction("onSafeMiningButtonPressed")
        ScriptUI():stopInteraction()
        return
    end

    if checkCaptain() then
        removeSpecialOrders()
	local ship = Entity()
	local faction = Faction(ship.factionIndex)
	local player = Player(faction.index)
	local ai = ShipAI()
	if ship.durability < ship.maxDurability / 2 then
		player:sendChatMessage(player.name.." : "..ship.name, 0, "Currently waiting until damage is repaired.")
		ai:setPassive()
	end
        Entity():addScript("ai/safemine.lua")
    end
end

function onSalvageButtonPressed()
    if onClient() then
        invokeServerFunction("onSalvageButtonPressed")
        ScriptUI():stopInteraction()
        return
    end

    if checkCaptain() then
        removeSpecialOrders()
        Entity():addScript("ai/salvage.lua")
    end
end

function onSalvageAllButtonPressed()
    if onClient() then
        invokeServerFunction("onSalvageAllButtonPressed")
        ScriptUI():stopInteraction()
        return
    end

    if checkCaptain() then
        removeSpecialOrders()
        Entity():addScript("ai/salvageall.lua")
    end
end

function removeSpecialOrders()

    local entity = Entity()

    for index, name in pairs(entity:getScripts()) do
        if string.match(name, "data/scripts/entity/ai/") then
            entity:removeScript(index)
        end
    end
end
[code]

 

both LUA in the AI folder , and still its not working ... can the SafeMining cousing it ?

 

---

 

nvm problem solved . i forgot to copy it to steam game aslo.

Link to comment
Share on other sites

I suggest the carrier commands and fighter for salvaging.

When you notice how the AI doing mining and salvaging too, you just thing are they drunk !.

 

Fighter still do fighter behaviour while salvaging but they do it better then an AI ship.

 

The only problem are to get good salvage fighter. We need a fighter factory that works like the turret factory.

 

 

Link to comment
Share on other sites

I suggest the carrier commands and fighter for salvaging.

When you notice how the AI doing mining and salvaging too, you just thing are they drunk !.

 

Fighter still do fighter behaviour while salvaging but they do it better then an AI ship.

 

The only problem are to get good salvage fighter. We need a fighter factory that works like the turret factory.

 

Working on that as well, but making it based in your carrier..well trying to anyways.

Link to comment
Share on other sites

How would one add the salvage captin option as a server side only mod, eg client doesnt need any files.

If its at all possible?

 

Not possible, as the client needs to know the command. It does not receive that information from the server.

Link to comment
Share on other sites

so this script needs to be on the server as well as the client for it to work ? cause if so that would explain why nothing is working now, lol the ship will not even escort me now just sits there.

 

yea im almost positive it does at this point, well i found a bug, if the script is not on the server you are playing on and you tell it to salvage or clean sector it will do nothing, .... ever lol any commands after that are ignored, unless you disconnect and wait then reconnect.

Link to comment
Share on other sites

not sure what im doing wrong but hopeing someone can help bin trying to sort it since 10pm going to sleep in min hopeing some can reply and il see it morning and be like ahhhhh yeaa yeaa naa i had nah frickin clue i did dat wrong but ur yea i downloaded the salavge command read what ya said n thought ummm yea probbley due that to the due hickey sounds simple found the found through instructions but i guess i need a more direct or step to step 1,2,3 etc proccess cause im not sure where i went wrong would greatly like abit of help for big lez n sassy safe.  ;D

Link to comment
Share on other sites

I'm not getting this to work either. This is the first mod i have tried to install so bear with me. I took the zip file and put it in the install folder then extracted here. All the files look like they are there but i can't get it to work.  Do the commands show up in the ship interaction menu or do you have to run a command line. Do i need a target selected? Does this work with the beta version.  Thanks in advance for any info and please forgive my ignorance

Link to comment
Share on other sites

1. Download the Salvage command.zip

2. Unpack the Salvage command.zip -> u get a Data Folder

3. Copy the Data Folder u get

4. Go to your Steam installation Folder

5. Steam/Steamapps/common/Avorion  -> open your Avorion Folder

6. get your copy in there and hit OK -> if something needs to be overwrite, then do it

7. You are ready now, start your game

8. Get a commander on one of your ships

9. Target your ship (u cant fly it by your self)

10. Give the Ship an order, take salvage (the ship needs a salvage laser)

11. Its done, watch and be happy

 

hope this helps you out!

Link to comment
Share on other sites

Found a Bug in the Script long time usage.

 

If you order your Ships to Salvage, they will do it BUT

If the ship fly to short to an salvage object, the ship cant aim at the object any more & then its bugged.

We need a loop up command that check the last target of this ship. Is this target not destroyed or disapeared in more then 1 Minute

The ship has to fly away from that target & then try again.

 

Anti Stuck loop

 

Thanks!

Link to comment
Share on other sites

The data file is unpacked and in the right place but no salvage option appears in the orders menu. I am playing on beta but i will try a complete reinstall and see if that helps. Thanks for the info

 

I would check the log file to see if there is any error in it as well.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...