Logo Platform
logo amplifiers simplified

How to use $Property value, and right path.

Reply
Copied to clipboard!
9 years ago
Nov 13, 2015, 10:17:31 AM
Hi ! me again smiley: smile



After Reading the SimulationDescriptors[Class].xml, i try to test an use of propertys.



Example, this city improvement should add the BaseCityPointPerPopulation to the BaseFoodPerPopulation.

Others parts of the mini mod work well (it's a copy past of sucessfull code).

In this example, mod work well if I write :

[CODE] [/CODE]

So it's a very local problem.



But here, it's impossible to access property.



@path=Simulation\SimulationDescriptors[CityImprovement].xml

[CODE]









[/CODE]



I've looked in many files of the game and tryed many syntax, like :



[CODE] [/CODE]



[CODE] [/CODE]



and so many others ones than i can't remember.





Not really same problem, but I'm still confused with "paths" and points "../", "./"

It's not a folder path, so an object structure path ? but what is this object structure ? What is arborescence and syntax rules to walk into ?

How can I know where I'm am in the structure, and good "./", "../" or even ".../" or no "." to go elsewhere.



Why in SimulationDescriptors[CityImprovement].xml, I must write "./ClassCity"

Except here :

[CODE]



[/CODE]

Worst headaches with EmpireTypeMajor and ClassEmpire



or in SimulationDescriptors[Approval].xml, just write "ClassCity"

[CODE]









[/CODE]



or in DepartmentOfIndustry+Constructibles[CityImprovement].xml, write "../ClassCity"

[CODE]



75

.../ClassEmpire,AffinityBrokenLords

../ClassCity/CityImprovementFood0

TechnologyFood0

[/CODE]



Except here, with non understandables "../ClassEmpire/ClassCity", or ".../ClassEmpire/ClassCity/CityImprovementIndustry10" (3 points !!!)

[CODE]





600

5

WondersAndColossiPack

.../ClassEmpire/Uniques,CityImprovementIndustry10

.../ClassEmpire/ClassCity/CityImprovementIndustry10

TechnologyIndustry2

$Count(../ClassEmpire/ClassCity) le 1

CityImprovementIndustry10

[/CODE]



And again in SimulationDescriptors[FactionTrait].xml, with "EmpireTypeMajor/ClassCity"

[CODE]







[/CODE]



Thanks for reading.
0Send private message
9 years ago
Nov 13, 2015, 11:00:46 AM
EDIT FOR FUTURE READERS: ThorTillas has a better, more concise and far more correct answer below.

-----

This is stuff to do with Classes and Subclasses. It's a section of programming (databases) that I've not had much experience with, but I can try to help.



The . .. and ... all change how the game, in this case the Simulation in particular, determines where it currently is and where to affect things. A first thing first: "The Simulation" here refers to the magical black box of iteration that happens when you hit the End Turn button. Which is separate from the part of the game code which maps models, generates/renders the map, creates tooltips, pathfinds, etc.



EL is databases. It's databases all the way down. Every entity, every army, every thing is a database, or a database modifier.



So as an example, an Empire has 1) properties, like it's faction and a count of the number of heroes it has, and it also has 2) children, Cities, armies and etcetera.



The important thing to realise is that everything is nested. So a city improvement is itself a database entry, 'owned' by the city which has built it. The city improvement then has a list of properties, which can affect the city or things outside the city.



This means that for the following, because a city improvement 'lives' in its city

[code]













[/code]

in particular

[code]./ClassCity[/code]

means "look backwards until you find something that satisfies "ClassCity". Ie: give your owning city +10 food.

The comma means "also check for", in this case; also check that it is summer. Summer and winter are a bit odd, as they are global variables (denoted by the # symbol), and hence have a value at every level of the simulation and can be checked at any time, even when the simulation is currently looking in a place which doesn't have it explicitly defined.



However! Once we leave The Simulation things are a little bit different.



DepartmentOfIndustry+Constructibles[CityImprovement].xml deals with the "can you build this yes/no?" question. It principally is used to check if the requisite technologies are met.

In your example:

[code]



75

.../ClassEmpire,AffinityBrokenLords

../ClassCity/CityImprovementFood0

TechnologyFood0

[/code]

The lines mean, in order:

1: definition of this database entity

2: define the value of one of the entity's attributes (cost)

3: If the faction is broken lords, then they cannot build it.

4: if any city already has this improvement, they cannot build it

5: if the technology is not researched, it cannot be built.



Each line of code must check a different location:

Line 3 needs to check the faction. The easiest way to do this is to go back to the root, which as far as I can tell is the player's empire, and then checks that empire for its affinity tag. Factional affinities are 'tags', which an empire owns. It's kinda like a property (number of cities, etc.), but instead of checking its value you check if it exists or not. In this instance the .../ means "go back as far as you can", then search for things which are ClassEmpire.

Line 4 checks for cities, and then cities which have the improvement already. From this I can hazard a guess to say that this block of code is read, and 'lives' in the Empire level. So since it's already in the Empire it simply needs to find all other children of the empire which are cities, hence the ../ "Go backwards until you find things which are cities, then go forwards"

line 5 is structured differently because the Technology Prerequisite code doesn't bother with paths. Technologies are common enough that they have their own shortcuts, and you don't need to worry about finding where technologies live every time. Instead, by using the TechnologyPrerequisite code you're telling it to check the current researched technology list of the active empire.



[code]





600

5

WondersAndColossiPack

.../ClassEmpire/Uniques,CityImprovementIndustry10

.../ClassEmpire/ClassCity/CityImprovementIndustry10

TechnologyIndustry2

$Count(../ClassEmpire/ClassCity) le 1

CityImprovementIndustry10

[/code]

CityImprovement10 is a national wonder, so it can only be built once per empire. Hence, two things must be checked. First, a few lines check to see if the improvement (wonder) is built anywhere else in your empire:

[code].../ClassEmpire/ClassCity/CityImprovementIndustry10[/code]

translates as "check every city in the empire to see if it has the building already"

the other line, [code].../ClassEmpire/Uniques,CityImprovementIndustry10[/code]

exists for a few edge cases. The Uniques thing, i believe (but haven't actually checked) exists in the empire class, and is just a list of unique things. It's there so that if someone Setseke Ho's with the improvement, or razes the city or loses it then they can't build another. However, if you capture a new city with one in it, and then later lose that city again you can build your own one. It's more or less a "yes I have done this" flag.

[code]$Count(../ClassEmpire/ClassCity) le 1[/code]

is an interesting line. It more or less tells the AI not to build this improvement here if the city is losing it money. I think. The AI code is a lot of handwaving and heuristics.



And for your last example:

[code]









[/code]

Faction traits are children of ClassMajorEmpire. So this trait, which adds one dust on terrain with dust works as follows: In the empire, in all cities, on all tiles, provided those tiles have the tag "terraintagdust", then give them +1 dust production.



EL is coded such that each region (in The Simulation) is defined by its owning city. A city technically owns all tiles, which may or may not be flagged as being within the exploitation zone of the city. only tiles in the exploitation zone generate income, but any city improvement which increases the yield of the tile will show its effect even on tiles outside the city's exploitation. This is actually pretty cool, when you look at it. If you start up a game and build a geomics lab in a city, you can see that the exact same tile, say Frozen Spikes, within the region will be +1smiley: industry+4smiley: science, while one in the uncolonised region next to it will be +1smiley: industry+2smiley: science in the mouseover tooltips. Because the improvement has literally changed the output of the tile, even though you're not getting it.



As an aside, this implies a few things about the game which we're not really told. I believe that all uncolonised regions are 'owned' by an AI 'faux empire', the same one which manages the roaming minor faction barbarians, and I think it's the one which populates the market and decides what to attack where with which barbarian armies. Unfortunately there's no way to select it within the debug mode, so I can't confirm or mod it.
0Send private message
9 years ago
Nov 13, 2015, 11:04:14 AM
Oh, I completely forgot: When it comes to [code]Value="$Property(./ClassCity:BaseCityPointPerPopulation)"[/code] things, I have no idea. I do know that you need to use the $property to get the numerical value out of some things when you're looking at them from other classes, but I don't understand them well enough to actually tell you how they work. Your best bet is probably to look at the class definitions in SimulationDefinitions[class], since there's the most complicated auto-summing values I can think of in there.
0Send private message
9 years ago
Nov 13, 2015, 11:51:48 AM
DISCLAMER: Please be aware that, for time reason, I didn't check any of the tag or property name I use in this post. You will have to check on the naming for each tags and property before using any of them!

Sorry... But don't hesitate to ask further questions or ask for tag validation if needed!!!!




Just wanted to point out that we do not use Database.



You have to think about simulation as a bunch of "generic objects" organized in a "Hierarchy".



So on the top of the hierarchy is the object "Empire", under it there is object for "City", "Army", "Research", etc. You can go through the simulation hierarchy with a tool (I do not remember the command right know, but it should be in the help of the console when you enable the modding tools).

[EDIT] Link to the debug activation post



Each object has a list of descriptor which specialize it.

Each descriptor add a "Tag" on the object.

For example:

A city for the broken lords will have the following tags: "ClassCity", "Garrison", "AffinityBrokenLords", etc

An hero Forgotten will have the following tags: "ClassUnit", "UnitTypeInfantry", "UnitBodyHeroForgottenA", "AffinityForgotten", etc

An exploited tile on a river will have the following tags: "ClassDistrict", "DistrictTypeExploitation", "TerrainTagFood", "TerrainTypePlain", "TerrainTagRiver"



You can navigate in this hierarchy with a path. The path will start somewhere and then use the following syntaxe to move up, down or stay on the same object.

The goal of a path is to validate or not a sequence of action.



"ClassCity" : will be true or correct if the current object has the tag "ClassCity".

"./ClassCity" : will be true if the direct parent of the current object has the tag "ClassCity".

"../ClassCity" : will be true if one of the parent of the current object has the tag "ClassCity".

".../ClassCity" : will be true if the root of the hierarchy has the tag "ClassCity.



When you are dealing with SimulationPropertyModifier, you are trying to apply a modification in the hierarchy. The Path attribut is here to define where your modificator will be applied.

If you are defining a city improvement descriptor and want to add 2 on the industry production of the city you have to use the path "./ClassCity" or "../ClassCity" to say "go up to find the city and apply your modificator on it".

[Code][/Code]



If you want to use a property of the city to compute your bonus, there is a boolean on the modificator which determine where it should look for the "Property" define in the "Value" attribute. It's called IsBindOnSource... yeah... we are not speaking english every day you know... sorry...

Example: A building want to add the city defens as production.

[Code][/Code]



When you are dealing with prerequisite, you are trying to define if a condition is valid or not. We have build a small interpreted language which allow you to get some property value in the simulation or check a path and some other stuff.

This is done via $Property(...), $Path() etc in a InterpretedPrerequisite element.

You cannot use this in a simulationModifier.





Does it help in any way? or do you need more info?
0Send private message
9 years ago
Nov 13, 2015, 12:28:29 PM
Nice post! You said more or less what I meant to, but more clearly and in less words, haha.



So for the second thing: When you set "IsBindOnSource" to false, you're telling it that the Value="$(Something)" should be checking that Something at the destination, not at the source? That's useful.



And then $property and $path work in the prerequisites! Of course! They return true/false, so that would explain why I see them in some places and not others.



I have a kind-of related question: Who or what owns a tile if the region it's in hasn't been colonised?

I was toying with the idea of making a unit that could give a FIDS bonus/penalty on the tiles adjacent to or standing on, but I suspect it wouldn't work with a .../ path because you'd only be changing the FIDS values of tiles that are owned by your own empire.
0Send private message
9 years ago
Nov 13, 2015, 12:55:35 PM
I have to thank you very much both of you.

I stick this in my mind and will read again carefully the enseignement dispensed here.



As example (if well understood)

./ClassCity/DistrictLevel1

will be true if the direct parent of the current object has the tag "ClassCity" and in each child object of this city with District tag and level 1.



The structure look more flexible than a pure database hierarchy with this tag system.



Another example :

"./ClassCity" : will be true if the direct parent of the current object has the tag "ClassCity".

"../ClassCity" : will be true if one of the parent of the current object has the tag "ClassCity".




In hierarchy, CityImprovement is child of City (and City is an object of the generic class "ClassCity", but here, it means, go to current object instance city).

So ./ClassCity say that.

But when using ../ClassCity, it does the same, because in hierarchy, ClassCity have a relation 1-N with CityImprovement, and a city improvement is owned by one, and only one city.

So in this case ./ClassCity and ../ClassCity does the same (i was asking why in a previous post "point point point").



Now, all of this need to be more experimented for me, and read each code line with this conceptual knowing and understand what it does, a long way.
0Send private message
9 years ago
Nov 13, 2015, 1:33:35 PM
Yep, in my case, ./ClassCity and ../ClassCity does exactly the same.



because, the city is directly the parent of the improvement object. But you may want to use a "../Garrison" on a item to modify the army or the city which is the parent of the unit which is the parent of the item. ^^



In the case of an improvement adding 1 to the food output of the path "./ClassCity/DistrictLevel1", you will improve the food production of all the district (exploitation or city tile or city center) that are level 1.



If, for the example, I wanted to restrict that on the city center, i could modify the path that way : "./ClassCity/DistrictLevel1,DistrictTypeCenter". So by adding more descriptor tags and separating them with a "," I can specialize my research.



Be aware that there is some "GlobalTag" that you may reach with the keyword "#". The only one I have in mind right now is winter.

If you want an improvement to add some food production during winter you have to use the following path "./#Winter,ClassCity". You are not force to use it before the "ClassCity", but I have coded the tooltip parser and I know that I will always use the last keyword to define on what the modifier will be applied... so try to end your path with the most defined keyword. (I can go into more detail if you want... but I not sure it's a good idea to do it right now ^^')



Another special keyword is "!" which allow to check the non existance of a tag. Best example ever: I want to add some dust on the city when it's not winter: "./!#Winter, ClassCity" ^^



Any questions? just fire away!!! ^^



Cheers,

flo.
0Send private message
9 years ago
Nov 13, 2015, 1:41:07 PM
Sorry for the double post, I didn't see the question about non colonized tiles before...





So, there is too much tiles in the EL world to allow us to instanciate all of them. In fact, if you are playing a long game and you are creating really big cities, in the end we will end up having one object for each tile, which could go over 40 000 object just for the terrain... considering there is at least 10-20 properties on each tiles, and more that 3-5 modifiers per property per tiles... well... that's a lot of objects ^^



Anyway.



Basically what we are doing is we create tiles only when a city exploit them. If you look at the tooltip of a tile, we create a "Dummy" temporar tile just to compute the tile yield, print it in the tooltip or in the overlay and reuse the dummy for the next tile...

With this, we do not create one object per tile until it's really necessary.



So, you won't be able to mod a minor faction that use the tile when not colonized.



On the same idea, region are simply not represented in the simulation. We create city only when needed and region without cities does not exists.

However, we do have some villages/resource location/temple/etc which are created from the begining of the game and added to the city upon creation. These objects are in their own hierarchy of one object... so no chance for you to grab them.

But each minor empire should have its own hierarchy of objects. It will be much simplier (only empire, army and village) but still, it exists. You should be able to check them in the simulation debugger tools.



I hope I am still readable ^^



Cheers,

flo.
0Send private message
9 years ago
Nov 13, 2015, 2:06:37 PM
SUCCESS !! (or near)



I've done the property manipulation :



All of this DON'T WORK :

[CODE]











[/CODE]



But This WORK :

[CODE]



[/CODE]



It really need the BinarySimulationModifierDescriptor, multiply by one the amount.





Another Succesfull test :

[CODE]



[/CODE]



Here, the city tile must be Exploitation AND Forest.

There is still a problem with this 2nd example : the text effect is wrong, it just indicate the latest condition in the list (TerrainTagForest), but the ingame effect is good and applied.

So now, I'm looking how to say to the player, hey guy, you don't need only a forest, you need an exploitation too !



But it's a big step, use of propertys can do amazing stuff and very originals capacitys, or funny one, like : "numbers of workers in CityPoint give +1 base pop in dust. ah ah, player will put the workers in dust so. Shit, basedustpop loose all bonus then !"



Very funny tooltip "par par par"..

0Send private message
9 years ago
Nov 13, 2015, 2:30:14 PM
+1 dust per population per influence per population on city? smiley: confused

That trait better be named Bureaucracy.... smiley: stickouttongue
0Send private message
9 years ago
Nov 13, 2015, 2:49:02 PM
you know, enchanteur is french... so... well..



By the way you won't be able to change how much population is assigned on the food or dust. This is a gameplay variable (sealed). But you may change how much each population produce.



Cheers,

flo.
0Send private message
9 years ago
Nov 13, 2015, 8:43:22 PM
Here, some greats news cityimprovements i will surely use in a future tech mod. And some silly stuff too, just for testing.

I try hard a maximum of possibilitys and combinations, before to organize what i will use in the mod.







Made with :

[CODE]



























































[/CODE]



Commentary :



[CODE]



[/CODE]

The improvement I prefer in the list, probably, left will be 0,5, because 1 is to powerfull.

Players loves micro-manage their workers smiley: smile



The property below have various problems, from fail to little anoyement :

[CODE]



[/CODE]

Here OwnedUnitRegenModifier is 0.05, and then the ingame effect is correct, but popup information show a strange "+100%". I wanted to try a binary operation with a percent instead of an addition and see the result.



[CODE]



[/CODE]

Here, i try to use again the "UnitSlotCount", but want restrict this to unitsettler only.

I think it can be a cool tech, because producing settler cost population, but you keep the settlers in city and they produce more food there.

This SimulationModifier is a total fail. I even don't know if what I project is doable.



[CODE]



[/CODE]

Here, i wanted to add a cool bonus (or a best reason) to construct the watchtowers everywhere. 10 Dust maybe too much, but the idea is there.

So, the simulationModifier fail too, I don't know if it's doable.



[CODE]



[/CODE]

Here, the effect work well, but popup information show a strange "Dust" symbol, instead of title "Frais militaires".

Idea is : the most the city pay for army, the most the city get citypoint (compensation).



[CODE]



[/CODE]

All work here, except the information : how to say it's "Exploitation+Forest", and not just "Forest" ?

Strangely, the game effect is good, game don't need to read popupinformation, game know what happens ^^



CHeer,
0Send private message
9 years ago
Nov 14, 2015, 12:42:03 PM
I've made a strange discovery :

[CODE]











[/CODE]



In this case, the district value can't be change with a variable value.

DistrictFood : 0 food is added, like if NumberOfExtensionInCity = 0 (in fact, the real value is 1).



DistrictDust : the value is changed, but only once. when improvement build finish. And because I let one worker on food the turn before.

After, If I move the worker elsewhere, district value don't change, even if i go to the next turn.

AND, the land is x10, not x11, as if the worker do nothing.



Is there a way to change dynamiquely Districts values with variables ?
0Send private message
?

Click here to login

Reply
Comment