rem: inflictor.traits.up.curr = 0; 
add: inflictor.traits.xp.curr = 0; 
context: function entityDamage( damage, inflictor ){		// Apply armour and work out how much damage we actually take	crushDamage = parseInt(damage.crush - this.traits.armour.value * this.traits.armour.crush);	if ( crushDamage < 0 ) crushDamage = 0;	pierceDamage = parseInt(damage.pierce - this.traits.armour.value * this.traits.armour.pierce);	if ( pierceDamage < 0 ) pierceDamage = 0;	hackDamage = parseInt(damage.hack - this.traits.armour.value * this.traits.armour.hack);	if ( hackDamage < 0 ) hackDamage = 0;	totalDamage = parseInt(damage.typeless + crushDamage + pierceDamage + hackDamage);	// Minimum of 1 damage	if( totalDamage < 1 ) totalDamage = 1;	this.traits.health.curr -= totalDamage;	if( this.traits.health.curr <= 0 )	{		// If the inflictor gains promotions, and he's capable of earning more ranks,		if (inflictor.traits.up && inflictor.traits.up.curr && inflictor.traits.up.req				&& inflictor.traits.up.newentity && inflictor.traits.up.newentity != ""				&& this.traits.loot && this.traits.loot.up)		{			// Give him the fallen's upgrade points (if he has any).			if (this.traits.loot.up)				inflictor.traits.up.curr = parseInt(inflictor.traits.up.curr) + parseInt(this.traits.loot.up);			// Notify player.			if (this.traits.id.specific)				console.write(this.traits.id.specific + " has earned " + this.traits.loot.up + " upgrade points!");			else				console.write("One of your units has earned " + this.traits.loot.up + " upgrade points!");			// If he now has maximum upgrade points for his rank,			if (inflictor.traits.up.curr >= inflictor.traits.up.req)			{				// Notify the player.				if (this.traits.id.specific)					console.write(this.traits.id.specific + " has gained a promotion!");				else					console.write("One of your units has gained a promotion!");								// Reset his upgrade points.				inflictor.traits.up.curr = 0; 				// Upgrade his portrait to the next level.				inflictor.traits.id.icon_cell++; 				// Transmogrify him into his next rank.				inflictor.template = getEntityTemplate(inflictor.traits.up.newentity);			}		}		// If the fallen is worth any loot,		if (this.traits.loot)		{			// Cycle through all loot on this entry.			pool = this.traits.loot;			for( loot in pool )			{				switch( loot.toString().toUpperCase() )				{					case "up":					break;					default:						// Give the inflictor his resources.						getGUIGlobal().giveResources( loot.toString(), parseInt(pool[loot]) );						// Notify player.						console.write ("Spoils of war! " + pool[loot] + " " + loot.toString() + "!");					break;				}			}		}		// 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." );		// Make him cry out in pain.		if (this.traits.audio && this.traits.audio.path)		{			curr_pain = getGUIGlobal().newRandomSound("voice", "pain", this.traits.audio.path);			if (curr_pain) curr_pain.play();		}		else		{			console.write ("Sorry, no death sound for this unit; you'll just have to imagine it ...");		}		// We've taken what we need. Kill the swine.		console.write("Kill!!");		this.kill();	}	else if( inflictor && this.actions.attack )	{		// If we're not already doing something else, take a measured response - hit 'em back.		// You know, I think this is quite possibly the first AI code the AI divlead has written		// for 0 A.D....		if( this.isIdle() )			this.order( ORDER_GENERIC, inflictor, ACTION_ATTACK );	}}
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