rem: this.traits.promotion.rank="2" 
add: this.traits.promotion.rank = "2" 
context: function entityInit(){	// Initialise an entity when it is first spawned (generate starting hitpoints, etc).	this.addCreateQueue = entityAddCreateQueue;		// Generate civ code (1st four characters of civ name, in lower case eg "Carthaginians" => "cart").	if (this.traits.id && this.traits.id.civ)	{		this.traits.id.civ_code = this.traits.id.civ.toString().substring (0, 4)		this.traits.id.civ_code = this.traits.id.civ_code.toString().toLowerCase()		// Exception to make the Romans into rome.		if (this.traits.id.civ_code == "roma") this.traits.id.civ_code = "rome"		// Exception to make the Hellenes into hele.		if (this.traits.id.civ_code == "hell") this.traits.id.civ_code = "hele"	}	// If entity can contain garrisoned units, empty it.	if (this.traits.garrison && this.traits.garrison.max)		this.traits.garrison.curr = 0	// If entity has health, set current to same.	if (this.traits.health && this.traits.health.max)		this.traits.health.curr = this.traits.health.max	if (this.traits.supply)	{		// If entity has supply, set current to same.		if (this.traits.supply.max)			this.traits.supply.curr = this.traits.supply.max		// If entity has type of supply and no subtype, set subtype to same		// (so we don't have to say type="wood", subtype="wood"		if (this.traits.supply.type && !this.traits.supply.subtype)			this.traits.supply.subtype = this.traits.supply.type					// The "dropsitecount" array holds the number of units with gather aura in range of the object;		// this is important so that if you have two mills near something and one of them is destroyed,		// you can still gather from the thing. Initialize it to 0 (ungatherable) for every player unless		// the entity is forageable (e.g. for huntable animals).		this.traits.supply.dropsitecount = new Array();		initialCount = this.traits.supply.forageable ? 1 : 0;		for( i=0; i<=8; i++ )		{			this.traits.supply.dropsitecount[i] = initialCount;		}	}	if (!this.traits.promotion)		this.traits.promotion = new Object();			// If entity becomes another entity after it gains enough experience points, set up secondary attributes.	if (this.traits.promotion.req)	{		// Get the name of the entity. (I wish there was a safer way of doing it, but currently unravelling the exported template string.)		entityName = this.template.toString()		entityName = entityName.substring (24, entityName.length - 1)			// Determine whether current is basic, advanced or elite, and set rank to suit.		switch (entityName.substring (entityName.length-2, entityName.length))		{			case "_b":				// Basic. Upgrades to Advanced.				this.traits.promotion.rank="1"				nextSuffix = "_a"			break;			case "_a":				// Advanced. Upgrades to Elite.				this.traits.promotion.rank="2"				nextSuffix = "_e"			break;			case "_e":				// Elite. Maximum rank.				this.traits.promotion.rank="3"				nextSuffix = ""			break;			default:				// Does not gain promotions.				this.traits.promotion.rank="0"				nextSuffix = ""			break;		}			// The entity it should become (unless specified otherwise) is the base entity plus promotion suffix.		if (!this.traits.promotion.newentity && nextSuffix != "" && this.traits.promotion.rank != "0")			this.traits.promotion.newentity = entityName.substring (1, entityName.length-2) + nextSuffix		// If entity is an additional rank and the correct actor has not been specified		// (it's just inherited the Basic), point it to the correct suffix. (Saves us specifying it each time.)		actorStr = this.actor.toString();		if (this.traits.promotion.rank > "1"			&& actorStr.substring (actorStr.length-5, actorStr.length) != nextSuffix + ".xml")			this.actor = actorStr.substring (1,actorStr.length-5) + nextSuffix + ".xml";	}	else	{		this.traits.promotion.rank="0"	}		// Register our actions with the generic order system	if( this.actions )	{		if( this.actions.attack )		{			a = this.actions.attack;			minRange = ( a.minRange ? a.minRange : 0.0 );			this.setActionParams( ACTION_ATTACK, minRange, a.range, a.speed, "melee" );		}		if( this.actions.gather )		{			a = this.actions.gather;			this.setActionParams( ACTION_GATHER, 0.0, a.range, a.speed, "gather" );		}		if( this.actions.heal )		{			a = this.actions.heal;			this.setActionParams( ACTION_HEAL, 0.0, a.range, a.speed, "heal" );		}	}		// Attach functions to ourselves		this.processAttack = entityEventAttack;	this.processAttackRanged = entityEventAttackRanged;	this.processGather = entityEventGather;	this.processHeal = entityEventHeal;		this.damage = entityDamage;	// Attach Auras if the entity is entitled to them.	if( this.traits.auras )	{		if( this.traits.auras.courage )		{			a = this.traits.auras.courage;			this.addAura ( "courage", a.radius, new DamageModifyAura( this, true, a.bonus ) );		}		if( this.traits.auras.fear ) 		{			a = this.traits.auras.fear;			this.addAura ( "fear", a.radius, new DamageModifyAura( this, false, -a.bonus ) );		}		if( this.traits.auras.infidelity ) 		{			a = this.traits.auras.infidelity;			this.addAura ( "infidelity", a.radius, new InfidelityAura( this, a.time ) );		}		if( this.traits.auras.dropsite ) 		{			a = this.traits.auras.dropsite;			this.addAura ( "dropsite", a.radius, new DropsiteAura( this, a.types ) );		}	}				if ( !this.traits.id )	{		this.traits.id = new Object();	}/*		// Generate entity's personal name (if it needs one).	if (this.traits.id.personal)	{		// todo		// Look in the appropriate array for a random string.		switch (this.traits.id.classes[])		{			case "Male":				this.traits.id.personal.table1 = "Male"			break;			case "Female":				this.traits.id.personal.table1 = "Female"			break;			default:				this.traits.id.personal.table1 = "Gen"			break;			}						this.traits.id.personal.name = getRandom (this.traits.id.civ_code + this.traits.id.personal.table1 + "1")		this.traits.id.personal.name = this.traits.id.personal.name + " " + getRandom (this.traits.id.civ_code + this.traits.id.personal.table1 + "2")	}	else		this.traits.id.personal.name = "";*/	// Log creation of entity to console.	//if (this.traits.id.personal && this.traits.id.personal.name)	//	console.write ("A new " + this.traits.id.specific + " (" + this.traits.id.generic + ") called " + this.traits.id.personal.name + " has entered your dungeon.")	//else		//	console.write ("A new " + this.traits.id.specific + " (" + this.traits.id.generic + ") has entered your dungeon.")}
meta: 1070	/local1/tlutelli/issta_data/temp/all_js/javascript/2006_temp/2006/1070/1200f2c98ce97fffe22a632011864da3c813ef3f/template_entity_script.js/clean/binaries/data/mods/official/entities/template_entity_script.js