# Fixed some script bugs.

- Loot script was not properly giving loot.
- Some errors were occuring in the GUI every frame when XML files are
lacking certain traits.
- Fixed time on celt female citizen forage gather animation.

This was SVN commit r4832.
This commit is contained in:
Matei
2007-02-02 14:53:16 +00:00
parent 6ae5576d3f
commit 892fb6ce9e
4 changed files with 66 additions and 50 deletions
@@ -12,7 +12,7 @@
<!-- Citzen Soldier Specific -->
<animation file="infantry/general/chop.psa" name="gather_wood" speed="100"/>
<animation file="biped/hoe.psa" name="gather_grain" speed="150"/>
<animation file="infantry/general/forage.psa" name="gather_fruit" speed="35"/>
<animation file="infantry/general/forage.psa" name="gather_fruit" speed="100"/>
<animation file="infantry/general/mine.psa" name="gather_stone" speed="150"/>
<animation file="infantry/general/dude/dudebuild.psa" name="Build" speed="150"/>
<!-- Shared -->
@@ -345,14 +345,24 @@ function updateTab (tab, type, cellSheet, attribute, attribute2, arrayCells)
{
case "pick":
// Set tooltip.
if (arrayCells == true) // Check a .sheet property for each item in the list to know its cellsheet.
if (arrayCells == true) { // Check a .sheet property for each item in the list to know its cellsheet.
listObject.tooltip = cellGroup[listArray[createLoop].sheet][listArray[createLoop]].name;
else // Assume each item uses the same cell sheet as the tab.
listObject.tooltip = cellGroup[cellSheet][listArray[createLoop]].name;
}
else { // Assume each item uses the same cell sheet as the tab.
if(cellGroup[cellSheet][listArray[createLoop]]) {
listObject.tooltip = cellGroup[cellSheet][listArray[createLoop]].name;
}
else {
listObject.tooltip = "(no name)";
}
}
// Set portrait.
setPortrait (listObject.name,
"IconSheet", cellSheet + "Button", cellGroup[cellSheet][listArray[createLoop]].id);
if(cellGroup[cellSheet][listArray[createLoop]]) {
setPortrait (listObject.name,
"IconSheet", cellSheet + "Button", cellGroup[cellSheet][listArray[createLoop]].id);
}
// Store properties which we will need when doing the press event as a comma-delimited string.
// * 0 Name of variable that contains the ".curr" value.
// * 1 String name of current button's content.
@@ -110,6 +110,7 @@ function refreshResource (resourceName, resourceIndex)
// The Population counter also lists the amount of available housing.
if (resourceName == "Population")
caption += "/" + localPlayer.resources["housing"];
resourceObject.caption = caption;
// Update counter tooltip.
@@ -908,57 +908,62 @@ function damage( dmg, inflictor )
if (this.traits.loot && inflictor.actions && inflictor.actions.loot)
{
// Cycle through all loot on this entry.
for( loot in this.traits.loot )
const LOOTS = ["food", "wood", "metal", "stone", "xp"]
for( i in LOOTS )
{
switch( loot.toString().toUpperCase() )
{
case "XP":
// If the inflictor gains promotions, and he's capable of earning more ranks,
if (inflictor.traits.promotion && inflictor.traits.promotion.curr && inflictor.traits.promotion.req
&& inflictor.traits.promotion.entity && inflictor.traits.promotion.entity != ""
&& this.traits.loot && this.traits.loot.xp && inflictor.actions.loot.xp)
{
// Give him the fallen's upgrade points (if he has any).
if (this.traits.loot.xp)
inflictor.traits.promotion.curr = parseInt(inflictor.traits.promotion.curr) + parseInt(this.traits.loot.xp);
// Notify player.
/*if (inflictor.traits.id.specific)
console.write(inflictor.traits.id.specific + " has earned " + this.traits.loot.xp + " upgrade points!");
else
console.write("One of your units has earned " + this.traits.loot.xp + " upgrade points!");
*/
// If he now has maximum upgrade points for his rank,
if (inflictor.traits.promotion.curr >= inflictor.traits.promotion.req)
var loot = LOOTS[i];
if(this.traits.loot[loot]) {
switch( loot )
{
case "xp":
// If the inflictor gains promotions, and he's capable of earning more ranks,
if (inflictor.traits.promotion && inflictor.traits.promotion.curr
&& inflictor.traits.promotion.req
&& inflictor.traits.promotion.entity
&& inflictor.traits.promotion.entity != ""
&& this.traits.loot && this.traits.loot.xp
&& inflictor.actions.loot.xp)
{
// Notify the player.
// Give him the fallen's upgrade points (if he has any).
if (this.traits.loot.xp)
inflictor.traits.promotion.curr = parseInt(inflictor.traits.promotion.curr) + parseInt(this.traits.loot.xp);
// Notify player.
/*if (inflictor.traits.id.specific)
console.write(inflictor.traits.id.specific + " has gained a promotion!");
console.write(inflictor.traits.id.specific + " has earned " + this.traits.loot.xp + " upgrade points!");
else
console.write("One of your units has gained a promotion!");*/
// Reset his upgrade points.
inflictor.traits.promotion.curr = 0;
console.write("One of your units has earned " + this.traits.loot.xp + " upgrade points!");
*/
// Upgrade his portrait to the next level.
inflictor.traits.id.icon_cell++;
// If he now has maximum upgrade points for his rank,
if (inflictor.traits.promotion.curr >= inflictor.traits.promotion.req)
{
// Notify the player.
/*if (inflictor.traits.id.specific)
console.write(inflictor.traits.id.specific + " has gained a promotion!");
else
console.write("One of your units has gained a promotion!");*/
// Reset his upgrade points.
inflictor.traits.promotion.curr = 0;
// Transmogrify him into his next rank.
inflictor.template = getEntityTemplate( inflictor.traits.promotion.entity, inflictor.player );
inflictor.setupRank();
// Upgrade his portrait to the next level.
inflictor.traits.id.icon_cell++;
// Transmogrify him into his next rank.
inflictor.template = getEntityTemplate( inflictor.traits.promotion.entity, inflictor.player );
inflictor.setupRank();
}
}
}
break;
default:
if ( inflictor.actions.loot.resources )
{
// Notify player.
//console.write ("Spoils of war! " + this.traits.loot[loot] + " " + loot.toString() + "!");
// Give the inflictor his resources.
this.player.resources[loot.toString()] -= parseInt(this.traits.loot[loot]);
}
break;
break;
default:
if ( inflictor.actions.loot.resources )
{
// Give the inflictor his resources.
this.player.resources[loot.toString()] -= parseInt(this.traits.loot[loot.toString()]);
}
break;
}
}
}
}