Random events in FFP

PsiCorps

FF: Babylon 5 mod team
Joined
Dec 30, 2007
Messages
1,425
Location
Britain
Hi all
I've been busy with the B5 Mod and have managed to get a few more events (some from C2C) added to the ones you had in.

So far I've successfully added in the following:-

  • Ion Storm event - destroys trade routes.
  • Abundant World - Food bounty to help growth.
  • Famine - Opposite of above.
  • Faux Pas - Same as standard Civ event.
  • The Huns - Same as standard event.

I've also added in variations of the following events but have yet to see them fire off.

  • Tsunami - Modified to be a Meteor Strike (may need some Python Modification to make it work)
  • Mining Accident - Same as standard event.
  • Influenza - Similar to standard event.
  • Best Defense - Same as standard event.

These are where I have run into a problem.

  • The Huns - Same as standard event.
  • The Vandals - Same as standard event.
  • The Goths - Same as standard event.
  • The Philistines - Same as standard event.
  • The Vedic Aryans - Same as standard event.

The event appears to fire and I have experienced one assault courtesy of the Huns variation but python keeps throwing out the following messages, which I am assuming means there is some C++ reference for the event.
Line 142 in Buffy is:-

Code:
if (loopCity.canTrain(iCounterUnit, false, false, false, false)):

Which is part of this whole section in Buffy:-

Code:
# BUG - 3.17 - Start
	if (GameUtil.isVersion(317)):
		# rest indented but unchanged
		# Can we build the counter unit?		
		iCounterUnitClass = gc.getInfoTypeForString('UNITCLASS_CRUISER_II')
		iCounterUnit = gc.getCivilizationInfo(player.getCivilizationType()).getCivilizationUnits(iCounterUnitClass)
		if iCounterUnit == -1:
			return false

		(loopCity, iter) = player.firstCity(false)
		bFound = false
		while(loopCity):
			if (loopCity.canTrain(iCounterUnit, false, false, false, false)):
				bFound = true
				break

			(loopCity, iter) = player.nextCity(iter, false)

		if not bFound:
			return false
# BUG - 3.17 - End

If this does require C++ coding then I'll have to remove the event as I have no C++ skill at all. If it's possible to resolve the issue without messing with C++ then I'm hoping someone that reads the FFP posts will be able to point me in the right direction or tell me what needs to be changed in order to get it to work.

Any help is greatly appreciated.
 
So, the error means what it says: you're calling canTrain with the wrong set of arguments. Taking a look at CyCity.cpp (which is the Python bindings in the DLL), it looks like the function should be defined as:

Code:
bool CyCity::canTrain( int /*UnitTypes*/ eUnit, bool bContinue, bool bTestVisible )
{
    return m_pCity ? m_pCity->canTrain((UnitTypes)eUnit, bContinue, bTestVisible) : false;
}

Taking a look at the copy of Buffy.py in civ4ffplus trunk, it seems they have it correct:

Code:
        while(loopCity):
            if (loopCity.canTrain(iCounterUnit, false, false)):
                bFound = true
                break

I'm not sure how you got the two extra "false, false" arguments, but remove them and it should all work.

I should also note that the second error message (over in your "Deleted" thread, where the screenshots are still posted) looks like it's complaining about the same thing on line 387 in CvRandomEventInterface.py.
 
Not a problem!

Adding more random events was always on the to-do list... how would you feel about having the events you got working added to FF+ upstream as well?

There have been one or two bugfixes that could stand to go into a small 1.84 patch along with new random events.
 
Not a problem!

Adding more random events was always on the to-do list... how would you feel about having the events you got working added to FF+ upstream as well?

There have been one or two bugfixes that could stand to go into a small 1.84 patch along with new random events.

More than happy to have them added to FF+, you may need to amend the text so they fit better with FF+. You will need to change any prereq techs and triggers to use the FF+ techs instead of the B5 techs, there's probably some other stuff that would need to be amended in Python so it looks for the right techs/ship types.
 
Sorry for the necro, but I just had an idea for a random event should you ever get around to implementing them in FFP: How about when one of your ships is about to be destroyed by a black hole you have the chance to get a one time research bonus to the tech you are currently researching? Basically the data you can gather from your doomed crew before they are silenced forever (or rather screaming in slow motion) widened your understanding of the universe, physics etc. or something.
 
Top Bottom