From 892fb6ce9ea3b8664d301e5d80bb402f0a55be9a Mon Sep 17 00:00:00 2001 From: Matei Date: Fri, 2 Feb 2007 14:53:16 +0000 Subject: [PATCH] # 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. --- .../art/actors/units/celts/female_citizen.xml | 2 +- .../functions_page_session_status_commands.js | 20 +++- .../official/gui/test/functions_sim_player.js | 1 + .../mods/official/scripts/entity_functions.js | 93 ++++++++++--------- 4 files changed, 66 insertions(+), 50 deletions(-) diff --git a/binaries/data/mods/official/art/actors/units/celts/female_citizen.xml b/binaries/data/mods/official/art/actors/units/celts/female_citizen.xml index e68722a670..4ee72af9fb 100644 --- a/binaries/data/mods/official/art/actors/units/celts/female_citizen.xml +++ b/binaries/data/mods/official/art/actors/units/celts/female_citizen.xml @@ -12,7 +12,7 @@ - + diff --git a/binaries/data/mods/official/gui/test/functions_page_session_status_commands.js b/binaries/data/mods/official/gui/test/functions_page_session_status_commands.js index 90e144999e..f35101b39b 100644 --- a/binaries/data/mods/official/gui/test/functions_page_session_status_commands.js +++ b/binaries/data/mods/official/gui/test/functions_page_session_status_commands.js @@ -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. diff --git a/binaries/data/mods/official/gui/test/functions_sim_player.js b/binaries/data/mods/official/gui/test/functions_sim_player.js index 0c10265642..d17253a55d 100644 --- a/binaries/data/mods/official/gui/test/functions_sim_player.js +++ b/binaries/data/mods/official/gui/test/functions_sim_player.js @@ -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. diff --git a/binaries/data/mods/official/scripts/entity_functions.js b/binaries/data/mods/official/scripts/entity_functions.js index e66f32a08b..b65cf94c3d 100644 --- a/binaries/data/mods/official/scripts/entity_functions.js +++ b/binaries/data/mods/official/scripts/entity_functions.js @@ -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; + } } } }