Need Help - Corsair Mod

aweills

Chieftain
Joined
Sep 5, 2011
Messages
7
I was hoping someone out there better versed in modding could help a brother out. I want to create a somewhat simple scenerio where player is a Corsair stealing and pillaging from other Civs.

I would like:
-captured workers become "slaves". They can be sold to city-states.
-city-states randomly offer missions requesting slaves for reward

I've been reading about the history of the mediterranean and how slavery was key to power. Corsairs ran rampant in the middle ages capturing and selling this important commodity.

I was thinking something along the lines what a great merchant does maybe for selling slaves as an alternative.

If that's too complicated, how do you change the value of "killing" off unit to reclaim their value and how to adjust this value?

Much thanks!
 
-captured workers become "slaves". They can be sold to city-states.

Changing what unit captured workers become is simple: the game already includes an XML field for that in the Units table. This is why captured Settlers become Workers. So all you'd need to do is create your "slave" unit, with entries in all the usual tables for a new unit, and then set it to be the unit Workers become. (Make sure you set the Slave's cost equal to -1, so that no one builds them in their cities.)

The problem with this is the same one that applies to nearly every great idea: the AI would have no understanding of the underlying mechanisms. The AI wouldn't see the value in Slaves, and wouldn't understand that the way to get them is to capture workers. It also wouldn't generally know what to DO with them once it has them, unless you find some existing AI that already acts appropriately.

-city-states randomly offer missions requesting slaves for reward

This one, unfortunately, is just not possible at present. City-state missions are fairly embedded in the game engine; we can disable certain missions through XML flags, but we can't generally modify the effects of the missions or add new ones.

I was thinking something along the lines what a great merchant does maybe for selling slaves as an alternative.

That can work, and is basically the same mechanism the City-State Diplomacy mod uses for its "ambassador" units: the Merchant AI simply says "find the nearest city-state, go there, and sacrifice yourself", with the effects of that sacrifice action being handled through Lua. But realize that this generally doesn't work across water; the AI won't embark a Great Merchant to use on a city-state halfway around the world. If your game focuses on pirate naval units, this is a major drawback.

If that's too complicated, how do you change the value of "killing" off unit to reclaim their value and how to adjust this value?

Now THAT is much easier to do. All you need to do is create a new Lua event tied to EndCombatSim. ECS triggers at the end of every combat, except when you play in Strategic View or have Quick Combat turned on (and the corresponding start-of-combat event is RunCombatSim). ECS's arguments are the player ID and unit ID of the attacking unit, the player ID and unit ID of the defending unit (note: unit ID will be -1 if it was a city attacking or defending), and most importantly, the amount of damage each unit has taken, and the max HP for each unit (10, by default).

So all you do, then, is see if the defending unit's damage taken meets or exceeds its total HP. If so, then the unit was killed; give the attacking player money directly, and it's easy to have the amount of money scale with the stats of the unit attacked (by tying it to cost, AdvancedStartCost, or even combat strength). In my own mod, I have a special AI-spawned unit type (the Spore Tower) that gives 100, 150, or 200 gold to any civ that kills one, so I know this works.
 
Much thanks, Spatz. I've been killing hours today figuring out some things and, as you say, all have draw backs it seems.

How about this? Creating unit that is returnable to 'capital' that rewards victory points and gold, exactly as 'treasure units' do in the Incan/Spain DLC. Create I've been trying to reverse engineer this .lua script :eek: and can't seem to get my new 'treasure = slave' to sacrifice when it reaches 'capital'.

Love to hear your and other's thoughts or perhaps simple script :D. Really just needs to be exactly like the DLC mentioned above to work I'm thinking.

Thx again!

edit- do you think the ambassador idea would work on a small, in-land sea map, such a Mediterranean? Not really concerned about AI doing this much. Would LOVE to be able to assign victory points to this as well. Victory points would be a good win-condition in the scenerio I'm dreaming up as can't see any other way to win!

edit #2 - Layed awake a bit last night thinking and going to go with the Great Merchant option and see how creative I can get with it. I'll share what I come up with.
 
Back
Top Bottom