FF: Wormholes: need assistance

Logitech

A Person.
Joined
Mar 11, 2007
Messages
409
Location
Where I need to be
Hi, I'm not an expert on civ IV moding, so I need some help.
I'm working on the Final Frontier mod, more specificly, the Star Trek beta 3 mod, and I am adding a feature (wormhole) that when ocupied by a unit, will transport that unit to another wormhole. I have it all put together, the XML, the python, and I've tested it, but the method I am using now is sending all units to the same wormhole, and any unit on that wormhole plot doesn't move. What I want is the code to loop through all plots, find all wormholes (both of which it does right now), then make a list of other wormholes, and pick a random plot (with wormhole) and send the unit there. All this must be done on a random map.

So, I need to find out: (1: How to make a list of all plots with wormholes, and (2: how to make it chose one, without making it crash or freak or anything it's not suposed to do.

I allready have or know how to: (1: Loop through all plots (learned from the surrounding code), and (2: moving the unit to a targeted plot.

BTW: If there is an easy way to make a wormhole send units to another specific wormhole-containing tile, and vise-versa between the two, with all others not sending any units to either of them on a random map (whew!), I would like that much better.
PS: if anyone can sugjest a way to allow trade through wormholes, that too would be appreciated!
 
Trade through wormholes probably needs DLL modification, though there might be a nifty trick to bypass that.

Linking 2 wormholes on random maps almost certainly requires DLL work, but wouldn't be too hard.


To choose a random Wormhole to send units into, you need to store each wormhole you find during the loop in a list. Then you select a random item from the list to be the one you move to. Here is a sample of a similar function so you can re-write from it:

Code:
	listProms = []
	for iCount in range(gc.getNumPromotionInfos()):
		if (pOpponent.isHasPromotion(iCount)):
			if gc.getPromotionInfo(iCount).isEquipment() == False:
				if (iCount != iChanneling3 and iCount != iDivine and iCount != iBronze and iCount != iIron and iCount != iMithril):
					if gc.getPromotionInfo(iCount).isRace() == false:
						listProms.append(iCount)
	if len(listProms) > 0:
		iRnd = CyGame().getSorenRandNum(len(listProms), "Mimic")
		pCaster.setHasPromotion(listProms[iRnd], True)

the [] indicated an empty list. .append adds an item into a list. having a number in the brackets indicates which list item you want to use. In your case, you can also add a check to make sure that the wormhole you are adding to the list is not the same one that the unit is currently standing in.
 
Thanks, xienwolf!
By the code you've put there, I see how to make it chose a tile. The question now is, will it work?...
EDIT: Yes! It works! Thanks a bunch, xienwolf!

As for the trade and 2 wormholes connetion, thanks, but I really don't want to edit the DLL. I'm still open for more sugjestions... And adding to that wish list: making AI realize value of wormholes...
 
Well?

As for the AI, I want it to know that wormholes move their units, thus they will use them to explore. I noticed that the AI used the wormhole once, but I don't know why. I do know that the entrance wormhole and exit wormhole were close enough for the unit that used them to have seen both of them.

I'm still wishing and hoping that there is a simple way for trade to be allowed through wormholes...

And I'm forgeting the plan to tie two wormholes to each other. After some testing, the wormholes seem to 'prefer' another wormhole, although I'm sure it's my imagination. I found that they were quite useful, especially in picking up some early goody ships.
 
Teaching the AI that they wish to move to a location is not too easy. You might be able to cheat a bit and flag it as providing a goody or defense bonus, since the AI will attempt to end move on a tile with a high bonus and to move through tiles with Goodies. But I doubt you want to be handing out goodies with each wormhole visit, so it would be tricky to block that from happening, and the defense bonus may not be appropriate for what you want.
 
Top Bottom