[BTS MODCOMP] [Python/XML] Event Signs

Dresden

Emperor
Joined
Jul 10, 2008
Messages
1,081
Event Signs for Civ4: Beyond the Sword

Author: Dresden; Current Version: 1.00

Download: CFC Downloads Database or attachment on this post

Description:

This is a very simple mod component which adds "landmark" signs to the map
when an event which changes plot yields is triggered. For example, when the
Truffles event happens, a sign will be placed on the affected plot noting
the food and commerce increase as well as a short event identifier. It
consists of 1 Python and 2 XML files; details on the changes below. This
mod is designed for single-player BTS 3.17; compatibility with previous
versions and/or multiplayer is unknown.

The signs produced are the very same ones you can add yourself via ALT-S or
the Strategy Layer "Sign" option. As such they can be easily removed if you
find one getting in the way. One caveat is that if there is an existing sign
already on that plot, the pre-existing sign will be left alone and nothing
denoting the event will be added. However unless you really use a lot of
signs yourself this will generally be a rare situation and should only occur
on plots that are already visible to you. In such a case it would be easy to
modify your old sign manually.

Known Issues:

Jerrymander has reported that signs are visible even on unrevealed plots.
As that is spoiler information which tells you where other people are, I'm
trying to find a workaround to keep them invisible until you've explored there.

Distribution:

There are no licensing or distribution restrictions for this mod component.
However if you do incorporate it into a publicly-released mod of your own,
a mention in the credits would be greatly appreciated.

Sample before and after screenshot:


Installation:
Spoiler :
Code:
	This mod contains 3 files which should be placed within your CustomAssets
	directory; the directory structure of this download mirrors that of the
	CustomAssets directory to assist in placement. Two of the files replace
	original game files and so the originals should be backed up to a safe
	location before you copy this mod's files over. Step-by-step instructions:

	1. Backup your current CustomAssets/Python/EntryPoints/CvRandomEventInterface.py
	2. Backup your current CustomAssets/XML/Events/CIV4EventInfos.xml
	3. Copy the included CvRandomEventInterface.py to CustomAssets/Python/EntryPoints/
	4. Copy the included CIV4EventInfos.xml to CustomAssets/XML/Events/
	5. Copy the included EventSigns_CIV4GameText.xml to CustomAssets/XML/Text
	6. Play.

Technical Information:
Spoiler :
Code:
	For those who wish to merge this with other Event mods, customize it
	for their own preferences, or are simply curious as to how it works,
	below is a summary of the changes made. See also comments in the code.

	The guts of this mod are in the Python file CvRandomEventInterface.py; all
	additions in that file are marked with "EventSigns" comments and should be
	easy to locate. The mod provides 3 new functions at the end of the file and
	alters one previously-existing function. The new functions are:

	1. applyLandmarkFromEvent -- the generic event callback
	2. placeLandmark -- a helper function that actually puts the signs on the map
	3. clearSignsAndLandmarks -- an unused helper function that removes all signs
	                             and landmarks from a given plot.

	The existing callback function applySaltpeter was also modified to call the
	placeLandmark function for all plots whose yields it changes.

	If you have a simple event which only changes plot yields through the use of
	<PlotExtraYields> the only thing you have to do to make signs appear for it
	is to assign applyLandmarkFromEvent as the <PythonCallback> for it and add
	an appropriate caption in EventSigns_CIV4GameText.xml. In fact, the only
	changes this mod makes to CIV4EventInfos.xml are to assign this callback to
	each of the following Events:
		 EVENT_HORTICULTURE_1
		 EVENT_HORTICULTURE_2
		 EVENT_PARROTS_1
		 EVENT_JADE_1
		 EVENT_BLACK_PEARLS_1
		 EVENT_CLUNKER_COAL_1
		 EVENT_SOUR_CRUDE_1
		 EVENT_TRUFFLES_1
		 EVENT_SEA_TURTLES_1
		 EVENT_TIN_1
		 EVENT_PRAIRIE_DOGS_1
		 EVENT_APPLESEED_1
		 EVENT_FORTY_THIEVES_1
		 EVENT_WATERS_OF_LIFE_1
		 EVENT_GREAT_BEAST_1

	If you modify any of those events to no longer provide plot yield changes,
	you should remove the callback although no sign should appear unless there
	is an actual yield change. And if you decide to write your own callback
	for one of those events, you can see how to call placeLandmark directly by
	using the applySaltpeter callback as an example.

	Note that the placeLandmark function will allow you to make true "landmarks"
	instead of team signs; these appear in a different color and can only be
	removed via the WorldBuilder. If you would rather use those you only need
	to change one parameter of the placeLandmark function in the generic callback;
	you should also change any manual placeLandmark calls in other callbacks too.

	In order to provide captions for any added events, you need to make new
	entries in EventSigns_CIV4GameText.xml (or another text XML file). The tags
	for the entry should be the <type> of the added event with "TXT_KEY_SIGN"
	prepended to it. For example, if you create an event with a <type> of 
	EVENT_BAND_CAMP_1 then for the descriptive caption you would create an xml 
	text entry with tag TXT_KEY_SIGN_EVENT_BAND_CAMP_1.

	There are also several TXT_KEY_SIGN_FORMAT_* entries in EventSigns_CIV4GameText.xml
	which give you some control over how the generated signs look.

Note: apologies on the weird post formatting; I basically just copied my README file to the post and added a screenshot.
 

Attachments

  • EventSigns.rar
    33.3 KB · Views: 362
There's a bug with your mod. It's not a terrible bug, but hampering on maps like Tectonics and Continents. Observe:

Spoiler :


Kinda makes it too easy to find opponents over the ocean. Other than that, the mod is great.
 
Thanks for the report Jerrymander. I'm not sure what's up with that. During my initial testing, the signs remained invisible before the plot was revealed. But your screenshot shows that obviously isn't always the case. I'll look into it.
 
If it helps at all, I'm using Solver's 3.17 patch, as well as Civscale and Blue Marble.

Edit: And the map was a Huge Fractal Marathon map.
 
Does it also reveal the Holy Mountain ? I'd assume so, imo that spoils those type of events.
 
Does it also reveal the Holy Mountain ? I'd assume so, imo that spoils those type of events.

No idea, I haven't gotten the quest yet, and this was the first game I've played with event signs on.

moopoo: It's more fun than it sounds. :p
 
It doesn't mark the Holy Mountain. It only marks plots which have yield changes, and I'm trying to fix the spoiler aspect of that. The full affected event list is in the "Technical Information" spoiler on the first post.
 
Jerrymander has reported that signs are visible even on unrevealed plots. . . . I'm trying to find a workaround to keep them invisible until you've explored there.

You could store them in SdToolkit and add them to the map in response to the plotRevealed event. If you wanted, you could even add them to an internal list that gets checked every turn and only displays a sign once the player takes control of the tile.

As there will be very few tiles that require signs, SdToolkit should be perfect. Store a single list of events, each holding the plot ID (int), text, and a set of teams for whom it has been made visible.

This would also allow you to store any overwritten signs or have a button to toggle the event sign visibility map-wide, though I suspect if a player has it on, they want to see the signs.
 
There's a bug when two or more events occur on the same plot as demonstrated in the first image in this post. It needs to merge the old sign somehow which might require adding meta information to describe the event and bonuses to the plot, or we could just parse the existing sign.

  • Tin, 2P
  • Tin & Truffles, 2P 3C
  • Tin, Truffles & Gems, 2P 6C
Space will probably be an issue. :(
 
a python fix to the revealing problem is using the visibility of the tiles

CyPlot
BOOL isRevealed (TeamType eTeam, BOOL bDebug)

using eTeam as being the human
 
Top Bottom