Version 9 (modified by noep, 11 years ago) (diff) |
---|
Big Ships
WARNING: Currently (as of revision 10058) destroying a part of a ModularSpaceShip by shooting at it is likely to cause a segmentation fault, crashing the game. The command ModularSpaceShip killshippart can be used to destroy a ShipPart through the console. |
NOTE: Not all features mentioned in this article are implemented yet. |
A BigShip (aka ModularSpaceShip) is a spacecraft consisting of multiple parts, which can be destroyed individually. The destruction of parts can alter the behaviour of the vessel, for example by weakening shields, engines or disabling weapons.
Ticket #356: Big Ships
Ticket #418: Big Ships implementation
Implementation
All you need to create such a ModularSpaceShip is the model of a spacecraft which is cut into different pieces, so that the parts can be implemented as individual StaticEntities.
To assign an attached StaticEntity to a ShipPart, give it the same name as the ShipPart you want it to belong to (c.f. example below). (Note: Multiple StaticEntities can be assigned to the same ShipPart.)
<ModularSpaceShip . . . > <attached> <StaticEntity name="wing" . . . /> <StaticEntity name="tail" . . . /> </attached> <parts> <ShipPart name="wing" . . . /> <ShipPart name="tail" . . . /> </parts> <engines> <Engine /> <Engine /> </engines> </ModularSpaceShip>
Now hits received on StaticEntities assigned to a ShipPart will forward their damage to the corresponding ShipPart instead of to the main SpaceShip. Every ShipPart has multiple parameters to customize its behaviour, which can be defined in the XML files:
health | Same as for a normal Pawn |
initialhealth | Same as for a normal Pawn |
maxhealth | Same as for a normal Pawn |
damageabsorption | Value ranging from 0 to 1. Defines how much of the damage received is absorbed by the part, while the rest is forwarded to the main Spaceship. This can be used e.g. to create "physical" shields which get destroyed after getting too damaged (high absorption value) |
If you want the destruction of ShipParts to alter the vessels behaviour, add PartDestructionEvent to the ShipParts.
Example
Currently the HeavyCruiser ship created in the HS13 PPS provides a model for such a large spaceship.
In a demonstration level ("Modular Ships - Test 1") the vessel can be flown, and all its parts are individually destructible and alter the ships behaviour.
HeavyCruiser is composed of (at least) 9 parts:
Part | attached to | description | Event on destruction |
body | N/A | Main part of the ship. | Death |
frontL/R | body | Front extensions of the ship. | Loss of the weapon mounted on the part. |
partL/R | body | Boxes on the sides to the front of the ship. | Boost regenerates slower. Speed, acceleration and boost of the body's engine are weakened. |
sidearmL/R | body | Large sidearms of the ship. | Loss of the engine mounted on the part. Less controllability of the ship. (As well as destruction of sidearmL/Rfront) |
sidearmL/Rfront | sidearmL/R | Front ends of the sidearms. | Engines mounted on sidearms don't provide any more boost. |
turrets | body | (optional) Rapid firing autonomous turrets, defending the ship against nearby opponents. |
Look at the HeavyCruiser.oxt template to see an implementation of this!
Development
TODO
- Fix segfault when parts are destroyed by shooting at them
- Implement turrets to be attached as ShipParts
Problems
Severe problem: Destroying a ShipPart by shooting at it can cause a segfault. This is probably due to the collisionshapes of the part being deleted, while the Bullet physics engine is still handling a collision with them. This can probably be solved by changing the destruction process of a ShipPart to something similar like for Pawns, which use a PawnManager to coordinate their destruction inbetween ticks.
More Ideas
- BigShips could use an own HUD, to show individual parts health.
- Systems of the BigShip could be controlled, e.g. power can be manually directed to engines, shields or weapons.