Platy's Peculiar Pleasant Posh Python

Weird, that was a test code I added to test the scenarios...
I thought I removed it before uploading...
Re-uploaded without it.
 
nice , thank you good friend.

i still wonder what was the thing in the different autoaiplay that conflicted with the warnpeace event.

weird.

im now using the woc autuaiplay which is a whole different python code (also using the cvcustomeventmanager).

i know your not interested, still thought to share :)


****
yes! i did it! i figured it out!

in the autoai i removed this section:
Code:
            try :
                self.customEM.removeEventHandler( "BeginGameTurn", customEM.onBeginGameTurn )
                self.customEM.addEventHandler( "BeginGameTurn", self.onBeginGameTurn )
            except ValueError :
                print "Failed to remove 'onBeginGameTurn', perhaps not registered"
                self.customEM.setEventHandler( "BeginGameTurn", self.onBeginGameTurn )

thank you platy , you inspired me to find a solution no matter what, i put 20 hours in to it but it was worth it.

thank you again for the mod.
 
HEY AGAIN PLATY,


im afraid you have a crash in your world builder -

i loaded the latest platyui - loaded some scenario map (africa) ,
placed a ciy with the world builder -
pressed edit city - changed the population amount and the culture and the defense -
and theres a crash.

i loaded the ui clean - downloaded your latest version, placed in the mods - playui-> assets
and tried to do what i did, bam, a crash.


:)
 
Civ4ScreenShot0001_zpsbd5499b0.jpg


@Keldath
Press Enter after editing
 
Reinforcement Script

Features:
Spawns Units at a specific time.

Code:
################################### Reinforcement Script ##########################################
## Modified by Platyping
##
## Change Reinforcement.loadEvents("Mods/ReinforcementScript/Assets/XML/CustomXML/Reinforcement.xml") in CvEventManager
## to point to correct location after merging to own mods
##
## <Owner> Specific Civilization or Specific Leader
## <iDate> "NONE" to ignore, "-" to represent BC
## <iTurn> "-1" to ignore, <iTurn> overwrites <iDate>
## <sTriggerMap> Specific Map to Trigger
## <sIgnoreMap> Specific Map to Ignore
##
## <Type>	Unit Type or Unit Class Type
## <LeaderUnit>	Unit Type or Unit Class Type
## <iQuantity>
## <iPlotX>
## <iPlotY>
## <bCapital>	Spawns at Capital, Overwrites <iPlotX> and </iPlotY>
## <sName>
## <iLevel>
## <iExperience>
## <iImmobile>	Number of Immobile Turns
## <iDamage>	% Damage
## <Promotion>	List of Promotions
## <Message>	"NONE" to ignore, Adds a pop up for Human Player
##
###############################################################################################

<SkriptInfo>
		<Event>
			<Owner>CIVILIZATION_FRANCE</Owner>
			<iDate>-3920</iDate>
			<iTurn>4</iTurn>
			<sTriggerMap>NONE</sTriggerMap>
			<sIgnoreMap>NONE</sIgnoreMap>
			<Units>
				<Unit>
					<Type>UNITCLASS_ARCHER</Type>
					<LeaderUnit>UNITCLASS_GREAT_GENERAL</LeaderUnit>
					<iQuantity>1</iQuantity>
					<iPlotX>2</iPlotX>
					<iPlotY>4</iPlotY>
					<sName>Platyping</sName>
					<iLevel>3</iLevel>
					<iExperience>25</iExperience>
					<Promotion>PROMOTION_COMBAT1</Promotion>
					<Promotion>PROMOTION_LEADER</Promotion>
					<Promotion>PROMOTION_COMBAT2</Promotion>
				</Unit>
				<Unit>
					<Type>UNITCLASS_ARCHER</Type>
					<iQuantity>3</iQuantity>
					<iPlotX>2</iPlotX>
					<iPlotY>4</iPlotY>
					<iLevel>1</iLevel>
					<iDamage>30</iDamage>
				</Unit>
			</Units>
			<Message>NONE</Message>
		</Event>		
</SkriptInfo>

Notes:
Naval Units cannot spawn on Land, except in Coastal Cities.
All others can spawn anywhere, except impassable plots.
 
He was active.
Sounds weird to fix his works while he was still around and could have done so himself.
Also depends on my mood lalala
 
Hi Platy this is The_J civil war (new version) which is he write for me on my request few months ago:
Spoiler :
PHP:
###civil war - custom event - generic
def canTriggerCivilWar_Generic(argsList):
	kTriggeredData = argsList[0]	
	player = gc.getPlayer(kTriggeredData.ePlayer)
	pCity = player.getCity(kTriggeredData.iCityId)
	if gc.getMAX_CIV_PLAYERS ()==CyGame().countCivPlayersAlive ():
                return False
        if player.getNumCities () <=1:
                return False
        if pCity.isCapital():
                return False
        
        return True


def applyCivilWar_Generic(argsList):
        kTriggeredData = argsList[1]     

	DeclareWar = True

        dice = gc.getGame().getMapRand()
	lAllive = []
	del lAllive[:]
	iMaxCiv = gc.getMAX_CIV_PLAYERS ()
	for i in range(iMaxCiv):
                pPlayer = gc.getPlayer(i)
                lAllive.append(pPlayer.getCivilizationType () )
        lAllive.append(-1)
	iAllCivs = gc.getNumPlayableCivilizationInfos ()

        pPlayer = gc.getPlayer(kTriggeredData.ePlayer)
        iDerivative = gc.getCivilizationInfo(pPlayer.getCivilizationType()).getDerivativeCiv ()
        if not iDerivative in lAllive:
                iNewCiv = iDerivative
        else:
                lNotAllive = []
                del lNotAllive[:]
                for i in range (iAllCivs):
                        if i in lAllive:continue
                        lNotAllive.append(i)                
                iTempCiv = dice.get(len(lNotAllive) , "OracleSayMeCiv" )
                iNewCiv = lNotAllive[iTempCiv]
        CurCiv = gc.getCivilizationInfo(iNewCiv)
        NumLeaders = CurCiv.getNumLeaders ()        
        LeaderNum = dice.get(NumLeaders , "OracleSayMeTheLeader" )
        LeaderCounter=0
        for iLeaders in range(gc.getNumLeaderHeadInfos ()):
                if CurCiv.isLeaders(iLeaders):
                        if NumLeaders==1:
                                NewLeaderID =iLeaders
                                break
                        else:
                                if LeaderCounter==LeaderNum:
                                        NewLeaderID=iLeaders
                                        break
                        LeaderCounter=LeaderCounter+1       

###find ID for new civ start	
        iNewID = -1	
	for iID in range (iMaxCiv):
                pTestPlayer = gc.getPlayer(iID)
                if not pTestPlayer.isAlive():
                        iNewID = iID
                        break
        else:
                return False
###find ID for new civ end
### add the player to the game

        CyGame().addPlayer(iNewID,NewLeaderID,iNewCiv)
        pNewPlayer = gc.getPlayer(iNewID)
        pNewTeam = gc.getTeam(pNewPlayer.getTeam())
        pPlayer = gc.getPlayer(kTriggeredData.ePlayer)        
        pCity = pPlayer.getCity(kTriggeredData.iCityId)
        pTriggerTeam=gc.getTeam(pPlayer.getTeam())

###give new team open borders tech
###easier to handle over units with that solution        
        iMaxTech = gc.getNumTechInfos ()
        for OBtech in range (iMaxTech):
                pTech = gc.getTechInfo(OBtech)
                if pTech.isOpenBordersTrading ():
                        pNewTeam.setHasTech(OBtech,True,iNewID,False,False)
                        break
        pNewTeam.signOpenBorders(pTriggerTeam.getID())


###add techs to new player
        iMaxTech = gc.getNumTechInfos ()
        for counter in range (iMaxTech):
                if ((pTriggerTeam.isHasTech(counter)==true)and ((pNewTeam.isHasTech(counter)==false))):
                        pNewTeam.setHasTech(counter,true,iNewID,false,false)
                        
###handle over cities        
        iX = pCity.getX()
        iY = pCity.getY()
        #CyInterface().addMessage(0,False,15,str(kTriggeredData.iCityId),'',0,'Art/Interface/Buttons/General/happy_person.dds',ColorTypes(44), iX, iY, True,True)            
        pNewPlayer.acquireCity(pCity,False,False)

        pPlot = CyMap().plot(iX,iY)
        iMaxNumUnits = pPlot.getNumUnits ()
        for iUnits in range(iMaxNumUnits,-1,-1):
                pUnit = pPlot.getUnit(iUnits)
                if pUnit.getOwner()==pPlayer.getID():
                        pUnit.doCommand(CommandTypes.COMMAND_GIFT,-1,-1)
 
        iUnitClassType = CvUtil.findInfoTypeNum(gc.getUnitClassInfo, gc.getNumUnitClassInfos(), 'UNITCLASS_MODERN_ARMOR')
        iUnitType = gc.getCivilizationInfo(pNewPlayer.getCivilizationType( )).getCivilizationUnits(iUnitClassType)

        for i in range(2):
                pNewPlayer.initUnit(iUnitType, iX,iY, UnitAITypes.UNITAI_ATTACK, DirectionTypes.NO_DIRECTION )

        iUnitClassType = CvUtil.findInfoTypeNum(gc.getUnitClassInfo, gc.getNumUnitClassInfos(), 'UNITCLASS_MECHANIZED_INFANTRY')
        iUnitType = gc.getCivilizationInfo(pNewPlayer.getCivilizationType( )).getCivilizationUnits(iUnitClassType)

        for i in range(2):
                pNewPlayer.initUnit(iUnitType, iX,iY, UnitAITypes.UNITAI_CITY_DEFENSE, DirectionTypes.NO_DIRECTION ) 

        ###remove open borders tech
        ###just in case, you never know		
	pNewTeam.setHasTech(OBtech,False,iNewID,False,False)
        ###declare war
        if DeclareWar:
                pNewTeam.declareWar(pTriggerTeam.getID(),False,WarPlanTypes.WARPLAN_LIMITED)
	return True

I have one question for you, in this event i have mechanized infantry and modern armor, i want to make more similar events like this. If i make lots of events more than 10 for this civil war, is my mod go slower, or if i have lots of another events? Is my PC read all codes after every turn? Can you explain me if you know?
 
Frankly speaking, I can't be bothered to read codes more than 100 lines.
Try asking in the general threads and see if the moderators are free to look into it :)
 
Hi Platy, you know that i use lots of your python work in my mod. I have one error for your Spiritual trait please see images (I hope that you can see)

I play with Spiritual leader (THIRD IMAGE) and i am spread my religion, i am build 19 missionaries (i am get error (FIRST IMAGE) on 19th missionary), my 19th missionary spread my state religion in rival holy city (SECOND IMAGE), i am spread my state religion in more rivals holy cities and i am not get this error before, this is same error which i am post in my thread yesterday.
 

Attachments

  • Spiritual_error.JPG
    Spiritual_error.JPG
    107.3 KB · Views: 138
  • sp_2.JPG
    sp_2.JPG
    127.1 KB · Views: 136
  • sp_3.JPG
    sp_3.JPG
    17.2 KB · Views: 133
newUnit = player.initUnit(pUnit.getUnitType(), capital.getX(),capital.getY(), UnitAITypes.UNITAI_MISSIONARY, DirectionTypes.NO_DIRECTION )

replace player with pPlayer? You think on this?
 
You know... it is faster to change one word and test directly, then to ask me the same question and wait for a reply :D
 
Hi Platy, i am see that you start modify The_J's python, can you modify civil war? The_J is make some error please see image.

Ethiopia and Persia are declare their independence from America, but when 3rd civ declare independence i am get error.

How i can fix it?
 

Attachments

  • thej-cw-error.JPG
    thej-cw-error.JPG
    143.5 KB · Views: 91
Have to wait a looooong time till the next time I am in a good mood though.
Because generally, it is not really entertaining to look through someone else's codes just to see
1) What it is supposed to do
2) Does it actually do it
3) Under what special conditions it may fail
4) Any other things to improve

One thing I can think of is that the max number of players is already reached, hence it is impossible to create a new player via the event.
Which is why you get a runtime error.

You know...
It is more entertaining to read a novel or watch tv than to rectify codes written by others :D
 
@ zlatko - I'm not sure it's The_J error. I use a civil war without error message :) check code more, please

Good news, Platy. After many attempts, I finally managed to do all trackers buttons visible :) seven weeks - I'm pretty fast :)

I see that civil war is in the limelight. Do you think there could be time to try write code for tracker, I asked for? I know that you think it is unnecessary, but if all things were just baldly functional, the world would be without joy :(

BTW, I wanted to ask you for help. I have building XY and it should be 2% each turn that will generate UNIT_1 and two percent each turn that will generate UNIT_2 in the city, where is build.
You can write to me, please? For you it would be easy :) thank you very much
 
Depends what you mean...
Does it mean:
A) 4% to generate either A or B
B) 2% to generate A, and a separate 2% to generate B, which means there is a chance that both occurs on same turn, and you get both A and B
 
Aaaah. You are right. Poorly I commented. The building has a 2% chance of generating unit A. If unit A is not generated, Try building at 2% generating unit B.

If is born unit A building will not try to generate unit B :)

If is born unit A or B send game one message: blebleble :)

Thanks for your help, Platy :)
 
Back
Top Bottom