Jump to content

WakelessREX

Members
  • Posts

    5
  • Joined

  • Last visited

Posts posted by WakelessREX

  1. having no idea what im doing really I just try this and it didnt work, I think if I knew what the pitch, yaw, and roll values were labeled I could maybe try a better attempt.


     

    function traffic_police(entity)
        -- for some weird reason (bug?), maxVelocity is smaller that actual value,
        -- so it needs to be multiplied by 2.5; probably programmed by some murican...
        local initial_top_speed = Engine(entity).maxVelocity*2,5

        local tier = ShipSystem(entity).numSlots

        -- we start off at 600m/s max, and loose 20m/s for each system slot of the ship
        -- that means 500m/s max with 5 slots, 400m/s with 10 slots, 300m/s with 15 slots
        local max_speed = 60 - tier*2
        local new_turningSpeed = 2.1 - tier*2
        -- yes, speed also have to be set divided by ten, another bug?

        -- new speed shouldn't be higher than the one provided by engines
        local new_speed = math.min(initial_top_speed, max_speed)

        -- reset to zero
        entity.addMultiplier(entity, StatsBonuses.Velocity, 0.0)
        entity.addAbsoluteBias(entity, StatsBonuses.Velocity, new_speed)
        entity.addMultiplier(entity, StatsBonuses.turningSpeed, 0.0)
        entity.addAbsoluteBias(entity, StatsBonuses.turningSpeed, new_turningSpeed)
        -- as you might have noticed, these two methods demand entity as first argument - contrary to what the Documentation says. 3 bugs in 1 piece of code, how bout that!?

        print(entity.name .. " - " .. Engine(entity).maxVelocity * 2.5)
    end

  2. On 3/4/2020 at 2:34 PM, alfuken said:

    OK, here's what I've came up with so far:

     

    File name: data/scripts/entity/init.lua

    Code:

     

    
    function traffic_police(entity)
        -- for some weird reason (bug?), maxVelocity is smaller that actual value,
        -- so it needs to be multiplied by 2.5; probably programmed by some murican...
        local initial_top_speed = Engine(entity).maxVelocity*2,5
    
        local tier = ShipSystem(entity).numSlots
    
        -- we start off at 600m/s max, and loose 20m/s for each system slot of the ship
        -- that means 500m/s max with 5 slots, 400m/s with 10 slots, 300m/s with 15 slots
        local max_speed = 60 - tier*2
        -- yes, speed also have to be set divided by ten, another bug?
    
        -- new speed shouldn't be higher than the one provided by engines
        local new_speed = math.min(initial_top_speed, max_speed)
    
        -- reset to zero
        entity.addMultiplier(entity, StatsBonuses.Velocity, 0.0)
        entity.addAbsoluteBias(entity, StatsBonuses.Velocity, new_speed)
        -- as you might have noticed, these two methods demand entity as first argument - contrary to what the Documentation says. 3 bugs in 1 piece of code, how bout that!?
    
        print(entity.name .. " - " .. Engine(entity).maxVelocity * 2.5)
    end
    
    if onServer() then
        local entity = Entity()
        if entity.isShip
            traffic_police(entity)
        end
    end
    
     

     

     

    This code is only applied when Entity is initialized, it's dirty and needs to be updated to re-apply after ship plan change, system install/remove, etc, but as a proof of concept it works.

    I used this and it works like a charm but id also like to adapt this to rotation speeds, for say pitch and yaw.  Do you mind helping me with that?

     

×
×
  • Create New...