Jump to content

[REQUEST] [MOD] The AI


T4Ken

Recommended Posts

The xml file is only the ship plan. Put it in your local ship folder (C:\users\USERNAME\AppData\Roaming\Avorion\ships) and you can load it on your ship in build menu.

 

Try to take a look into /data/scripts/entity/story/aibehaviour.lua and /data/scripts/lib/story/ai.lua. If you have further questions ask again.

Link to comment
Share on other sites

I know... did this allready but know i need a command or Mod to make them spawn when "The Ai" drops below 50% .

 

this also usable for other mods/mission :)

 

Add some code to the file aibehaviour.lua.

 

 

Before line 14 if onClient() then add:

local spawnedShips = false

 

In function updateServer() add this:

health = 0
    shield = 0

    local maxHealthSum = 0
    local maxShieldSum = 0

    local entities = {Sector():getEntitiesByType(EntityType.Ship)}
    for _, entity in pairs(entities) do
        if entity:hasScript("aibehaviour.lua") then

            health = health + entity.durability
            shield = shield + entity.shieldDurability

            maxHealthSum = maxHealthSum + entity.maxDurability
            maxShieldSum = maxShieldSum + entity.shieldMaxDurability
        end
    end

    maxHealth = math.max(maxHealth, maxHealthSum)
    maxShield = math.max(maxShield, maxShieldSum)

if not spawnedShips and health < maxHealth / 2 then
  -- Insert your custom code here. This will be executed once when health drops below 50%
end

 

I did no test it, it may be buggy.

 

To spawn the ships you may copy paste code from the file xsotan.lua, asyncpirategenerator.lua or any other script file where ships get spawned.

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