I hope I am posting in the right forum;
I am trying to figure out how to remove a specific subentity from a ship, when another subentity is destroyed, since you cannot attach a subentity to another and both get destroyed in one go.
I have this code that I recycled mostly from Eric Walsh'es Griff Sidewinder with frangible subentities
Code: Select all
case "player_escapepoddeluxe":
{
this.ship.owner.commsMessage("Sys. Destroyed - Escape Pod");
this.ship.owner.removeEquipment("EQ_ESCAPE_POD");
break;
//also insert code here to remove the escape pod light subentity that uses another .png
}
What I would like to do is that once the escape pod subentity is shot off (for example), the lights (which are a different subentity since they use another texture) are also removed from the (mother)ship. The same goes for the Large Cargo bay, which I would like to make destroyable, but then the lights and other subentities that appear attached to it also get destroyed.
I found these possibilities, and I know they should fit above the "break" code above, but don't really know how to define them so they apply to a specific subentity like "escapepodlights" for example :
Code: Select all
ship.subEntities[0].remove()
this.ship.subEntities[x].remove(true);
Also, I have a port and starboard shieldbooster subentity. How would I go about removing the installed shieldbooster equipment only when both subentities have been destroyed ?
Something in the lines of if Case shieldbooster Port and starboard are true, then remove equipment ? or if that is a backbreaker, have a 50% chance of destroying the shieldbooster by shooting destroyeing either one?
I am lost beyond belief in syntax and semantics here.
Edited:
How can I be such an idiot: Another thing I found out through testing is that sometimes player purchased equipment gets destroyed BEFORE the subentity. This means that the code up there does not work for Player ships. The proper mechanic should be that the subentity should be destroyed and that should trigger the EQUIPMENT to be removed. Not the other way around... anyway. help, ideas and code snippets are greatly appreciated.
Thank you.