Milaga
Prince
- Joined
- Jan 19, 2008
- Messages
- 470
I will be constructing this post over the next few days.
Can't wait!
Hint hint.
I will be constructing this post over the next few days.
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
def postCombat_Ability_PPQ(pCaster):
pCaster.kill(True, 0)
from CvPythonExtensions import *
from BasicFunctions import *
import PyHelpers
PyPlayer = PyHelpers.PyPlayer
gc = CyGlobalContext()
def postCombat_Ability_PPQ(pCaster):
pCaster.kill(True, 0)
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.
tigerUnit.getMasterUnit().isNone()
i'm using notepad++ for xml, and i think that most of team uses it
(( www.notepad-plus-plus.org ))
While we are at python. I wanted to make a function that kills the unit in question when trigered.
I came up with this.
But it does not work. Am I missing something?Code:def postCombat_Ability_PPQ(pCaster): pCaster.kill(True, 0)
My entire file looks like this:
File name is spellPPQ.pyCode:from CvPythonExtensions import * from BasicFunctions import * import PyHelpers PyPlayer = PyHelpers.PyPlayer gc = CyGlobalContext() def postCombat_Ability_PPQ(pCaster): pCaster.kill(True, 0)
I thought python was modular. What am I doing wrong?
Do I need to edit some other file as well?
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.
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)?
<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>
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