Dungeon Adventure MOD MOD

so for example --

if PyPlayer(gc.getPlayer(1)).getUnitList() == 0:
[do action stuff]
[other action stuff]

Would this check to see if the list for player 1 (actually the second player since the first player is "0") is empty and then execute the actions?

Am I parsing the conditional statement correctly, or does the "==" need to be an "=" or something else? Do you still use "0" for an empty set or is there another symbol?

I've noticed that Age of Ice uses some getUnitClassCount statements that have "> 0" as the condition. (These are in the onCombatResult code and check to see if Mulcarn or Kylorin were killed). I would have figured it should be written "=> 0" for python, but I think that there is a nuance to coding that I am missing here. Is it different for strings versus integers?

You'd need to check that the length is equal to 0 rather than the "list is equal to 0";

Code:
if len(PyPlayer(gc.getPlayer(iPlayerNum)).getUnitList()) == 0:



The "==" operator is read as "is equal to", whilst the "=" is read as either "is" or "becomes" (depending on your background ":=" is also "becomes").

  • If you're comparing two things, you need to see if they "are equal to" each other with "==".
  • If you're changing the value of a variable, you can say that it "is" the new value, or "becomes" the new value with "=".

"==" is comparison
"=" is assignation




The "GetUnitClassCount" tests are to see if any of that UnitClass exist. If there are greater than 0, then at least one of that unitclass exists. If there is 0, then none of that unitclass exists.

The example you gave of ">= 0" (the equals is always on the right in comparison operators btw >= <= == !=) wouldn't be of much use as it's checking if there's 0 or more units of that type. There are no occasions where counting the units should give a negative value - you'd never have "-5 goblins"
 
Ok, I looked for the other function in the DLL and it is really just CyPlayer::getNumUnits(). So a simple command like pPlayer.getNumUnits == 0 is what you are looking for.


Using the list you cannot do a == 0, you have to check for == NULL or Length(____) == 0, since it is not an integer container to begin with.


Here is the complete "Player Kill" function from the DLL:

Code:
void CvPlayer::verifyAlive()
{
	bool bKill;

	if (isAlive())
	{
		bKill = false;

		if (!bKill)
		{
			if (!isBarbarian())
			{
				if (getNumCities() == 0 && getAdvancedStartPoints() < 0)
				{
					if ((getNumUnits() == 0) || (!(GC.getGameINLINE().isOption(GAMEOPTION_COMPLETE_KILLS)) && isFoundedFirstCity()))
					{
						bKill = true;
					}
				}
			}
		}

		if (!bKill)
		{
			if (!isBarbarian())
			{
				if (GC.getGameINLINE().getMaxCityElimination() > 0)
				{
					if (getCitiesLost() >= GC.getGameINLINE().getMaxCityElimination())
					{
						bKill = true;
					}
				}
			}
		}

		if (bKill)
		{
			setAlive(false);
		}
	}
	else
	{
		if ((getNumCities() > 0) || (getNumUnits() > 0))
		{
			setAlive(true);
		}
	}
}

So, if the Player is currently flagged as Alive, is NOT the Barbarian Player, has no Cities and no Advanced Start Points, has no Units OR has already settled his first city and the game is NOT require complete kills, then they are marked for death.

Also, if the Player is currently flagged as Alive, is NOT the Barbarian Player, and has lost more Cities than the game was set for as Max City Elimination, they are marked for death.


Otherwise, if the player was not alive when this function was called, but they now have a Unit or a City somehow, they are marked as being alive once again.


Since neither setAlive, nor VerifyAlive are exposed to Python, you will probably have to use pPlayer.killUnits() & pPlayer.killCities() commands, then hope that a VerifyAlive is called sometime soonish. Looks like that is only called from TestAlive(), which is called only in CvGame::Update(), which isn't called from anywhere, but I assume runs at least once between each turn.
 
Xienwolf and Vehem,

Thank you both for the pointers. I will play around with this for a bit and report back and what works.

Thanks, again!
 
After an evening of messing around with this, here is what I learned:

1. For some reason, the python code does not like or respond to getNumUnits checks or getUnitList calls from within onCombatResult. I tried this in every permutation I could think of and it just wouldn't trigger.

2. So I changed tactics and worked with onSetPlayerAlive instead. Got it to do what I wanted on the first try. The mod will now trigger a special victory movie and designate a conquest victory if all of the opposing player's units are eliminated.

So this just goes to show you: The function you are trying to create probably already exists!
 
So I have been experimenting with a (very) stripped down FfH2 base to rebuild DA.

This presents problems of its own, as I may have stripped out too much.

When attempting to re-import the Tar Demon art for a new unit, it would not work. It just shows up as empty space. This was with the four files in the "Tar Demon" file added (2 nifs and 2 dds files) to the new unit directory and the unitartdefs pointing to the main nif.

Anybody know what all of the elements and files are that need to be added to make the Tar Demon look the way it is supposed to?

While we are at it, does anyone know of a good stationary egg graphic? Just one big egg looking thing sitting on the ground?

Thanks!
 
Found the answer to the Tar demon puzzle.

The Tar Demon makes use of an attachable highlight in the "attachables" xml file. It refers to an oilyslimeblob nif in the effects folder.

Oddly enough, the base unit graphic is a great prophet shrunk down to almost nothing. I'm wondering why the blob nif wasn't used as the base.

Hmmnn... something more with which to experiment!
 
the tar demon, aswell as the original fire elemental, were basically effects, not rigged units. To make the unit into an effect, Kael used the great prophet trick (i think you have to have a unit as base).
 
Yep. tried using just the effect NIF as the unit and got a crash. Pretty clever trick by Kael and crew. The only downside is that the unit does not display in the pedia -- but that is pretty minor!
 
You can make a static version of the unit just for the pedia. Make it really small, and crank up the Interface Scale.

Seriously? How? I understand the bit about adjusting the interface scale, but how do you make a unit especially for the pedia? And how do you get the effect to display statically?
 
No, you wouldn't get the effect to display, it's just a trick.


Right now, if you crank up the Interface Scale on a Tar Demon you'll get to see a nice Prophet in the Pedia (should at least... maybe I ought to test this). I'm saying create a model that looks like the Tar Demon and replace the 1 pixel Prophet with that new model, then crank up the Scale.
 
yes, it is a tiny little prophet -- I tested it. Currently, if you look closely in the pedia, you can see a tiny little speck on the ground. That's the 0.01 scale prophet or whatever. Scale it up and it looks like a regular prophet.

Is there a way to get the pedia to just display a jpeg picture file? Sort of like FfH2 does for leaderheads? That is something that I could easily do.
 
None I am aware of. Though you can have a different background by using the "ActAsAir" tag, and a similar one for Water. So if you find where those graphics are controlled at you could probably slip in a similar one to use as a graphic tag. It'd be the background behind the unit, but in cases like this that works perfectly fine.
 
yes, it is a tiny little prophet -- I tested it. Currently, if you look closely in the pedia, you can see a tiny little speck on the ground. That's the 0.01 scale prophet or whatever. Scale it up and it looks like a regular prophet.

Is there a way to get the pedia to just display a jpeg picture file? Sort of like FfH2 does for leaderheads? That is something that I could easily do.

hmm, if you create a "plain" in blender (or use one which comes with the game), and put your picture on it as texture, then you can put it into pedia by attaching it to the prophet.
just a quick thought, sorry, no time to look into it right now
 
yes, it is a tiny little prophet -- I tested it. Currently, if you look closely in the pedia, you can see a tiny little speck on the ground. That's the 0.01 scale prophet or whatever. Scale it up and it looks like a regular prophet.

Is there a way to get the pedia to just display a jpeg picture file? Sort of like FfH2 does for leaderheads? That is something that I could easily do.

Yeah. I added an image attribute to units. Its currently used for heroes and points to the dds file that is the special picture of the hero on the hero pedia pane.

It would be easy to change your unit pedia so that if that image attribute isn't empty use it as the picture instead of putting up the live unit model.
 
Well, I found a decent egg. Or made one rather.

A heavily modded orb of Sucellus from Age of Ice does the trick. It still even bobs around a bit, which is cool because it looks like it is about to hatch.

Still uses wolf animations, though. This is weird when your egg rears up and howls. Heh. I'll just make up a back story to explain this away. ;)
 
Back
Top Bottom