• Our friends from AlphaCentauri2.info are in need of technical assistance. If you have experience with the LAMP stack and some hours to spare, please help them out and post here.

Historical events coding help

stolenrays

Deity
Joined
Aug 2, 2009
Messages
2,063
OK so apparently I put a question in the tutorial forum. Sorry for that. I'm trying to create 2 types of historical events with python/XML and slightly have a clue how to do it based on some of the tutorials, but not really. I can create events via XML only.

I'm trying to create an event for my Iran Iraq war mod where one specific civ declares war on another at a certain turn.

The other type of event is for the capture of a specific city by a specific civ and even in a possible turn range. I guess this is kind of a quest.
 
You need to know Python programming in order to do these things. On the other hand, you don't have to use the random events interface, at all. But if you already know how to trigger events via this built-in system, then you still need to script the effects you're after in Python. So I guess you could use it then?

The requests themselves aren't very complicated to script, thankfully. So if you get the XML portion of the events in order someone (me?) could be able make them for you.
 
Well there are 6 events and I've included them in a word doc for clarity sake. They are all normal events, not quests, that have to do with capturing a city by a certain civ and one declaration of war. Only one needs to occur at a certain date and that is the declaration of war. Two events are connected where one is the caputure of the city and the other event is the liberation of the city.

If you need more info or files let me know. I thought that since they are about specific cities, you'd need to know coordinates of cities. For that reason I've included the worldbuilder file.

Wow, if you can do this you are tons of help. It is nice to know there is so much help on this board. :thanx:
 
Ok, so there are 6 events. What events are the incomplete ones, the ones that you need help with?

I can't seem to be able to extract the .doc file - what was it good for? Can you simply post the contents here?

If you enable cheat mode you can view map tile coordinates in-game. Look it up!

Also, can you pass me the link to the random events tutorial, because I've never made one myself.
 
Here is what was in the document:
Spoiler :
1. Anytime-EVENT_ABADAN
a. Capture of city Abadan, Iran by Iraq.
2. Anytime-EVENT_KHOR
a. Capture of Kermanshah, Iran by Iraq.
3. After EVENT_KHOR--EVENT_LOK
a. Liberation of Kermanshah, Iran in Iraq hands by Iran.
b. Requires EVENT_KHOR
4. Anytime-EVENT_BASRA
a. Iran captures Basra, Iraq from Iraq
5. Anytime-EVENT_KIRK
a. Kirkuk, Iraq conquered by Iran then receives Kurdish Rebels.
6. June , 1982-EVENT_ISRAELDOW
a. Israel declares war on Lebanon.


The incomplete ones are all six since I believe they all require python coding to specify the date, city coordinates, and civilization. My triggers and events should be fine, they just need to be linked to python script.

Link to non-random events: http://forums.civfanatics.com/showthread.php?t=230567
Another tutorial: http://forums.civfanatics.com/showthread.php?t=268759
These are for non-random events since (is that what you meant) since the events should always occur.

I'll take a look at the coordinates shortly.
 
Thanks, I think I need the historical date expressed as a turn number.
 
Thanks, I think I need the historical date expressed as a turn number.

City coordinates:
Spoiler :
Abadan 42, 15
Al Basrah 40, 15
Kirkuk 33, 31
Khermanshah 40, 28


Turn starts out at turn 8 (Sept, 1980), 22 turns later is the declaration of war which would be turn 30 for June, 1982 I believe.
 
Thanks, I'll look into it once I get the chance.

edit: A reminder now and then probably wouldn't hurt. ;)
 
I found this code in another thread to trigger an event at a certain date to just see if I could do it. The event triggers, but right off the bat and I believe for another civ. I of course changed the civlization, trigger name, and turn name.

http://forums.civfanatics.com/showthread.php?t=269280&page=2

Spoiler :
######## Destroyers4Bases (English event) #########

def canTriggerDestroyers4Bases(argsList):
kTriggeredData = argsList[0]
player = gc.getPlayer(kTriggeredData.ePlayer)

if (player.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_ENGLAND")):
game = gc.getGame()

if (game.getGameTurn() == 32):
return true
return false

return false
 
Well, I figured out how to code the events where a city is taken over by another country I believe. I haven't tried it out with other civs attacking the city though to make sure that it really is civ specific.

Spoiler :
def canTriggerAbadan(argsList):
kTriggeredData = argsList[0]
player = gc.getPlayer(kTriggeredData.ePlayer)

if kTriggeredData.ePlayer != 0:
return false

if gc.getMap().plot(42,15).getPlotCity().getOwner() != 1:
return false

return true
 
Play around with the code, then. Ask if you need help with something specific.

Know that there are no one correct solution to any programming task. The important thing is to be able to define very exactly what you need.
 
Try to get the scripts actually working, and once we figure out the ones that you may or may not get done yourself can we tackle the DOW event thing. Its a bit tricky but consider it done.
 
How is it going? :)
 
I've created around 18 events. They all work fine. They are mostly dependant on some sort of combination requiring ownership of cities, a specific civilization, or a turn. Just the DOW is beyond me right now. Just a few more tweaks and my mod update should be done.

THe only other thing is that since my mod is about a specific war, most events revolve around the opponent still being a civilization when the event triggers. I'm not sure how to code that in pythong, but it is probably somewhat like this:

if (player.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_IRAQ")):
 
Good to hear about your success.
if (player.getCivilizationType() == gc.getInfoTypeForString("CIVILIZATION_IRAQ")):
Looks fine to me. But as a footnote, you can lose the parenthesis around the boolean expression. Because they add nothing to the conditional statement.

Also, since you're making a scenario the PlayerTypes will always match. So you could just use CyPlayer.getID() and refer to integer IDs instead. Like Iraq is always player 0, Iran is always player 1, and so forth.
 
That code actually worked to specify that the event occurs only for a specific civilization. I figure though the code is similar to it to specify that another civ also still exists on the map. I just don't know how to code it. I'll try to look at some mods to see.

You are right about the playerID though, I have another code similar to that. Just like you said, multiple ways to do the same thing.
 
That code actually worked to specify that the event occurs only for a specific civilization. I figure though the code is similar to it to specify that another civ also still exists on the map. I just don't know how to code it. I'll try to look at some mods to see.
I afraid I don't understand what you're talking about. I might be able to help out if I only knew what you need.
 
Basically I need the event to be triggered for say the Soviets so that some benefit for them will occur. But it must also be triggered, contingent on that another civilization, the Afghans, are still present on the map and not destroyed already.

The event is about giving experience points to soviet air units that they started using in the 80's in response to the Afghans using SAMs more. The event just wouldn't be appropriate if the Afghans had already been destroyed.

If that is not possible I could prob just add a string about if a player owns a specific city still. I know how to do that much.
 
Back
Top Bottom