Non random event, don't trigger

muzbang

Prince
Joined
Feb 22, 2007
Messages
319
Hello

I'am trying to create a non random event ( a quest for a specific civilization - in FFH2)

In the Civ4EventTriggerInfos, i wrote this code :

Code:
       <EventTriggerInfo><!-- QUEST_AMURITES  -->
           <Type>EVENTTRIGGER_QUEST_AMURITES</Type>
           <WorldNewsTexts>
               <Text></Text>
           </WorldNewsTexts>
           <TriggerTexts>
               <TriggerText>
                   <Text>TXT_KEY_EVENT_TRIGGER_QUEST_AMURITES</Text>
                   <Era>NONE</Era>
               </TriggerText>
           </TriggerTexts>
           <EventArt>Art\EventImages\e_AMURITES_QUEST.dds</EventArt>
           <bGlobal>0</bGlobal>
           <iPercentGamesActive>100</iPercentGamesActive>
           <iWeight>-1</iWeight>
           <bPickCity>1</bPickCity>
           <PrereqCivilizationPleased>CIVILIZATION_AMURITES</PrereqCivilizationPleased>
           <Events>
               <Event>EVENT_QUEST_AMURITES_1</Event>
           </Events>
           <PythonCanDo></PythonCanDo>
       </EventTriggerInfo>

So that's simple. 100%game active, iWeight=-1 for the event to trigger when conditions are met.
Conditions are very simple... just need the amurite civilization, and i pick one of their cities.
That said, i expected the event to occur the turn after the 1st settler build a city (basically turn 2)

But the event don't trigger.

More surprisingly, i can trigger the event manualy (ctrl+maj+E).
As far as i know, it's only possible to trigger like this an event that has met his prereq conditions.

So why doesn't the event trigger automatically turn 2 ? or why can i trigger it manualy ?

Last thing... as i'am not totaly sure about the <PrereqCivilizationPleased> tag, i also tried to set a prereq with python
i removed the <PrereqCivilizationPleased> tag
and added
Code:
<PythonCanDo>CanTriggerQUEST_AMURITES</PythonCanDo>

+ added in the CvRandomEventInterface.py
Code:
def CanTriggerQUEST_AMURITES(argsList):
    kTriggeredData = argsList[0]  
    pPlayer = gc.getPlayer(kTriggeredData.ePlayer)
    if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_AMURITES'):
        return False
    return True

There again, the event don't trigger turn 2, but i can manually fire it

I guess this must be a very simple mistake...

Thanks for advises !
 
Last edited:
Going with the PythonCanDo option seems to be the right call, at least BtS does a similar thing with the Impeachment event, which can only trigger for the USA.

For the code you have, I think python needs to have the if condition in brackets, therefore you would need to change
Code:
if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_AMURITES'):
to
Code:
if (pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_AMURITES')):
also it might be case sensitive, so best change your False and True to false and true.
 
Thanks for the reply.

I already tried the () outside the if condition
but as many other events are coded without () and are functionning, this doesn't solve my problem.

Same thing for True and False, that are written like this all along the code (but i tried it anyway, with no better result)

I also tried to add a prereq building (BUILDINGCLASS_PALACE) in order to have at least a prereq XML ...
but still not working

Then.... i change the BUILDINGCLASS_PALACE for another building that is not present in the city at start.
There, i can't fire the event manualy, as expected.
So i expect that when i'll have the building in the city, the event will fire automatically. But no... by the way, i can trigger it manualy. :crazyeye: meaning that the prereq conditions are met.
But then why the event don't trigger automatically :sad: :confused:

I feel so stupid for a such simple thing....
 
Certainly strange, only other thing I could think of is that CIVILIZATION_AMURITES is maybe not completely right (again maybe case sensitive), but then you should not be able to trigger the event manually.

Maybe check the basics, for example that 'HidePythonExceptions' is set to 0 in your _Civ4Config file and that events are enabled in your game settings.
 
The civ name is ok, copied / pasted from the Civ4CivilizationInfos.xml
HidePythonExceptions = 0 in the ini file
and of course events are enabled.
I was questionning myself about a max_number of events in the XML file ? that "disable" events > certain number ... i will give it a try but with little hope :undecide:
 
I can't immediately see a problem with your event. Could it be that the option EVENT_QUEST_AMURITES_1 has requirements that are not satisfied? An EventTrigger without valid Events will not trigger correctly. Otherwise, I would try progressively removing conditions (PythonCanDo, bPickCity) to see where the problem might be.

PrereqCivilizationPleased in FfH requires a *different* player to be Amurites and pleased or friendly with you, so that won't work.

On Python: Parentheses around if conditions are not needed, and discouraged. It is case-sensitive, and True/False are correct. Civ4 defines true/false, too for whatever reason, so both works here.
 
Here is the EVENT_QUEST_AMURITES_1
this is in Civ4EventInfos.xml

I though that this was only the event resolution (if event is triggered)

There is quite nothing in it except that i set it as a quest

And again i ask myself why can i trigger the event manualy (meaning conditions are met) but don't trigger in game when conditions are met (i'll try - again-to remove some prereq)

Code:
<EventInfo>
            <Type>EVENT_QUEST_AMURITES_1</Type>
            <Description>TXT_KEY_EVENT_QUEST_AMURITES_1</Description>
            <LocalInfoText/>
            <WorldNewsTexts/>
            <OtherPlayerPopup/>
            <QuestFailText>TXT_KEY_EVENT_FAIL_QUEST_AMURITES</QuestFailText>
            <bQuest>1</bQuest>
            <bGlobal>1</bGlobal>
            <bTeam>0</bTeam>
            <bPickCity>1</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></PythonCallback>
            <PythonExpireCheck/>
            <PythonCanDo/>
            <PythonHelp></PythonHelp>
            <Button>,Art/Interface/Buttons/Process/Blank.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
            <iAIValue>1000</iAIValue>
        </EventInfo>
 
PrereqCivilizationPleased in FfH requires a *different* player to be Amurites and pleased or friendly with you, so that won't work.
Ok, so the python check is well suited here
I keep this in mind for another event :)
 
Still testing things to undersand...
I reduced the triggers and event to minimalist code :

Code:
        <EventTriggerInfo><!-- QUEST_AMURITES  -->
            <Type>EVENTTRIGGER_QUEST_AMURITES</Type>
            <WorldNewsTexts>
                <Text></Text>
            </WorldNewsTexts>
            <TriggerTexts>
                <TriggerText>
                    <Text>TXT_KEY_EVENT_TRIGGER_QUEST_AMURITES</Text>
                    <Era>NONE</Era>
                </TriggerText>
            </TriggerTexts>
            <EventArt>Art\EventImages\e_AMURITES_QUEST.dds</EventArt>
            <iPercentGamesActive>100</iPercentGamesActive>
            <iWeight>-1</iWeight>
            <Events>
                <Event>EVENT_QUEST_AMURITES_1</Event>
            </Events>
            <PythonCanDo>CanTriggerQUEST_AMURITES</PythonCanDo>
        </EventTriggerInfo>

and

Code:
        <EventInfo>
            <Type>EVENT_QUEST_AMURITES_1</Type>
            <Description>TXT_KEY_EVENT_QUEST_AMURITES_1</Description>
            <LocalInfoText/>
            <WorldNewsTexts/>
            <OtherPlayerPopup/>
            <QuestFailText>TXT_KEY_EVENT_FAIL_QUEST_AMURITES</QuestFailText>
            <bQuest>1</bQuest>
            <Button>,Art/Interface/Buttons/Process/Blank.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
            <iAIValue>1000</iAIValue>
        </EventInfo>

and python code unchanged

The good news is that i can't manually trigger with another civ :nono:

the bad news is that the event don't trigger naturally with amurites :sad:

Then i'am thinking about an alternative way to do what i want...
Maybe in the CvEventManager i can add some code to provide a message to the target player / civ in the onGameStart function, to describe quest's objective
then add the checks (if objectives are done) in the onBeginGameTurn
But... i'll probably have to not apply resolution each turn :rolleyes: that will lead to a problem/question of "how" to keep the information that the quest has already been done

But it's not really my prefered way to do as i fear that some of my other events won't work due to the same mechanism
 
Well, after many many tries, adding and removing prereqs... the event finaly works as firstly expected.

Here is the line that was missing in the trigger :

<iMaxOurLandmass>-1</iMaxOurLandmass>

Anyway, this still doesn't explain why it was possible to manually fire the event.

This lead me to my as usual programer philosophical question :
what's the more important ? to understand why a program don't works, or not to understand why a program works :mischief:
 
Top Bottom