I made a script that destroys blocks when hit, but sometimes when an AI ship loses a block ALL it's turrets are destroyed.
I'm using:
onBlockDamaged(objectIndex, blockIndex, inflictorId, damage, damageType)
Plan():destroy(blockIndex)
blockindex returns an obj ID, it's not the BlockIndex, so it's not that
no that's not the whole script the whole thing is long, but i've isolated it to the destruction of the block and nothing else changes the issue.
Everything works correctly, but for some reason, sometimes, when an AI ship first loses a block from this script ALL of it's turrets are destroyed. I'm not really sure what causes it, it's really bizarre. It's linked to the specific ship and not the blocks being destroyed, it either happens immediately when a ship first loses a block or never. It seems to occur more often on larger ships. It never happens on player owned ships. Adding more turrets to the AI ship just makes those turrets be destroyed immediately when the next block is destroyed. I haven't been able to find a single thing that differs between ships that this happens to and ships it doesn't happen to.
Anyone have any clue why this might be happening? Is it just some issue with the hardcoded parts of the game?
Solved: AI ships are sometimes generated with turrets that are a higher level material than the blocks they're on, and when the ship's plan changes, I guess it checks the turret's compatibility with the blocks they're on and just destroys them.