View Full Version : Help with ship capturing.


NwabudikeMorgan
Apr 09, 2008, 04:26 PM
So i know how to make it happen that when you defeat a unit, it is captured, and that's all fine and dandy, however, I would like a little help or feedback with this idea: In the Napoleon Mod by Alazkan Assassin it was coded in the Python that when you defeated a ship, you had a % chance to capture it, and then also coded was a preset amount of damage that ship would have sustained ie: captured frigate has 1.0/8 HP

I wanted to include this same feature in my mod, but try as i might I couldent get the python from Napoleon to work. I had another idea, which was to make a weaker version of each ship, which would be the "captured vessel" and could be upgraded at a small cost of gold to the original.
here's what i mean:

Frigate loses in a battle to an ironclad, so the frigate will be captured, but instead of a frigate, the ironclad player recieves a "damaged frigate" with, say 4HP instead of 8, which can be upgraded to a standard frigate with 8 HP for say 50 gold.

this second way is easy to code, as all you need is XML, but i just wanted some feedback, and to see if anyone has knowledge of how to script the capture thing in python.

primordial stew
Apr 09, 2008, 10:07 PM
Enslaving is what it's called, and it's in a few mods (eg FFH, RFRE). There is also a mod comp called something like zUnitEnslavement. Basically.. it's an override to onCombatResult that runs an initUnit that is guarded by certain conditions.

I'd recommend looking at FFH since it has both enslavement as well as ship promotions, and IMHO it would be best to have both. Ships didn't run around with entire extra crews on board, so battle + skeleton crewing the other ship would reduce the capabilities of both ships at least some. So maybe if there is a successful capture then pin a promotion on the winner that it can't capture another ship wo/ returning to port (ie check for this promo in the guard logic for initUnit), and give the captured ship a promo that gives -999% healing (does that work?), which is also removed when entering a port city.

NwabudikeMorgan
Apr 09, 2008, 10:45 PM
Alright, thanks for the tip!

I don't know how to python things like units getting promotions after a victory.

primordial stew
Apr 10, 2008, 01:01 AM
Here's part of the Iceni uprising code in rfre.py. It creates some units, and then gives all the Briton's units raider 1+2 promos.

iRaider1 = gc.getInfoTypeForString('PROMOTION_CITY_RAIDER1')
iRaider2 = gc.getInfoTypeForString('PROMOTION_CITY_RAIDER2')

pAssimPlayer.initUnit(self.iBritonMarouderID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK)
pAssimPlayer.initUnit(self.iBritonMarouderID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK)
pAssimPlayer.initUnit(self.iBoudicaID, pCity.getX(), pCity.getY(), UnitAITypes.UNITAI_ATTACK)
for pUnit in pAssimPlayer.getUnitList():
pUnit.setHasPromotion(iRaider1, True)
pUnit.setHasPromotion(iRaider2, True)

NwabudikeMorgan
Apr 10, 2008, 01:09 AM
alright, so the promotion class and description of in, obviously, and the units, but where's the condition for a victory in here? or is that a different condition than this one?

Also i figured out how to cripple the newly enslaved ship using just the XML, so even if this doesn't work, 2 out of 3 ain't bad.