Jump to content

Allow Modifiers to affect tokens


Recommended Posts

https://trac.wildfiregames.com/changeset/23843#file0

https://code.wildfiregames.com/D270

So, what syntax must I use in the technology file? Is there an example in-game? A good use case for EA would be the Seleucid reform techs. It unlocks either Silvershield Pikeman or Romanized Heavy Swordsman, so what the tech could do is remove the other. 

Link to comment
Share on other sites

modifications": [
{
"value": "ProductionQueue/Entities/_string",
"tokens": "units/{civ}_champion_infantry_a_barracks>units/{civ}_champion_infantry_e_barracks units/{civ}_champion_infantry_a>units/{civ}_champion_infantry_e"
}]

Where tokens is the new list separated by spaces

  • Like 1
  • Confused 1
Link to comment
Share on other sites

1 hour ago, Stan` said:

modifications": [

{

"value": "ProductionQueue/Entities/_string",

"tokens": "units/{civ}_champion_infantry_a_barracks>units/{civ}_champion_infantry_e_barracks units/{civ}_champion_infantry_a>units/{civ}_champion_infantry_e"

}

Where tokens is the new list separated by spaces

So, this probably won't work:

{
	"genericName": "Iphicrates",
	"description": "Iphicrates.",
	"icon": "athen_hero_iphicrates_card.png",
	"tooltip": "Select Iphicrates to lead your civilization.",
	"modifications": [
		{
			"value": "ProductionQueue/Entities/_string",
			"tokens": "
				-units/athen_hero_miltiades
				-units/athen_hero_pericles
				-units/athen_hero_socrates"
		}
	],
	"affects": ["CivilCentre"]
}

 

Edited by wowgetoffyourcellphone
Link to comment
Share on other sites

1 hour ago, Stan` said:

modifications": [

{

"value": "ProductionQueue/Entities/_string",

"tokens": "units/{civ}_champion_infantry_a_barracks>units/{civ}_champion_infantry_e_barracks units/{civ}_champion_infantry_a>units/{civ}_champion_infantry_e"

}

Where tokens is the new list separated by spaces

 

57 minutes ago, wowgetoffyourcellphone said:

> = replace?

/ = a new set?

From technologies.js:

 

Supports "A>B" to replace A by B, "-A" to remove A, and the rest will add tokens

Link to comment
Share on other sites

{
	"genericName": "Iphicrates",
	"description": "Iphicrates.",
	"icon": "athen_hero_iphicrates_card.png",
	"tooltip": "Select Iphicrates to lead your civilization.",
	"modifications": [{
		"value": "ProductionQueue/Entities/_string",
		"tokens": ["-units/athen_hero_miltiades_infantry -units/athen_hero_themistocles -units/athen_hero_pericles"]
	}],
	"affects": ["CivilCentre"]
}

This validates, but throw this error:

 

Spoiler

ERROR: Script message handler OnTemplateModification failed

ERROR: JavaScript error: globalscripts/Technologies.js line 58 TypeError: modification.split is not a function HandleTokens@globalscripts/Technologies.js:58:45 GetTechModifiedProperty@globalscripts/Technologies.js:32:11 ModifiersManager.prototype.FetchModifiedProperty@simulation/components/ModifiersManager.js:110:9 ModifiersManager.prototype.ApplyTemplateModifiers@simulation/components/ModifiersManager.js:193:9 ApplyValueModificationsToTemplate@simulation/helpers/ValueModification.js:19:11 AIInterface.prototype.OnTemplateModification@simulation/components/AIInterface.js:256:19 ModifiersManager.prototype.SendPlayerModifierMessages@simulation/components/ModifiersManager.js:69:1 ModifiersManager.prototype.ModifiersChanged@simulation/components/ModifiersManager.js:60:4 ModifiersManager.prototype.Init/this.modifiersStorage._OnItemModified@simulation/components/ModifiersManager.js:23:65 MultiKeyMap.prototype.AddItem@simulation/helpers/MultiKeyMap.js:49:2 MultiKeyMap.prototype.AddItems@simulation/helpers/MultiKeyMap.js:62:14 ModifiersManager.prototype.AddModifiers@simulation/components/ModifiersManager.js:265:9 TechnologyManager.prototype.ResearchTechnology@simulation/components/TechnologyManager.js:228:1 g_Commands["civ-choice"]@simulation/helpers/CommandsCivChoice.js:4:2 ProcessCommand@simulation/helpers/Commands.js:47:3

ERROR: Failed to call ProcessCommand() global script function

@Stan` @wraitii

Edited by wowgetoffyourcellphone
Link to comment
Share on other sites

without [ and ] like here

{
      "value": "ProductionQueue/Entities/_string",
      "tokens": "units/{civ}_champion_infantry_a_barracks>units/{civ}_champion_infantry_e_barracks units/{civ}_champion_infantry_a>units/{civ}_champion_infantry_e"
      }
  • Like 1
Link to comment
Share on other sites

17 minutes ago, Angen said:

This should remove house

{
      "value": "Builder/Entities/_string",
      "tokens": "structures/stonehenge -structures/{civ}_house"
      }

Thanks. It works to remove the other heroes as desired. However, I get this error:

 

ERROR: Script message handler OnValueModification failed

ERROR: Script message handler OnValueModification failed

ERROR: Script message handler OnValueModification failed

ERROR: Script message handler OnValueModification failed

ERROR: Script message handler OnValueModification failed

ERROR: Script message handler OnGlobalValueModification failed

ERROR: JavaScript error: simulation/components/ProductionQueue.js line 142 TypeError: token.split is not a function ProductionQueue.prototype.CalculateEntitiesMap/this.entitiesMap<@simulation/components/ProductionQueue.js:142:1 ProductionQueue.prototype.CalculateEntitiesMap@simulation/components/ProductionQueue.js:135:21 ProductionQueue.prototype.OnValueModification@simulation/components/ProductionQueue.js:940:2 ModifiersManager.prototype.SendPlayerModifierMessages@simulation/components/ModifiersManager.js:74:2 ModifiersManager.prototype.ModifiersChanged@simulation/components/ModifiersManager.js:60:4 ModifiersManager.prototype.Init/this.modifiersStorage._OnItemModified@simulation/components/ModifiersManager.js:23:65 MultiKeyMap.prototype.AddItem@simulation/helpers/MultiKeyMap.js:49:2 MultiKeyMap.prototype.AddItems@simulation/helpers/MultiKeyMap.js:62:14 ModifiersManager.prototype.AddModifiers@simulation/components/ModifiersManager.js:265:9 TechnologyManager.prototype.ResearchTechnology@simulation/components/TechnologyManager.js:228:1 g_Commands["civ-choice"]@simulation/helpers/CommandsCivChoice.js:4:2 ProcessCommand@simulation/helpers/Commands.js:47:3

ERROR: Failed to call ProcessCommand() global script function

Link to comment
Share on other sites

3 minutes ago, Angen said:

it is supposed to split string stored in token based on white spaces and reuse the same variable :)

Hmm, that might be an actual issue, can you show your modification file? 

{
	"genericName": "Iphicrates",
	"description": "Iphicrates.",
	"icon": "athen_hero_iphicrates_card.png",
	"tooltip": "Select Iphicrates to lead your civilization.",
	"modifications": [
		{
			"value": "ProductionQueue/Entities/_string",
			"tokens": "-units/athen_hero_miltiades_infantry -units/athen_hero_themistocles -units/athen_hero_pericles"
		}
	],
	"affects": ["CivilCentre"]
}

Here she is.

Link to comment
Share on other sites

10 minutes ago, Angen said:

it is supposed to split string stored in token based on white spaces and reuse the same variable :)

Hmm, that might be an actual issue, can you show your modification file? 

Oddly, altering the tech like this removed the error code.

 

{
	"genericName": "Iphicrates",
	"description": "Iphicrates.",
	"icon": "athen_hero_iphicrates_card.png",
	"tooltip": "Select Iphicrates to lead your civilization.",
	"modifications": [
		{
			"value": "ProductionQueue/Entities/_string",
			"tokens": "-units/athen_hero_miltiades_infantry -units/athen_hero_themistocles -units/athen_hero_pericles",
			"affects": "CivilCentre"
		},
		{
			"value": "ProductionQueue/Entities/_string",
			"tokens": "-units/athen_hero_socrates",
			"affects": "Stoa"
		}
	]
}

 

Link to comment
Share on other sites

This one still gives that error

{
	"genericName": "Socrates",
	"description": "Socrates.",
	"icon": "athen_hero_socrates_card.png",
	"tooltip": "Select Socrates to lead your civilization.",
	"modifications": [
		{
			"value": "ProductionQueue/Entities/_string",
			"tokens": "-units/athen_hero_miltiades_infantry -units/athen_hero_themistocles -units/athen_hero_pericles -units/athen_hero_iphicrates",
			"affects": "CivilCentre"
		}
	]
}

 

Link to comment
Share on other sites

Neh 

11 minutes ago, wowgetoffyourcellphone said:

Oddly, altering the tech like this removed the error code.

 


{
	"genericName": "Iphicrates",
	"description": "Iphicrates.",
	"icon": "athen_hero_iphicrates_card.png",
	"tooltip": "Select Iphicrates to lead your civilization.",
	"modifications": [
		{
			"value": "ProductionQueue/Entities/_string",
			"tokens": "-units/athen_hero_miltiades_infantry -units/athen_hero_themistocles -units/athen_hero_pericles",
			"affects": "CivilCentre"
		},
		{
			"value": "ProductionQueue/Entities/_string",
			"tokens": "-units/athen_hero_socrates",
			"affects": "Stoa"
		}
	]
}

 

Meh, at 100 seconds I get this similar error:

ERROR: Script message handler OnOwnershipChanged failed

ERROR: Script message handler OnOwnershipChanged failed

ERROR: Script message handler OnOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Error in timer on entity 1304, IID97, function TimerHandler: TypeError: token.split is not a function ProductionQueue.prototype.CalculateEntitiesMap/this.entitiesMap<@simulation/components/ProductionQueue.js:142:1 ProductionQueue.prototype.CalculateEntitiesMap@simulation/components/ProductionQueue.js:135:21 ProductionQueue.prototype.OnOwnershipChanged@simulation/components/ProductionQueue.js:624:3 Foundation.prototype.Build@simulation/components/Foundation.js:417:3 Builder.prototype.PerformBuilding@simulation/components/Builder.js:78:3 UnitAI.prototype.UnitFsmSpec.INDIVIDUAL.REPAIR.REPAIRING.Timer@simulation/components/UnitAI.js:2883:6 FSM.prototype.ProcessMessage@simulation/helpers/FSM.js:265:12 UnitAI.prototype.TimerHandler@simulation/components/UnitAI.js:4110:2 Timer.prototype.OnUpdate@simulation/components/Timer.js:139:4

Link to comment
Share on other sites

{
	"genericName": "General Craterus",
	"description": "General Craterus.",
	"icon": "mace_hero_craterus_card.png",
	"tooltip": "Select General Craterus to lead your civilization.",
	"modifications": [
		{
			"value": "ProductionQueue/Entities/_string",
			"tokens": "-units/mace_hero_philip_infantry -units/mace_hero_demetrius_infantry -units/mace_hero_alexander_infantry",
			"affects": "CivilCentre"
		}
	]
}

 

I get this error now once a building is "completed", but is not really completed. It just sits at 99.999999% completed.

Spoiler

 

ERROR: Script message handler OnOwnershipChanged failed

ERROR: Script message handler OnOwnershipChanged failed

ERROR: Script message handler OnOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Script message handler OnGlobalOwnershipChanged failed

ERROR: Error in timer on entity 1290, IID97, function TimerHandler: TypeError: token.split is not a function ProductionQueue.prototype.CalculateEntitiesMap/this.entitiesMap<@simulation/components/ProductionQueue.js:142:1 ProductionQueue.prototype.CalculateEntitiesMap@simulation/components/ProductionQueue.js:135:21 ProductionQueue.prototype.OnOwnershipChanged@simulation/components/ProductionQueue.js:624:3 Foundation.prototype.Build@simulation/components/Foundation.js:417:3 Builder.prototype.PerformBuilding@simulation/components/Builder.js:78:3 UnitAI.prototype.UnitFsmSpec.INDIVIDUAL.REPAIR.REPAIRING.Timer@simulation/components/UnitAI.js:2883:6 FSM.prototype.ProcessMessage@simulation/helpers/FSM.js:265:12 UnitAI.prototype.TimerHandler@simulation/components/UnitAI.js:4110:2 Timer.prototype.OnUpdate@simulation/components/Timer.js:139:4

 

@wraitii @Angen @Freagarach

Edited by wowgetoffyourcellphone
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...