1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Help out a python newbie?

Discussion in 'Civ4 - Creation & Customization' started by Dryhad, Jan 21, 2008.

  1. Dryhad

    Dryhad Prince

    Joined:
    Feb 23, 2006
    Messages:
    451
    Ok, what I'm trying to do here is make an event that removes a random religion from all cities. The event uses this python function:

    Code:
    def doObsoleteReligion1(argsList):
    	kTriggeredData = argsList[0]
    	iReligion = kTriggeredData.eReligion
    	gc.getGame( ).clearHolyCity( iReligion )
    	for iPlayer in range(gc.getGame( ).getNumCivPlayers()):
    		pPlayer = gc.getPlayer(iPlayer)
    		for iCity in range(pPlayer.getNumCities()):
    			pCity = pPlayer.getCity(iCity)
    			pCity.setHasReligion(iReligion, 0, 0, 0)
    It's mostly modified from the Gods of Old Inquisitor function, and I assume I've left out some important part, but I don't know enough about python to be sure. It doesn't seem to do anything at all, is the problem. Can anyone see anything immediately wrong with it?
     
  2. primordial stew

    primordial stew Emperor

    Joined:
    Sep 1, 2005
    Messages:
    1,219
    Location:
    a puddle
    Try adding a debug statement to make sure it actually fired, something like:
    CyInterface().addImmediateMessage("religion picked: %s"%(iReligion,"")

    This will go to the screen only with all the other messages, so don't miss it!

    And then look in PythonErr.log and see if there is a problem.
     
  3. ddrekins

    ddrekins Event Master

    Joined:
    Aug 6, 2007
    Messages:
    89
    Location:
    2 food, 2 commerce plot in Utah
    Hmm, the placement of the line: gc.getGame().clearHolyCity(iReligion) has me worried. I'm not certain but I think that bugger needs to be told which holy city to clear of iReligion. I don't think it hones in on the holy city of type iReligion.

    Notice that in the Gods of Old mod, the line preceding that one is:
    if pCity.isHolyCityByType( iReligionLoop ):

    Now, why would it be asking whether that pCity was the holy city of that type if it was just going to find it with the clearHolyCity thingi?

    Not only did you not specify which holy city to clear, you didn't really specify a city.

    There might be more, but I'll have to think about it.

    EDIT: Why did you use that line in the first place? Is it needed? If you are cycling through all of the cities anyway, you shouldn't need to specifically target the holy city beforehand, should you? Perhaps you are confusing the python as much as you are me. In the which case, just remove that line and you might be better.
     
  4. Dryhad

    Dryhad Prince

    Joined:
    Feb 23, 2006
    Messages:
    451
    Well my thinking with the holy city line is that the Gods of Old code apparently needs a separate line to remove the holy city so maybe there's some impediment to simply removing a given religion from the holy city. I'll try it without anyway, though, to see if that is the problem.
     
  5. ddrekins

    ddrekins Event Master

    Joined:
    Aug 6, 2007
    Messages:
    89
    Location:
    2 food, 2 commerce plot in Utah
    Wait, I think you're right. It does take something different to get rid of holy cities.

    Another thing, I may just be a total idiot, but is iReligion defined correctly? (I'll edit this after I check.)

    EDIT: It is entirely possible that I know a whole lot less about Python than you do, but shouldn't it be:
    iReligion = gc.getReligionInfo(kTriggeredData.eReligion)

    EDIT2: Gah, I just realized I've been thinking in terms of event modding. *sigh* I should just leave you alone.

    EDIT3: On second thought, maybe I should just learn to read. This is an event, so yes, I think iReligion needs to be defined like above.
     
  6. Dryhad

    Dryhad Prince

    Joined:
    Feb 23, 2006
    Messages:
    451
    Well, having tried the ideas in this thread and seeing no change whatsoever (most importantly, primordial stew's Immediate Message thing), I am forced to conclude that the python function isn't being called in the first place. This is how the event should be done, right?
    Code:
    		<EventInfo>
    			<Type>EVENT_OBSOLETE_RELIGION_1</Type>
    			<Description>They will be sorely missed</Description>
    			<LocalInfoText/>
    			<WorldNewsTexts/>
    			<OtherPlayerPopup/>
    			<QuestFailText/>
    			<bQuest>0</bQuest>
    			<bGlobal>0</bGlobal>
    			<bTeam>0</bTeam>
    			<bPickCity>0</bPickCity>
    			<bPickOtherPlayerCity>0</bPickOtherPlayerCity>
    			<bDeclareWar>0</bDeclareWar>
    			<iGold>0</iGold>
    			<bGoldToPlayer>0</bGoldToPlayer>
    			<iRandomGold>0</iRandomGold>
    			<iCulture>0</iCulture>
    			<iEspionagePoints>0</iEspionagePoints>
    			<bGoldenAge>0</bGoldenAge>
    			<iFreeUnitSupport>0</iFreeUnitSupport>
    			<iInflationMod>0</iInflationMod>
    			<iSpaceProductionMod>0</iSpaceProductionMod>
    			<Tech>NONE</Tech>
    			<TechFlavors/>
    			<iTechPercent>0</iTechPercent>
    			<iTechCostPercent>0</iTechCostPercent>
    			<iTechMinTurnsLeft>0</iTechMinTurnsLeft>
    			<PrereqTech>NONE</PrereqTech>
    			<UnitClass>NONE</UnitClass>
    			<iNumFreeUnits>0</iNumFreeUnits>
    			<bDisbandUnit>0</bDisbandUnit>
    			<iUnitExperience>0</iUnitExperience>
    			<iUnitImmobileTurns>0</iUnitImmobileTurns>
    			<UnitPromotion/>
    			<UnitName/>
    			<UnitCombatPromotions/>
    			<UnitClassPromotions/>
    			<BuildingClass>NONE</BuildingClass>
    			<iBuildingChange>0</iBuildingChange>
    			<BuildingExtraYields/>
    			<BuildingExtraCommerces/>
    			<BuildingExtraHappies/>
    			<BuildingExtraHealths/>
    			<iHappy>0</iHappy>
    			<iHealth>0</iHealth>
    			<iHurryAnger>0</iHurryAnger>
    			<iHappyTurns>0</iHappyTurns>
    			<iRevoltTurns>0</iRevoltTurns>
    			<iMinPillage>0</iMinPillage>
    			<iMaxPillage>0</iMaxPillage>
    			<iFood>0</iFood>
    			<iFoodPercent>0</iFoodPercent>
    			<FreeSpecialistCounts/>
    			<FeatureType>NONE</FeatureType>
    			<iFeatureChange>0</iFeatureChange>
    			<ImprovementType>NONE</ImprovementType>
    			<iImprovementChange>0</iImprovementChange>
    			<BonusType>NONE</BonusType>
    			<iBonusChange>0</iBonusChange>
    			<RouteType>NONE</RouteType>
    			<iRouteChange>0</iRouteChange>
    			<BonusRevealed>NONE</BonusRevealed>
    			<BonusGift>NONE</BonusGift>
    			<PlotExtraYields/>
    			<iConvertOwnCities>0</iConvertOwnCities>
    			<iConvertOtherCities>0</iConvertOtherCities>
    			<iMaxNumReligions>-1</iMaxNumReligions>
    			<iOurAttitudeModifier>0</iOurAttitudeModifier>
    			<iAttitudeModifier>0</iAttitudeModifier>
    			<iTheirEnemyAttitudeModifier>0</iTheirEnemyAttitudeModifier>
    			<iPopulationChange>0</iPopulationChange>
    			<AdditionalEvents/>
    			<EventTimes/>
    			<ClearEvents/>
    			<PythonCallback>doObsoleteReligion1</PythonCallback>
    			<PythonExpireCheck/>
    			<PythonCanDo/>
    			<PythonHelp/>
    			<Button>,Art/Interface/Buttons/Process/Blank.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
    			<iAIValue>1000</iAIValue>
     
  7. ddrekins

    ddrekins Event Master

    Joined:
    Aug 6, 2007
    Messages:
    89
    Location:
    2 food, 2 commerce plot in Utah
    Sorry to mislead you earlier ;( . I hope this helps though: You don't need to specify: "NONE" for BuildingClass followed by a 0 in iBuildingChange. A zero value in iBuildingChange doesn't make much sense to me. Is that how it is done in other XML events in the game? The values that I understand in iBuildingChange are -1 for destroy and 1 for create. But, like I said, you don't need either field filled in. That may not make a difference, but it can't take long and I'm fresh out of (bad) ideas.
     
  8. Dryhad

    Dryhad Prince

    Joined:
    Feb 23, 2006
    Messages:
    451
    I didn't put that in, I copied it (like most of the entry) from another event. They all have that in there.
     
  9. ddrekins

    ddrekins Event Master

    Joined:
    Aug 6, 2007
    Messages:
    89
    Location:
    2 food, 2 commerce plot in Utah
    Heh, interesting. I guess it doesn't matter whether that is in there or not. I'm really sorry. I thought I might be able to help you but alas, I don't know what I'm talking about.
     

Share This Page