Python events for spreading organic resources, how?

zenspiderz

Just some bloke..
Joined
Apr 10, 2006
Messages
1,496
Basically i want to make a mod for an earth map where certain organic resources such as corn, rice, and especially horses start out in their historical origins but with trade routes spread to other areas. So for example horses are not present in the new world but then when new world civs form trade routes with old world civs there becomes a chance that horses will appear in the new world.

The condition for triggering the event would be a trade route with a civ that has the resource assuming the affected civ doesn't already have the resource. With maybe an additional probability of event occuring if the horse civ is already trading the resource to the horseless civ.

Any clues how i could do this? Or better yet is there some code out there that already does something like this that i could modify?
 
So what no one has any clue how to do this? :confused:
seems to me this is the one feature civ desperately lacks, surely someone has done some kind of code that does this or similar?
 
The part I don't know is how to see which cities there are trade routes to. I suppose if you just consider who you have open borders with and which resources they have it may be reasonable to code. Actually I don't even see how to determine which resources they have available.. maybe by looking in the trade adviser code there are clues how to do this?

Anyway.. sorry, I don't know enough :/ I'd guess it can be done, someone just needs to discover the details.

My approach would probably be based on culture though. For example Germans migrate to Milwaukee and start up breweries, or Frenchmen migrate to Napa Valley and open wineries.
 
OK i managed to bodge together an event that does almost what i wanted just using xml. Basically the trigger is a harbour and a plot suitable for recieving the bonus in the players territory. Not exactly what i wanted but close enough. it does spread resources but trade routes or even contact with a civ that has the resource isn't a condition.

Perhaps later i can change it with some fancy python gubbins to behave more how i want it to.
 
Notes on fancy python gubbins.

OK i have had some thoughts on how python could be used to make this event better. Just the logic of how the process would work; i am not yet knowledgable enough to actually write this as working code.

The event trigger would call a python function called canSpreadResource or whatever...

this function would first check to see if the civ has the particular resource anywhere in its territory, if so it returns false (meaning the event won't trigger).
If the resource is not there then it will loop through all the other civs and check which ones do have the resource in their box. If none have it then it returns false.
If some do have it then each one is looped through to check if they can trade with the event triggering civ. If none can then it returns false. If at least one can then the event will return true and the event can trigger.

Alternatively the function could do this..

Function first checks to see if civ does not have resource in its borders as the previous example.

If not present it checks to see if the resource is present to the civ as a trade. If present then it returns true and event can trigger.

Could anyone write python code that does this? Or shall i just wait until i have enough knowledge to do it myself?
 
It's an interesting idea.
Another idea is the give workers the ability to create some resources, like wheat or pigs or whatever, once a civ has access to that resource (either themselves or through trade). I'm just starting to get the hang of python so it might be beyond me but I'll see what I can do.
Learning some python might be a good idea for you though, it opens up a lot of possibilities. I just started learning a little while ago because I just couldn't find anything someone else had done to get the effect I was after. (I made religion founding a random event rather than being tied to the tech tree, because honestly how often does a government deliberately try to found a new religion.)
 
Yeah that is a nice idea too. Should be a long work time for game balance tho. Might be a good idea if some tech requirements are needed to enable that worker action. So for example you might need 'biology' or 'genetics' in order to be able to build organic bonuses.

I will, time permitting, try and learn python and C++ too so i can change the sdk. I have so many good ideas like this and no way to implement it which is very frustrating. Would be great to able to just write the code i wanted and tweak it this way and that.
 
Top Bottom