Vision Improvements: a new improvement type!

primem0ver

Emperor
Joined
Jun 16, 2006
Messages
1,158
Location
Peoria, AZ
This is primarily a SDK mod that adds the capability to build "vision" improvements that extend vision range for an empire. It comes complete with AI so that the AI will build vision improvements. Sample mod files are included to show you how it is done. Please Note, this mod component is meant as a mod enhancement similar to my Graded Invisibility Mod.

Vision Improvements


What are Vision Improvements?

Vision improvements are a new special type of improvement that either push back the fog of war when they are built for a given radius, allow certain invisible types to be seen for a certain radius or both. They can be built outside the working range of the city (but not outside of cultural borders) and work regardless of whether they are being “manned” or not. This mod includes all necessary AI so that the computer knows when and where to build AI improvements as well as recommend good vision builds to a human player. I would like to thank Blake for pointing me in the right direction on where to get started on this part of the mod!


How do they work?

All one has to do is build the improvement and the vision is improved for the tiles that are affected by the radius specified in new XML tags. The alteration relies on 4 new tags added to the CvImprovementInfos.xml schema and file. These tags are optional so you do not need to add these tags to all info types. Details on the new tags and how they should be used are included in the documentation.


IMPORTANT: Merging the SDK files

I wanted people to be able to merge this mod with or without my previously released “graded invisibility mod.” I recommend you check this mod out if you haven’t already because it goes very nicely with this one and allows for several new expanded options when using new (or even old) invisible types in your mod. VERY IMPORTANT: If you are using my Graded Invisibility mod you will need to uncomment sections in the SDK code for this mod with the prefix //GRADED: (remove the entire comment up to the colon). ALL of these commented “graded” lines are located in only one method in CvPlot.cpp (CvPlot::setImprovementVisibility(…). You do not need to make any other by-hand changes when merging the two mod components.

Credits

The graphics in the sample mod were generously provided by hrochland (sonar buoy and radar tower).


Lisence/When using or Modding this mod

1. Please give credit where credit is due.
2. Let me know if you want to use it (just for curiosity sake... i like to know if anyone else finds things like this useful).
3. Let me know of bugs, ideas, or significant enhancements you have made.

Note: I have left commented code lines that can be uncommented if you wish to debug the code upon changing or see what is going on during game execution. It also shows an example of how to “create” your own debug log files.


Future Plans

I would like to add code/a tag that will allow enemies, other players to “steal” the vision range/capabilities of the vision improvement if they have a unit on the same space as the improvement. This would allow an enemy to use your “guard tower” (an upcoming improvement in the Genetic Era Mod) if they had military on the same space on which it is built. I may also add python access to the new properties of CvImprovementInfo if people want me to.

ADDED:
The Files

I wanted to keep source files and the sample mod seperate but alas... I had to shuffle files to fit them under the 300k limit (the source/documentation files totaled 318k in zip format)
 

Attachments

  • VisionImprovements_AI_And_SampleMod.zip
    223 KB · Views: 440
  • VisionImprovements_SourceCode-Documentation.zip
    258 KB · Views: 446
Wow. Quick response. Sorry guys... I am still uploading the files... had to resize them because of the silly 300K limit (silly because it allows 500k pictures but only 300k zips!!??).

Anyway... uploads coming in just a few
 
I was able to merge your mod with some of the other mods I run. It worked great, 2 comments though. There were no comments in the civ4unitinfos.xml, I figured out that I needed to add the <build> sections to the workers. I noticed though that you did not have the <build> section in the indian fast workers. Thanks for a great mod. It is a great addition to my gameplay. I am especially impressed with how you were able to get the ai to use the additions. Thanks.

ebo
 
thanks for the feedback and comments ebo (and everyone else). You are right. I forgot to include that little note in the documentation. I suppose I should let people know lest they forget about it but that is part of of creating new improvements... you must add them to the build list of units who create them.

... and you are right. I forgot to add them to fast workers.

A little side note might be due: My current version of the mod I am working on (the genetic era mod) allows workers to modify peaks to hills when you work them with roads... so I created a worker unit to build gaurd towers who could not build roads because I do not like workers making such drastic (and back then impossible) changes to the landscape. Even now it is extremely difficult for us to blast away an entire mountain! So currently I use one worker for regular builds and one for any regular non-route builds as well as peak builds... this is probably why I did not change the indian worker. I forgot that I was using a different unit in my own mod. I figured that the new ability would "slow" the workers down so I didn't bother changing it.

My AI currently does not build the right workers as far as I can tell but anyone who uses the mod and adds vision builds to regular workers should not have any problems.
 
Have you considered combining this with Lopez's build outside Borders mod, you would need a means of establishing ownership outside of cultural borders then. I would recommend a short int on every plot "m_iTempOwner" it would over-ride cultural ownership if not set to -1, Moving a military unit into a tile would re-set the TempOwner value. This would allow capturing of these vision improvements and allow some really neat dynamic territory acquisition during war as you move through enemy territory. When a ceasefire is signed the temp owner values between the waring parties would get wiped returning control to the cultural owner.
 
Personally... I don't like the idea of building improvements outside of cultural borders with one exception (which I am considering doing in the future):

The fort. I think the fort should actually expand cultural borders a small bit (much like the vision improvement expands vision). This is the way it worked in CTP2. The "fort" should have its own set culture rating that only increases on upgrades (something like outpost->fort->mission).

I am considering doing a culture addon later on like the the vision addon that would allow for cultural expansion with limited application. This would allow you to fill in those gaps within your own borders that the AI likes to steal away sometimes, planting their own cultural plot in your country. (Very annoying).

Things that would include slight cultural expansions are:
cottage->towns
and forts and a system of upgradable forts like above.

Other than the fort group, I do not think that improvements should be built outside of cutural borders but your own mod is your own. You can do with it what you like :) !
 
I have discovered a bug in the mod that causes the game to crash when the owner of a plot with a vision improvement is changed to none. I will post an update/fix at the latest by next week
 
I have discovered a bug in the mod that causes the game to crash when the owner of a plot with a vision improvement is changed to none. I will post an update/fix at the latest by next week
OK, where is this update/fix? ;)
 
This would be a good mod for any Alpha Cenaturi modding that people do - it's similar to the SMAC:Sensor Array. Although, with the Sensor Array, your troops get a bonus when they're in the range (presumably due to better Intel).
 
we still have the original posted? Sorry... maybe I forgot. I will update ASAP.
 
Hi!

I discovered a crash in CvCityAI::AI_updateBestVisionBuild()
If there is a city near the border of the map,
pLoopPlot = plotXY(getX_INLINE(), getY_INLINE(), iDX, iDY);
will return an invalid plot.
pLoopPlot->getImprovementType()
then leads to a crash.

Matze
 
Great contribution ;-). I have added it to my mod. And thanks to Matzehh for the correction.
 
Top Bottom