Python Modding

TC01

Deity
Joined
Jun 28, 2009
Messages
2,216
Location
Irregularly Online
Last Updated: 9/24/09

So I've been charged with writing the python code that is needed to make this mod work. So this thread is mainly so I don't clutter up the other one.

As I add to the code, I'm going to do it in the original Civ 4 python files (copied over, of course), rather than in the Final Frontier ones. This is mainly so I don't have to mess with the solar system code.

Currently, I've done/am working on:

Code:
-Make mapscript use planets instead of solar systems [COLOR="Red"][Complete][/COLOR]
-Adding python action buttons for "force powers" [COLOR="Red"][Complete][/COLOR]
-Limit building of specific units to specific planets [COLOR="Red"][Complete][/COLOR]
-Add an Ion Pulse python action button to certain fighter craft [COLOR="Red"][Complete][/COLOR]
-Add Superweapons, created by projects, with unique nuke abilities. [COLOR="Red"][Complete][/COLOR]
-Add Starbases from Final Frontier [COLOR="Red"][Complete][/COLOR]
-Make the Star Forge improvement provide units every turn randomly if you control it [COLOR="Red"][In progress][/COLOR]
-Fix any reported bugs

If someone has a request for what should go into the Star Wars mod python code, post here. I'll tell you if I can do it, if I need to post in the main C&C forum to get other opinions, on how to it, or if you need an SDK/DLL/C++ modder to get done what you want to do. And, if you have a bug in what I have written, post it here.

Below, in spoilers for size, is a list of everything that is referenced in Python that is coded in the XML. Mapscript stuff not included. If you have a question on what something there should do, please ask here.

Spoiler :
Units:

This is a nuke that has a special nuke ability.
UNIT_DEATH_STAR

Terrains:

This is space terrain.
TERRAIN_TUNDRA

Features:

Forest is asteroids (see Final Frontier), while Planet Core has no graphics but is important to the mapscript and random planets.
FEATURE_FOREST
FEATURE_PLANET_CORE

Promotions:

Force Ability Prereqs: These promotions form two chains, Light Side and Dark Side. Each should individually be available to a Unit Combat Jedi and Unit Combat Sith. Each ability is a requirement for a certain force ability- but this is handled in python. They should also decrease combat strength of their owners to balance force abilities.
PROMOTION_LIGHT_SIDE_1
PROMOTION_LIGHT_SIDE_2
PROMOTION_LIGHT_SIDE_3
PROMOTION_LIGHT_SIDE_4

PROMOTION_DARK_SIDE_1
PROMOTION_DARK_SIDE_2
PROMOTION_DARK_SIDE_3
PROMOTION_DARK_SIDE_4

PROMOTION_ION_BLAST

Force-Awarded Promotions: All of these promotions should not be awardable to any specific unit. They are all attached via force action abilities and removed on the next turn.

PROMOTION_BATTLE_MEDITATION
PROMOTION_ION_BLASTED
PROMOTION_MIND_TRICKED
PROMOTION_FORCE_CONCEALED

Buildings:

Planetary Buildings: Each is built via python and thus should be unbuildable, but should have a 100% chance to survive invasion. Specific units can be made the prereqs for individual worlds.
BUILDING_BALMORRA
BUILDING_FOEROST
BUILDING_FONDOR
BUILDING_MECHIS_III
BUILDING_MUSTAFAR
BUILDING_NELVAAN
BUILDING_ORD_CESTUS
BUILDING_QUEYTA
BUILDING_SALUECAMI
BUILDING_SKAKO
BUILDING_TAR_MORDEN
BUILDING_TELTI
BUILDING_VULPTER
BUILDING_XAGOBAH


Credits:
-TC01
-civ_editor11
-Jawa's Revenge
-God-Emperor
-The_J

Latest Version:
 

Attachments

  • Python.zip
    40.3 KB · Views: 224
So I've completed a basic version of the mapscript. It should NOT be used with Final Frontier python code. It should be used in default civ.

Features like black holes, supernovas, radiation clouds, asteroids are all in here.

I've renamed TERRAIN_TUNDRA, space terrain, to TERRAIN_SPACE. Further, all terrain used for the planets has been given the original name. So Grass, Plains, Burning Sands, Tundra, Snow, and Desert (four planet types for now) are in here.

There's currently a 1 in 10 chance of finding a habitable (Grass + Plains) planet. There's a 3 in 10 chance of finding either a volcanic, desert, or arctic planet. Or at least, theoretically it would work that way.

I have yet to do bug-testing. If you find any, please let me know and I'll fix them. It's attached below.

(Attachment removed, new files attached directly to first post)
 
Could you post the Death Star Python So that I can add it
The one on the other was planet core/edge
 
Could you post the Death Star Python So that I can add it

I said this in the other thread, but I'd prefer to add the python code to the files myself, and then attach them here for you to add into the mod.

So attached is a Python folder containing CvEventManager.py for the Star Wars mod. It's the original Event Manager file from normal Civ 4, with one change: the Death Star code has been added to onNukeExplosion(). Because that's the only python we have needed so far.

The Python folder should be copied into the Star Wars/Assets folder.

(Attachment removed, new files attached directly to first post)
 
This one is planet core/edge still
 
Thanks
and after that could you see if you could add force powers to the game as promotions
 
Updated version with the planetary stuff for Death Star straightened out.

Thanks
and after that could you see if you could add force powers to the game as promotions

Force powers?

Do you mean, that, if a unit had the promotion PROMOTION_FORCE_LIGHTNING, it would be able to, say, use force lightning on an opponent? I'm thinking the FFH spell system would be very useful for this. Unfortunately, that's custom DLL work.

I know you're away, but I'll start investigating what would be necessary to do this. Custom DLL work is tricky, and I'd rather get started now. I'd rather not use the entire FFH DLL, just what's necessary for the spell system to work.
 
Okay, so I think I can do the force powers by using python action buttons. The advantage of this is that a custom DLL is not necessary and it's slightly easier to code.

I think I can make this work instead of needing to use a custom DLL.

What kind of force powers do you want? Thus far I've added Force Lightning, Force Choke, and Force Push- all of which need promotions and promotion button graphics to work.
 
When I used your map script it takes a long time to load and then its just plains and rivers do you Know how to fix this
And the Death Star code doesn't work it just adds Fallout
 
When I used your map script it takes a long time to load and then its just plains and rivers do you Know how to fix this
And the Death Star code doesn't work it just adds Fallout

What are you calling the asteroid feature? You see, in Final Frontier it's "Forest", so that's what (out of habit) I used in the death star code. if you're calling it FEATURE_ASTEROIDS, then it won't find a FEATURE_FOREST and not set the plot to anything (so fallout will appear as by default). I'll fix this in the new version that I upload.

In fact, that may be the problem with the mapscript. In FF, features are called by their "original" Civ names (FEATURE_OASIS is the black hole, for instance). That's what the mapscript is supposed to deal with- and it's not finding those features so giving errors.

Just to check, are these terrains and features in your terrain and feature infos (for features, tell me which one it's called).

TERRAIN_GRASS
TERRAIN_PLAINS
TERRAIN_SNOW
TERRAIN_TUNDRA
TERRAIN_BURNING_SANDS
TERRAIN_DESERT
TERRAIN_SPACE

FEATURE_ASTEROIDS (or FEATURE_FOREST)
FEATURE_NEBULA (or FEATURE_ICE)
FEATURE_BLACK_HOLE (or FEATURE_OASIS)
FEATURE_SUPERNOVA (or FEATURE_JUNGLE)
FEATURE_GRAV_FIELD
FEATURE_DAMAGE_ZONE
FEATURE_FALLOUT (radiation cloud)
FEATURE_FLOOD_PLAINS

If you don't, copy the Grav Field, Damage Zone, and Flood Plains feature infos from the Final Frontier CIV4FeatureInfos.xml, as well as their art defines from CIV4ArtDefines_Feature.xml in that same folder. These are "fake features"- they are used to prevent other features from being placed too close, or to damage units when they get near features (supernova), or to pull them in closer (black hole).
 
What would space be I have Tundra set as space but called tundra
I don't have grav-field
Damage Zone
I used bts feature and terrain infos
Basically I've been building it off of bts and adding in final frontier where I need it
 
Please copy over the Final Frontier feature info file, but delete Solar System from the top of it since we're not using those. This has all of the feature infos for a space terrain map. With the same names that are used in the mapscript.


Other than that, you should be good with features and terrains, but there are some bugs I've found and will solve before reuploading.

Sorry about this, but as I have no real way to test, there will probably be plenty of bugs...
 
One of the main problems in my code was that I was using the "set plot feature" command for terrains... I've fixed this.

I've attached a revised mapscript to the first post. Please test it without waiting for the other stuff- but make sure you did the copying of the Final Frontier FeatureInfos and ArtDefines_Features over first.
 
Where's the Event Manager code for the death star
 
Where's the Event Manager code for the death star

It's zipped in, along with an XML file containing the Force Power button descriptions (drop it in Star Wars\Assets\XML\Text), and the Force Powers code, in the first post. However, if you don't have the 8 force promotions and the 12 buttons that I said were needed in the Graphics thread, you can not test that stuff yet.
 
Thanks this is great I'll check it soon my bts isn't currently workig so I have to try and fix that
 
I've fixed my bts but neither one is working do you know what is wrong
Do I need to rename TERRAIN_TUNDRA as TERRAIN_SPACE?
Am i doing something wrong or is it the programming I'm looking at it don't completely understand it but it looks like it should be working
 
I've fixed my bts but neither one is working do you know what is wrong
Do I need to rename TERRAIN_TUNDRA as TERRAIN_SPACE?
Am i doing something wrong or is it the programming I'm looking at it don't completely understand it but it looks like it should be working

What are your errors? The same as before? Or does the mapscript simply not load?

Did you copy Final Frontier's CIV4FeatureInfos.xml into the Star Wars\Assets\XML\Terrain folder?

You shouldn't have to rename TERRAIN_TUNDRA. Do you have the other terrains?
 
Yes to everything

The mapscript adds plains and rivers and it also has the ice polar caps

The Death Star Code makes it fallout exactly like a regular ICBM
 
Top Bottom