T4Ken Posted February 24, 2018 Share Posted February 24, 2018 Hello , I wanna set some Minions for The Ai when it becomes 50% Damage of Shield or Hull. I got allready a The_ai_Minion.xml , but no clue how to get it done ;D Link to comment Share on other sites More sharing options...
Hammelpilaw Posted February 27, 2018 Share Posted February 27, 2018 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 More sharing options...
T4Ken Posted February 27, 2018 Author Share Posted February 27, 2018 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 :) Link to comment Share on other sites More sharing options...
Hammelpilaw Posted March 4, 2018 Share Posted March 4, 2018 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now