Jump to content

Rinart73

Members
  • Posts

    416
  • Joined

  • Last visited

  • Days Won

    4

Posts posted by Rinart73

  1. Why not give NPCs a chance to spawn with a specific upgrade module? It would also affect their stats (acceleration, speed, shields, shield regen, speed limit removal,...).

    I agree. It would make NPC ships stronger and more diverse.

    But I disagree with 100% chance drop. It will be too easy to farm.

     

    Are you telling me that I can build a 5000 blocks of a ship, have my buddy blast that ship and we get a whole bunch of modules?

    Yes, you can. You can do this without friend. Due to the testing, I created few small ships without modules. Then I destroyed one and got yellow energy module.

  2. Currently upgrade/turret drops with some chance from every destroyed block.

     

    I suggest to change this, because this can be easilly exploited by players. Player can build a cheap ship with a bunch of small blocks and just destroy them.

    Also xsotan are often generated with a bunch of small blocks, which makes farming upgrades from them preferred way instead of NPC faction fights e.t.c.

     

    1. Upgrade drop should be based on ship size (or this new variable that determines how many upgrades you can use) and some chance.

    As an example, let's say we have an enemy ship which can hold 3 upgrades and drop chance is 20%. As battle goes, if due to the loss of volume ship can have installed only 2 modules, there is a 20% chance that it will drop a module. If ship is destroyed, there is a 20% chance for every slot to 'drop' a module.

     

    2. Turret drop should be limited to the amount of turrets on NPC ship. Again, with some chance, some turrets might be destroyed in battle and not drop.

     

    3. Player/Alliance owned ships can't drop additional modules/turrets (only those which were installed on ship). This will prevent players from exploiting mechanics.

  3. Originally this mod was developed to show devs that we really need built-in 'getGameLanguage()' function. Also I just wanted to know if it's even possible. Thanks to the devs since game version 0.16.5, there is a 'getCurrentLanguage()' function on client-side. Now the main purpose of this mod is to help modders to easily provide localization files for their mods.

     

    GitHub

     

    Doesn't need to be installed on server.

    Version 1.1.0 works with Avorion 0.21.x+.

     

    Making a few small changes in structure of your mod and adding just one line of code, you can easilly provide localization for your mod!

     

    Installation

    1. Unpack mod archive in your Avorion folder, not in data folder

    2. Open "data/scripts/lib/stringutility.lua" and add following code to the bottom of the file:

    if not pcall(require, "mods/i18n/scripts/lib/stringutility") then eprint("[ERROR][i18n]: failed to extend stringutility.lua!") end --MOD: i18n

     

    Uninstallation

    It is safe to uninstall, this mod can't corrupt your galaxy. Just remove the line you added during installation and "i18n" folder from "mods".

     

    For users

    There is a config file in "mods/i18n/config" folder that has 'SecondaryLanguages' option. There you can specify your secondary languages, i18n will try to load localization files for them if some mod doesn't have translation files for your main language. Also, first language in this array will be used as language for the server side (if you launched server in console).

     

    How to adjust your mod

    1. First of all, you need to create a folder for your mod localization files - "Avorion/mods/YourModName/localization".

     

    2. Create localization files: "de.lua" for Deutsch, "ru.lua" for Russian, "zh-hk.lua" for Hong Kong Chinese e.t.c

    These files should have following structure:

    return {
      ["This is how it works"] = "So funktioniert es",
      ["i18n /* Internationalization */"] = "Internationalisierung"
    }

     

    There is no need to create files for languages that you don't have translation yet.

     

    Also, if your native language is not english (you're writing a mod in Russian for example), you can easilly switch places for phrases and create "en.lua":

    return {
      ["При наличии необходимых файлов это работает и в обратную сторону"] = "If you have the necessary files, this also works in the opposite direction"
    }

     

    3. Now, just require "stringutility" and register your mod once in every file that you need to localize:

    require ("stringutility")
    -- some code
    if i18n then i18n.registerMod("YourModName") end

     

    4. Write your mod as usual, any "YourPhrase"%_t  will be shown as translated from now on.

     

    API

     

    • function number [, string] i18n.registerMod(string modname [, custompath]) - Registers mod and loads localization from mod folder.
      Arguments
      modname - The name of your mod folder.
      custompath - Optional argument, in case you want to load translation from different folder. Path should end with slash "/".
      Returns
      0 - everything is ok
      1 - there was an error while loading i18n mod
      2 - this mod was already registered
      3 - there was an error while loading localization. This probably means that you have errors in your localization file syntax. There are also a second return value provided that contains an error text.
      4 - translation file wasn't found.
    • function table i18n.getMods()
      Returns the list of all mods that tried or successfully registered in i18n.

     

     

    Explanation

     

     

    Mod overrides the default interop function which is used to translate things. And it does that only if at least one mod was registered, so there is a minimum performance impact.

    All loaded strings are stored together and can override each other, but you can use /* comments */ in your strings to make them unique.

     

     

     

    Changelog

     

     

    1.1.0

    • Changed: 'i18n.registerMod' now first return value can be '4' which means that translation file wasn't found. Return code '3' now stands for all other file errors.
    • Changed: 'i18n.registerMod' now accepts an optional argument 'custompath' in case you want to load translation from different folder. Path should end with slash "/".
    • Improved: Updated for Avorion 0.21.4

    1.0.0

    • Added: Added new API function 'i18n.getMods' - returns the list of all mods that tried or successfully registered in i18n
    • Added: Config - new option 'secondaryLanguages' - mod will try to load translation files for specified languages if it will fail to load for language, determined by 'getCurrentLanguage()'. Also, first language in this array will be used as server language
    • Improved: Mod updated to Avorion 0.16.5+ - using 'getCurrentLanguage' function now for client-side
    • Improved: Function 'i18n.registerMod' now returns various error codes that will help to determine the source of a problem
    • Removed: Config - options 'langCode' and 'detectMode'
    • Removed: API functions 'i18n.detectLanguage' and 'i18n.getLanguage' were removed. Use native function 'getCurrentLanguage' instead

    0.0.4

    • Fixed: Clientlog will now calculate correct timestamp to compare with old one
    • Improved: Clientlog performance - regex is now fast
    • Changed: Due to the improvements, default detect mode was changed to "full" (which uses clientlog)

    0.0.3

    • Initial release

     

     

    Credits

    Thanks to Dirtyredz for coding hints and new mod structure.

     

    Download

    Second file - the mod itself. First file - mod example for modders.

    i18n-example-1.0.0-0.16.5.zip

    i18n-1.1.0-0.21.4.zip

  4. I can add, that some actions need to be close to a docking port, and other actions need to be close to the station itself.

    "Trade Goods" neet to be docked

    "Transfer Crew/Stuff" needs to be 0km from the Station itself.

     

    That's because most of this checks use CheckPlayerDocked function from "scripts/lib/player.lua", but "scripts/entity/transfercrewgoods.lua" uses getNearestDistance: 20 for Crew, 2 for Cargo and Fighters.

     

    I agree, this should be unified.

  5. Correct me if I'm wrong, but I checked a few times and factory/station/mine price margin doesn't affect spawning traders in any way, though it should.

    Calculation when traders should spawn and how much they should by happens on Lua-side in "sector/traders.lua" and "lib/tradingutility.lua". And neither of this files has anything to do with station price margin.

  6. Please if you have spare time, check this out and tell me what do you think about it. I'll pull request on github in the near future maybe too.

    From my point of view, it's as fast as your code, but maybe I missed something.

    This is mine implementation of ingame formula for your mod. I tested it, it works (there might be a few bugs though).

    It's not precise as default (rounded a few things) ingame algorithm, but still.

     

    oospConfig.consumptionFormulaMultiplier is 1.0 by default

     

    Instead of calculating every 5 seconds independently (apply 50% chance, select random good, decrease count 1 to 6), we take:

    1) 10 seconds, assuming that 50% means 1 fail and 1 success in 10 seconds.

    2) Important moment: default ingame formula doesn't check if station has enough good. And I like it, it's like people on the station needed it, but there is no more processors. And they're like "well ok".

     

    So:

    1) Divide timeDelta / 10 and round it to the smaller value. This is the number of "steps" (times that our ingame function worked).

    2) Spread steps equally amongst all goods. In case we have some leftovers or like 3 steps and 10 goods, I added an algorithm that will randomly choose goods.

    3) Take result value for every good, and get a random number between result and result * 6

    4) Decrease.

     

     

    function consumption(station, timestamp)
    ...
        --CUSTOM: OOSP adjustments
        if oospConfig.consumptionUseGameFormula then
            local goodsCount = #boughtGoods
            local steps = math.floor(timeDelta / 10 / oospConfig.consumptionFormulaMultiplier)
            local part = math.floor(steps / goodsCount)
            local extra = steps % goodsCount
    
            for i = 1, goodsCount do
                local good = boughtGoods[i]
                local amount = part
                if extra > 0 and math.random() <= extra / (goodsCount - i + 1) then
                    amount = amount + 1
                    extra = extra - 1
                end
                amount = math.random(amount, amount * 6)
                debugPrint(4, "(ingame)removing", nil, amount, good.name, "from", station.name, maxStock, percentageToTake, currentStock)
                local status = station:invokeFunction("scripts/entity/merchants/consumer.lua", "decreaseGoods", good.name, amount)
            end
        else
        --CUSTOM
            for _,good in pairs(boughtGoods) do
                local status, currentStock, maxStock = station:invokeFunction("scripts/entity/merchants/consumer.lua", "getStock", good.name)
                local percentageToTake = (timeDelta / oospConfig.consumptionTime) * (1 + (math.random() * 2 * oospConfig.consumptionTimeVariation) - oospConfig.consumptionTimeVariation)
                local amount = math.floor(maxStock * percentageToTake)
                debugPrint(4, "removing", nil, amount, good.name, "from", station.name, maxStock, percentageToTake, currentStock)
                if amount > 5 then
                    local status = station:invokeFunction("scripts/entity/merchants/consumer.lua", "decreaseGoods", good.name, amount)
                end
            end
        end --CUSTOM: OOSP adjustments
    

  7. Hi, your mod is great, thanks for your work.

     

    Found a bug: Trading Post uses "oospConfig.consumptionTime" for both soldGoods and boughtGoods. So basically config variable "generationTime" doesn't affect anything. Version 0.99_2d

     

     

    Is there any chance for a version, that will use current "TradingManager:useUpBoughtGoods" algorithm?

    function TradingManager:useUpBoughtGoods(timeStep)
    
        if not self.useUpGoodsEnabled then return end
    
        self.useTimeCounter = self.useTimeCounter + timeStep
    
        if self.useTimeCounter > 5 then
            self.useTimeCounter = 0
    
            if math.random () < 0.5 then
    
                local amount = math.random(1, 6)
                local good = self.boughtGoods[math.random(1, #self.boughtGoods)]
    
                if good ~= nil then
                    self:decreaseGoods(good.name, amount)
                end
            end
        end
    
    end

     

    So, basically, this uses 1 to 6 of a 1 random good(that station buys) every 5 seconds with 50% chance.

     

    Why I think that this algorithm is better that current one? Because current one doesn't really care about how many goods can fit in the station. If "config.consumptionTime = 86400" it will eat all goods from Shipyard or Upgrade station regardless of its size in 1 day.

     

    I'm currently in stating sector and I already see that Shipyard has almost 6 times more goods than an Upgrade station and ingame algorithm will use all goods from Upgrade station in 20 hours and from Shipyard in 6 days.

  8. I guess that even stations with properly placed docking ports (that work with NPC traders) don't give true for

    object:hasComponent(ComponentType.DockingPositions)

    in scripts/lib/player.lua.

     

    Because me and my friends almost always get "You must be closer to the object for this" instead of "You must be docked to the object for this". We need to almost hit the station with our ships to be able to transfer anything.

     

    Let's look at the code:

    function CheckShipDocked(faction, ship, object, errors, generic)
    ...
        local error
        if object:hasComponent(ComponentType.DockingPositions) then
            if not object:isDocked(ship) then
                error = errors[object.type] or generic or "You must be docked to the object for this."%_T
            end
        else
            if object:getNearestDistance(ship) > 50 then
                error = errors[object.type] or generic or "You must be closer to the object for this."%_T
            end
        end
    

    So, if station has docks, then one error message. If not, another. And we always getting second message. Tried with different stations and mines.

  9. Player sends localized letter text to the server. Server sends a letter with received text to player.

    But server uses it's own localization for sender and letter header.

    ...
    
    local mailText = [[
    Hello,
    
    It looks like you have been betrayed by Bottan and his smugglers, too, and I think we might have a common enemy now.
    I'd like to work with you. Meet me at (${x}:${y}).
    
    - A Friend
    ]]%_t
    
    if onServer() then
    
    ...
    
    else -- if not on server
    
        function getUpdateInterval()
            return 12
        end
    
        function updateClient()
            invokeServerFunction("sendMail", mailText)
        end
    
    end
    
    function sendMail(text)
        local player = Player()
    
        if player:hasScript("story/smugglerretaliation") then return end
    
        local specs = SectorSpecifics()
        local center = directionalDistance(280)
        local location = specs:findFreeSector(random(), center.x, center.y, 0, 5, Server().seed)
    
        local mail = Mail()
        mail.sender = "A Friend"%_t
        mail.header = "The Enemy of my Enemy is my Friend"%_t
        mail.text = text % location
    
        player:addMail(mail)
        player:addScriptOnce("story/smugglerretaliation", location.x, location.y)
    
        terminate()
    end
    

     

    So basically this should look like this (added or for compatibility):

    ...
    
    local mailSender = "A Friend"%_t
    local mailHeader = "The Enemy of my Enemy is my Friend"%_t
    local mailText = [[
    Hello,
    
    It looks like you have been betrayed by Bottan and his smugglers, too, and I think we might have a common enemy now.
    I'd like to work with you. Meet me at (${x}:${y}).
    
    - A Friend
    ]]%_t
    
    if onServer() then
    
    ...
    
    else -- if not on server
    
        function getUpdateInterval()
            return 12
        end
    
        function updateClient()
            invokeServerFunction("sendMail", mailText, mailSender, mailHeader)
        end
    
    end
    
    function sendMail(text, sender, header)
        local player = Player()
    
        if player:hasScript("story/smugglerretaliation") then return end
    
        local specs = SectorSpecifics()
        local center = directionalDistance(280)
        local location = specs:findFreeSector(random(), center.x, center.y, 0, 5, Server().seed)
    
        local mail = Mail()
        mail.sender = sender or mailSender
        mail.header = header or mailHeader
        mail.text = text % location
    
        player:addMail(mail)
        player:addScriptOnce("story/smugglerretaliation", location.x, location.y)
    
        terminate()
    end
    

  10. Once I had the idea to add an UI to print some custom texts. F.e. you need to buy lot of different goods to get your factories running, you can write some kind of shopping list wich you always see on your screen. This would fit perfectly into MoveUI.

    I agree, some kind of notepad would be a cool addition.

  11. Hi. Recently tried your mod.

    Noticed a few things that I'd like to discuss:

    Firstly, FactionNotifier. This is how it looks for me (look at the screenshot). It is supposed to look like this? I mean, it eats a lot of space without any reason and faction name is way bottom.

     

    Also, I have a few suggestions/questions:

    [*]My friends just want to install modpack and play, they're not very good at settings e.t.c. Usually I'm getting all mods together for our server. Can you add a way to export/import settings? As far as I know devs disabled ability for Lua on client-side to access file system. But you can use something like json/other format string. Just a popup, textbox with settings string. And user can copy/paste it and apply.

    [*]Can you please add a way to set UI element position in pixels? It's hard to properly drag ResourcesWindow, for example,

    to match ingame resource view.

    factionNotifierQuestion.jpg.2c874a66d8b0cf4af771b959b9739529.jpg

  12. Starting from game version 0.23 mod is moved to the Steam Workshop.

     

    Client-side features work perfectly even if mod is not installed on a server side and vice versa.

     

    Versions:

    • 1.4.0 is for 0.21.x+
    • 1.3.0 is for 0.17.1-0.18.3
    • 1.0.0 is for 0.15.x+

     

    GitHub

     

    Playing with friend who likes to destroy NPC stations and bring all their goods to ours, I've noticed really fast that I don't find current Transfer Cargo tab practical enough.

    All goods are in random (from user point of view) order, you either need to remember their icons or scroll and watch for blinking tooltips e.t.c

    Of course, many modders and devs improved transfer cargo tab from it's original state so I decided to participate.

     

    Client Features

    • Goods are sorted in alphabetical order now (in all supported languages)
    • Each good (and crew 1.2.0+) row has overlay name that is displayed on top of their statistics bar
    • You can search cargo by name
    • Fixed vanilla bug that resets numbers in textboxes if you have the same good in different states (like usual and stolen)
    • Added option that allows to increase the amount of rows in cargo transfer tab in case you have a lot of different cargo in your station/ship (can be set in 'mods/TransferCargoTweaks/config/config.lua')
    • You can transfer 5/10/50 goods/crew simultaneously by holding Ctrl/Shift/Alt while clicking transfer button (1.2.0+)
    • You can mark goods as favorites or trash. Favorites will be sorted to the start of the list, trash in the bottom (1.2.0+)
    • When transfering the crew you now see how much crew workforce your and other ship/station has and needs (1.2.0+)

     

    Server Features

    • Crew, cargo and fighters transfer distance can be changed in the config (1.3.0+)
    • You now need to be docked to a station instead of being really close to it to transfer stuff (1.3.0+). You can toggle the default behaviour back on in the config

     

    Installation

    [*]Make a copy of 'data/scripts/entity/transfercrewgoods.lua'

    [*]Unpack mod archive into Avorion folder

    [*]Optionally install i18n - Internationalization mod, if you want to use this mod in your language

     

    Uninstallation

     

     

     

    Configuration

     

    Config file is located in "mods\TransferCargoTweaks\config" directory. There you have following settings:

     

    Client settings:

    • CargoRowsAmount - maxumum amount of cargo rows. Increase if you have more than 100 unique goods in your ship/station
    • EnableFavorites - enables/disables cargo favorites system
    • ToggleFavoritesByDefault - if favorites system is enables, should it be toggled on by default?
    • EnableCrewWorkforcePreview - show current and minimal crew workforce in Crew Transfer Tab

    Server settings:

    • FightersMaxTransferDistance - allows to change fighters max transfer distance
    • CargoMaxTransferDistance - allows to change cargo max transfer distance
    • CrewMaxTransferDistance - allows to change crew max transfer distance
    • CheckIfDocked - if enabled, when a ship transfers goods from/to a station, server will check if the ship is docked instead of checking the distance (usually this will allow to transfer from a greater distance)

     

     

    Compatibility

     

    Mod replaces 'data/scripts/entity/transfercrewgoods.lua'. The following functions were changed:

    • TransferCrewGoods.initUI
    • TransferCrewGoods.updateData
    • TransferCrewGoods.onPlayerTransferCargoTextEntered
    • TransferCrewGoods.onSelfTransferCargoTextEntered
    • TransferCrewGoods.onPlayerTransferCargoPressed
    • TransferCrewGoods.onSelfTransferCargoPressed
    • TransferCrewGoods.onPlayerTransferCrewPressed - from version 1.2.0
    • TransferCrewGoods.onSelfTransferCrewPressed - from version 1.2.0
    • TransferCrewGoods.onPlayerTransferCargoPressed - from version 1.2.0
    • TransferCrewGoods.onSelfTransferCargoPressed - from version 1.2.0
    • TransferCrewGoods.renderUI - from version 1.2.0
    • TransferCrewGoods.onShowWindow - from version 1.2.0
    • TransferCrewGoods.onCloseWindow - from version 1.2.0

     

     

    Planned features

    • Implement either favorites/trash system (like the one that we have now for upgrades) or multiple customizable groups like "Turret Goods", "Pizza ingredients" e.t.c. Restore these settings after revisiting the sector (save them on client side) - done in 1.2.0

     

    Notes

    • Mod also changes some lines in accordance with Lua performance recommendations

     

    Changelog

     

     

    1.4.0

    • Fixed: Lowercase caching didn't work.
    • Fixed: When user favorited some good, removed it from ship and then closed a window, it caused a script error.
    • Fixed: 'Favorites system' was sometimes assigned to wrong goods or incorrectly displayed.
    • Fixed: Some other small bugs.
    • Improved: Updated to Avorion 0.21.x.

    1.3.0

    • Added: A way to change max transfer distance for crew, cargo and fighters via config (if mod is installed server-side)
    • Added: If you're transfer goods to/from station you should now be docked instead of being really close. You can toggle default behaviour on in config (if mod is installed server-side)
    • Added: Partial Deutsch and French translation
    • Fixed: Minor fixes

    1.2.0

    • Added: Localization support. You'll need to install 'i18n' mod for it to work (optional)
    • Added: An option to transfer 5/10/50 goods at once by clicking transfer button while you hold Ctrl/Shift/Alt
    • Added: Favorites/trash system. Hover on row and you'll see two small icons (star and trasbin). Right-click them and you'll mark that good as favorites/trash.
      Self/Other ship favorites are independent from each other. You can also turn on/off favorites sorting by clicking big button with a star.
      All your preferences are saved on your(client) side in AppData(or other folder on Linux)
    • Added: Overlay crew names with their profession levels
    • Added: A way to show how much crew workforce you currently have and need
    • Improved: A bit more utf8 performance
    • Fixed: Minor errors in utf8 library

    1.1.0

    • Fixed: Cargo sorting order for languages that have non-latin characters (no more "Ö" after "Z" in German)
    • Improved: Mod updated to Avorion  0.17.1+
    • Improved: utf8 library was rewritten to make mod more performance friendly
    • Improved: Localized 'Search' label
    • Improved: Search toogle button now has different icon when search query is not empty. This should be helpful in case you searched something and then toggled search bar off

    1.0.0

    • Initial release

     

     

    Help to Translate

    Currently supported languages: English, Russian, German. You can help to translate this mod:

     

     

    • "Level %u" - example: "1 General (Level 2)"
    • "Untrained" - example: "1 General (Untrained)"
    • "Untrained /* plural */" - example: "3 Generals (Untrained)"

     

     

     

    Screenshots

     

     

    transfercargotweaks_1_2_0_favorites.jpg

     

    transfercargotweaks_1_2_0_crew.jpg

     

    TransferCargoTweaks-1.0.0.zip

    TransferCargoTweaks-1.3.0_0.17.1-0.18.2.zip

    TransferCargoTweaks-1.4.0_0.21.x.zip

    [*]Remove 'TransferCargoTweaks' folder from 'mods'

    [*]Restore  'data/scripts/entity/transfercrewgoods.lua' from backup

  13. Since now game is being localized into several languages, we faced new problem: most of non-English languages use some characters that are being encoded with more that 1 char.

     

    Currently we have Lua 5.2. Upgrading to Lua 5.3 will give some basic UTF-8 functions implemented on C-level, but it will not be

    enough for comfortable coding.

     

    Of course, you might say, there is a pure-lua libraries that allow you to search and even replace UTF-8 strings. It is true. But when it comes to such simple things as string.lower/upper, real problems start. It's kinda hard and not performance-wise to map all character table upper-lower variants in Lua.

     

    I recently tried to make a cargo search mod. And believe me, utf8.find function and my string.upper workaround are really not performance-friendly.

     

    So, please, add UTF-8 support on C++ level.

     

    You can use free solutions like this one (Github link)

  14. - unusable offline

    So.. the difference in singleplayer between no wiki when offline and nonexistent ingame wiki?

    - has mini-loadings

    Which will happen only if you're using it.

    - wiki can't read what you've discovered. It shows you everything it has regardless of your preference about spoilers

    So, who's forcing you to use it?

    - info depends on people posting instead of being pulled directly from the game's files. Can be outdated

    Do you really think that devs are going to write an entire wiki for you? Game community usually does that. And current wiki are made by community. Yes, it's somewhat outdated. But being able to access it from the game its a good idea. Though I'm against integrating browser in game. This thing is slow and eats a lot of memory. Better be just making a HTTP-request and using really simple formatting on retrieved info.

  15. I play in Russian language.

    Galaxy map search: I'm typing "Верфь" (Shipyard) and no sectors highlighted. I can still search for specific sector names, because they're in English.

    Inventory filter: typing "наонит лазер" (naonite laser) and there is no turrets hightlighed.

     

    I tried to switch to English: I can successfully search for facton names, stations e.t.c on galaxy map and for turret/upgrade rarity/type.

     

    Maybe your search/filtering doesn't use utf-8 search/strpos functions, but ascii-ones?

    Please fix this, because currently this cool feature almost doesn't exists for non-English players.

×
×
  • Create New...