Jump to content

Help whit adding new resource


Trinketos
 Share

Recommended Posts

I have this error

https://imgur.com/EvPmyPW

here is the xml file of the resource template

<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_gaia_geo_obsidiana">
  <VisualActor>
    <Actor>geology/obsidiana_small_a.xml</Actor>
  </VisualActor>
</Entity>

and the template file

<?xml version="1.0" encoding="utf-8"?>
<Entity parent="template_gaia_geo">
  <Identity>
    <GenericName>Volcanic Rock</GenericName>
    <SpecificName>Obsidiana Mine</SpecificName>
    <Tooltip>Mine these to provide Stone building material.</Tooltip>
    <Icon>gaia/geology_stone_1.png</Icon>
  </Identity>
  <Minimap>
    <Type>obsidiana</Type>
    <Color r="170" g="170" b="170"/>
  </Minimap>
  <ResourceSupply>
    <KillBeforeGather>false</KillBeforeGather>
    <Amount>1000</Amount>
    <Type>obsidiana.glass</Type>
    <MaxGatherers>12</MaxGatherers>
  </ResourceSupply>
  <Sound>
    <SoundGroups>
      <select>interface/select/resource/sel_stone.xml</select>
    </SoundGroups>
  </Sound>
</Entity>

and the resource json file

{
    "code": "obsidiana",
    "name": "Obsidiana",
    "description": "Mine from volcanic stones.",
    "order": 5,
    "subtypes": {
        "glass":"Glass"
    },
    "truePrice": 100,
    "aiAnalysisInfluenceGroup": "sparse"
}

 

 

  • Like 1
Link to comment
Share on other sites

Maybe I am wrong but actually as I remember it does not matter what type of resource it is ( except you have to choose from current ones as display type for minimap) , I mean everything  what makes difference for current minimap is color. So setting minimap acording stone resource  but changing color should be everything you can now do. 

Edited by Angen
Link to comment
Share on other sites

1 hour ago, s0600204 said:

(Clearly we missed something whilst de-hard-coding resource types...)

#4404.

I was worried about these though:

Spoiler



simulation/ai/common-api/entity.js:	// will return either "food", "wood", "stone", "metal" and not treasure.
simulation/ai/petra/queueplanBuilding.js:		let type = this.metadata.type ? this.metadata.type : "wood";
simulation/ai/petra/queueplanBuilding.js:				let value = placement.map[j] - gameState.sharedScript.resourceMaps.wood.map[j]/3;
simulation/ai/petra/queueplanBuilding.js: * resources have a weight (1 if dist=0 and 0 if dist=size) doubled for wood
simulation/ai/petra/queueplanBuilding.js:	let w = resourceMaps.wood.width;
simulation/ai/petra/queueplanBuilding.js:	let cellSize = resourceMaps.wood.cellSize;
simulation/ai/petra/queueplanBuilding.js:		let weigh0 = k == "wood" ? 2 : 1;
simulation/ai/petra/queueManager.js:// If for some reason the AI stops getting new food, and this queue lacks, say, wood, no other queues will
simulation/ai/petra/config.js:			"wood": 10,
simulation/ai/petra/config.js:			"wood": 200,
simulation/ai/petra/researchManager.js:			else if (template.modifications[i].value === "ResourceGatherer/Rates/wood.tree")
simulation/ai/petra/startingStrategy.js:		gameState.ai.queues.civilCentre.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_civil_centre", { "base": -1, "resource": "wood", "proximity": startingPoint[imax].pos }));
simulation/ai/petra/startingStrategy.js: *   - count the available wood resource, and allow rushes only if enough (we should otherwise favor expansion)
simulation/ai/petra/startingStrategy.js:	// - count the available wood resource, and react accordingly
simulation/ai/petra/startingStrategy.js:	// - count the available wood resource, and allow rushes only if enough (we should otherwise favor expansion)
simulation/ai/petra/startingStrategy.js:	let startingWood = gameState.getResources().wood;
simulation/ai/petra/startingStrategy.js:			for (let supply of base.dropsiteSupplies.wood[proxim])
simulation/ai/petra/startingStrategy.js:				startingWood += supply.ent.resourceSupplyAmount();
simulation/ai/petra/startingStrategy.js:		API3.warn("startingWood: " + startingWood + " (cut at 8500 for no rush and 6000 for saveResources)");
simulation/ai/petra/startingStrategy.js:	if (startingWood < 6000)
simulation/ai/petra/startingStrategy.js:		if (startingWood < 2000 && this.needFarm)
simulation/ai/petra/startingStrategy.js:	if (startingWood > 8500 && this.canBuildUnits)
simulation/ai/petra/startingStrategy.js:		let allowed = Math.ceil((startingWood - 8500) / 3000);
simulation/ai/petra/startingStrategy.js:	// immediatly build a wood dropsite if possible.
simulation/ai/petra/startingStrategy.js:		let newDP = this.baseManagers[1].findBestDropsiteLocation(gameState, "wood");
simulation/ai/petra/baseManager.js:		if (total > 150 || total > 60 && type != "wood")
simulation/ai/petra/baseManager.js:		else if (target.hasClass("House") || target.hasClass("DropsiteWood"))
simulation/ai/petra/headquarters.js:				// checking against wood, could be anything else really.
simulation/ai/petra/headquarters.js:				if (a[1].resourceGatherRates() && a[1].resourceGatherRates()["wood.tree"])
simulation/ai/petra/headquarters.js:				if (b[1].resourceGatherRates() && b[1].resourceGatherRates()["wood.tree"])
simulation/ai/petra/headquarters.js:		return this.findEconomicCCLocation(gameState, template, "wood", undefined, true);
wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==


 

Also we can probably add new files rather than replace existing files for added resource icons by supporting directory includes in the XML page definition.

Link to comment
Share on other sites

2 hours ago, elexis said:

#4404.

I was worried about these though:

  Hide contents

 



simulation/ai/common-api/entity.js:	// will return either "food", "wood", "stone", "metal" and not treasure.
simulation/ai/petra/queueplanBuilding.js:		let type = this.metadata.type ? this.metadata.type : "wood";
simulation/ai/petra/queueplanBuilding.js:				let value = placement.map[j] - gameState.sharedScript.resourceMaps.wood.map[j]/3;
simulation/ai/petra/queueplanBuilding.js: * resources have a weight (1 if dist=0 and 0 if dist=size) doubled for wood
simulation/ai/petra/queueplanBuilding.js:	let w = resourceMaps.wood.width;
simulation/ai/petra/queueplanBuilding.js:	let cellSize = resourceMaps.wood.cellSize;
simulation/ai/petra/queueplanBuilding.js:		let weigh0 = k == "wood" ? 2 : 1;
simulation/ai/petra/queueManager.js:// If for some reason the AI stops getting new food, and this queue lacks, say, wood, no other queues will
simulation/ai/petra/config.js:			"wood": 10,
simulation/ai/petra/config.js:			"wood": 200,
simulation/ai/petra/researchManager.js:			else if (template.modifications[i].value === "ResourceGatherer/Rates/wood.tree")
simulation/ai/petra/startingStrategy.js:		gameState.ai.queues.civilCentre.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_civil_centre", { "base": -1, "resource": "wood", "proximity": startingPoint[imax].pos }));
simulation/ai/petra/startingStrategy.js: *   - count the available wood resource, and allow rushes only if enough (we should otherwise favor expansion)
simulation/ai/petra/startingStrategy.js:	// - count the available wood resource, and react accordingly
simulation/ai/petra/startingStrategy.js:	// - count the available wood resource, and allow rushes only if enough (we should otherwise favor expansion)
simulation/ai/petra/startingStrategy.js:	let startingWood = gameState.getResources().wood;
simulation/ai/petra/startingStrategy.js:			for (let supply of base.dropsiteSupplies.wood[proxim])
simulation/ai/petra/startingStrategy.js:				startingWood += supply.ent.resourceSupplyAmount();
simulation/ai/petra/startingStrategy.js:		API3.warn("startingWood: " + startingWood + " (cut at 8500 for no rush and 6000 for saveResources)");
simulation/ai/petra/startingStrategy.js:	if (startingWood < 6000)
simulation/ai/petra/startingStrategy.js:		if (startingWood < 2000 && this.needFarm)
simulation/ai/petra/startingStrategy.js:	if (startingWood > 8500 && this.canBuildUnits)
simulation/ai/petra/startingStrategy.js:		let allowed = Math.ceil((startingWood - 8500) / 3000);
simulation/ai/petra/startingStrategy.js:	// immediatly build a wood dropsite if possible.
simulation/ai/petra/startingStrategy.js:		let newDP = this.baseManagers[1].findBestDropsiteLocation(gameState, "wood");
simulation/ai/petra/baseManager.js:		if (total > 150 || total > 60 && type != "wood")
simulation/ai/petra/baseManager.js:		else if (target.hasClass("House") || target.hasClass("DropsiteWood"))
simulation/ai/petra/headquarters.js:				// checking against wood, could be anything else really.
simulation/ai/petra/headquarters.js:				if (a[1].resourceGatherRates() && a[1].resourceGatherRates()["wood.tree"])
simulation/ai/petra/headquarters.js:				if (b[1].resourceGatherRates() && b[1].resourceGatherRates()["wood.tree"])
simulation/ai/petra/headquarters.js:		return this.findEconomicCCLocation(gameState, template, "wood", undefined, true);
wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==

 

 

 

Also we can probably add new files rather than replace existing files for added resource icons by supporting directory includes in the XML page definition.

I don't understand, the minimap colors are hardcoded?

Link to comment
Share on other sites

The colors of minimap icon types are in the templates / XML files, the possible minimap icon types are hardcoded in CCmpMiniMap.cpp. A subset of them are the 4 default resources.

Quote

            "<element name='Type'>"
                "<choice>"
                    "<value>food</value>"
                    "<value>wood</value>"
                    "<value>stone</value>"
                    "<value>metal</value>"
                    "<value>structure</value>"
                    "<value>unit</value>"
                    "<value>support</value>"
                    "<value>hero</value>"
                "</choice>"
            "</element>"

I think you can use an arbitrary minimap type for your new resource as the color can be set independently in the template.

If I read the current component correctly, the Type property is not even used. Probably intended to allow the player to show only minimap icons of a specific type.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...