Implements SpawnEntityOnDeath property for entities (i.e. rubble). Fixes #1166.
Adds some placeholder rubble entities. They currently reuse foundation actors until proper rubble models are created. This was SVN commit r12717.
This commit is contained in:
parent
772c10801c
commit
bf55acadaa
@ -15,6 +15,11 @@ Health.prototype.Schema =
|
||||
"<data type='positiveInteger'/>" +
|
||||
"</element>" +
|
||||
"</optional>" +
|
||||
"<optional>" +
|
||||
"<element name='SpawnEntityOnDeath' a:help='Entity template to spawn when this entity dies. Note: this is different than the corpse, which retains the original entity's appearance'>" +
|
||||
"<text/>" +
|
||||
"</element>" +
|
||||
"</optional>" +
|
||||
"<element name='RegenRate' a:help='Hitpoint regeneration rate per second. Not yet implemented'>" +
|
||||
"<ref name='nonNegativeDecimal'/>" +
|
||||
"</element>" +
|
||||
@ -112,9 +117,13 @@ Health.prototype.Reduce = function(amount)
|
||||
if (this.hitpoints)
|
||||
{
|
||||
state.killed = true;
|
||||
|
||||
|
||||
PlaySound("death", this.entity);
|
||||
|
||||
// If SpawnEntityOnDeath is set, spawn the entity
|
||||
if(this.template.SpawnEntityOnDeath)
|
||||
this.CreateDeathSpawnedEntity();
|
||||
|
||||
if (this.template.DeathType == "corpse")
|
||||
{
|
||||
this.CreateCorpse();
|
||||
@ -134,7 +143,7 @@ Health.prototype.Reduce = function(amount)
|
||||
|
||||
var old = this.hitpoints;
|
||||
this.hitpoints = 0;
|
||||
|
||||
|
||||
Engine.PostMessage(this.entity, MT_HealthChanged, { "from": old, "to": this.hitpoints });
|
||||
}
|
||||
|
||||
@ -210,6 +219,28 @@ Health.prototype.CreateCorpse = function(leaveResources)
|
||||
return corpse;
|
||||
};
|
||||
|
||||
Health.prototype.CreateDeathSpawnedEntity = function()
|
||||
{
|
||||
// If the unit died while not in the world, don't spawn a death entity for it
|
||||
// since there's nowhere for it to be placed
|
||||
var cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
|
||||
if (!cmpPosition.IsInWorld())
|
||||
return INVALID_ENTITY;
|
||||
|
||||
// Create SpawnEntityOnDeath entity
|
||||
var spawnedEntity = Engine.AddLocalEntity(this.template.SpawnEntityOnDeath);
|
||||
|
||||
// Move to same position
|
||||
var cmpSpawnedPosition = Engine.QueryInterface(spawnedEntity, IID_Position);
|
||||
var pos = cmpPosition.GetPosition();
|
||||
cmpSpawnedPosition.JumpTo(pos.x, pos.z);
|
||||
var rot = cmpPosition.GetRotation();
|
||||
cmpSpawnedPosition.SetYRotation(rot.y);
|
||||
cmpSpawnedPosition.SetXZRotation(rot.x, rot.z);
|
||||
|
||||
return spawnedEntity;
|
||||
};
|
||||
|
||||
Health.prototype.Repair = function(builderEnt, work)
|
||||
{
|
||||
var damage = this.GetMaxHitpoints() - this.GetHitpoints();
|
||||
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_1x1.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_1x1pal.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_1x3pal.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_2x2.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_2x4.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_3x3.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_3x6.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_4x2.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_4x4.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_4x4_dock.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_4x6.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_5x5.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_6x4.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_6x4_dock.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_6x6.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_8x8.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity parent="template_rubble">
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_wall.xml</Actor>
|
||||
</VisualActor>
|
||||
</Entity>
|
@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Entity>
|
||||
<Decay>
|
||||
<DelayTime>10.0</DelayTime>
|
||||
<SinkRate>0.2</SinkRate>
|
||||
<SinkAccel>0</SinkAccel>
|
||||
</Decay>
|
||||
<Position>
|
||||
<Altitude>0</Altitude>
|
||||
<Anchor>upright</Anchor>
|
||||
<Floating>false</Floating>
|
||||
<TurnRate>6.0</TurnRate>
|
||||
</Position>
|
||||
<Vision>
|
||||
<Range>0</Range>
|
||||
<RetainInFog>true</RetainInFog>
|
||||
<AlwaysVisible>false</AlwaysVisible>
|
||||
</Vision>
|
||||
<VisualActor>
|
||||
<Actor>structures/fndn_1x1.xml</Actor>
|
||||
<SilhouetteDisplay>false</SilhouetteDisplay>
|
||||
<SilhouetteOccluder>false</SilhouetteOccluder>
|
||||
</VisualActor>
|
||||
</Entity>
|
Loading…
Reference in New Issue
Block a user