Random Events Mod

Awaiting an update (or certification) for cIV 1.52.
I really appreciate the variability (i.e., random events) :) of this mod, though sometimes I wish they happened more often. Then again, I am talking Huge Epic games.
 
Hi DireAussie,
I'm excited to give it a try.

One problem I noticed right away was the graphics in the map globe view on the bottom right window. In default high res I get blue streaks distorting the map view. It works fine in medium res. I'm using patch 1.52. I can use all high res graphics in the standard game with no problems.
 
would you post a tutorial of how to make these events? i have many many more events Id like to add, including: (some you have already done)

Terrorist attacks
Hurricanes
Plagues/Disease Epidemics
Tornados
Tsunamis
Earthquakes
Floods
Volcanoes
Landslides
Avalanches
Droughts
Wildfires
Friendly Fire (ex. pilot crashes into area near landing site on accident)
Railroad Accidents
Alien aggresion
Olympics
World competitions (ex. World Cup, Ms. Universe, etc)
Crime
Work ethic boost (units in tile gain an HP boost and workers in tile work twice as fast. lasts ~2 turns)


Please consider adding some of these or please show me how to do it myself.
 
Thanks for the feedback, I havent done any work on the mod since because I've been too busy playing civ 4 and testing it for myself :) Also, I have another unrelated project I'm working on that I need to give priority over this mod.

Could you add plague into random events?

Its on my to do list :) The algorithm you presented is similar to how I was going to implement it, but its going to be a bit more extensive than just a random chance in one city. Think world epidemics :)

One problem I noticed right away was the graphics in the map globe view on the bottom right window

Since my mod doesnt do anything to the map globe view I doubt it is my mod that is causing the problem (I havent played a game with it yet though).

would you post a tutorial of how to make these events? i have many many more events Id like to add, including: (some you have already done)

I think the best way to learn is to read the code I've written, and also take a look at the mods provided by Firaxis eg desert war. You'll need to know how to program otherwise you wont know what you're doing. I'll describe the basic steps for adding a new random event.

My code is quite modular. This means you can go away and write your own event and then post it here and I can put it in with relative ease (if you dont totally mess up the structure :) ).

As an example, say you want to make a flood. Here are the steps:

- Create a file called RandomEventFlood.py and write all the code that does the flood in there. A good idea is to copy one of the other files there and then change the code around a bit.

- If your flood needs a popup screen, open the RandomEventsScreen.py file and write the screen handler code there. You should only add 2 functions:

setEarthquakeScreenVars - allows you to pass variables from RandomEventFlood.py so they can be shown in the popup text

showEarthquakeScreen - code to show the screen

You'll also need to add an entry to the updateScreen() function. Have a look at the other events as an example.

You will also need to create some class variables in the init function at the top of the RandomEventsScreen.py file, and should clearly mark what the flood variables are so that its easy for me to change.

- If your flood needs IO (input/output, so you can save stuff between save/loads) then you'll need to open the RandomEventsIO class and add the needed functions in there. You'll need a "set" and "get" function and the data will need to be a basic data type like int or string or whatever. Take a look at the file and use what I've already done there as a start.

- open the RandomEvents.py file. Here you'll need to put in your class constructor call for your flood and change the event handler code so that the flood will occur. Have a read of the file to see how I've done it for other events - its relatively easy to follow.

- add any constants that will be used by your flood to RandomEventsConstants.py
 
DireAussie said:
Thanks for the feedback, I havent done any work on the mod since because I've been too busy playing civ 4 and testing it for myself :) Also, I have another unrelated project I'm working on that I need to give priority over this mod.



Its on my to do list :) The algorithm you presented is similar to how I was going to implement it, but its going to be a bit more extensive than just a random chance in one city. Think world epidemics :)



Since my mod doesnt do anything to the map globe view I doubt it is my mod that is causing the problem (I havent played a game with it yet though).



I think the best way to learn is to read the code I've written, and also take a look at the mods provided by Firaxis eg desert war. You'll need to know how to program otherwise you wont know what you're doing. I'll describe the basic steps for adding a new random event.

My code is quite modular. This means you can go away and write your own event and then post it here and I can put it in with relative ease (if you dont totally mess up the structure :) ).

As an example, say you want to make a flood. Here are the steps:

- Create a file called RandomEventFlood.py and write all the code that does the flood in there. A good idea is to copy one of the other files there and then change the code around a bit.

- If your flood needs a popup screen, open the RandomEventsScreen.py file and write the screen handler code there. You should only add 2 functions:

setEarthquakeScreenVars - allows you to pass variables from RandomEventFlood.py so they can be shown in the popup text

showEarthquakeScreen - code to show the screen

You'll also need to add an entry to the updateScreen() function. Have a look at the other events as an example.

You will also need to create some class variables in the init function at the top of the RandomEventsScreen.py file, and should clearly mark what the flood variables are so that its easy for me to change.

- If your flood needs IO (input/output, so you can save stuff between save/loads) then you'll need to open the RandomEventsIO class and add the needed functions in there. You'll need a "set" and "get" function and the data will need to be a basic data type like int or string or whatever. Take a look at the file and use what I've already done there as a start.

- open the RandomEvents.py file. Here you'll need to put in your class constructor call for your flood and change the event handler code so that the flood will occur. Have a read of the file to see how I've done it for other events - its relatively easy to follow.

- add any constants that will be used by your flood to RandomEventsConstants.py
im not a coder. :( is there no chance you'll put these into the mod?
 
Okay, I've just run into a big issue, and it's something that I don't think is fixable.

Because volcanoes, droughts, and fertiles are implemented as resources, they are resources. However, since there's no tile improvement that effects them, normally they can't be "obtained" in any real sense.

The problem crops up where in my current game, drought has struck a variety of squares, one of which is a city square. City squares seem to be unique and not something you can mod via XML. They are hardcoded(?) to pick up any resource they are on, and thus, you can get Drought. And even trade it to the AI. If the AI won't take it, no problem; just give it to them!

This seems to be a problem. Now, I don't think trading them actually DOES anything, since the drought resource doesn't show up in the city screen. But perhaps more annoyingly, I can find no way to declare a resource "non-tradeable" in the XML files. There's no option for it in the BonusInfos file. I tried changing <TechCityTrade>, say, TECH_FUTURE_TECH but that had no effect -- and that might only effect the city screen, anyway. There's no "NEVER" option, either.

If it actually had an improvement, I could set <bBonusTrade> to 0 in ImprovementInfos, but since this doesn't seem to have any effect when a city is on it. (It's not like cities automatically call the farm, mine, etc. routines... sigh.)

Finally, I tried to making <TechObsolete> to something I already had, like TECH_AGRICULTURE. That didn't work, either. I don't understand why.

At this point, I'm stumped. There doesn't seem to be a way to make a non-improveable resource non-tradeable. Now in Civ4, all normal resources require improvements to unlock them, so you could make them non-tradeable then. But I'm thinking there's also a bug in THAT code, in that cities built on the resource will still be able to trade it, since the non-tradeable code is associated with the improvement, not the resource.

But I'm a newbie at this and maybe I've missed something completely. Anyone?

Bruce
 
Okay, I'm partly wrong here.

The problem seems to be a drought-sticken tile that somehow got placed there when the world was created. It's not on my city and not improved or even being worked, but it's within my bounds and it still shows up for trade...

Bruce
 
well jsut make sure their is no way to trade them like make them only tradeable if worked a certain way then dont make that way avaiable in the game LOL
 
That's what I was going for, but there doesn't seem to be a way to do that, since founding a city on a resoures always makes it available (since a Worker can't improve it to access it otherwise), and every resource has to have a tech which makes is tradeable (there's no "never").

However, that wasn't the problem anyway, as I discovered. The problem is that some fertile and drought tiles (and possibly "stray" volcano too) were getting populated on the game map through the regular map generation procedures, and somehow these are allowed to be tradeable even when not worked. What I've done is change <iPlacementOrder> from 2 to -1; that seems to make it so the resources won't get placed during map generation. Volcanos will still get placed anyway by the Python script when a new game is actually started.

Bruce
 
DireAussie said:
Thanks for the feedback, I havent done any work on the mod since because I've been too busy playing civ 4 and testing it for myself :) Also, I have another unrelated project I'm working on that I need to give priority over this mod.



Its on my to do list :) The algorithm you presented is similar to how I was going to implement it, but its going to be a bit more extensive than just a random chance in one city. Think world epidemics :)



Since my mod doesnt do anything to the map globe view I doubt it is my mod that is causing the problem (I havent played a game with it yet though).



I think the best way to learn is to read the code I've written, and also take a look at the mods provided by Firaxis eg desert war. You'll need to know how to program otherwise you wont know what you're doing. I'll describe the basic steps for adding a new random event.

My code is quite modular. This means you can go away and write your own event and then post it here and I can put it in with relative ease (if you dont totally mess up the structure :) ).

As an example, say you want to make a flood. Here are the steps:

- Create a file called RandomEventFlood.py and write all the code that does the flood in there. A good idea is to copy one of the other files there and then change the code around a bit.

- If your flood needs a popup screen, open the RandomEventsScreen.py file and write the screen handler code there. You should only add 2 functions:

setEarthquakeScreenVars - allows you to pass variables from RandomEventFlood.py so they can be shown in the popup text

showEarthquakeScreen - code to show the screen

You'll also need to add an entry to the updateScreen() function. Have a look at the other events as an example.

You will also need to create some class variables in the init function at the top of the RandomEventsScreen.py file, and should clearly mark what the flood variables are so that its easy for me to change.

- If your flood needs IO (input/output, so you can save stuff between save/loads) then you'll need to open the RandomEventsIO class and add the needed functions in there. You'll need a "set" and "get" function and the data will need to be a basic data type like int or string or whatever. Take a look at the file and use what I've already done there as a start.

- open the RandomEvents.py file. Here you'll need to put in your class constructor call for your flood and change the event handler code so that the flood will occur. Have a read of the file to see how I've done it for other events - its relatively easy to follow.

- add any constants that will be used by your flood to RandomEventsConstants.py
Can you create the spy can steal a technology from a rival civilization ?
 
Okay guys, I retract my earlier retraction. There's actually two bugs at work here: first, the placement of a few fertile and drought tiles at map creation (which I think my suggestion fixes), but also, as I originally suspect, if a drought or fertility strikes on top of a city, it becomes a tradeable resource. And there doesn't seem to be any way in the Civ 4 engine that I can see to mod how a city effects a resource; it seems to always assume it can access it if a city is on it.

I believe adding "and not newplot.isCity()" in the drought and fertile python files in the apporpriate place will fix this. I suggest putting it only in the placement function, not in the removal one; that way existing saves who have the bug will still have it removed once the drought or fertility ends. The only drawback to this fix is that they are slightly less impactful, but this is not a big deal. They can still happen "centered" on city squares; they just won't affect the city square itself.

I hope DireAussie sees this. :)

Bruce
 
SirBruce, to help you in the future remember that ALL resources are tradeable when not worked. You only need the improvement and a road, it doesn't even have to be in city limits, just cultural boundaries. You get it as a trade resource but of course none of the worked bonus. Since drought and fertile normally don't need an improvement or tech they are just avalible. It shouldn't make a difference if they are placed on start or by an event either, though they shouldn't be placed on start anyway.

Making them unworkable without things that don't exist seems a very sloppy workaround to me. For one it doesn't fix cities like you said. Also it means putting an unobtainable tech or improvement in the game for them to not use and that will show up in the Civapedia.

My solution is more drastic and I am not sure it would work but would solve most of these issues. We have oodles of resources as it is and these things are not really resources anyway. Make them features instead. Features don't produce trade resources, do modify terrain output, I think they can even overlap other features, something the resources can't do with other resouces. It fixes most of the problems both conceptually and in terms of game mechanics. Volcanoes are unarguably closer in concept to a forest or icecap than beavers or dye. I think this works on the XML level though I haven't double checked, I think the Python could be changed to handle it but I am new at Python myself.
 
Hi DireAussie, I'm having some problems combining this mod with the RealFort mod. this is because in the CvEventInterface.py file located in the python/entrypoints folder, RealFort defines:

normalEventManager = CvCustomEventManager.CvCustomEventManager()

while your mod defines:

normalEventManager = CvRandomEventsEventManager.CvRandomEventsEventManager()

is there a way around this? thanx in advance for your support! :)
 
I agree that features seem to be the right way to go, as well. However, I you're wrong in that simply building a road to a resoures makes it available for trade, if you have the right tech. I think it does have to be worked. I haven't tested it, though, so maybe I'm wrong, but since I made my change, fertility strikes don't suddenly make my fertility tradeable.

But I agree, changing them to features seems to be the appropriate answer...

Bruce
 
Hi guys my first post here

I was wondering if its possible to use 2 different mods at once? Say I want to use the composite mod which i load up in the menu and then want the random events mod as well it will only use the last mod which i loaded up, that being the random events one

cheers guys
 
Not really, no. You can't even do multiple new civilizations at once, which seems like a really major oversight on the part of Firaxis.... they should have made every civ compartmentalized, so you could load multiple new civs at the very least.

But as for mods in general, mods basically have versions of their own files that are loaded instead of the stock game files at startup. Two mods most likely will have at least one file that they both have, so there's no way to really load them both at once without actually editing them.

Some people are making collected mod packs of various other mods, but these are really just one big mod that are hand-cobbled together by smart people. :)

Bruce
 
Okay guys, I retract my earlier retraction. There's actually two bugs at work here: first, the placement of a few fertile and drought tiles at map creation (which I think my suggestion fixes),

That's a bug I never got around to fixing. Also I think that when a drought/fertile land ends, it sometimes leaves the odd square around - this may be because other civ's trade it with other civs. Not 100% sure though.

But I agree, changing them to features seems to be the appropriate answer...

Thats something I was considering at the time. Resources are definitely not the most ideal solution.

Maybe when the SDK comes out it will allow more flexibility with what I could do with this mod.

normalEventManager = CvRandomEventsEventManager.CvRandomEventsEventMana ger()

is there a way around this?

No because both mods use their own separate events manager. There are ways to merge the two but you'd need to know how to program it in.

Can you create the spy can steal a technology from a rival civilization ?

I think it is possible but its not a simple add in, it would need work. Not sure why you're posting this in random events mod though.
 
Top Bottom