Jump to content

[MOD] All Turret Auto-Targeting


RebCom1807

Recommended Posts

So! After fiddling about in the files, I have something that, while not the most elegant of solutions, works. This mod modifies the factions.lua file under ..scripts/server, and the turretgenerator.lua file under ..scripts/lib - So the mod will probably conflict with anything that modifies those files.

 

If anyone can come up with a more elegant solution, feel free! There probably is a way that I'm missing.

 

Original post:

 

So, figure I might as well get the one that I'd find more interesting out of the way - What, exactly, determines the size of the turrets? Is this value independent from the number of crew needed to run it?

 

And, secondly, how might one go about making it so that every turret has the Independent Targeting system on it - As well as, perhaps, a minor damage buff to compensate for the lowered damage from that mod? I'm asking partly for the sake of being able to try out how it feels, as I'm one of those odd sorts that enjoys having the turrets do their thing while I fly.

AllTurretsAuto.zip

Link to comment
Share on other sites

Alright, I got something mildly.. Well, cludgey working, but hey, it's working!

 

All I did was replace, in TurretGenerator.lua, this:

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

with this:

local TurretTemplate T = GenerateTurretTemplate(seed, weaponType, dps, tech, rarity, material)
T.automatic = true
return T

 

And then, in factions.lua, under the player initialization, I added

turret.automatic = true

in the appropriate places.

 

Sadly, I had no luck finding the actual GenerateTurretTemplate code, but this works, from what I'm seeing, otherwise I would have modified that.

Link to comment
Share on other sites

:'( been trying to get this to work in turretgenerator.lua for an hour, 12 game tests and nothings loading, could you please be more specific about where to place "turret.automatic = true" argument? and/or would you mind posting your full lua, for examination. im very interested in seeing how many other variables you could force with turretgenerator. thanx

 

-- Love Avorion, Love Exploration!

Link to comment
Share on other sites

Thank you soo much! now next thing im gonna look into is where the "read only" parameters stored. because if we can acess them, we can write separe turret generator addons luas to make custom weapons, like cluster rockets, or even guided pulse torpedoes XD now that would be interesting!

 

Testing Update:

Managed to get This working:

 

-- added float multipliers to energy consuming weapons, effectively

        -- making them use 1/10th of a % of their normal, compliments to

        --"RebCom1807"

    local TurretTemplate T = GenerateTurretTemplate(seed, weaponType, dps, tech, rarity, material)

T.automatic = true

T.baseEnergyPerSecond = 0.001

T.energyIncreasePerSecond = 0.001

return T

 

Link to comment
Share on other sites

Sorry, I should have clarified.. Well, actually, I'll do one better. Have a standard install format!

 

Just drag the data folder into your Avorion base folder, and overwrite what needs overwriting.

 

EDIT: Sorry, wrong file included. Fixed now! And as for it working with the other mod, it depends on if they are using the function in TurretGenerator. For Aki's mod, at least, it won't, as I have no access - To my knowledge - to the function that actually generates the turrets. All I have is the ability to intercept the TurretTemplate object in a couple of places and manually adjust the 'automatic' variable.

AllTurretsAuto.zip

Link to comment
Share on other sites

To help answer the weapon scaling.

Although I've not tested [weaponTech], I have tested [weaponDPS]

 

When I adjusted the value of generated salvagers/miners to have X4 dps, the turrets were big! And this also adjusted the amount of crew needed to use them

 

In turretgenerator.lua

    if weaponType == WeaponType.MiningLaser then
        dps = miningDPS * 4     --added to existing code here
        tech = miningTech
if weaponType == WeaponType.SalvagingLaser then    --added this to affect salvagers only
	dps = dps * 4
	tech = weaponTech
    elseif weaponType == WeaponType.ForceGun then
        dps = rand:getFloat(800, 1200); -- force
        tech = weaponTech
    else
        dps = weaponDPS
        tech = weaponTech
    end

Link to comment
Share on other sites

Something in the mod is breaking world generation.

Everytime I create a new world, it's putting me at coords 0,0 (the centre of the galaxy)

I can't do a clean playthrough with this

 

Hold that thought...it could be something i'm doing. Testing now

 

Update: Yep it was me

WARNING - be careful when editing turretgenerator.lua - it appears to have a retroactive effect on existing turrets. The changes I made above, tried to adjust the drones starter turrets. Then it must have thrown a wobbly and generated me in the centre. It is indeed odd that it only manifests on world generation. I'm gonna leave it alone for a while till I get more used to coding in lua

Link to comment
Share on other sites

I'll try to make a 'cleaner' version when I get home today. The way I'm doing it currently might have some issues - Namely, adjusting something too close to the source. If I could, I would totally adjust the actual function at a base level. To help with the issue you're having, Havoc, maybe adjust it where it's calling the TurretGenerator's function?

Link to comment
Share on other sites

  • 2 weeks later...

Hi, the mod seems to work but it is not retroactive for me.

 

- When i create a new game it generate me in the center of the galaxy too.

- Creative mod is affected : must pay to build

 

I put " turret.automatic = true " at the wrong place in faction.lua file:

 

	    -- create turret generator
    local dps, tech = Balancing_GetSectorWeaponDPS(450, 0)
    local turret = InventoryTurret(GenerateTurretTemplate(random:createSeed(), WeaponType.ChainGun, dps, tech, Rarity(RarityType.Uncommon), Material(MaterialType.Iron)))
    player:getInventory():add(turret)
    player:getInventory():add(turret)

    local dps, tech = Balancing_GetSectorMiningDPS(450, 0)
    local turret = InventoryTurret(GenerateTurretTemplate(random:createSeed(), WeaponType.MiningLaser, dps, tech, Rarity(RarityType.Uncommon), Material(MaterialType.Iron)))
    player:getInventory():add(turret)
    player:getInventory():add(turret)

    player:createShipStyle("TestStyle")

turret.automatic = true
end

        [s]turret.automatic = true[/s]

function matchResources(player)

 

Apparently it solve the problem

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...