Star Sign modmod

That line simply ensures that those random promotions will not spawn for non combat units like settlers or missiles which might have changed for c2c though.
So whether it is still relevant u can check with dh better.

I didn't bother to look at the uploaded file because that site crashed my IE repeatedly but looking at the bits and pieces u posted, I guess more or less it should be 12 sets of if else statements.
Use a list and everything solved with 1 if statement.
 
I got rid of all the if statements and put it all in arrays. When is it not displaying the icon? It is giving notice and a the notice "bubble" has the icon in it. The text message does not, which is what I think this new code does.
 
Spoiler :

Code:
gaiStarSigns= None

def init():
	BugUtil.debug("Initializing StarSigns")
	
	global gaiStarSigns
	
	gaiStarSigns = [gc.getInfoTypeForString("PROMOTION_AQUARIUS"),
				gc.getInfoTypeForString("PROMOTION_ARIES"),
				gc.getInfoTypeForString("PROMOTION_CANCER"),
				gc.getInfoTypeForString("PROMOTION_CAPRICORN"),
				gc.getInfoTypeForString("PROMOTION_GEMINI"),
				gc.getInfoTypeForString("PROMOTION_LEO"),
				gc.getInfoTypeForString("PROMOTION_LIBRA"),
				gc.getInfoTypeForString("PROMOTION_PISCES"),
				gc.getInfoTypeForString("PROMOTION_SAGITTARIUS"),
				gc.getInfoTypeForString("PROMOTION_SCORPIO"),
				gc.getInfoTypeForString("PROMOTION_TAURUS"),
				gc.getInfoTypeForString("PROMOTION_VIRGO"),
			]
			
def onUnitCreated(self, argsList):
	pUnit = argsList[0]

	BugUtil.debug("StarSigns - onUnitCreate")
	chance = CyGame().getSorenRandNum(1200, "Random to get a Sign") #returns a number 0-1199
		
	if chance < 12:  ### Lucky 7 Lol -> so 1% chance of getting a "sign promotion" ###
		iStarPromotion = gaiStarSigns[chance]
		pUnit.setHasPromotion(iStarPromotion, True)
		
		pPID = pUnit.getOwner()
		
		iXa = pUnit.getX()
		iYa = pUnit.getY()

		strMessage = localText.getText("TXT_KEY_MESSAGE_STARSIGN_CREATE")
		szIcon = gc.getPromotionInfo(iStarPromotion).getButton()
		CyInterface().addMessage(pPID, false, 15, strMessage, "", 0, szIcon, ColorTypes(44), iXa, iYa, True,True)

Comments:
1) chance = CyGame().getSorenRandNum(99, "Random to get a Sign") #returns a number 0-100
Nope, it does not.

2) Units that are built, will trigger both onUnitCreated AND onUnitBuilt.
You are giving those built an extra chance.

3) pPlayer = PyPlayer(pUnit.getOwner())
pPID = pPlayer.getID()
Extra work... Why bother to get pPlayer just to get the ID when you can get ID directly.

4) iplayer = gc.getPlayer(pCity.getOwner())
????????

5) And because there is no other if else conditions, this function will consider all units... including settlers, animals, missiles whatever.
Looking at the list of promotion effects, some of them will just look weird, like XP boost, first strike, etc
In fact, most of them look weird for those non combat units.
 
Spoiler :

Code:
gaiStarSigns= None

def init():
	BugUtil.debug("Initializing StarSigns")
	
	global gaiStarSigns
	
	gaiStarSigns = [gc.getInfoTypeForString("PROMOTION_AQUARIUS"),
				gc.getInfoTypeForString("PROMOTION_ARIES"),
				gc.getInfoTypeForString("PROMOTION_CANCER"),
				gc.getInfoTypeForString("PROMOTION_CAPRICORN"),
				gc.getInfoTypeForString("PROMOTION_GEMINI"),
				gc.getInfoTypeForString("PROMOTION_LEO"),
				gc.getInfoTypeForString("PROMOTION_LIBRA"),
				gc.getInfoTypeForString("PROMOTION_PISCES"),
				gc.getInfoTypeForString("PROMOTION_SAGITTARIUS"),
				gc.getInfoTypeForString("PROMOTION_SCORPIO"),
				gc.getInfoTypeForString("PROMOTION_TAURUS"),
				gc.getInfoTypeForString("PROMOTION_VIRGO"),
			]
			
def onUnitCreated(self, argsList):
	pUnit = argsList[0]

	BugUtil.debug("StarSigns - onUnitCreate")
	chance = CyGame().getSorenRandNum(1200, "Random to get a Sign") #returns a number 0-1199
		
	if chance < 12:  ### Lucky 7 Lol -> so 1% chance of getting a "sign promotion" ###
		iStarPromotion = gaiStarSigns[chance]
		pUnit.setHasPromotion(iStarPromotion, True)
		
		pPID = pUnit.getOwner()
		
		iXa = pUnit.getX()
		iYa = pUnit.getY()

		strMessage = localText.getText("TXT_KEY_MESSAGE_STARSIGN_CREATE")
		szIcon = gc.getPromotionInfo(iStarPromotion).getButton()
		CyInterface().addMessage(pPID, false, 15, strMessage, "", 0, szIcon, ColorTypes(44), iXa, iYa, True,True)

Comments:
1) chance = CyGame().getSorenRandNum(99, "Random to get a Sign") #returns a number 0-100
Nope, it does not.

2) Units that are built, will trigger both onUnitCreated AND onUnitBuilt.
You are giving those built an extra chance.

3) pPlayer = PyPlayer(pUnit.getOwner())
pPID = pPlayer.getID()
Extra work... Why bother to get pPlayer just to get the ID when you can get ID directly.

4) iplayer = gc.getPlayer(pCity.getOwner())
????????

5) And because there is no other if else conditions, this function will consider all units... including settlers, animals, missiles whatever.
Looking at the list of promotion effects, some of them will just look weird, like XP boost, first strike, etc
In fact, most of them look weird for those non combat units.

Yeah, not intended for NON-combat units.
So IF you had to Completely RE-write it, how would it look then?:confused:

\EDIT: If you are bored as you stated, i have had this on my books waiting for DH and the python people since 17 Feb now, but still haven't figured it out, if you could help i really would appreciate it:
Attached is Original modcomp and the one i wanted, it also can be changed, no biggy .. . . SO
 
Already rewritten the whole thing, except to add in non combat units check.

There are various ways to filter out all those non combat units

1) if pUnit.getUnitCombatType() > -1:
will work for BTS because non combat units like workers and animals do not have any combat type.
Whether that is still true for C2C, I guess you may know better than me

2) if pUnit.isCombat():
if i remember, checks if there is a combat str for it, which will still include animals.

3) Some of the promotions may not make sense for air units as well, so it is up to you if you want to exclude those too.


Edit:
Regarding that camp thingy, I am bored but lazy to read more than 20 lines lol
At least tell me what is it intended to do rather than read the codes to figure out
DH should have a better idea what method to use to filter out the unwanted units since he is more familiar with C2C units.

P.S.
You may want to take note of this
onUnitBuilt is activated only when units are built, literally.
onUnitCreated is activated under much more situations as I already mentioned.
Built, Draft, Initial Units, Captured Workers, Gifted Units, Events, Python, WorldBuilder, Great People Born, Free Units from Techs.

Using onUnitCreated may lead to unwanted results.
Example, Survival Promotions generally use python to create a duplicate unit after the original unit died.
This mean a revived unit will get a chance to get the stars too.

The worse part is gifted units.
For a MP game, I can simply park 100 units at a border to my team mate and keep gifting to each other just to trigger the stars.
 
Already rewritten the whole thing, except to add in non combat units check.

There are various ways to filter out all those non combat units

1) if pUnit.getUnitCombatType() > -1:
will work for BTS because non combat units like workers and animals do not have any combat type.
Whether that is still true for C2C, I guess you may know better than me

2) if pUnit.isCombat():
if i remember, checks if there is a combat str for it, which will still include animals.

3) Some of the promotions may not make sense for air units as well, so it is up to you if you want to exclude those too.


Edit:
Regarding that camp thingy, I am bored but lazy to read more than 20 lines lol
At least tell me what is it intended to do rather than read the codes to figure out
DH should have a better idea what method to use to filter out the unwanted units since he is more familiar with C2C units.

Star: OK air units are ok, since they are really a unit that has a person flying it anyways. And I'd rather not have animals included to get the promotion. Only Human like or Alien person are the person of interest. No canine units, no GP unless they can maybe give the promotion also (just thinking)? No civilian, No explorers, No siege, No sea animals, No Biological, No settler, no worker, No missionary (hmm maybe), No well you get the point . .

As far as the Camp goes:
The Mongol Camp works correctly (Original Mongol Camp).
Mine has changed from ONLY the Mongols to Only the Barbarians Civ. But cant figure out how to??
 
If all you want is simply replace mongol with barbarian, done...
Didn't bother to read the rest of the codes.
MongolCamp file:

1) self.iMongolsID = gc.getBARBARIAN_PLAYER()
2) Remove whole chunk
Code:
       for iPlayer in range(gc.getMAX_PLAYERS()):
            player = gc.getPlayer(iPlayer)
            if (player.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_MONGOL')):
                self.iMongolsID = iPlayer
 
If all you want is simply replace mongol with barbarian, done...
Didn't bother to read the rest of the codes.
MongolCamp file:

1) self.iMongolsID = gc.getBARBARIAN_PLAYER()
2) Remove whole chunk
Code:
       for iPlayer in range(gc.getMAX_PLAYERS()):
            player = gc.getPlayer(iPlayer)
            if (player.getCivilizationType() == gc.getInfoTypeForString('CIVILIZATION_MONGOL')):
                self.iMongolsID = iPlayer

I wouldn't really look at the original python that much, DH RE-DID it better to work with BUG and C2C.

It is NOW completely different, almost all of it, as far as i know:dunno::dunno:

DH isn't around so thats why he has been quite on this.
 
Frankly speaking, I have no idea why are there 2 places defining the same global variables, but I just leave them alone.

Remove all unnecessary stuff.
There are even variables defined which are not used anywhere at all.

And looking at what it is doing...
It is gonna be taxing on performance when there are alot of barb units.

What it does:
Every single turn:
Loop through every single unit of barb player.
If it is a camp unit:
Roll a number and do this do that blah blah blah
Then spawn the selected unit.

Guess what happens every turn when barb player has 100+ units?
 
Frankly speaking, I have no idea why are there 2 places defining the same global variables, but I just leave them alone.

Remove all unnecessary stuff.
There are even variables defined which are not used anywhere at all.

And looking at what it is doing...
It is gonna be taxing on performance when there are alot of barb units.

What it does:
Every single turn:
Loop through every single unit of barb player.
If it is a camp unit:
Roll a number and do this do that blah blah blah
Then spawn the selected unit.

Guess what happens every turn when barb player has 100+ units?

No actually when you click on "fortify" the camp settles down like a settler on a certain tile and then reproduces like a NORMAL settler with buildings units, etc etc. . .
\
Then if things get bad enough you click on it again and it becomes a camp again then it all begins again, over and over, so really its a moving city.
Its more or less like a migrating flock, when the weather is bad you move the "city/camp"" to a better location(s), just like birds fly south for the winter and then back again north for the summer.
 
def onBeginGameTurn(argsList):
blah blah blah


Then what is this part doing?
 
The "founding" part is under def onSelectionGroupPushMission(argsList):
And it is not just fortify actually, it includes all where the unit remain stationary like Heal.

The def onBeginGameTurn(argsList): part will do exactly what I mentioned and give you hell of a nightmare if your barb civ managed to get "big" with many cities and units.

Not a problem with normal mods since barbs are just... mild and die off fast.
So depending on how barbs perform in C2C, if they are capable of growing big, then you are simply adding a loop through hundreds of units of the barbie every turn.
 
The "founding" part is under def onSelectionGroupPushMission(argsList):
And it is not just fortify actually, it includes all where the unit remain stationary like Heal.

The def onBeginGameTurn(argsList): part will do exactly what I mentioned and give you hell of a nightmare if your barb civ managed to get "big" with many cities and units.

Not a problem with normal mods since barbs are just... mild and die off fast.
So depending on how barbs perform in C2C, if they are capable of growing big, then you are simply adding a loop through hundreds of units of the barbie every turn.

Actually i am making this a PLAYABLE civ.

@ DH,

I am going to need to to chime in on the Star Mod, because i have NO idea what he actually wrote above and what i am suppose to do? Sorry?
And also the Camp, thx.
 
You know what is happening every turn?
Loop through every single unit of that player.
If the unit is a camp, roll a number.
If rolled number is within a certain chance, spawn a free unit.
Free unit = Horse Archer, Keshik, Archer, Camp or Trebutchet.

The main intention of this mongol camp mod is that every turn, there is a chance to spawn a random unit at the "mobile camp" units, rather than the part about fortifying to found a city.

I guess this mod is ripped from a scenario or something, where there are camps all over the world, and mongol units start pouring out from them.

This will sound weird as a playable civ I believe.
 
Code:
<TEXT>
	<Tag>TXT_KEY_UNIT_CAMP_STRATEGY</Tag>
	<English>The Camp unit is the means by which the Mongols obtain new units. Guard them in order to ensure the survival of your empire.</English>
</TEXT>

<TEXT>
	<Tag>TXT_KEY_CAMP_SUCCESS</Tag>
	<English>[COLOR_SELECTED_TEXT]A camp has produced new units![COLOR_REVERT]</English>
</TEXT>

<TEXT>
	<Tag>TXT_KEY_UNIT_CAMP_INFO</Tag>
	<English>The Mongol civilization was nomadic and did not build cities throughout most of its history.  Rather, the entire Mongol people moved as the armies moved, with the women and children following behind and young men growing up to take their fathers' places on the battlefield.  The Camp is essentially a 'city on wheels', and produces the armies that you will use to fuel your war machine.[NEWLINE][TAB]You cannot choose production for Camps like for cities but they can be manipulated to produce differently depending on their situation.  Camps have a chance of producing a unit every turn.  That chance is increased between five turns. Additionally, the type of unit a Camp produces can be altered depending on what type of terrain and feature it's on.  The odds of the type of unit can be greatly favored based on the following:[NEWLINE][TAB]- Plains: Horse Archer[NEWLINE]- Desert: Keshik[NEWLINE]- Hills: Archer[NEWLINE]- Forest: Trebuchet[NEWLINE][NEWLINE]You do not begin the game with the ability to spawn Trebuchets.  If on Forest prior to obtaining 'Engineering' or any plot type not listed above the chance of each unit being created will not be modified by any bonuses.</English>
</TEXT>

I know you don't understand python...
You read about this? :D
You sure it is still what you want?
 
I know you don't understand python...
You read about this? :D
You sure it is still what you want?

ahaa, nice!!!

Forgot to ask: Will the AI know how to use this??
Correct, i am actually making a Barbarian Civ that will take over the world by storm. (as a "what if" type as in "Bad things happen" or an "Alt Timeline."
I am going to have special events just for them, well here look, i really have no idea what i can or cant do yet, its really just a thought for now:confused::crazyeye:
http://forums.civfanatics.com/showthread.php?t=488753
 
You know what is happening every turn?
Loop through every single unit of that player.
If the unit is a camp, roll a number.
If rolled number is within a certain chance, spawn a free unit.
Free unit = Horse Archer, Keshik, Archer, Camp or Trebutchet.

The main intention of this mongol camp mod is that every turn, there is a chance to spawn a random unit at the "mobile camp" units, rather than the part about fortifying to found a city.

I guess this mod is ripped from a scenario or something, where there are camps all over the world, and mongol units start pouring out from them.

This will sound weird as a playable civ I believe.

As I said, this works for a scenario where there are already camps placed.
When there are no camps to begin with, nothing is going to be spawned.
And since the free unit choices are hard coded into the code, if a keshik spawned, it is going to kill every civ like flies.
If you change all the choices to all the starting units, then as time goes by, it will still be spawning garbage when all civs have advanced.

And this mod has nothing to do with ability to build a city and then change back to mobile camp and walk around the world again.
 
As I said, this works for a scenario where there are already camps placed.
When there are no camps to begin with, nothing is going to be spawned.
And since the free unit choices are hard coded into the code, if a keshik spawned, it is going to kill every civ like flies.
If you change all the choices to all the starting units, then as time goes by, it will still be spawning garbage when all civs have advanced.

And this mod has nothing to do with ability to build a city and then change back to mobile camp and walk around the world again.

Hmm it shouldn't work that way, it should maintain its buildings that were produced when in the "camp" faze?? At least thats what is supposed to do??

And yes i am going to change ALL the units to the very begging of the Prehistoric Era, ie Wanderer, Stone Thrower, Slinger etc.
Sorry i just have alot of JUNK in my mind and keep forgetting to say what i need to in certain situations, like this, whereas i figure everyone knows what i do, DUH!! NOT!:blush:
 
Top Bottom