View Full Version : Wormholes code
TC01 Jul 24, 2009, 08:43 AM This is a thread for dealing with the Wormholes component of MOO2Civ. If you don't know, I designed the Wormholes modcomp for Star Trek, then released a Final Frontier compatible version, and then worked on including it in MOO2Civ with JEELEN. I recently updated it to v1.4/v1.2. So this thread is for two things:
a. Ideas about Wormholes. If you have an idea about how Wormholes should work, if more wormholes should be added, if more features should be added, etc., post it here.
b. Bugs/issues related to Wormholes. If you find a bug, please post it here and I'll correct it and issue a patch of my own (that JEELEN can then include in his next patch).
A changelog for v1.4/v1.2 (for ST/FF versions respectively) is below:
-Added two Wormholes features (blue wormhole, red wormhole)
-Added python code that transports units that move onto one wormhole to the other wormhole of the same type
-Added tutorial popup when you first discover a wormhole of either type
-Added a version of the FinalFrontierFlat mapscript called Wormholes.py that places wormholes (red wormhole placed only on standard, large, or huge maps)
-Added a landmark label via python to each wormhole
-Prevented wormholes from being placed on Duel Maps
-Added a version of the SpiralGalaxy mapscript that places wormholes just like the Wormholes mapscript called WormholesSpiralGalaxy.py
-Made AI consider wormhole position before deciding where to build a starbase
-Added Barzan Wormhole- pale purple- to Huge Maps
-Made labeling of wormholes a custom map option
-Added a map option allowing you to alter the order of wormholes
-Fixed Wormholes.py wormhole placement bug
When I release v1.5/v1.3 and so on, I'll attach a zipped file below with it so JEELEN can add it to MOO2Civ.
JEELEN Jul 24, 2009, 10:07 PM Thanks a lot!:goodjob: (The FF Flatmapscript was kindly provided by deanej, so I don't really know if and what he changed for it to be usable on FF or FF modmods.) I'll try and include this in the next patch to be released.
TC01 Jul 27, 2009, 09:43 PM I've gotten wormholes to be successfully placed on the Spiral Galaxy mapscript.
Unfortunately, there are two small bugs:
1. Red Wormholes are never placed. Even with 200,000 tries for each feature and the feature numbers slightly lowered (so there's only ever 1 wormhole type on a map).
2. The function I wrote to make sure Wormholes were placed away from each other didn't work (the game hanged during map loading), so you might occasionally get two wormholes clumped together.
Anyway, attached is the mapscript if you want to use it. It's the version from the Star Trek mod, of course, not the released version by cephalo- I don't know if this will make much of (or any) difference.
JEELEN Jul 29, 2009, 05:25 PM I'll be sure to use it!:D
It's weird about the no red wormholes (I'm not sure about the difference with blue wormholes?), but I wouldn't worry that much about the second 'bug', as in MoO wormholes can also exist not that far apart on the galaxtic map. Anyway, I'll check it out ASAP, thanks.:goodjob:
TC01 Jul 29, 2009, 09:09 PM I've fixed both problems.
The first was an embarrasing mis-read of the XML worldsize as "World" instead of "Worldsize" (So the game was looking for WORLD_DUEL, not WORLDSIZE_DUEL, for instance).
The second was more complicated and God-Emperor helped me fix it. Now, wormholes have to be a quarter or so across the map from each other- usually, the game drops them in seperate arms of the spiral galaxy.
So attached is the fixed mapscript.
On another note, you might want to change the pedia text for wormholes to be less Star Trek-ish. It has a ST explanation of what wormholes are in concept page.
TC01 Aug 02, 2009, 10:03 AM Also in the newest version of the Wormholes mod I made an AI change which makes the AI consider if a plot is near a wormhole before choosing to build a starbase there.
This is to help the fact that the AI knows nothing about Wormholes and won't know how to use them. So now it knows that building starbases near them (for defense) is important.
Attached is the change modded into MOO2Civ's CvAI.py, if you want to use it.
JEELEN Aug 02, 2009, 02:29 PM Sorry, sure I can use it. (Forgot to subscribe to this thread plus I got distracted by an uninstall/install problem w/BtS...)
This is to help the fact that the AI knows nothing about Wormholes and won't know how to use them. So now it knows that building starbases near them (for defense) is important.
How do you mean? I've seen AI and barbs enter Wormholes (I believe even with a Colony Ship).
TC01 Aug 02, 2009, 03:04 PM Sorry, sure I can use it. (Forgot to subscribe to this thread plus I got distracted by an uninstall/install problem w/BtS...)
How do you mean? I've seen AI and barbs enter Wormholes (I believe even with a Colony Ship).
Really? In ST Galaxy, in my mod, or in MOO2Civ with wormholes added?
To my knowledge, the AI shouldn't actually know what a wormhole is and what it can do- the AI doesn't know what python code does (whereas we can read the pedia and find out, or we can open up the python files and have a look around). Of course, it may be that once the AI uses a wormhole once, it can do it again?
Of course, it could simply be that the AI's movement path has been calculated to cross the wormhole, and so it does, but ends up getting moved.
Anyway, no matter what, building starbases near wormholes is a good defensive strategy.
JEELEN Aug 02, 2009, 04:36 PM Yes, certainly. I have seen the wormholes in action during an MP game with apenpaap, so on his Star Trek wormhole-mapscript and in single-player game on the ST Galaxy map. Haven't been able to implement wormholes w/MOO2Civ yet as it's currently uninstalled on my PC...
TC01 Aug 02, 2009, 05:18 PM Yes, certainly. I have seen the wormholes in action during an MP game with apenpaap, so on his Star Trek wormhole-mapscript and in single-player game on the ST Galaxy map. Haven't been able to implement wormholes w/MOO2Civ yet as it's currently uninstalled on my PC...
Oh well. Maybe I was wrong...
In any event, the AI change would still be useful, especially since normally the AI only considers bonus placement before deciding where to build a starbase (for example, they would only build a starbase before my change if there were two or more resources within two plot radius around it, according to the code.)
JEELEN Aug 02, 2009, 11:00 PM I've indeed never seen the AI build a Starbase at any other location than resources; if you have enough cash, it's quite useful to have one near a Star System. (Though over time I've actually followed the AI example and build them usually only to get resources now.)
JEELEN Aug 02, 2009, 11:54 PM BTW, would it be possible to simply use the Wormholes (Final Frontier) modcomp you just uploaded or am I missing something here?:confused:
TC01 Aug 03, 2009, 08:42 AM BTW, would it be possible to simply use the Wormholes (Final Frontier) modcomp you just uploaded or am I missing something here?:confused:
Have you (or Minor Annoyance) made any changes to your python files? Specifically CvEventManager.py and CvAI.py?
If that's a "no", then the answer's "yes", since all the XML is handled via module.
Some mods have, like Star Trek, which is why I released the seperate FF version in the first place.
Anyway, I first began posting stuff here before I decided to make a FF compatible version.
JEELEN Aug 03, 2009, 09:49 AM Ok, thanks for your reply. (I was asking as I have currently no access to BtS...)
JEELEN Aug 11, 2009, 11:41 PM TC01, I've been trying to python edit, but each time I want to save the edit I'm not allowed; Notepad ++ is telling me to check if the .py is opened somewhere else. Any suggestion?
TC01 Aug 12, 2009, 09:03 AM Strange, never seen that before.
I'd do it myself, except I don't know if any other changes have been made to the python since patch 4j was released (like the bug I fixed here (http://forums.civfanatics.com/showpost.php?p=8256310&postcount=31)).
If there wasn't anything else changed, I can merge that change and the Wormholes code into MOO2Civ Patch 4j's python files and then just post them here.
JEELEN Aug 12, 2009, 10:19 AM So far no python changes since the last patch; so if you could, I'd appreciate it (haven't done anything in python so far and my first try just faltered).
TC01 Aug 13, 2009, 10:49 AM Topic updated with the code actually merged into the MOO2Civ files, and both mapscripts (if you need them).
Ignore all the other zips... I'll be removing them shortly.
JEELEN Aug 13, 2009, 03:59 PM Cool! Ill make sure and include your work with the next patch to be released this week. Many thanks! :goodjob:
JEELEN Aug 13, 2009, 04:18 PM Darn... I just tried loading both mapscripts: the Wormholes.py shows the same problem I got when using the Module-installmethod - no star systems show up. The SpiralGalaxyWormholes.py freezes upon loading... :mad:
TC01 Aug 13, 2009, 04:32 PM Hmm. I had this issue when reverting to Final Frontier from Star Trek, I had to manually copy my code over.
Don't know what the problem is, though- but as a hunch, try using the Star Trek versions of the scripts (from the ST version linked in my sig).
If that doesn't work, I'll fix this myself by starting fresh in the MOO2Civ versions of the scripts.
JEELEN Aug 13, 2009, 04:59 PM Thanks - will try the ST versions first.
JEELEN Aug 13, 2009, 05:14 PM Wel, now both scripts get stuck on init... :(
TC01 Aug 13, 2009, 05:28 PM Wait- you say no star systems show up?
I think I may have the solution: You need these two XML features:
FEATURE_WORMHOLE
FEATURE_RED_WORMHOLE
You should just be able to use the XML module, which has them, their text, and their art.
apenpaap ran into this issue when I uploaded an older version of the module missing FEATURE_RED_WORMHOLE. The game tried to label every single plot with it's feature type and ran into some problems...
JEELEN Aug 13, 2009, 05:31 PM Makes sense... so how do I get 'em in? Simply copy another feature and replace the name with either feature?
TC01 Aug 13, 2009, 05:36 PM Makes sense... so how do I get 'em in? Simply copy another feature and replace the name with either feature?
Well, they should be in the modular XML in the modcomp. Assuming there are no schema changes to the CIV4FeatureInfos.xml and CIV4ArtDefines_Feature.xml files, the Wormholes modcomp (either version)'s XML modular stuff should work. (Modules\Wormholes)
If you want to move it out of a module and into the mod, you should probably add the features to the end of CIV4FeatureInfos.xml. Apparently deanej had issues when adding features to the top.
JEELEN Aug 13, 2009, 05:58 PM Thanks - I'll check. ;)
TC01 Aug 14, 2009, 05:27 PM Did it work?
I realized that you probably shouldn't use the Star Trek ones, since the Spiral Galaxy script is set to import the FinalFrontier mapscript normally, but the ST Spiral Galaxy imports the StarTrek mapscript.
JEELEN Aug 15, 2009, 12:01 AM Actually, no. Even with modular loading the mod still doesn't seem to get past initializing when selecting either mapscript. (If you like I can upload my current testversion for you to have a look at it.)
TC01 Aug 15, 2009, 09:58 AM Believe I fixed the problem.
If in your Pedia you don't see two features, Bajoran Wormhole and Jalbrador Wormhole you edited the wrong .ini file (I did this, because of the weird way I installed MOO2Civ I have two .inis, Patch 4i and Patch 4j, but my directory is still called Patch 4i).
Anyway, I messed up in adding stuff to the tutorial section of the Final Frontier Event Manager. Try downloading the zipped file below, dropping it into your Python folder (overwriting the existing one) and starting a game. Both scripts worked perfectly after fixing this.
JEELEN Aug 15, 2009, 10:39 AM Cool. Will check - if OK, I'll include it in patch4k to be released tonight.;)
JEELEN Aug 15, 2009, 10:56 AM Still getting stuck on init... I don't know what's wrong. If you want to have a look, here's the link to the working version of patch4k: http://www.2shared.com/file/7194533/138ee7b8/MOO2Civ_Patch4k.html
(It doesn't include the CvAI and CvfinalFrontierevents python files, just the 2 mapscripts.)
TC01 Aug 15, 2009, 01:07 PM Anyway, I fixed the problem. When I commented out the labeling code I got suns and planets, but no wormholes. So that meant that modular loading wasn't enabled. (this is the issue apenpaap ran into).
Which is because there are two .ini files, Patch 4i ini and Patch 4k ini. But since the directory is called MOO2Civ Patch4k, it reads from the Patch4k ini.
Upon enabling modular loading in both files, both scripts worked perfectly. (WSG takes a while to load but that's because Spiral Galaxy normally takes a while to load)
I've attached the modified MOO2Civ Patch4k directory (the files I modified in it, not the whole thing) In addition simply fixing everything, I added my changes from Wormholes v1.3, which I'm about to release. That adds a 3rd wormhole on Huge maps, and does a few other things that only apply to the Star Trek version.
JEELEN Aug 15, 2009, 01:35 PM Yes!:D The finally load OK. Looking great - especially the third wormhole. ;)
I do have a final suggestion for v 1.4 (or .5): would it be possible to unedit the names of the wormholes?:confused: (I appreciate it for Star Trek, but they aren't quite appropriate for a MoO setting.)
At any rate, I'll include it in the patch4k upload. Many thanks!:goodjob:
TC01 Aug 15, 2009, 01:40 PM You're welcome. :)
I do have a final suggestion for v 1.4 (or .5): would it be possible to unedit the names of the wormholes? (I appreciate it for Star Trek, but they aren't quite appropriate for a MoO setting.)
I can implement it as a custom map option (like Solar System Density, Feature Density, etc.), and move the code from the event manager to the Mapscript. That would probably be appropriate for Final Frontier as well.
Of course, you could change the names of the wormholes if you have a MoO-appropriate name in the XML files.
JEELEN Aug 15, 2009, 02:13 PM MoO wormholes don't really have any names, so I'll leave that to you.
I'm going to release the upload now. ;)
JEELEN Aug 15, 2009, 07:33 PM TC01, I've been playing the patch on IP connection using the Spiral Galaxy wormholes map, and we noticed a fake wormhole (see shot below). If the wormholes don't have names, it wouldn't have shown up. (As is, it's just a name sign with nothing underneath; so just a visual error.) Otherwise the map played fine and everything looked perfect.
TC01 Aug 15, 2009, 08:53 PM Hmm.
What size map was it? Did all the other wormholes appear? (i.e., if it was a Standard, Large, or Huge map did you find 2 Jalbador Wormholes?)
That isn't even a valid plot to place a wormhole, since it's one plot away from a Nebula.
JEELEN Aug 16, 2009, 01:54 AM Yeah, I noticed location was 1 square next to a Nebula. Size played was Large. We found 2 Wormhole couples; this is as should be on that size, no? (Jalbador and Bajor.) Need a WBS?
TC01 Aug 16, 2009, 09:03 AM Yeah, I noticed location was 1 square next to a Nebula. Size played was Large. We found 2 Wormhole couples; this is as should be on that size, no? (Jalbador and Bajor.) Need a WBS?
No- that's what it should have been. Weird. No idea how that's possible.
TC01 Aug 23, 2009, 02:27 PM I uploaded the three changed files in the first post. CvFinalFrontierEvents.py (removes labelling code) and the two mapscripts (add custom map options, fix bugs in
Wormholes.py).
For this version, I set the default to Labelling Off, but in the Star Trek one the default is Labelling On.
If you have any problems with it, let me know and I'll try to fix them.
JEELEN Aug 23, 2009, 03:07 PM Cool. I'll include them in the next patch. (I'll playtest 'em; I don't expect any problems though - the one MP non-wormhole hasn't recurred so far and no problems have been reported either.):goodjob:
And thx for the update promise - I appreciate that too. ;)
|
|