From 590086571bd7dbb09d7e0bdd397e4da8796537ae Mon Sep 17 00:00:00 2001 From: Matei Date: Sun, 9 Jul 2006 23:13:20 +0000 Subject: [PATCH] # More work on territories - Settlements are now claimable. This was SVN commit r4074. --- .../template_structure_civic_civil_centre.xml | 4 +- .../template_structure_gaia_settlement.xml | 4 +- .../mods/official/scripts/entity_functions.js | 38 +++++++++++++++++++ 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/binaries/data/mods/official/entities/template_structure_civic_civil_centre.xml b/binaries/data/mods/official/entities/template_structure_civic_civil_centre.xml index d86173957d..3ae385ba6a 100644 --- a/binaries/data/mods/official/entities/template_structure_civic_civil_centre.xml +++ b/binaries/data/mods/official/entities/template_structure_civic_civil_centre.xml @@ -13,13 +13,15 @@ 47 - Housing, Village + Housing, Village, CivilCentre The heart of the player's empire. Trains economic units, and can only be built on settlements. foundation_5x5 + + Settlement 24.0 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 bfc3f3bd45..6a008e9bbd 100644 --- a/binaries/data/mods/official/entities/template_structure_gaia_settlement.xml +++ b/binaries/data/mods/official/entities/template_structure_gaia_settlement.xml @@ -1,7 +1,7 @@ @@ -24,8 +24,6 @@ true - foundation_5x5 - 24.0 24.0 diff --git a/binaries/data/mods/official/scripts/entity_functions.js b/binaries/data/mods/official/scripts/entity_functions.js index 0ecaf5066d..fc6386f3a8 100644 --- a/binaries/data/mods/official/scripts/entity_functions.js +++ b/binaries/data/mods/official/scripts/entity_functions.js @@ -417,6 +417,11 @@ function attachAuras() this.addAura ( "trample", a.radius, a.speed, new TrampleAura( this ) ); } } + + if( this.hasClass("Settlement") ) + { + this.addAura ( "settlement", 0.1, 0, new SettlementAura( this ) ); + } } // ==================================================================== @@ -1848,6 +1853,39 @@ function TrampleAura( source ) // ==================================================================== +function SettlementAura( source ) +{ + // Defines the effects of the Settlement Aura. Changes ownership of entity when a civil center is on it. + + this.source = source; + + this.affects = function( e ) + { + return ( e.hasClass("CivilCentre") ); + } + + this.onEnter = function( e ) + { + if( this.affects( e ) ) + { + // If a new Civ Centre has entered our radius, it must mean it's on us; switch player and become invisible + source.player = e.player; + source.visible = false; + } + }; + + this.onExit = function( e ) + { + if( this.affects( e ) ) + { + // If a Civ Centre has entered our radius, it must mean the one on us died; become visible again + source.visible = true; + } + } +} + +// ==================================================================== + function GotoInRange( x, y, run ) { if ( !this.actions || !this.actions.move )