ModModder's Guide

ok, now you can via modules overwrite existing spells and prereqs ... (( theoretically, idk whether it works :D ))
 
Quote:
Originally Posted by Billyank
so i noticed that a lot of the python code has been written differently, and i was wondering what the implications of this were (if there were any) such as, can i just keep writing code the way it used to be done, or am i going to have to relearn it?

Also, im a little unsure how modular python works, could someone explain this?
If you mean the dicts... That's just a performance thing, the old method still works fine.

As for MPL... It's not too complex, and there are good examples in the Mekara module. For each file, you need a few specific lines (Which ones depend on the file type (Spell, Event, Utils, RandomEvent); Check the very top of the base file, lines such as those in the code block below should be included), and then the functions.

For Spells and RandomEvent, your functions are simple, exactly the same as you'd add a new function to the base files. Nothing new.

For Event and Utils, it's a bit different, as you don't define new functions but modify existing ones. To do this, though, you simply clone the function header (ex: def cannotTrain(self,argsList): , and then whatever variable definitions below it you happen to need), and then add code as normal. Again, not really difficult.

Code:
from CvPythonExtensions import *
import PyHelpers
import CvEventInterface
import CvUtil


so... i tried all this, and it still didn't work, and then after a fresh install of 1.3, i decided to try the maogata and mekara and found that their python stuff wasn't working either. :confused:

EDIT: never mind, working now
 
While we are at python. I wanted to make a function that kills the unit in question when trigered.

I came up with this.
Code:
def postCombat_Ability_PPQ(pCaster):
	pCaster.kill(True, 0)
But it does not work. Am I missing something?

My entire file looks like this:
Code:
from CvPythonExtensions import *
from BasicFunctions import *
import PyHelpers

PyPlayer = PyHelpers.PyPlayer
gc = CyGlobalContext()

def postCombat_Ability_PPQ(pCaster):
	pCaster.kill(True, 0)
File name is spellPPQ.py

I thought python was modular. What am I doing wrong?
Do I need to edit some other file as well?
 
how can i differ between a summoned tiger (e.g. tiger from priest of leave) and a "normal" tiger captured with a hunter from the wild with python?

i'd like to do some stuff if i kill an animal but i dont want this effect if it's just a summoned unit.
 
how can i differ between a summoned tiger (e.g. tiger from priest of leave) and a "normal" tiger captured with a hunter from the wild with python?

i'd like to do some stuff if i kill an animal but i dont want this effect if it's just a summoned unit.

Check if the unit has a master.

Code:
tigerUnit.getMasterUnit().isNone()

True if the unit isn't summoned.

edit:
Actually, if the unit is summoned, but the master unit was killed, this will be incorrect. Such a unit will have tigerUnit.isMustDie() True. The unit will be killed soon anyway and none as far as I can tell no one bothers to check for that. Reference
 
getMasterUnit was exactly what i was searching for. thx

is there some sort of api for rife out there?




and what's with the isDelayedDeath() command? can i use it for this check?
 
This is kind of a stupid question, but I'm new to modding modmodding and playing with XML in general, so I was wondering if everyone typically used notepad or if there are decent free XML editors out there.
 
While we are at python. I wanted to make a function that kills the unit in question when trigered.

I came up with this.
Code:
def postCombat_Ability_PPQ(pCaster):
	pCaster.kill(True, 0)
But it does not work. Am I missing something?

My entire file looks like this:
Code:
from CvPythonExtensions import *
from BasicFunctions import *
import PyHelpers

PyPlayer = PyHelpers.PyPlayer
gc = CyGlobalContext()

def postCombat_Ability_PPQ(pCaster):
	pCaster.kill(True, 0)
File name is spellPPQ.py

I thought python was modular. What am I doing wrong?
Do I need to edit some other file as well?

That python should work. The file is in YOURMODULE/python, right? spellPPQ.py is named correctly, at the very least... Hmm.

getMasterUnit was exactly what i was searching for. thx

is there some sort of api for rife out there?




and what's with the isDelayedDeath() command? can i use it for this check?

Eh.... Not really an api, but if you open up the C++ files (which aren't available atm, sorry! Will be as soon as 1.31 is out!), all the files beginning with 'Cy' are for python, and determine what commands are accessible.

This is kind of a stupid question, but I'm new to modding modmodding and playing with XML in general, so I was wondering if everyone typically used notepad or if there are decent free XML editors out there.

I use Notepad++.
 
That python should work. The file is in YOURMODULE/python, right? spellPPQ.py is named correctly, at the very least... Hmm.

Yes, the path is PPQ\Python\spellPPQ.py

The promotion has the line:
<PythonPostCombatWon>postCombat_Ability_PPQ(pCaster)</PythonPostCombatWon>


But I still can't get it to work at all.
 
That did the job thanks.
I honestly had no idea that casing mattered with the folders.

BTW. Could someone take a look at a unit that is causing me problems? I made it from copy paste parts but newer had problems with it before. (will also serve as a small spoiler for what is to come)


It is giving me the classic No pedia entry + crash on unit created via worldbuilder thing.
What could be causing this thing?


PS. I feel bad about asking so many questions and I feel like I am exploiting you people. Sorry if I am trouble.


PPS. About leaders, what exactly is the difference between major (2 traits) and Minor (2 traits again in most cases)?
 
That did the job thanks.
I honestly had no idea that casing mattered with the folders.

BTW. Could someone take a look at a unit that is causing me problems? I made it from copy paste parts but newer had problems with it before. (will also serve as a small spoiler for what is to come)


It is giving me the classic No pedia entry + crash on unit created via worldbuilder thing.
What could be causing this thing?


PS. I feel bad about asking so many questions and I feel like I am exploiting you people. Sorry if I am trouble.


PPS. About leaders, what exactly is the difference between major (2 traits) and Minor (2 traits again in most cases)?

I'm going to ask anw to try and remove the case requirement.

On the unit: The art looks fine. A crash of that nature is generally an xml error (the unit artdefine); Post your xml?

I don't mind answering questions at all. :goodjob:

On leaders: Currently, none. After 1.4, large ones. :mischief:
 
Thanks, here is the XML.
Code:
		<UnitArtInfo>
			<Type>ART_DEF_UNIT_PPQ_ADEPT</Type>
			<Button>Art\Interface\Buttons\Units\Adept.dds</Button>
			<fScale>0.44</fScale>
			<fInterfaceScale>1</fInterfaceScale>
			<bActAsLand>0</bActAsLand>
			<bActAsAir>0</bActAsAir>
			<NIF>Modules/NormalModules/PPQ/Art/Units/Civs/PPQ/Arcane/Mage/grenadier.nif</NIF>
			<KFM>Modules/NormalModules/PPQ/Art/Units/Civs/PPQ/Arcane/Mage/grenadier.kfm</KFM>
			<ShadowDef>
				<ShadowNIF>Art\Units\01_UnitShadows\UnitShadow.nif</ShadowNIF>
				<ShadowAttachNode>BIP Pelvis</ShadowAttachNode>
				<fShadowScale>1</fShadowScale>
			</ShadowDef>
				<fBattleDistance>0.35</fBattleDistance>
				<fRangedDeathTime>0.31</fRangedDeathTime>
				<bActAsRanged>0</bActAsRanged>
				<TrainSound>AS2D_UNIT_BUILD_UNIT</TrainSound>
			<AudioRunSounds>
				<AudioRunTypeLoop/>
				<AudioRunTypeEnd/>
			</AudioRunSounds>
		</UnitArtInfo>
It's an indentical copy of UNIT_ART_DEFINE_ADEPT but with the .nif and .kfm file swaped out for my own.
 
this is probably very easy but how do you limit how many times you can build a unit via XML
i.e. make it a national unit
thanks in advance
 
Top Bottom