View Full Version : Everything Python and SDK related


TheLopez
Jun 14, 2006, 06:24 AM
I am starting this thread to provide a place to discuss the different Python and SDK needs for the WH mod.

From my discussion with Ploep it is my understanding that we need to identify which existing components need to be included, for the ones that need to be included what WH customizations are needed and identify what new code is needed.

TheLopez
Jun 14, 2006, 06:45 AM
reserved reserved reserved reserved

TheLopez
Jun 14, 2006, 06:47 AM
reserved reserved reserved reserved

reserved reserved reserved reserved

TheLopez
Jun 14, 2006, 06:47 AM
reserved reserved reserved reserved

reserved reserved reserved reserved

reserved reserved reserved reserved

woodelf
Jun 14, 2006, 07:14 AM
I would hope a lot of your work will already be included. :D

Ploeperpengel
Jun 14, 2006, 07:25 AM
Ok I think I can spam now:D

These are components that'll be nice:

For the next patch:
mercsmod updated
Greatgeneral Amped

After that comes the long read of my suggestions(first I have to say I don't know anything about python or the SDK so be patient with me):

starting again with the mercmod:

I'd like only specific units available namely what's called the dogs of war in WH-World: Who are they? you can read here(units we don't have art for we can use placeholders for):
http://uk.games-workshop.com/dogsofwar/
This could even affect the civs differently:
http://uk.games-workshop.com/dogsofwar/including/1/

So what would have to be done is create a separate list of units für the different civs which units they can hire from another(elves won't hire orcs i.e- except Darkelves of course)

The GreatGeneralsmod(amped):
should of course not produce Names like Adolf Hitler instead it might be combinated with the renamermod to pruduce Fantasylikenames(eventually even possible with different styles for the civs again?)
Example names are found here:
http://forums.civfanatics.com/showpost.php?p=3862323&postcount=175

I definitly like the pirates and the water animals mod! I don't think they would be changed much(maybe just some unitstats for balancing). The pirates mod could be combined with the unique babarians(Yes that's what norse are unfamous for- raiding the coasts!)

A civspecific Immegrationmod!(Elves won't emigrate to orcs and vice versa, but dwarfs to Humans is possible i.e., goblins to chaosdwarfs - searching for better fortune than starving - or vice versa - fleeing slavery - is perfect)

The Mad nukes I absolutly fell in love with! I think it would be easy to modify it to a kind of armageddon spell;)

The random unit names would be nice also. I didn't test that yet but like the idea.

the sniper mod could maybe also be useful converted to spell casting.

The Great doctor mod could be interesting for civs who have a flavor for healing art(obviously not undead but again elves for sure)

Ok I think this is enough work for the first day in our forum, Lopez:p

What do you think about it?

Ploeperpengel
Jun 14, 2006, 08:03 AM
I think Lord Olleus will start that thread as soon his pc is working again. He's been working on spells along with psycholgy scripts. Which aren't implemented in the mod yet. You two should coordinate about that. Maybe you can help each other with all this.

TheLopez
Jun 14, 2006, 08:11 AM
I think Lord Olleus will start that thread as soon his pc is working again. He's been working on spells along with psycholgy scripts. Which aren't implemented in the mod yet. You two should coordinate about that. Maybe you can help each other with all this.

Well I'll let him lead since:
Lord Olleus-Leadprogrammer, Python, Xml

Ploeperpengel
Jun 14, 2006, 08:14 AM
I'm not totally against anarchism if it leads to creativity;) Do as you two like best.

Ploeperpengel
Jun 14, 2006, 08:27 AM
One more:

We definitly need the Flying mod for Dragons, Griffons and the like:
http://forums.civfanatics.com/showthread.php?t=171813

Lord Olleus
Jun 14, 2006, 12:26 PM
Right, I have started another thread which will, hopefully, become a list of everything that needs to be done. By having that on its own, it should make it easier for us to organise things. This thread should simply be for solving problems which come up when we try to actualy program it. Did that make sence?

This is how I think spells should work

3 new SDK missions are made:

castRangeSpell()
castSummoningSpell()
castSelfSpell()


A wizard can carry spell books who have a UNITCOMBAT_ respective of the list above.


If a wizard is carrying a book, then the he is able to use the respective mission.


The specifics of the spells are not in the SDK, but in python. The new missions are simply used as call points for casting spells and as a way of sending data to the python (spell book name, CyUnit, CyPlot, ect...). castRangeSpell() should let the player select a square in much the same way as it does for bombers.


One possible problem is what happens when a wizard carries 2 books of the same UNICOMBAT_. Can the same mission appear twice on the user interface?

I am writing as I am thinking so forgive me if this makes no sence at all.

PS: How do you do nested lists in this forum?

Ploeperpengel
Jun 14, 2006, 12:43 PM
Yes it does. Sorry just thought you didn't see this thread before you posted I think I'm just a litlle too enthusiastic cause of the the new wonderful conditions we have here. I just wright while I think either. And not having slept yet adds to the chaotic outcome. Don't worry I will hold back myself in the future if it involves python and SDK you two are here to fight with the coding and organize to your needs. I just will post ideas refering to design as anyone can and should do here.

Btw: I think someone should give a brief tutorial here how to use the forum efficiently(polls, spoilers and anything else that might be useful cause I still can't figure that out and especially the unitdesign will be unreadable without spoilers I fear)

TheLopez
Jun 14, 2006, 07:03 PM
Sorry about my absense all day, well most of my afternoon. Anyways, I wanted to throw this one in the mix. Would you guys be interested in show casing my next mod comp: Dynasty Mod?

It adds the regicide victory option, two mods of it: Single leader elimination and dynastic elimination (you need to kill off all of the members of the family instead of just the one leader). Which brings up another new feature leader/nobility points. They are kinda like great person points except for after a threshold you get a new leader/noble that you can marry off to increase relations, if the second regicide mode is active then one of the spawned nobles/leaders would take over if the main leader is killed off, etc.

What do you guys think?

EDIT: Ploep, I'll answer your questions more in depth tomorrow morning. I need to get some food right now and some sleep.

Lord Olleus
Jun 15, 2006, 12:24 AM
Sounds like a good idea. Not sure if it really fits in with the warhammer world though. Orcs do not have an organised dynasty.

Ploeperpengel
Jun 15, 2006, 03:17 AM
I was hoping for regicide options too, yes we need something like that cause I want to make Units that represent the Leaders(they should be the most interesting units since we would'nt have to care much about the polycount) but as Olleus said it would be better fitting just with one Leader for WH:)

Edit:
Your techconquestmod would be cool too->chances for the warmongers like orcs to get some advance too

Duke van Frost
Jun 16, 2006, 12:12 PM
Sorry about my absense all day, well most of my afternoon. Anyways, I wanted to throw this one in the mix. Would you guys be interested in show casing my next mod comp: Dynasty Mod?

It adds the regicide victory option, two mods of it: Single leader elimination and dynastic elimination (you need to kill off all of the members of the family instead of just the one leader). Which brings up another new feature leader/nobility points. They are kinda like great person points except for after a threshold you get a new leader/noble that you can marry off to increase relations, if the second regicide mode is active then one of the spawned nobles/leaders would take over if the main leader is killed off, etc.

What do you guys think?

EDIT: Ploep, I'll answer your questions more in depth tomorrow morning. I need to get some food right now and some sleep.

I´m really not sure about that, because I think Leaders are very strong units and I would like to have them to be build during the game, not being available from the start (but maybe something like in the Sengoku scenario for civ3 would also be good for leaders - relatively weak start, but getting very powerfull over the time - maybe with those "boosting techs" like heavy armour etc. JP thought about).

But I can definitely see some good scenarios coming from the dynasty mod for Warhammer.

Psychic_Llamas
Jun 17, 2006, 08:40 AM
how about giving the leaders a Hero-like promotion which slowly gives them XP like in FfH?

Civmansam
Jun 17, 2006, 04:37 PM
Lord Olleus, when you've got the basic C++ for the spells done and the base python, send me what you have. I'm not as good as you or TheLopez (Actually I'm not even near you guys) but I can do pretty simple things and might be able to take some load of you guys.

Lord Olleus
Jun 19, 2006, 10:06 AM
When I play to do is to create a new python call in CvEventManager.py called onSpellCast(). It will look a bit like this:


onSpellCast():
szSpellName = argsList[0] #Name of the spell cast
pUnit = argsList[1] #Unit which cast the spell
pPlayer = argsList[2] #Player who cast the spell
pPlot = argsList[3] #Plot on which pUnit is


So you can just start coding the individual spells, although it might be hard as you can not test them yet.

TheLopez
Jun 19, 2006, 11:17 AM
When I play to do is to create a new python call in CvEventManager.py called onSpellCast(). It will look a bit like this:


onSpellCast():
szSpellName = argsList[0] #Name of the spell cast
pUnit = argsList[1] #Unit which cast the spell
pPlayer = argsList[2] #Player who cast the spell
pPlot = argsList[3] #Plot on which pUnit is


So you can just start coding the individual spells, although it might be hard as you can not test them yet.

Lord Olleus,

A couple of things, in the arg list you might also want to either include the targetted unit or plot of the spell.

You might want to create a second spell event called onBeforeSpellCast allowing for units with higher initiative (yes, that is D&D speak...) to react to the spell casting. Personally I think it will provide more flexability down the road, but then of course this is just opinion.

Lord Olleus
Jun 19, 2006, 11:48 AM
Actualy, I decided to change the spell system. Having different kinds of spells made things needlessly complicated. I thought that it would be easier to have just 1 event for all the spells and then use python to select a square, which I believe has already been done.

Psychic_Llamas
Jun 20, 2006, 03:03 AM
could just steal the FfH spell system...

Duke van Frost
Jun 20, 2006, 03:11 AM
No, no, no. We´ll have one of our own. We´re not just a clone of FfH, we´ll get some things even better, I think.

Psychic_Llamas
Jun 20, 2006, 03:17 AM
lol, yeh your right;)

Ploeperpengel
Jun 20, 2006, 09:53 AM
Not sure if it will be better. FFH is really good! But WH-Magic is what we focus on and so it will certainly have to be different and as close to WH-Gamerules as possible.

Lord Olleus
Jun 20, 2006, 09:57 AM
an improvement from the system I posted earlier. If the function returns true, then you will get to select a square. If you return False, you can cast a spell as normal.

Kael
Jun 20, 2006, 10:36 PM
Ploeperpengel requested the python for the Homeland trait in case you guys would like to do something similar. In FfH the trait gives all your units a slight strength bonus is they are in a plot they control.

The way this works is there is a Homeland promotion that gives the iCombat adjustment (you could of course have it do whatever you would prefer). Then all you need is a small python routine in onUNitMove int he CvEventManager.py as follows:


pUnit.setHasPromotion(gc.getInfoTypeForString('PRO MOTION_HOMELAND'), False)
if pPlot.isOwned():
if (pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_D EFENDER')) and pPlot.getOwner() == pUnit.getOwner()):
if (pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_MELEE') or pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_RECON') or pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_ARCHER') or pUnit.getUnitCombatType() == gc.getInfoTypeForString('UNITCOMBAT_MOUNTED')):
pUnit.setHasPromotion(gc.getInfoTypeForString('PRO MOTION_HOMELAND'), True)


Let me know if you have any quesitons about the code, it basically if the player has the homeland trait it checks the plot the units moves into to see if it is owned by the same player that owns the unit. If it does the homeland promotion is added.

Similar code could be added to grant promotions if a unit is in forest, in a city, within 3 spaces of a general, whatever you want.

Kael
Jun 21, 2006, 07:40 AM
Ploeperpengel requested the python for the Hidden, Barbarian, Scorched Earth and Raiders traits.

Hidden isn't implemented yet, it doesn't currently do anything.

Barbarian is implemented by including the following in the onGameStart function in CvEventManager.py:


if player.hasTrait(gc.getInfoTypeForString('TRAIT_BAR BARIAN')):
eTeam = gc.getTeam(player.getTeam())
iTeam = gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam()
eTeam.makePeace(iTeam)


Scorched Earth is an SDK only change (change in the city capture code that forces the raze).

Raiders is a mix of an SDK change (do modify the amount of gold gained by pillaging) and a python change to grant an extra experience point after each successful combat. The following goes in onCombatResult in CvEventManager.py to accompolish it:


if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_RA IDERS')):
pWinner.changeExperience(1, -1)

Ploeperpengel
Jun 21, 2006, 07:46 AM
Thx Kael! That will help I think.:)

Ploeperpengel
Jun 21, 2006, 10:06 PM
@Olleus and theLopez
The traits Barbarian and Raiders I'd like to have combined(renamed the trait to Trait_Barbarian_Raiders) for the greenskins. The additional features for them: minus warwearyness and +1extrahealth if multiple meadresources are available should be added to it.

Here's the current traitinfo:
Please also check in the additional +1food on foresttile for trait_friendsofthewood(the current healthbonus is irrelevant).
and Homeland to the trait_defender

Lord Olleus
Jul 01, 2006, 12:04 PM
I have finished making the magic mod but I currently have no AI for it, and don't really know how to do this. TGA, theLopez if you read this please help me. Right now the plan is this:

1) Have a new UNIT_AI called WIZARD

2) All the spells have a 'strengh' tag, and the spell the wizard casts is random, but weight towards spells with higher strenghts.

3) The AI checks every plot in which the spell can be cast and chooses the best one (depending on whether the spell is an attack spell, a collateral spell, a heal spell, ect...)

4) If there are no 'decent' places to cast a spell the wizard moves to a better place.


This will, obviously, produce a rather bad AI. 2 and 3 could be merged so that it checks every plot for every spell, and then chooses the best spell to cast. I have no idea on how to make step 4. Should I just copy the UNITAI_ATTACK and UNITAI_DEFENCE?

Psychic_Llamas
Jul 01, 2006, 08:19 PM
when you say "the spell the wizard casts is random" does that include the player? i sure hope not, because that would detract a huge part of the strategy in the mod.

Lord Olleus
Jul 02, 2006, 03:22 AM
No, the player which choose which spell he casts and where. This is onlyconcerning the AI.

Psychic_Llamas
Jul 02, 2006, 04:21 AM
oh. well thats ok then:D