From 088f3b54bed9696e66109147d898046b8e9d7891 Mon Sep 17 00:00:00 2001 From: Matei Date: Sat, 12 Jul 2008 07:22:11 +0000 Subject: [PATCH] - Treat units with health.max = 0 (the default when not defined as immortal and unattackable. This applies to Settlements, trees, etc. Should solve the problem of these things being killed by arrows by mistake. - Better "unit X has killed unit Y" message - now includes player number. This was SVN commit r6213. --- .../template_structure_gaia_settlement.xml | 6 +++--- .../mods/official/scripts/entity_functions.js | 20 ++++++++++++------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/binaries/data/mods/official/entities/template_structure_gaia_settlement.xml b/binaries/data/mods/official/entities/template_structure_gaia_settlement.xml index 09303a6164..606a0b5818 100644 --- a/binaries/data/mods/official/entities/template_structure_gaia_settlement.xml +++ b/binaries/data/mods/official/entities/template_structure_gaia_settlement.xml @@ -8,7 +8,7 @@ - Gaia Building + Settlement Settlement Gaia @@ -37,6 +37,6 @@ true - + - \ No newline at end of file + diff --git a/binaries/data/mods/official/scripts/entity_functions.js b/binaries/data/mods/official/scripts/entity_functions.js index c2db6344d5..24c981f9fd 100644 --- a/binaries/data/mods/official/scripts/entity_functions.js +++ b/binaries/data/mods/official/scripts/entity_functions.js @@ -858,7 +858,10 @@ function performRepair( evt ) function damage( dmg, inflictor ) { var arm = this.traits.armour; - if(!arm) return; // corpses have no armour, everything else should + if( !arm ) return; // corpses have no armour, everything else should + + // Use traits.health.max = 0 to signify immortal things like settlements + if( this.traits.health.max == 0 ) return; this.lastCombatTime = getGameTime(); @@ -944,10 +947,13 @@ function damage( dmg, inflictor ) } // Notify player. - if ( inflictor ) - console.write( this.traits.id.generic + " got the point of " + inflictor.traits.id.generic + "'s weapon." ); - else - console.write( this.traits.id.generic + " died in mysterious circumstances." ); + if ( inflictor ) { + console.write( "P" + this.player.id + "'s " + this.traits.id.generic + + " got the point of " + inflictor.traits.id.generic + "'s weapon." ); + } else { + console.write( "P" + this.player.id + "'s " + this.traits.id.generic + + " died in mysterious circumstances." ); + } // Make him cry out in pain. if (this.traits.audio && this.traits.audio.path) @@ -1052,7 +1058,7 @@ function entityEventNotification( evt ) function getAttackAction( target ) { - if (!this.actions.attack) + if ( !this.actions.attack || target.traits.health.max == 0 ) return ACTION_NONE; var attack = this.actions.attack; if ( attack.melee ) @@ -2216,4 +2222,4 @@ function getBuildingLimit( category/*, gameMode*/ ) if(category=="Special") return 1; return 0; -} \ No newline at end of file +}