Alliances in python?

The_J

Say No 2 Net Validations
Administrator
Supporter
Joined
Oct 22, 2008
Messages
39,634
Location
DE/NL/FR
Hi guys :).

You see the question: Can alliances be done in python?
Maybe i'm to stupid and just can't find it, but i've looked into the API, and i can't see a function to create an alliance or to change the team of a player in the classes CyPlayer, CyTeam, CyGame or CyDiplomacy.

Am i missing something, or is there no way?


I hope, somebody has the answer :).
J
 
If you want, you can use Python to create a Barbarian Alliance ;)

In that mod I experimented with addTeam() to make an alliance with the barbarian player/team, but the civ and the barbarians shared mapview and the consequence was that spawning barbs opened views on the entire map.

Anyway, the code I used in 1 Python file was pretty simple (look for BARBARIAN_TRAIT). You can use and modify that bit to get things going for your own plans.
 
The civ and the barbarians shared mapview and the consequence was that spawning barbs opened views on the entire map.

Wouldn't that also make barbarians block the spawning of more barbarians as the barbarians themselves would reduce the fog of war. Barbarians are so mean, they even hurt their own team!! :lol:
 
I believe you are looking for CyTeam.addTeam(eTeam).

Oh, i was right :D:
Maybe i'm to stupid and just can't find it

Damn :wallbash: why didn't i see this function :wallbash:?

Thanks :).

If you want, you can use Python to create a Barbarian Alliance ;)

In that mod I experimented with addTeam() to make an alliance with the barbarian player/team, but the civ and the barbarians shared mapview and the consequence was that spawning barbs opened views on the entire map.

Anyway, the code I used in 1 Python file was pretty simple (look for BARBARIAN_TRAIT). You can use and modify that bit to get things going for your own plans.

Thanks for the hint, but an barbarian alliance that's not intended.
But i'll have a look at it, maybe i can find something interesting :).

And, it's sad, i had to kick out the mongol camp, it sucked to much performance :(.
Maybe i'll try it again, and try to attach the effect only to the barbarians. This i should have done first, but i hadn't thougt enough about it.
And now i don't have enough time, because i promised a release at the end of the month :(.
 
Wouldn't that also make barbarians block the spawning of more barbarians as the barbarians themselves would reduce the fog of war. Barbarians are so mean, they even hurt their own team!! :lol:

Interesting question and hard to give a concrete answer, but I think it's not that bad as active map view is not entirely the same as fog of war. Spawning barbarians have a tendency to disappear when not encountering other civs, leaving an active map view as a fog of war and enabling it again to spawn new barbarians. So, theoretically, yes, but in practice, not much difference, I guess.
 
Thanks for the hint, but an barbarian alliance that's not intended.
But i'll have a look at it, maybe i can find something interesting :).

And, it's sad, i had to kick out the mongol camp, it sucked to much performance :(.
Maybe i'll try it again, and try to attach the effect only to the barbarians. This i should have done first, but i hadn't thougt enough about it.
And now i don't have enough time, because i promised a release at the end of the month :(.

I don't know what you are working on, but you mentioned the mongol camp as well. If you have trouble merging Python code for your own mod in the most optimal way, performance wise, feel free to ask.
 
Active map view is not entirely the same as fog of war.

Oh right. I thought you meant visibility, but it makes sense now. So the human would get an updated view of the map's state (as if freshly revealed) but not see the units on it (still under fog of war because it's not visible).
 
In my test I noticed that there was a rather short TTL (time to live) of the shared visibility to the fog of war, but I can imagine there will spawn less barbarians taken in account there should be a lot on raging barbarians setting. In my mod I opted to take a different approach to prevent shared visibility and went with:

Code:
for iPlayer in range(gc.getMAX_PLAYERS()):
				player = gc.getPlayer(iPlayer)
				if player.isAlive():
					if player.hasTrait(gc.getInfoTypeForString('TRAIT_BARBARIAN')):
						eTeam = gc.getTeam(player.getTeam())
						iTeam = gc.getPlayer(gc.getBARBARIAN_PLAYER()).getTeam()
						eTeam.makePeace(iTeam)
						eTeam.signOpenBorders(iTeam)
						eTeam.setPermanentWarPeace(iTeam,true)

A permanent peace with all things barbarian, animals and units, plus open borders.

EDIT: the term I was looking for was: visibility decay
 
I don't know what you are working on, but you mentioned the mongol camp as well. If you have trouble merging Python code for your own mod in the most optimal way, performance wise, feel free to ask.

Thanks for the offer, but i hope, it won't be necessary :).

I know, what i did wrong.
I wanted to attach the effect to a special barbarian unit, but didn't remember, that barbarians are also a civilization. So i deleted the civilization-check, so the algorithm would be triggered every round for every civ, which sucks the performance.
For my next attempt, i'll only change CIVILIZATION_MONGOL in CIVILIZATION_BARBARIAN, and test, how the performance will be.

I would only need some more time, there are 3 unfinished things also to do :(, but i'll manage it :).
 
Top Bottom