Xml/Lua Trait Help needed.

Dadicho

Chieftain
Joined
Mar 15, 2016
Messages
8
Location
Canada
Hello there ! I'm new here and this is my first thread.
So I hope tihs is the right place to post this but I need help/suggestion/guidance.
I want my custom civilization to have a unique trait that, I believe, required skill and knowledge in LUA and XML that I do not possess.
So I'll try to sound a clear and precise as I'm able to be.

<<Unique Trait Name : Eternal Night
Description: Your territory remains unexplored to other civilizations.Upon entering a Hex tile inside your territory, the enemy units sight is reduced to 1.>>

So basically I want every other civilization to be unable to see inside your territory ( remains black as unexplored. And if a foreign unit enter your land, it can only see around the tile it is currently on (1 sight). If it moves, all previous explored tiles reverse back to unexplored.I also wish that units outside your borders cannot see inside your territory except if on a tile next to your land.For instance,planes have a great sight radius, it normally would be able to see every tiles inside its radius,but if your land is present on certain tiles,he would be unable to see your tiles. Another exception is if a foreign spy/diplomat is in your capital, it sees only 1 tile around the city it is in.Now I may add another bonus to it like a +combat STR if in your territory or something else like a -combat STR for foreign units inside your land.
Technically,for other players,they would see a dark,black getting bigger (depending on culture) on the mini map.
So I'd like a reply containing a Xml code ( if possible) representing what I have describe above :c5happy:.

Also if anyone know where I could look up a Technology Xml bonus ( Machinery -- +1 :c5moves: movement on Roads for instance) or where the Policy bonus are,that be great ! :)

Thanks in advance,if you have read all of this, you get + 1 thanks ! :D
 
After a quick search I think you might want to use this (lua) function:
void Plot:SetRevealed(void pPlot:SetRevealed(TeamID team, bool newValue, bool terrainOnly, TeamID fromTeam) (Taken from whoward's Lua's cheat sheet)

the first argument would be the team ID of the other players and the second argument would be false (this combination will cause pPlot (the tile) to be hidden (bool newValue = false) from all players in a team with an ID of 'team'). I'm not sure what the other values mean though...

Known bugs (according to Google):
1) It does not hide the Resource Icons in the 3D view
2) It does not update the mini map

The only way to 'solve' these bugs is to reload the game

(I am kind of in a hurry so sorry if this might be unclear to you :blush:)

Good Luck! :D
 
Wow ,thanks ! Any idea where I could have this ''whoward's Lua's cheat sheet'' ?
about the minimap bug,could I do that each turn the minimap is updated instead of reloading the game if so,how ?
Also, I have next to none knowledge about lua so I don't know how I would implement
'' void Plot:SetRevealed(void pPlot:SetRevealed(TeamID team, bool newValue, bool terrainOnly, TeamID fromTeam)'' unto a code.
Still, thanks for your help. :c5happy:
 
I see, instead,could foreign units simply be reduced to 1 sight ? like a promotions similar to The Great wall ?
 
Assuming the highlighted column here takes negative numbers, you could theorectically add a promotion into the game that reduced unit sight by 1, and then give that promotion to adversary or enemy units that toodle by the borders of the civ:
Code:
<Row>
	<Type>PROMOTION_SENTRY</Type>
	<Description>TXT_KEY_PROMOTION_SENTRY</Description>
	<Help>TXT_KEY_PROMOTION_SENTRY_HELP</Help>
	<Sound>AS2D_IF_LEVELUP</Sound>
	<PromotionPrereqOr1>PROMOTION_SHOCK_1</PromotionPrereqOr1>
	<PromotionPrereqOr2>PROMOTION_DRILL_1</PromotionPrereqOr2>
	<PromotionPrereqOr3>PROMOTION_TARGETING_1</PromotionPrereqOr3>
	<PromotionPrereqOr4>PROMOTION_BOMBARDMENT_1</PromotionPrereqOr4>
	<PromotionPrereqOr5>PROMOTION_COASTAL_RAIDER_1</PromotionPrereqOr5>
	<PromotionPrereqOr6>PROMOTION_BOARDING_PARTY_1</PromotionPrereqOr6>
	<PromotionPrereqOr7>PROMOTION_WOLFPACK_1</PromotionPrereqOr7>
	<PromotionPrereqOr8>PROMOTION_FLIGHT_DECK_1</PromotionPrereqOr8>
	<PromotionPrereqOr9>PROMOTION_ARMOR_PLATING_1</PromotionPrereqOr9>
	<OrderPriority>3</OrderPriority>
	[COLOR="Blue"]<VisibilityChange>1</VisibilityChange>[/COLOR]
	<PortraitIndex>43</PortraitIndex>
	<IconAtlas>PROMOTION_ATLAS</IconAtlas>
	<PediaType>PEDIA_SCOUTING</PediaType>
	<PediaEntry>TXT_KEY_PROMOTION_SENTRY</PediaEntry>
</Row>
But it would still be a medium-difficult code-script to write, especially if you have no knowledge of lua. Generally it is better to start with smaller steps.
 
So i'd do :
Code:
<UnitPromotions>
<Row>
<Type>PROMOTION_NIGHT</Type>
<Description>TXT_KEY_PROMOTION_NIGHT</Description>
<Help>TXT_KEY_PROMOTION_NIGHT_HELP</Help>
<Sound>AS2D_IF_LEVELUP</Sound>
<PromotionPrereqOr1>PROMOTION_SHOCK_1</PromotionPrereqOr1>
<PromotionPrereqOr2>PROMOTION_DRILL_1</PromotionPrereqOr2>
<PromotionPrereqOr3>PROMOTION_TARGETING_1</PromotionPrereqOr3>
<PromotionPrereqOr4>PROMOTION_BOMBARDMENT_1</PromotionPrereqOr4>
<PromotionPrereqOr5>PROMOTION_COASTAL_RAIDER_1</PromotionPrereqOr5>
<PromotionPrereqOr6>PROMOTION_BOARDING_PARTY_1</PromotionPrereqOr6>
<PromotionPrereqOr7>PROMOTION_WOLFPACK_1</PromotionPrereqOr7>
<PromotionPrereqOr8>PROMOTION_FLIGHT_DECK_1</PromotionPrereqOr8>
<PromotionPrereqOr9>PROMOTION_ARMOR_PLATING_1</PromotionPrereqOr9>
<OrderPriority>3</OrderPriority>
<VisibilityChange>-10</VisibilityChange>
<PortraitIndex>43</PortraitIndex>
<IconAtlas>PROMOTION_ATLAS</IconAtlas>
<PediaType>PEDIA_SCOUTING</PediaType>
<PediaEntry>TXT_KEY_PROMOTION_NIGHT</PediaEntry>
</Row>
</UnitPromotions>

Which if I understand correctly will create a promotion that would reduce visibility to 1 while beiing unable to be chosen (in game when lvl in up) because of the prequeq (shock,drill,targeting,etc,.)
So next I should..lets see... reverse engineer the Great wall? So that <Type>PROMOTION_NIGHT</Type> is received the same way .
Correct ?
 
reduced unit sight by 1, and then give that promotion to adversary or enemy units that toodle by the borders of the civ

And therein lies the problem.

A standard unit on the tile just outside/inside the northern border needs a normal sight of 2 when looking north and a sight of 1 when looking south - which a) can't be done with any XML base sight promotions and b) will require an awful lot of Lua.

(Edit: And later era ships don't even need to adjacent to the border to be able to see beyond it.)

Assuming the northern border runs straight, when the unit moves left/right, the game core will automatically hide/reveal tiles as required, so a UnitSetXY event handler will be needed to hide any tiles so revealed. Sight range is also affected by what the unit is standing on (hills/flat) and what they can see (hills/mountains), so you'll be scanning a large number of tiles every time the unit moves.

Any natural wonders revealed in the dark will have to be left revealed as hiding them will give +1 happiness again when next revealed.

Aircraft recon range and diplomats will need similar code, as at the start of the turn all visible tiles are automatically revealed.

At a guess, this is also going to make the main map flicker as foreign units move along the borders / within the dark.

Edit: And as the civ acquires tiles (purchase, expansion, culture bomb, city capture, city trade, etc), the code is going to have to hide them from any foreign civ that may have wandered past previously and revealed them, and special consideration will need to be given as foreign civs discover Satellites

W
 
So i'd do :
Code:
<UnitPromotions>
<Row>
<Type>PROMOTION_NIGHT</Type>
<Description>TXT_KEY_PROMOTION_NIGHT</Description>
<Help>TXT_KEY_PROMOTION_NIGHT_HELP</Help>
<Sound>AS2D_IF_LEVELUP</Sound>
<PromotionPrereqOr1>PROMOTION_SHOCK_1</PromotionPrereqOr1>
<PromotionPrereqOr2>PROMOTION_DRILL_1</PromotionPrereqOr2>
<PromotionPrereqOr3>PROMOTION_TARGETING_1</PromotionPrereqOr3>
<PromotionPrereqOr4>PROMOTION_BOMBARDMENT_1</PromotionPrereqOr4>
<PromotionPrereqOr5>PROMOTION_COASTAL_RAIDER_1</PromotionPrereqOr5>
<PromotionPrereqOr6>PROMOTION_BOARDING_PARTY_1</PromotionPrereqOr6>
<PromotionPrereqOr7>PROMOTION_WOLFPACK_1</PromotionPrereqOr7>
<PromotionPrereqOr8>PROMOTION_FLIGHT_DECK_1</PromotionPrereqOr8>
<PromotionPrereqOr9>PROMOTION_ARMOR_PLATING_1</PromotionPrereqOr9>
<OrderPriority>3</OrderPriority>
<VisibilityChange>-10</VisibilityChange>
<PortraitIndex>43</PortraitIndex>
<IconAtlas>PROMOTION_ATLAS</IconAtlas>
<PediaType>PEDIA_SCOUTING</PediaType>
<PediaEntry>TXT_KEY_PROMOTION_NIGHT</PediaEntry>
</Row>
</UnitPromotions>

Which if I understand correctly will create a promotion that would reduce visibility to 1 while beiing unable to be chosen (in game when lvl in up) because of the prequeq (shock,drill,targeting,etc,.)
So next I should..lets see... reverse engineer the Great wall? So that <Type>PROMOTION_NIGHT</Type> is received the same way .
Correct ?
hmmmm....no.
  1. Great Wall doesn't give a promotion, its effect is handled entirely at the DLL/C++ level of the game.
  2. You would want something more like this as the promotion
    Code:
    <GameData>
    	<UnitPromotions>
    		<Row>
    			<Type>PROMOTION_NIGHT</Type>
    			<Description>TXT_KEY_PROMOTION_NIGHT</Description>
    			<Help>TXT_KEY_PROMOTION_NIGHT_HELP</Help>
    			<Sound>AS2D_IF_LEVELUP</Sound>
    			<VisibilityChange>-10</VisibilityChange>
    			<CannotBeChosen>true</CannotBeChosen>
    			<PortraitIndex>59</PortraitIndex>
    			<IconAtlas>ABILITY_ATLAS</IconAtlas>
    			<PediaType>PEDIA_SHARED</PediaType>
    			<PediaEntry>TXT_KEY_PROMOTION_NIGHT</PediaEntry>
    		</Row>
    	</UnitPromotions>
    </GameData>
  3. But the exact structure of such a promotion is essentially a moot point for this particular effect especially given all the additional problems outlined by whoward69 that would have to be solved, and which take this effect from being a medium-hard to nearly impossible effect to create in lua scripting.
  4. Such an effect is completely impossible in xml-only coding
 
Alright then, thanks for your replies,instead, i'll give this civ trait a 50% discount on aquiring culture tiles and + 1 sight 1 :c5moves: movement and 20 % :c5strength:.

Now, If I wanted a trait to do :
For 12 turns after declaring war to a civilization or beiing declared war, gains a 50 % :c5strength: combat str bonus when fighting that civilization.
What would it look like ?

Also a promotion like ?

I hope you guys don't feel like you're doing all the job cuz i'm going to start to feel bad ......
Thanks again.
 
...
Now, If I wanted a trait to do :
For 12 turns after declaring war to a civilization or beiing declared war, gains a 50 % :c5strength: combat str bonus when fighting that civilization.
As far as I'm concerned, this has to be done via Lua as well. From what I've heard as well, this combat strength will either always show up vs any unit, or never show up vs any unit (as in, the estimated damage UI thing that pops up before you attack something). However, the damage will still apply, since your Lua code adds the extra combat strength pre-attacking but post-UI (if that sounds clear enough?)
I'm not sure about this again, since I'm (still) a new modder as well. Just trying to recall from what I've read in other posts that asked a similar question!

I hope you guys don't feel like you're doing all the job cuz i'm going to start to feel bad ......
Thanks again.
No of course not! Everybody here enjoys helping other people! ;) (Well, if you don't, why are you here reading this and/or replying? :p)
 
Now, If I wanted a trait to do :
For 12 turns after declaring war to a civilization or beiing declared war, gains a 50 % :c5strength: combat str bonus when fighting that civilization.
What would it look like ?
More complex than the "dark lands" one.

The standard Firaxis combat events are specifically designed for their UI needs - they only fire if the unit is visible to a human player, and not at all if viewing the SV map or if Quick Combat is enabled.

Writing a comprehensive set of combat events requires modding the DLL.
 
Side note to whoward's comment:
For 12 turns after declaring war to a civilization or beiing declared war, gains a 50 % :c5strength: combat str bonus when fighting that civilization.
Coding this would become immeasurably easier if you removed the conditional requirement of "when fighting against that civ." A flat, temporary Combat Strength modifier would be quite simple to implement, whereas having to check what civ your units are fighting makes things much more complex, for reasons whoward outlined.
 
Whew ! Thanks again for answering ! Wow okay, guss i'll have to postpone that trait another day :/


Here's 1 more quesiton that comes into my mind, I think it was whoward that gave the xml files for Units,buildings and Civ ( which I downloaded and for which i'm really grateful) but any idea where I could find the Tech and the policies, For instance, the Marchinery allow the production of Crossbowman, the Ironworks and another passive bonus that gives faster movements on road ( +1 :c5moves: movement on roads I assume). Now I want one of my civ to have a +1 :c5moves: movement bonus on roads added to its trait, How could add that to the trait ? And how does that +1 :c5moves: move on roads work ?
 
Back
Top Bottom