Jump to content

Biggers guns on the turret factory


Serenity424

Recommended Posts

Hello guys ,

 

Working on the creation of bigger guns with the factory but there is a catch, it display correctly the gun that should be purchased but when I try to create it it don't add to my inventory :'( had to wreck many systems to get the components for it.

 

Except for the checkbox initialization and changed the ingredients amounts there is nothing too wild that would prevent the turret from being made, and the server doesn't show errors, someone have an idea ?

 

 

function makeTurret(weaponType, rarity, material, ingredients)

    local turret = makeTurretBase(weaponType, rarity, material)
    local weapons = {turret:getWeapons()}

    turret:clearWeapons()

    for _, weapon in pairs(weapons) do
        -- modify weapons
        for _, ingredient in pairs(ingredients) do
            if ingredient.weaponStat then
                -- add one stat for each additional ingredient
                local additions = math.max(ingredient.minimum - ingredient.default, math.min(ingredient.maximum - ingredient.default, ingredient.amount - ingredient.default))

                local value = weapon[ingredient.weaponStat]
                if type(value) == "boolean" then
                    if value then
                        value = 1
                    else
                        value = 0
                    end
                end

                value = value + ingredient.statDelta * additions
                weapon[ingredient.weaponStat] = value

            end
        end

        turret:addWeapon(weapon)
    end

    for _, ingredient in pairs(ingredients) do
        if ingredient.turretStat then
            -- add one stat for each additional ingredient
            local additions = math.max(ingredient.minimum - ingredient.default, math.min(ingredient.maximum - ingredient.default, ingredient.amount - ingredient.default))

            local value = turret[ingredient.turretStat]
            if type(value) == "boolean" then
                if value then
                    value = 1
                else
                    value = 0
                end
            end

            value = value + ingredient.statDelta * additions

            turret[ingredient.turretStat] = value
        end
    end

    -- if the automatic property was set, we must adjust damage of the turret
    if turret.automatic then
        local weapons = {turret:getWeapons()}
        turret:clearWeapons()

        for _, weapon in pairs(weapons) do
            weapon.damage = weapon.damage / 2.0
            if weapon.hullRepair > 0.0 then
                weapon.hullRepair = weapon.hullRepair / 2.0
            end
            if weapon.shieldRepair > 0.0 then
                weapon.shieldRepair = weapon.shieldRepair / 2.0
            end

            turret:addWeapon(weapon)
        end
    end

if biggunCheckBox.checked and weaponType == WeaponType.Cannon then
turret.size=70
turret.slots=70
-- turret.Crew=round(totalcomp)
turret.turningSpeed=0.05
turret:clearWeapons()	
for _, weapon in pairs(weapons) do
        weapon.reach=9500
	-- weapon.heatPerShot=1000
	weapon.otherForce=10^8
	weapon.damage=1000*1000^6
	weapon.hullDamageMultiplicator=2
	weapon.shieldDamageMultiplicator=0.7
	weapon.shieldPenetration=1500
	-- weapon.maxHeat	=1000

	weapon.recoil=10^5
	-- weapon.baseEnergyPerSecond=10^6
	-- weapon.automatic=false
	weapon.psize = weapon.psize * turret.size/10 * 1 --Projectile size, change this for fun :D
	weapon.pvelocity = weapon.pvelocity /10
	weapon.pmaximumTime = weapon.reach / weapon.pvelocity --Leave this alone for accurate range, projectile lifetime calculated after the altered velocity
	weapon.pcolor =ColorRGB(0.1, 0.3, 1.2)
	weapon.fireRate =0.1
        turret:addWeapon(weapon)
	sendError("This turret should be here."%_t)
    end
    
        --Range for beam weapons
				-- if weapontype == WeaponType.Laser or weapontype == WeaponType.MiningLaser or weapontype == WeaponType.RailGun  or weapontype == WeaponType.RepairBeam or weapontype == WeaponType.LightningGun or weapontype == WeaponType.TeslaGun or weapontype == WeaponType.ForceGun or weapontype == WeaponType.SalvagingLaser then
					-- weapon.blength = weapon.blength * rangemul
					-- weapon.reach = weapon.blength
					-- weapon.bwidth = weapon.bwidth * sizemul * math.sqrt(dpsmul) * 1 --Size of beam
					-- weapon.bshapeSize = weapon.bshapeSize * sizemul * math.sqrt(dpsmul) * 1 --Size of beam
				-- else --Range / projectile properties for Physical weapon
					-- weapon.reach = weapon.reach * rangemul * 1
					-- weapon.psize = weapon.psize * sizemul * math.sqrt(dpsmul) * 1 --Projectile size, change this for fun :D
					-- weapon.pvelocity = weapon.pvelocity * math.sqrt(dpsmul)
					-- weapon.pmaximumTime = weapon.reach / weapon.pvelocity --Leave this alone for accurate range, projectile lifetime calculated after the altered velocity
				-- end

end


    return turret;
end

 

Link to comment
Share on other sites

if biggunCheckBox.checked and weaponType == WeaponType.Cannon then
turret.size=70
turret.slots=70

Wow

(Note: Turrets above size 10 cannot be installed: the custom turret interface has a max turret size of 10. Also, slots is usually size mutliplied by 2.)

 

Maybe the information didn't transfer out and another, normal-sized turret spawned in its place. Right now (or maybe it has been fixed), turrets often get wrong stats. Once I even got 0 damage launchers by trying to make "ideal-very-slow-overheating" 900 damage ones :(.

 

Link to comment
Share on other sites

Thanks for the feed back, yeah since I haven't spawned one yet I haven't any idea of how the size reflect on the ship.

If you talk about custom turret I haven't tried to build one (like on the ship editor UI) dunno how this work. I haven't found a proper "display" function to send a chat message for debugging purposes so don't really know what's happening in the if loops.

 

I tried (after trying to build a big one) to build a normal one same thing happen no turret :/ .

So yeah for the stats I just tried which property can be changed and which is not, the doc is not completely accurate or  I missed something.

Link to comment
Share on other sites

So I found the culprit but I have no idea of why, here is the thing

buyer:pay("Paid %1% credits to build a turret."%_T, price)

    for i, ingredient in pairs(ingredients) do
        local g = goods[ingredient.name]:good()
        ship:removeCargo(g, ingredient.amount)
	displayChatMessage('good god', 'the code', 0)
    end
displayChatMessage('good god', 'the code', 0) 
    local turret = makeTurret(weaponType, rarity, material, ingredients)
displayChatMessage(' bad god', 'the code', 0) 
    buyer:getInventory():add(InventoryTurret(turret))

    invokeClientFunction(player, "refreshUI")

 

it's in the function when you clic on "buy" now if I remove the first display call (btw this work nice for display )  it take me the ingredients and the money but turret is nowhere to be found. Now if I let it, it will take only the first kind and stop but no message nor turret. There is no return, no bug logged in the server so why ?

Link to comment
Share on other sites

So here is a catch I have no idea why,

 

	displayChatMessage('good god3', 'the code', 0)
    if missing then
        sendError(player, "You need more %s."%_t, missing)
        return
    end

    local canPay, msg, args = buyer:canPay(price)
    if not canPay then
        sendError(player, msg, unpack(args))
        return
    end
displayChatMessage('good god2', 'the code', 0)
    local errors = {}
    errors[EntityType.Station] = "You must be docked to the station to build turrets."%_T
    errors[EntityType.Ship] = "You must be closer to the ship to build turrets."%_T
    if not CheckPlayerDocked(player, station, errors) then
        return
    end

    -- pay
    receiveTransactionTax(station, taxAmount)
displayChatMessage('good god1', 'the code', 0)
    buyer:pay("Paid %1% credits to build a turret."%_T, price)
-- displayChatMessage(ingredient,'the code',0)
    for i, ingredient in pairs(ingredients) do
        local g = goods[ingredient.name]:good()
        ship:removeCargo(g, ingredient.amount)
	-- displayChatMessage('good god', 'the code', 0)
    end
displayChatMessage('good god', 'the code', 0) 
    local turret = makeTurret(weaponType, rarity, material, ingredients)
displayChatMessage(' bad god', 'the code', 0) 
    buyer:getInventory():add(InventoryTurret(turret))

    invokeClientFunction(player, "refreshUI")

 

As you can see I put more display stuff, and nothing happen, like the message thingy make avorion refuse to execute anything apparently, like nada.

I did few test with basic turret (no mod implication) and right now when I try to make a turret nothing happen and no bug.

 

So why ?

 

here is the log of the server, where should appear something, anything

2018-09-18 00-14-21| Starting thread [LoadingScreen Plan]...

2018-09-18 00-14-21| Started thread [LoadingScreen Plan] with id 23

2018-09-18 00-14-21| <Server> Player XXXXX joined the galaxy

2018-09-18 00-14-21| Player XXXXX joined the galaxy

2018-09-18 00-15-54| <> You paid 575403456 credits to pay the crew of B.

2018-09-18 00-15-54| You paid 575403456 credits to pay the crew of B.

2018-09-18 00-15-54| <> The crew of your ship 'B' was paid.

2018-09-18 00-15-54| The crew of your ship 'B' was paid.

Link to comment
Share on other sites

Maybe displayed chat messages do not appear in the server log ?

Console messages, made with "print" may appear. Check out the client log too for the messages~.

But it's really weird, since the turret buying message (Paid %1% credits to build a turret.) didn't appear like the crew one.

Link to comment
Share on other sites

Yeah I checked ingame (client log ?) and server log nothing appear, if I cut out the "displayChatMessage" the code will execute all the way down to removing the ingredients but not making the turret and it doesn't make any sense :/  like :

-If the message function make the code go wrong why no sign of error ?

-Why does the code just stop like this, like there is no break, return of any shouldn't it bug ?

-And the maketurret work since it display the turret with the value I gave it.

So still searching of why, but without anything to work with I'm stuck :/

Link to comment
Share on other sites

Okay someone need to point out the problem here I'm giving up, I looked into again to find who/what what bugging the mod.

If I let a if loop in the turret making function it will never build a turret, like if I let only the if loop without instructions in it, and even turret that does not trigger the IF.

 

If I try to printlog anything in the "buildturret" function it's just like the game is blind to this, like nothings happens, wtf ?

Link to comment
Share on other sites

WORK RESUMED

 

Sooo, found a way around using the rarity this time, it does work I'll need to make a mod for each weapons (at least the main types) and rework the ui to help.

But you can have pretty big weapons, to have to note the ship has 300M Hp +, the plat where the coax big gun is mounted is 100*100

20180922000358_1.jpg

Link to comment
Share on other sites

So, reworked the TurretFactory to create big weaponry , as of now only the laser is added and just the main proprieties  (size/range/damage)

I'm looking forward to add more weapons to the list.

For now the biggest laser look like this

20180929233000_1.jpg

(it's in front of the ship which you have the stats)

It's 300as size , I need to rework the propriety upgrade schematics to have something bit more realistic.

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