From 659049eb1c2fee3eb67ea2fbfd488012237ce551 Mon Sep 17 00:00:00 2001 From: leper Date: Thu, 7 Jun 2012 21:56:29 +0000 Subject: [PATCH] Auto-gather all types of treasures. Fixes #1422. Patch by Deiz. This was SVN commit r11948. --- binaries/data/mods/public/gui/session/input.js | 8 ++++---- .../mods/public/simulation/components/UnitAI.js | 17 ++++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index 208c7713e8..ff39b74ecf 100644 --- a/binaries/data/mods/public/gui/session/input.js +++ b/binaries/data/mods/public/gui/session/input.js @@ -229,14 +229,14 @@ function getActionInfo(action, target) } else if (targetState.resourceSupply) { - var resourceType = targetState.resourceSupply.type.specific; - if (targetState.resourceSupply.type.generic === "treasure") + var resourceType = targetState.resourceSupply.type; + if (resourceType.generic == "treasure") { - cursor = "action-gather-" + targetState.resourceSupply.type.generic; + cursor = "action-gather-" + resourceType.generic; } else { - cursor = "action-gather-" + targetState.resourceSupply.type.specific; + cursor = "action-gather-" + resourceType.specific; } data.command = "gather"; data.resourceType = resourceType; diff --git a/binaries/data/mods/public/simulation/components/UnitAI.js b/binaries/data/mods/public/simulation/components/UnitAI.js index 78182aadf2..bba5f332cd 100644 --- a/binaries/data/mods/public/simulation/components/UnitAI.js +++ b/binaries/data/mods/public/simulation/components/UnitAI.js @@ -511,7 +511,7 @@ var UnitFsmSpec = { "Order.GatherNearPosition": function(msg) { // TODO: see notes in Order.Attack var cmpFormation = Engine.QueryInterface(this.entity, IID_Formation); - cmpFormation.CallMemberFunction("GatherNearPosition", [msg.data.x, msg.data.z, msg.data.type, false]); + cmpFormation.CallMemberFunction("GatherNearPosition", [msg.data.x, msg.data.z, msg.data.type, msg.data.template, false]); cmpFormation.Disband(); }, @@ -946,8 +946,9 @@ var UnitFsmSpec = { var nearby = this.FindNearbyResource(function (ent, type, template) { return ( ent != oldTarget - && type.specific == oldType.specific - && (type.specific != "meat" || oldTemplate == template) + && ((type.generic == "treasure" && oldType.generic == "treasure") + || (type.specific == oldType.specific + && (type.specific != "meat" || oldTemplate == template))) ); }); if (nearby) @@ -981,8 +982,9 @@ var UnitFsmSpec = { // Also don't switch to a different type of huntable animal var nearby = this.FindNearbyResource(function (ent, type, template) { return ( - type.specific == resourceType - && (type.specific != "meat" || resourceTemplate == template) + (type.generic == "treasure" && resourceType.generic == "treasure") + || (type.specific == resourceType.specific + && (type.specific != "meat" || resourceTemplate == template)) ); }); @@ -1130,8 +1132,9 @@ var UnitFsmSpec = { // Also don't switch to a different type of huntable animal var nearby = this.FindNearbyResource(function (ent, type, template) { return ( - type.specific == resourceType.specific - && (type.specific != "meat" || resourceTemplate == template) + (type.generic == "treasure" && resourceType.generic == "treasure") + || (type.specific == resourceType.specific + && (type.specific != "meat" || resourceTemplate == template)) ); }); if (nearby)