Jump to content

Welcome to the Forum!

The best place to exchange builds and ideas! Vote for the best ideas and suggestions here.

Join the Avorion Discord!

Connect with other passionate players and talk about the latest news.
Discord

DLC Avorion Into the Rift Out Now!

Now available on Steam!
Steam

[MOD] Salvager/Miner range and auto turrets


LordHavoc
 Share

Recommended Posts

This multiplies the miner/salvager ranges by 4

 

First of all - credit

I've not created this, I've just mashed them together :)

 

Credits:

RebCom1807 - Turrets

https://www.avorion.net/forum/index.php/topic,1120.0.html

 

Olmmy - Weapon ranges

https://www.avorion.net/forum/index.php/topic,2571.0.html

 

Edit the TurretGenerator.LUA

After line 50 add the following

 

(I've even left in RebCom's notes, it helped me put this together)

 

	-- Begin altered code.
    --local TurretTemplate T = GenerateTurretTemplate(seed, weaponType, dps, tech, rarity, material)
--T.automatic = true
--return T
    --get the template and mess with reach
   
    local template = GenerateTurretTemplate(seed, weaponType, dps, tech, rarity, material)
    local weapons = {template:getWeapons()}
    template:clearWeapons()
    for _, weapon in pairs(weapons) do
        -- if salvager or miner, double blength and adjust reach
        if weaponType == WeaponType.MiningLaser then
            weapon.blength = weapon.blength * 4
            weapon.reach = weapon.blength
        elseif weaponType == WeaponType.SalvagingLaser then  
            weapon.reach = weapon.isBeam and weapon.blength * 4 or weapon.pvelocity*weapon.pmaximumTime

        end
    template:addWeapon(weapon)
    end
template.automatic = true
    return template

Link to comment
Share on other sites

I like this but I feel this and miner/salvage dps would work well together especially with the mining upgrade.  as it would make more sense with the upgrade than the retarded "highlight"ing of asteroids.  then it would enable x mod for getting y resource in actual usage.

Link to comment
Share on other sites

I am experiencing the same issue. Spawning in the centre of the galaxy for some reason.

Halp. I've attached a screenshot for visibility and code just below that.

 

 

sdpJI7VoHLWR0K9T2JzxE2J_-jWJvM6k_HXJLBj14h8?size=2048x1536&size_mode=3

 

 

 

    local rarities = {}
    rarities[5] = 0.1 -- legendary
    rarities[4] = 1 -- exotic
    rarities[3] = 8 -- exceptional
    rarities[2] = 16 -- rare
    rarities[1] = 32 -- uncommon
    rarities[0] = 128 -- common

    local rarity = rarity_in or Rarity(getValueFromDistribution(rarities))


-- Begin altered code.
    --local TurretTemplate T = GenerateTurretTemplate(seed, weaponType, dps, tech, rarity, material)
--T.automatic = true
--return T
    --get the template and mess with reach
   
    local template = GenerateTurretTemplate(seed, weaponType, dps, tech, rarity, material)
    local weapons = {template:getWeapons()}
    template:clearWeapons()
    for _, weapon in pairs(weapons) do
        -- if salvager or miner, double blength and adjust reach
        if weaponType == WeaponType.MiningLaser then
            weapon.blength = weapon.blength * 4
            weapon.reach = weapon.blength
        elseif weaponType == WeaponType.SalvagingLaser then  
            weapon.reach = weapon.isBeam and weapon.blength * 4 or weapon.pvelocity*weapon.pmaximumTime

        end
    template:addWeapon(weapon)
    end
template.automatic = true
    return template

    return GenerateTurretTemplate(seed, weaponType, dps, tech, rarity, material)
end

 

Link to comment
Share on other sites

It appears you've got an extra : "return GenerateTurretTemplate(seed, weaponType, dps, tech, rarity, material)"

AFTER the "return template"

 

Remove it, it only needs to return the template

 

 

This is what I've got...showing a few lines before and after. Just so you can see how it all fits

 

    local rarity = rarity_in or Rarity(getValueFromDistribution(rarities))

-- Begin altered code.
    --local TurretTemplate T = GenerateTurretTemplate(seed, weaponType, dps, tech, rarity, material)
--T.automatic = true
--return T
    --get the template and mess with reach
   
    local template = GenerateTurretTemplate(seed, weaponType, dps, tech, rarity, material)
    local weapons = {template:getWeapons()}
    template:clearWeapons()
    for _, weapon in pairs(weapons) do
        -- if salvager or miner, double blength and adjust reach
        if weaponType == WeaponType.MiningLaser then
            weapon.blength = weapon.blength * 4
            weapon.reach = weapon.blength
        elseif weaponType == WeaponType.SalvagingLaser then  
            weapon.reach = weapon.isBeam and weapon.blength * 4 or weapon.pvelocity*weapon.pmaximumTime

        end
    template:addWeapon(weapon)
    end
template.automatic = true
    return template

end

function TurretGenerator.generateArmed(x, y, offset_in, rarity_in, material_in) -- server

Link to comment
Share on other sites

  • 1 year later...

I know i am Necroing this thread. But adding it EXACTLY as posted. Using Notepad ++. It causes ANYTHING new in sectors to NOT generate/Appear..

 

Please advise.

 

Vanilla game.

 

NON-Beta.

 

Edit. Fixed..

 

I modified the code slightly. Was missing a Dash.. Somehow.

Link to comment
Share on other sites

  • 2 weeks later...

On the current non-beta version of Avorion, this mod completely breaks the wormhole spawns of the 0:0 boss. I get about ~130-170 total 'ships' spawned from the boss wormholes, but they are completely stationary, and does not engage.

Link to comment
Share on other sites

  • 4 weeks later...
  • 4 weeks later...

i have done some tweaking, now it seems to work.....I think. you can open the file and adjust the vaules for yourself around where i have placed the comments.

otherwise drop it in /Avorion/scripts/lib and hit overwrite

 

and I have done some modifications, should not stop satellites and torps from generating, at least on my side

turretgenerator.zip

Link to comment
Share on other sites

Wow...I never thought this thread would be resurrected

 

I took a look at your script and looks fine.

 

If you wanted to re-add the turrets then you could always add the commented line here (erm...without the comment syntax of course)

 

        end
    template:addWeapon(weapon)
    end
--template.automatic = true
    return template

Link to comment
Share on other sites

Wow...I never thought this thread would be resurrected

 

Hello Havoc i was wondering if you know how to make it to were the cost does t scale so high with this script. I really dont have time to play the game how it was meant but still want to work towards an empire so dont want to play creative i modified the dmg and efficiency  but now the turrets are 6mil so kinda defeat purpose thank you for any reply.

Link to comment
Share on other sites

Have a poke around the "InventoryItemPrice.LUA"

 

There are two sections in there which add price if they're miner or salvager...both of them take the raw 'VALUE' variable and then add additional price to it

The raw 'value' has a reach calculation on it...but you don't want to mess with it there...you only want the miner/salvager. So the trick is to reduce it within those sections by a proportion to how much you added it on in the turretgenerator

 

    if object.stoneEfficiency > 0 then
        costFactor = 3.0

        local materialFactor = material.strengthFactor * 5.0
        local efficiencyFactor = object.stoneEfficiency * 8.0

        value = value * materialFactor
        value = value * (1.0 + efficiencyFactor)  --Put some kind of divide here for Miner
    end

    if object.metalEfficiency > 0 then
        costFactor = 3.0

        local efficiencyFactor = object.metalEfficiency * 8.0
        value = value * (1.0 + efficiencyFactor) --Put some kind of divide here for salvager
    end

Link to comment
Share on other sites

Have a poke around the "InventoryItemPrice.LUA"

 

There are two sections in there which add price if they're miner or salvager...both of them take the raw 'VALUE' variable and then add additional price to it

The raw 'value' has a reach calculation on it...but you don't want to mess with it there...you only want the miner/salvager. So the trick is to reduce it within those sections by a proportion to how much you added it on in the turretgenerator

 

    if object.stoneEfficiency > 0 then
        costFactor = 3.0

        local materialFactor = material.strengthFactor * 5.0
        local efficiencyFactor = object.stoneEfficiency * 8.0

        value = value * materialFactor
        value = value * (1.0 + efficiencyFactor)  --Put some kind of divide here for Miner
    end

    if object.metalEfficiency > 0 then
        costFactor = 3.0

        local efficiencyFactor = object.metalEfficiency * 8.0
        value = value * (1.0 + efficiencyFactor) --Put some kind of divide here for salvager
    end

 

 

Thank you Havoc ill mess with it today i dont code much other than messing around here and there,but have fun learning whats what. so i appreciate you taking time to explain and showing example.

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
 Share

×
×
  • Create New...