Jump to content

[REQUEST] Simple custom torpedo spawn script (SOLVED)


Mattoropael

Recommended Posts

Create 2 new files:

/scripts/commands/torpedo.lua

/scripts/player/torpedo.lua

 

/scripts/commands/torpedo.lua :

package.path = package.path .. ";data/scripts/lib/?.lua"
package.path = package.path .. ";data/scripts/player/?.lua"
function execute(sender, commandName, warhead)

    local ship = Player(sender).craft
    ship:addScriptOnce("data/scripts/player/torpedo.lua")
    ship:invokeFunction("data/scripts/player/torpedo.lua", "start", sender, commandName, warhead)

    return 0, "", ""
end

function getDescription()
    return "/torpedo [type]"
end

function getHelp()
    return "soo many torpedos"
end

 

/scripts/player/torpedo.lua :

package.path = package.path .. ";data/scripts/lib/?.lua"
local torps =
{
    Nuclear = 1,
    Neutron = 2,
    Fusion = 3,
    Tandem = 4,
    Kinetic = 5,
    Ion = 6,
    Plasma = 7,
    Sabot = 8,
    EMP = 9,
    AntiMatter = 10,
}

function initialize()

end

function start(sender, commandName, warhead)
    if not torps[warhead] then warhead = "Nuclear" end
    local ship = Player(sender).craft


    local TorpedoGenerator = require("torpedogenerator")
    local x, y = Sector():getCoordinates()

    local torpedo = TorpedoGenerator.generate(0, 0, nil, nil, torps[warhead])

    --stats
    ---general properties
    torpedo.rarity = Rarity(RarityType.Legendary)
    torpedo.tech = torpedo.tech
    torpedo.size = torpedo.size

    -- body properties
    torpedo.durability = torpedo.durability
    torpedo.turningSpeed = torpedo.turningSpeed
    torpedo.maxVelocity = torpedo.maxVelocity
    torpedo.reach = torpedo.reach

    -- warhead properties
    torpedo.shieldDamage = torpedo.shieldDamage
    torpedo.hullDamage = torpedo.hullDamage * 100
    torpedo.shieldPenetration = torpedo.shieldPenetration --[true or false]
    torpedo.shieldDeactivation = torpedo.shieldDeactivation --[true or false]
    torpedo.shieldAndHullDamage = torpedo.shieldAndHullDamage --[true or false]
    torpedo.energyDrain = torpedo.energyDrain --[true or false]
    torpedo.storageEnergyDrain = torpedo.storageEnergyDrain
    torpedo.damageType = DamageType.Physical
    torpedo.acceleration = torpedo.acceleration -- reach max velocity after 10km of travelled way

    if warhead.damageVelocityFactor then
        -- scale to normal dps damage dependent on maxVelocity
        torpedo.damageVelocityFactor = torpedo.damageVelocityFactor
        torpedo.maxVelocity = torpedo.maxVelocity
        torpedo.hullDamage = 0
    end

    -- torpedo visuals
    torpedo.numShockwaves = 1
    torpedo.shockwaveSize = 60
    torpedo.shockwaveDuration = 0.6
    torpedo.shockwaveColor = ColorRGB(0.9, 0.6, 0.3)
    -- torpedo.shockwaveColor = ColorRGB(0.1, 0.3, 1.2) -- this looks cool :)
    torpedo.explosionSize = 6
    torpedo.flashSize = 25
    torpedo.flashDuration = 1

    -- see /lib/torpedogenerator.lua for more

    local launcher = TorpedoLauncher()
    if launcher == nil then return end
    local shafts = {launcher:getShafts()}

    for _, shaft in pairs(shafts) do
        for i = 1, launcher:getMaxTorpedoes(shaft) do
            launcher:addTorpedo(torpedo, shaft)
        end
    end
    --torpedo storage
    --[[for j = 1, 50 do
        launcher:addTorpedo(torpedo)
    end]]
    terminate()
end

Ingame type

/torpedo

enjoy

 

 

Egr0Nwh.jpg

 

 

Link to comment
Share on other sites

 

Create 2 new files:

/scripts/commands/torpedo.lua

/scripts/player/torpedo.lua

 

/scripts/commands/torpedo.lua :

package.path = package.path .. ";data/scripts/lib/?.lua"
package.path = package.path .. ";data/scripts/player/?.lua"
function execute(sender, commandName, warhead)

    local ship = Player(sender).craft
    ship:addScriptOnce("data/scripts/player/torpedo.lua")
    ship:invokeFunction("data/scripts/player/torpedo.lua", "start", sender, commandName, warhead)

    return 0, "", ""
end

function getDescription()
    return "/torpedo [type]"
end

function getHelp()
    return "soo many torpedos"
end

 

/scripts/player/torpedo.lua :

package.path = package.path .. ";data/scripts/lib/?.lua"
local torps =
{
    Nuclear = 1,
    Neutron = 2,
    Fusion = 3,
    Tandem = 4,
    Kinetic = 5,
    Ion = 6,
    Plasma = 7,
    Sabot = 8,
    EMP = 9,
    AntiMatter = 10,
}

function initialize()

end

function start(sender, commandName, warhead)
    if not torps[warhead] then warhead = "Nuclear" end
    local ship = Player(sender).craft


    local TorpedoGenerator = require("torpedogenerator")
    local x, y = Sector():getCoordinates()

    local torpedo = TorpedoGenerator.generate(0, 0, nil, nil, torps[warhead])

    --stats
    ---general properties
    torpedo.rarity = Rarity(RarityType.Legendary)
    torpedo.tech = torpedo.tech
    torpedo.size = torpedo.size

    -- body properties
    torpedo.durability = torpedo.durability
    torpedo.turningSpeed = torpedo.turningSpeed
    torpedo.maxVelocity = torpedo.maxVelocity
    torpedo.reach = torpedo.reach

    -- warhead properties
    torpedo.shieldDamage = torpedo.shieldDamage
    torpedo.hullDamage = torpedo.hullDamage * 100
    torpedo.shieldPenetration = torpedo.shieldPenetration --[true or false]
    torpedo.shieldDeactivation = torpedo.shieldDeactivation --[true or false]
    torpedo.shieldAndHullDamage = torpedo.shieldAndHullDamage --[true or false]
    torpedo.energyDrain = torpedo.energyDrain --[true or false]
    torpedo.storageEnergyDrain = torpedo.storageEnergyDrain
    torpedo.damageType = DamageType.Physical
    torpedo.acceleration = torpedo.acceleration -- reach max velocity after 10km of travelled way

    if warhead.damageVelocityFactor then
        -- scale to normal dps damage dependent on maxVelocity
        torpedo.damageVelocityFactor = torpedo.damageVelocityFactor
        torpedo.maxVelocity = torpedo.maxVelocity
        torpedo.hullDamage = 0
    end

    -- torpedo visuals
    torpedo.numShockwaves = 1
    torpedo.shockwaveSize = 60
    torpedo.shockwaveDuration = 0.6
    torpedo.shockwaveColor = ColorRGB(0.9, 0.6, 0.3)
    -- torpedo.shockwaveColor = ColorRGB(0.1, 0.3, 1.2) -- this looks cool :)
    torpedo.explosionSize = 6
    torpedo.flashSize = 25
    torpedo.flashDuration = 1

    -- see /lib/torpedogenerator.lua for more

    local launcher = TorpedoLauncher()
    if launcher == nil then return end
    local shafts = {launcher:getShafts()}

    for _, shaft in pairs(shafts) do
        for i = 1, launcher:getMaxTorpedoes(shaft) do
            launcher:addTorpedo(torpedo, shaft)
        end
    end
    --torpedo storage
    --[[for j = 1, 50 do
        launcher:addTorpedo(torpedo)
    end]]
    terminate()
end

Ingame type

/torpedo

enjoy

 

Egr0Nwh.jpg

 

 

 

This works well for my purposes, thanks a lot.

Link to comment
Share on other sites

  • 3 weeks later...
  • 10 months later...
  • 1 month later...
  • 2 months later...

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