View Full Version : QUESTION: How do Events work?


renegadechicken
Aug 19, 2009, 01:47 PM
Specifically, how are random events triggered using XML and SDK in Vanilla BTS? I understand the premise, but I need to know the exact files and code lines that are used to ensure random events trigger.

To elaborate further, I've created over 200 events for the Final Frontier mod/scenario in BTS. All of them are random, but not a single one will trigger (unless I trigger them using the chipotle cheatcode). I've tested that events are actually in the game by setting up events to trigger as soon as a city reaches size 4, etc., and those non-random events trigger nicely, but NO random events will trigger. Ever. Despite being present in all games, having a very high weight, and pretty lax requirements.

I have altered the GlobalDefinesAlt.xml file in the Final Frontier XML folder to include "EVENT_MESSAGE_TIME", "EVENT_MESSAGE_TIME_LONG", "EVENT_MESSAGE_STAGGER_TIME", "EVENT_PROBABILITY_ROLL_SIDES" and "FIRST_EVENT_DELAY_TURNS" (basically everything from the Vanilla XML file that includes "event" in the tag), however, random events simply will not trigger. Is there another file I need to modify so that random events will trigger? It's just so odd that non-random events will fire, but random ones won't!

If you have any ideas (or questions to clarify what I've said), please post away! :) Thanks in advance for any help!

The_J
Aug 19, 2009, 06:14 PM
With an iWheigt of -1 an event will trigger immediatly, after all prerequisites are reached.
-> Try out, if the events trigger. If not, there's an problem with their definition.

renegadechicken
Aug 19, 2009, 07:19 PM
With an iWheigt of -1 an event will trigger immediatly, after all prerequisites are reached.
-> Try out, if the events trigger. If not, there's an problem with their definition.

Yes, that's exactly what I mean by non-random events. As I mentioned, I've set up some events (for test purposes) to trigger once certain prerequisites are achieved (by setting the iWeight to -1), and they trigger fine, so I know that the events are...in the game. The problem is that none of the random events (those with an iWeight of, for example, between 50 and 250) will trigger, even after hundreds of turns of meeting all the prerequisites.

And yes, I understand random means you could, theoretically, go thousands of turns without a single event triggering. :) But I've never gone a BTS game with events on and had NO events (I've had games where I had only a few, but there were still events affecting both the AIs and me), so I suspect there's something wrong. I've played two full Final Frontier games with my events active (250+ turns), and ONLY events with an iWeight of -1 will trigger!

Just to remove all (well, hopefully most :) ) doubts about my skills as an event modder, ALL of my events have been tested multiple times using the chipotle cheatcode, and each one has triggered and worked perfectly if I trigger them with the console. So it's not a spelling error or something. :)

TC01
Aug 19, 2009, 07:41 PM
I've had the same issues making events for Final Frontier (well, Star Trek Mod for Final Frontier). Events with no prereq but a python check set to return true 100% of the time did not trigger with the weight set to -1, were in every game not triggered.

I think FF breaks the event engine, and I want to fix this. But I'm not sure why or where or how to fix this. It could be a SDK error that only causes problems when using solar system python and other FF python...?

renegadechicken
Aug 19, 2009, 07:56 PM
Yeah, it's quite frustrating, because it's like, did they intentionally remove the functionality of events? I mean, how convoluted is the implementation of events? I always figured that all you needed to do is add the new event tags in EventTriggerInfos.txt and EventInfos.txt and they'd work-- that's how it is in Vanilla BTS!

Do I need to add those files-- EventTriggerInfos.txt and EventInfos.txt-- to a list in some other XML or SDK file so that the game knows to check those files? It just makes no sense that non-random events work, but random events will NEVER trigger... :(

TC01
Aug 19, 2009, 08:13 PM
Some of my random events have triggered in Star Trek. But only four out of like 10 I've tried. Here they are:

Ion Storm:

An ion storm has decimated an extraction facility near the colony of %s2_city.

1. Pay to have the facility rebuilt. (-20 Gold)
2. We cannot spare any resources to deal with this. (The Extraction facility is lost)

Tantalus Prison Colony: (Requires a jail in a city to trigger, will only trigger once per player)

Reports have emerged that the director of the Tantalus Penal Colony in the solar system of %s2_city, Dr. Tristan Adams, has been conducting illegal and unethical experiments on prisoners and staff using a dangerous "neural neutralizer".

1. Arrest Dr. Adams, destroy the neural neutralizer, and renovate the prison into a medical clinic for treating the injuries of Adams' victims. (-100 Gold, +2 Health in Jail, +1 Happy in all Cities)
2. Arrest Dr. Adams, but study the valuable pyschological and neurological data he collected in his experiments using the neutralizer. (-50 Gold, -(something) to the tech being researched)
3. Appoint Dr. Adams to the head of our Prison System. Use his techniques in all prisons to increase scientific research and make our prison system something to be afraid of! (+1 Research, +1 Commerce in Jail, -1 Health and Happiness in all cities)

Babel Conference: (Cannot trigger before Turn 50, only triggers once per player)

(If it's the Ent Era)
Local empires have agreed to come together at the Babel diplomatic facility, in neutral space for a conference. We have received an invitation from one of those empires, the %s1_civ.

(If it's any other era)
Major galactic empires have agreed to come together at the Babel diplomatic facility, in neutral space, for a conference. We have received an invitation from one of those empires, the %s1_civ.

1. Accept their invitation. (+1 with %s1_civ)
2. Accept their invitation and escort their ambassador to Babel on our flagship. (+2 with %s1_civ)
3. I don't have time for conferences. Refuse their invitation.

Radiation Dissipation: Requires a plot with a radiation cloud

Radiation clouds near the system of %s2_city have dissipated. They will no longer damage ships or impede travel through the area.

1. This is excellent news (Radiation Cloud is removed)

renegadechicken
Aug 19, 2009, 08:24 PM
Oh, really, you've actually had random events trigger? Wow, I need to know what you did in any files (except EventTriggerInfos.xml and EventInfos.xml) to get the events working! Did you add "EVENT_PROBABILITY_ROLL_SIDES" to the GlobalDefinesAlt.xml file? I've done that, so what else? :)

TC01
Aug 19, 2009, 08:34 PM
Err... nothing... I'm checking right now if any work in vanilla Final Frontier. If they don't, it may be because Star Trek was originally built on Warlords, merged in with BTS, and merged in with Final Frontier. So some of whatever blocks events triggering might not be there.

(I DO know that deanej ran into similar problems when he first wanted to add events to Star Trek, and gave up as a result. And as I said, most of my events failed to work at all.)

Otherwise, I have no idea. Maybe someone more experienced with the event engine then me can investigate this.

renegadechicken
Aug 19, 2009, 08:37 PM
Well, an easy way to check is to search for that tag in the GlobalDefinesAlt.xml file-- if you don't have it and random events are working for you, maybe I don't need it either! :)

TC01
Aug 19, 2009, 08:50 PM
Something I realized: you say yours don't trigger at all, if they aren't set to trigger with <iWeight> at -1. Well, the events I tried to made that didn't trigger at all, not by the python console or by the <iWeight>. I can't confirm that any do, in fact, trigger randomly.

Yet some did work, though again, I don't know if they trigger randomly.

I know for a fact that deanej ran into this problem for Star Trek. Whether his events weren't triggering randomly, I have no idea.

I think it's because Star Trek is different from Final Frontier (for instance, my wormholes mapscript for Star Trek hanged when I dropped it into FF, so I had to re-add my code manually to a vanilla version of FinalFrontier.py). Perhaps an event that would not work at all for me in ST would trigger on command in Final Frontier.


And no, I didn't have that tag in GlobalDefinesAlt.xml.

renegadechicken
Aug 19, 2009, 09:03 PM
Hmmmm...so you're saying that your random events don't trigger either? I had thought that you were saying that yours DID trigger, but I must've misunderstood you.

That's really too bad-- I remember when I was starting this, deanej was helping with ideas and we were going to collaborate. I had no idea that he had run into this problem too.

Just to make sure I understand: you've had events work in the Star Trek mod, but you're unsure about whether they were random or not, and you've never had any random events work in Final Fronter? Not very encouraging. :) If you DO have a random event trigger...well, randomly, let me know! That way I can figure out what I need to change.

PS: While waiting for your (very helpful-- thank you!) responses, I checked out your sig, and saw your Wormholes modcomp. I would prefer not to have to replace my CvFinalFrontierEvents.py file, as I've edited it to allow for some Python functions in my (belligerent) events-- are your additions all in one place for easy copy&paste into my file, or are they all over and it'd be a lot of work to manually add them?

TC01
Aug 19, 2009, 09:17 PM
That's really too bad-- I remember when I was starting this, deanej was helping with ideas and we were going to collaborate. I had no idea that he had run into this problem too.


Yeah. When I first started doing it, he was going to use any events I could get to work for the next version of Star Trek. You can check out some of his issues on page 6 of Solver's Event Guide. This specifically is my problem:

I have another problem. I attempted to add an event that will trigger on a plot owned by the player with no features that will add the supernova feature onto said plot. However, it seems to require something, because when I attempt to test it in the console it won't trigger. What could such an event require? Could someone respond to this and my above post? And could someone explain to me why whenever I attempt to add an event it requires hours of troubleshooting?

Well, it's not the same event, but many of the events I've tried do this. A few (4) worked when I made them via console/worldbuilder.

It also came to me: if you added a supernova event of some sort, you need to do more then just set the feature type to FEATURE_JUNGLE. The plot flips back to a solar system the next turn unless you have code like this (God-Emperor came up with it):

pPlot.setFeatureType(gc.getInfoTypeForString('FEAT URE_JUNGLE'),0)
pPlot.setScriptData("")
pSystem = self.getSystemAt(iX,iY)
self.apSystems.remove(pSystem)
self.iNumSystems -= 1

They assume this is CvFinalFrontierEvents.py (the "self." statements).

Just to make sure I understand: you've had events work in the Star Trek mod, but you're unsure about whether they were random or not, and you've never had any random events work in Final Fronter? Not very encouraging. If you DO have a random event trigger...well, randomly, let me know! That way I can figure out what I need to change.

Yes, correct. Except I haven't really tried to make events trigger in base Final Frontier.

PS: While waiting for your (very helpful-- thank you!) responses, I checked out your sig, and saw your Wormholes modcomp. I would prefer not to have to replace my CvFinalFrontierEvents.py file, as I've edited it to allow for some Python functions in my (belligerent) events-- are your additions all in one place for easy copy&paste into my file, or are they all over and it'd be a lot of work to manually add them?

Well, everything I changed is marked with "Wormholes" or " -- TC01" in comments. I do have a file with all of my alterations, though. It's zipped below if you need it.

renegadechicken
Aug 19, 2009, 10:02 PM
Man, what is up with Final Frontier? We really need Jon Shafer to let us know what he did to the event system! I just read deanej's posts, and there seem to be quite a few problems. Glad to see you found a solution to your event!

Excellent, thanks for the zip! This'll be awesome having wormholes in my games-- definitely add some more strategy to them! :) I did have a thought, though...since blue wormholes are already everywhere (just not labelled, because they're not "special"), is there a way to exchange the light purple with the blue? I don't often play on Huge maps (too few players, and duplicates are annoying!) in Final Frontier, so I'd never see them anyway, and the purple and red wormholes would stand out whereas blue sort of blends in with the rest of the non-special wormholes.

TC01
Aug 20, 2009, 08:08 AM
Man, what is up with Final Frontier? We really need Jon Shafer to let us know what he did to the event system! I just read deanej's posts, and there seem to be quite a few problems. Glad to see you found a solution to your event!

Excellent, thanks for the zip! This'll be awesome having wormholes in my games-- definitely add some more strategy to them! :) I did have a thought, though...since blue wormholes are already everywhere (just not labelled, because they're not "special"), is there a way to exchange the light purple with the blue? I don't often play on Huge maps (too few players, and duplicates are annoying!) in Final Frontier, so I'd never see them anyway, and the purple and red wormholes would stand out whereas blue sort of blends in with the rest of the non-special wormholes.

What I'm wondering about is if it wasn't actually Jon Shafer's fault, but other people at Firaxis who were coding events made a small bug somewhere that doesn't really do anything (or it might not even be a bug) but when we add the complicated Solar System code in, the bug is exposed somehow. I have no idea how that might be possible, though.

I might be able to make another custom map option (I'm making one at the request of JEELEN for MOO2Civ to allow you to turn off the labels on wormholes). I don't know how it would work, though. It could be called "Wormhole Order" and have 6 options:

Blue, Red, Purple
Blue, Purple, Red
Red, Purple, Blue
Red, Blue, Purple
Purple, Blue, Red
Purple, Red, Blue

It would be annoying to code, but it should work fine.

renegadechicken
Aug 20, 2009, 12:10 PM
Yeah, it's not like I'm blaming Jon Shafer for anything, he's just the only one I know about who worked on Final Frontier. :) And that's a good point-- it may be a tiny "problem" with the code somewhere that is barely even related to events. :shrug:

Ah, I see. Well, as long as you're not doing it just on my account. :)

--------

By the way, to all others, I still can't seem to get random events to trigger by themselves in Final Frontier. Events with an iWeight of -1 will fire with no problem, and I can manually trigger random events using the console (so I know they "work" the way designed). Any ideas why the game will never offer up random events?

God-Emperor
Aug 20, 2009, 07:57 PM
I believe I have found the answer to this, if you are using the CIV4EraInfos.xml from Final Frontier (or have the same problem).

In CIV4EraInfos.xml there is a tag called iEventChancePerTurn. In all of the eras defined in the Final Frontier version of this file this is set to 0. This gives a 0% chance of having a random event happen on any turn (the code for this in the DLL is in CvPlayer.cpp, line 18486 which sets the bNewEventEligible flag to false if a random number is greater than or equal to this value from the era info file).

FF uses ERA_MODERN (changing the text to "Galactic" in FinalFrontierTextInfosObjects.xml).

Therefore, edit CIV4EraInfos.xml: find the ERA_MODERN section and set iEventChancePerTurn to something greater than 0. (Or just change them all.)

The range of values for this in regular BtS is 1 in the earlier eras up to 10 in the future era (modern is 8).

renegadechicken
Aug 20, 2009, 09:41 PM
No way, seriously!? Wow, you just made my day! :)

I'll try it out and see what happens, but I suspect that's the problem. See, I just knew that there was some "hidden" thing affecting events somewhere, and I suspected someone else would know where it was.

Cheers, God-Emperor! :beer:

renegadechicken
Aug 21, 2009, 01:09 AM
Worked like a charm-- thanks so much, God-Emperor! Finally I have events in my Final Frontier games! :D

(Should a moderator lock this thread now, as my question has been answered?)

God-Emperor
Aug 21, 2009, 01:18 AM
Worked like a charm-- thanks so much, God-Emperor! Finally I have events in my Final Frontier games! :D

(Should a moderator lock this thread now, as my question has been answered?)

Not before I say "Yea!"

I hadn't actually tested it, so I wasn't completely certain that changing just that one thing would fix it.