Guide to event modding in BtS

Alright I looked over the code in Notepad + +. What am I supposed to be seeing?

Here's the code. I basically took the other Barbarian SPawn code, and tried to make it work for my pirates. All I did was took out the bit about the counter units and changed the requirements around.

Spoiler :


######## THE_PIRATE_LORDS ###########

def canTriggerThePirates(argsList):

kTriggeredData = argsList[0]
player = gc.getPlayer(kTriggeredData.ePlayer)

# If Barbarians are disabled in this game, this event will not occur.
if gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_BARBARIANS):
return false

# At least one civ on the board must know Chemistry.
bFoundValid = false
iTech = CvUtil.findInfoTypeNum(gc.getTechInfo, gc.getNumTechInfos(), 'TECH_CHEMISTRY')
for iPlayer in range(gc.getMAX_CIV_PLAYERS()):
loopPlayer = gc.getPlayer(iPlayer)
if loopPlayer.isAlive():
if gc.getTeam(loopPlayer.getTeam()).isHasTech(iTech):
bFoundValid = true
break

if not bFoundValid:
return false

# At least one civ on the board must know Astronomy.
bFoundValid = false
iTech = CvUtil.findInfoTypeNum(gc.getTechInfo, gc.getNumTechInfos(), 'TECH_ASTRONOMY')
for iPlayer in range(gc.getMAX_CIV_PLAYERS()):
loopPlayer = gc.getPlayer(iPlayer)
if loopPlayer.isAlive():
if gc.getTeam(loopPlayer.getTeam()).isHasTech(iTech):
bFoundValid = true
break

if not bFoundValid:
return false

# Find an eligible plot
map = gc.getMap()
for i in range(map.numPlots()):
plot = map.plotByIndex(i)
if (plot.getOwner() == -1 and plot.isWater() and not plot.isImpassable() and plot.area().getCitiesPerPlayer(kTriggeredData.ePlayer) > 0 and plot.isAdjacentPlayer(kTriggeredData.ePlayer, true)):
return true

return false



Spoiler :


def getHelpThePirates1(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]

szHelp = localText.getText("TXT_KEY_EVENT_THE_PIRATE_LORDS_HELP_1", ())

return szHelp


Spoiler :


def applyThePirates1(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]
player = gc.getPlayer(kTriggeredData.ePlayer)

listPlots = []
map = gc.getMap()
for i in range(map.numPlots()):
plot = map.plotByIndex(i)
if (plot.getOwner() == -1 and plot.isWater() and not plot.isImpassable() and plot.area().getCitiesPerPlayer(kTriggeredData.ePlayer) > 0 and plot.isAdjacentPlayer(kTriggeredData.ePlayer, true)):
listPlots.append(i)

if 0 == len(listPlots):
return

plot = map.plotByIndex(listPlots[gc.getGame().getSorenRandNum(len(listPlots), "Pirate event location")])

if map.getWorldSize() == CvUtil.findInfoTypeNum(gc.getWorldInfo, gc.getNumWorldInfos(), 'WORLDSIZE_DUEL'):
iNumUnits = 2
elif map.getWorldSize() == CvUtil.findInfoTypeNum(gc.getWorldInfo, gc.getNumWorldInfos(), 'WORLDSIZE_TINY'):
iNumUnits = 3
elif map.getWorldSize() == CvUtil.findInfoTypeNum(gc.getWorldInfo, gc.getNumWorldInfos(), 'WORLDSIZE_SMALL'):
iNumUnits = 4
elif map.getWorldSize() == CvUtil.findInfoTypeNum(gc.getWorldInfo, gc.getNumWorldInfos(), 'WORLDSIZE_STANDARD'):
iNumUnits = 5
elif map.getWorldSize() == CvUtil.findInfoTypeNum(gc.getWorldInfo, gc.getNumWorldInfos(), 'WORLDSIZE_LARGE'):
iNumUnits = 6
else:
iNumUnits = 8

iUnitType = CvUtil.findInfoTypeNum(gc.getUnitInfo, gc.getNumUnitInfos(), 'UNIT_DREAD_PIRATE')

barbPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
for i in range(iNumUnits):
barbPlayer.initUnit(iUnitType, plot.getX(), plot.getY(), UnitAITypes.UNITAI_PIRATE_SEA, DirectionTypes.DIRECTION_SOUTH)

 
Please use the
PHP:
php tag
instead of the
Code:
code tag
.

Because the code tag can't show the intendation, but this is the thing, i want to see.
Or attach the files, then i can see it directly.

It won't allow me to attach .py ...
 
There you go. Screen shots.

If that can't help you, I'll have to concede this is too much for me. :(


;)
 

Attachments

  • PythonCode1.jpg
    PythonCode1.jpg
    393.3 KB · Views: 255
  • PythonCode2.jpg
    PythonCode2.jpg
    422.9 KB · Views: 241
For attaching the .py files: Next time just zip it or rename it to .txt ;).

To the problem: I can't see a direct problem with the code itself.
But i would check, if you wrote UNIT_DREAD_PIRATE really right, and if the AI UNITAI_PIRATE_SEA really exists.



:think: what happens, if you try to trigger another event via the console? Does it also not work?
 
For attaching the .py files: Next time just zip it or rename it to .txt ;).

To the problem: I can't see a direct problem with the code itself.
But i would check, if you wrote UNIT_DREAD_PIRATE really right,

Yeah it's a custom Unit.

and if the AI UNITAI_PIRATE_SEA really exists.

That's the one it uses for Privateers.


:think: what happens, if you try to trigger another event via the console? Does it also not work?

I can trigger any other event I made from there.

Hmmmmm... :think: I wonder what happens if I try to trigger another one that requires Python?

I didn't try that...
 
Did you activate the python exceptions like i suggested on the last page?

And could you maybe try to trigger the event without the console?
An event will immediatly trigger, after all requierements are met, when you set iPercentGamesActive to 100 and iWeight to -1. Try that. I hope, that will result in another exception.
 
Gidday!

This is a great help, explaining all the tags in the events mod! Some one should put it up in the Civ V modding wiki :)

I was playing with the idea of a nice mod where unique units are allocated to civs by events rather than by ... which civ you start with. I've read through the whole guide here and lots of the questions too and am starting to realize that this won't be a simple task...

Is there any way to change / add unique units and buildings to civs halfway through the game? (e.g.: by an event)

I considered adding hidden, unresearchable techs as prerequisites for the units, then giving these techs using Events. But that would mean that the original units would still be buildable, wouldn't it? If anyone can help out, it' be awesome!


On a different note, is it possible to have a condition in one of the event triggers being "Civilization A does NOT have resource X"? I didn't find it in the XML tags before, but perhaps I overlooked something.

Cheers
 
Yes, the original units would still be buildable. But you could make your new "UU"s an upgrade of your old units ;).


Resources:
:think: maybe check this event, where you can help your religious brothers in need by giving them a resource which they do not have.
 
Ok, I cannot find it here, and maybe I missed it. But, how do you have one civ declare war on another on a given turn in the game? I am not even worried about having the war end at this point. First things first, I just want to know how to get it started. I know there has to be a way. They used it in a WWI mod in Vanilla. Thanks, and give me some basic BTS 3.19 code, that can be used for this purpose.
 
The 12th tag listed for Civ4EventInfos.xml in the 1st post in the thread:

bDeclareWar- can be either 0 or 1. If set to 1, will cause the affected player and the other player to go to war.
 
Can more than one random event occur in the game in the same turn?

Can a Civ be hit my multiple random events in the same turn?
 
I think the game lets the RNG once per turn decide to let an event occur, so no, multiple events are not possible.

Yeah, that's what I think I see in testing. I created a Non-Random Event that occurs when a Tech is researched by any Civ and I had two Civs research it at the same time - only one of them got the Event Effects even though the other Civ did get the Event Trigger pop-up window (which is odd). So it seems some care must be used when doing this. Using this article for Non-Random Events:

http://forums.civfanatics.com/showthread.php?t=268759
 
Another question regarding AdditionalEvents, please

If you have more than one event listed, will all or only one of the events fire? The examples seem to suggest that only one will fire.

Thanks.
 
I've created an event for the Babylon 5 mod which is active in every game and will affect all civ's every turn if they have more than 12 units. The event triggers if the civ has a damaged unit and at present the unit is automatically destroyed when the event triggers.
Is there any way of reducing the chance of the event destroying the unit if they have certain promotions?
Alternatively is there any way to specify that the chances of the event destroying the unit is set very low say 2% of the time?
 
I had no response to my previous query, probably because I wasn't asking the right question.

The event is still pretty much the same. The event triggers if there is a damaged unit. I need to set the event now so that there is a PythonCanDoUnit tag.

I need to use this for ensuring that if the unit that triggered the event the first time around is still damaged after the number of turns specified by one of the three options it will trigger the next set of choices, which give a further chance to try and repair the unit. If after the second Event trigger the unit is still damaged you get the final option where the only choice is the unit is destroyed.

Again, I may not be explaining this too well and you may need to see the XML for the event to be able to respond.

From the guide and what I understand so far the Python I need to add is kTriggeredData.iUnitId I don't know where exactly I need to add this information as I have no clue about Python but have figured out from Solvers guide that this is the bit I need to use.

Any help will be greatly appreciated.
 
I just got into the random events and I have a few questions.

  • Is it possible to divide the CIV4EventsInfoTrigger into multiple files.
  • I've read about the tsunami and saw that the city has to be coastal. Is it possible to have a requirement like, the city has x jungle title or improvement to trigger an event ?
  • If an event is given to a player, can it be given to another one later?
  • If multiple events have the same weight, which one will be selected? All of them?

Thanks
 
Top Bottom