Index: binaries/data/mods/public/simulation/components/Health.js =================================================================== --- binaries/data/mods/public/simulation/components/Health.js +++ binaries/data/mods/public/simulation/components/Health.js @@ -47,6 +47,11 @@ "" + "" + "" + + "" + + "" + + "" + + "" + + "" + "" + "" + ""; @@ -283,9 +288,6 @@ cmpDeathDamage.CauseDeathDamage(); PlaySound("death", this.entity); - if (this.template.SpawnEntityOnDeath) - this.CreateDeathSpawnedEntity(); - switch (this.template.DeathType) { case "corpse": @@ -343,6 +345,17 @@ if (!cmpPosition || !cmpPosition.IsInWorld()) return; + if (this.template.SpawnEntityOnDeath) + this.CreateDeathSpawnedEntity(this.template.SpawnEntityOnDeath, true); + if (this.template.TransformToEntityOnDeath) + { + let spawnedEntity = this.CreateDeathSpawnedEntity(this.template.TransformToEntityOnDeath, false); + Engine.PostMessage(this.entity, MT_EntityRenamed, { + "entity": this.entity, + "newentity": spawnedEntity + }); + } + // Either creates a static local version of the current entity, or a // persistent corpse retaining the ResourceSupply element of the parent. let templateName = Engine.QueryInterface(SYSTEM_ENTITY, IID_TemplateManager).GetCurrentTemplateName(this.entity); @@ -350,7 +363,7 @@ let entCorpse; let cmpResourceSupply = Engine.QueryInterface(this.entity, IID_ResourceSupply); let resource = cmpResourceSupply && cmpResourceSupply.GetKillBeforeGather(); - if (resource) + if (resource && !this.template.TransformToEntityOnDeath) entCorpse = Engine.AddEntity("resource|" + templateName); else entCorpse = Engine.AddLocalEntity("corpse|" + templateName); @@ -401,18 +414,17 @@ }); }; -Health.prototype.CreateDeathSpawnedEntity = function() +Health.prototype.CreateDeathSpawnedEntity = function(EntityToSpawn, local = true) { - // 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 - let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); - if (!cmpPosition.IsInWorld()) - return INVALID_ENTITY; - // Create SpawnEntityOnDeath entity - let spawnedEntity = Engine.AddLocalEntity(this.template.SpawnEntityOnDeath); + let spawnedEntity; + if (local) + spawnedEntity = Engine.AddLocalEntity(EntityToSpawn); + else + spawnedEntity = Engine.AddEntity(EntityToSpawn); // Move to same position + let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); let cmpSpawnedPosition = Engine.QueryInterface(spawnedEntity, IID_Position); let pos = cmpPosition.GetPosition(); cmpSpawnedPosition.JumpTo(pos.x, pos.z); Index: binaries/data/mods/public/simulation/templates/gaia/tree/wood_chopped.xml =================================================================== --- binaries/data/mods/public/simulation/templates/gaia/tree/wood_chopped.xml +++ binaries/data/mods/public/simulation/templates/gaia/tree/wood_chopped.xml @@ -0,0 +1,12 @@ + + + + Wood + + + 200 + + + props/flora/water_log.xml + + Index: binaries/data/mods/public/simulation/templates/template_gaia_tree.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_gaia_tree.xml +++ binaries/data/mods/public/simulation/templates/template_gaia_tree.xml @@ -1,5 +1,20 @@ + + false + true + 0.0 + 3.0 + 9.8 + + + corpse + 10 + 0 + 0 + false + gaia/tree/wood_chopped + 15.0 @@ -18,8 +33,17 @@ true + + + + 1 + 1 + 1 + + + - false + true 1 wood.tree 8 Index: binaries/data/mods/public/simulation/templates/template_gaia_tree_chopped.xml =================================================================== --- binaries/data/mods/public/simulation/templates/template_gaia_tree_chopped.xml +++ binaries/data/mods/public/simulation/templates/template_gaia_tree_chopped.xml @@ -0,0 +1,51 @@ + + + + + 15.0 + + + Tree + Chop trees for wood. + gaia/flora_tree_generic.png + + + wood + + + + + + true + + + false + 1 + wood.tree + 8 + + + + + + 128x128/ellipse.png + 128x128/ellipse_mask.png + + + + + + + + + + 3.0 + 0.5 + 10.0 + + + + + + +