Map specific events

c.fe

Warlord
Joined
Sep 20, 2003
Messages
133
Location
Germany
Map specific events

If you want to make a mod that includes several different maps and you want to habe different events on each map you have three (perhaps even more?) choices:

  • Copy your mod for every map and make a specific CvEventManager for every instance.
  • Make if/case-statements in CvEventManager that somehow determine the used map and execute only the appropriate code.

Both approaches have more or less obvious drawbacks. The first leads to massive duplication. If the mod has a size of 100 MB and you have ten maps then you have to use 2 GB.
The second approach leads to big CvEventManager-file that gets hard to read. And it isn't really easy to expand this because you have to change the mod at least in the CvEventManager.

My third approach doesn't have the disadvantages of the ones above. It lets you specify a different event handling class for every map without the need to change anything of the core mod. And it's only python.
But it could perhaps slow the mod a bit down. But that should just happen on a map that you didn't specify an event handler for (see below).

How does it work?

I made a demo mod. You can copy the file "CvEventInterface.py" form "\Assets\Python\EntryPoints" into your mod. If you modified it yourself you, of course, have to merge the files. Then you have to options:
  • Create a map e.g. "MapOne.CivBeyondSwordWBSave". Then create a python file named "MapOne.py" in "\Assets\Python" and there declare a class "MapOne" that inherits from CvEventManager.
  • Create a map and name it as you wish. Then open it in Notepad and add to the plot with the coordinates (0,0) the line "ScriptData=MapTwo". Then create a python file named "MapTwo.py" in "\Assets\Python" and there declare a class "MapTwo" that inherits from CvEventManager.

For an example look at the attached demo mod. It comes with three maps. These are basically the same but on the map "Eventworks" everybody gets a worker at an specific turn. On the map "Event2" only you get a worker at a specific turn and on the map "EventNoChance" nothing should happen.

I tested this a bit and it seems to work. But there are probably still some more obscure problems. So if you've got problems or don't know how to use it - post here :) !
 

Attachments

  • ScenMod.zip
    14.8 KB · Views: 98
Top Bottom