HOW TO: BTS non-random Events

Fierabras,

Superb work.

I have an idea how to further adapt this; i'm developing an event that attempts to model the various East Indies Trading companies. I'll use my fav civ for reference:)

1) The event will create a building, Dutch East Indies Trading Company HQ in a city.
2) This will create a galleon every say, 5-15 turns. This ship cannot carry any cargo, pillage, bombard or attack. It CAN create a Trade mission a la a Great Merchant, to max value of say, 400-800:gold:.
3) The building will become obsolete with say Economics.

Ill post the code when Ive a first draft ready, cos i just KNOW i wont get the python right:)

Regards,
HDK
 
also, I was wondering about this, from Solvers superb event guide:

ClearEvents- if non-empty, specifies the events which get reset and the probability of that happening. For example:

<ClearEvents>
<EventChance>​
<Event>EVENT_DUSTBOWL_2</Event>​
<iEventChance>100</iEventChance>​
</EventChance>​
</ClearEvents>


This resets the EVENT_DUSTBOWL_2 unconditionally, which means that the event is considered to not have occurred.




Would this not achieve the same effect as your python script,if we used it as so:

Event General Election_1
in the eventinfo file we put

<EventTimes>
<EventTime>
<Event>EVENT_GENERAL_ELECTION_1</Event>
<iEventTime>4</iEventTime>
</EventTime>
</EventTimes>


The trigger file naturally has Recurring put to 1.

I doubt this would crash the game as, the event occurs, there is a marker for a specific event to occur in 4 turns (which happens to be that same event) and voilá, it does; ad infinitium.

No need for python, however small.

Or am i missing something basic? :/

HDK
 
I wish you won't use those square boxes at the end of a line, for some people its hard to figure out when using Notepad, and yes i have notepad + but i dont like it at all. Its just to hard to read is all.
 
Sorry about that. I read some time ago about your problem in another thread and have since switched my editor (EditPlus) back to non-Unix style (no square boxes).

You could open the file in Notepad+ and save it in different format (PC/ANSI instead of UNIX/UTF-8?) and then open that saved file in regular Notepad to get rid of those square boxes.
 
Sorry about that. I read some time ago about your problem in another thread and have since switched my editor (EditPlus) back to non-Unix style (no square boxes).

You could open the file in Notepad+ and save it in different format (ANSI?) and then open that saved file in regular Notepad to get rid of those square boxes.


I know, i just did it the hard way and replaced all with an empty space and hit enter where the square box was, it takes alot of time, but anyways, thx for answering. The guy making Stone Age mod does the same thing, its just really hard to read is all,

I am still looking over your Zeus one, seems intriguing.:p
 
hi, i'm new here and have a few questions right away :-)

I thought of making a nuclear-base which is very similiar to the starbase from the final frontier mod. I found some interesting-looking lines in the "CvFinalFrontierEvents.py" but I don't know how to work with them.

except for this question, my main question is as follows:
is it possible to stop triggering the event of creating units when an UN-Resolution is set (like the one, where you can't build nukes anymore [sorry, I'm german and I don't know the name of the reso. in english :) ] )?
So it would be possible (i.e.) to make the Manhatten Project produce a nuke every 15 rounds but stop doing it when the UN sets the bane on nukes.

I hope I could make my question clear despite of my bad english :-(

greetz David
 
Yes, it's possible I think. There is a Python function isNoNukes() which you can check in a conditional statement. I'm not sure how you would call it though. Most likely you have to add:

Code:
if (gc.getGame().isNoNukes()):
    return false

and then the code like I made in the example.
 
ok, but what about setting the trigger in dependence of a project (like the manhattan project) instead of a buildingclass?

i want that the player who acomplished the M-Project to get a free nuke every 10 (or 15) rounds.
 
Then you have to add it to Python as well, as there is no XML events tag for it. Something like CyTeam().getProjectCount("PROJECT_MANHATTAN_PROJECT")

Not sure again about the actual coding, but projects are team-based, so probably player.getTeam() to instantiate the team and then getProjectCount()

I found this in the Python Class Reference, by the way...
 
ok, and what about the fact of buildings getting obselete? what if the statue of zeus should'nt produce axeman after the invention of gunpowder?
 
so, when the building is obselete the eventtrigger won't fire, right?


btw: this is the ocde that i used:

Code:
def canTriggerManhattanNukes(argsList):
	kTriggeredData = argsList[0]
	turn = kTriggeredData.iTurn
					
	if (gc.getGame().isNoNukes()):
    		return false
	elif (turn % 15 == 0):
		return true
	else:
		return false

the event still triggers every 15th round, but it doesn't "care" for "NoNukes" ... could be somethin wrong with the "NoNuke" expression or did I make a misstake?
 
No, you have to obsolete the trigger. It will trigger as long as the building is there, even when the normal bonus is obsolete (war weariness for opponents with Statue of Zeus).

Probably you have to use the isNoNukes() function from the Diplomacy class. The Python guide does not give exact information and that function has the same name.
 
Maybe you could try this. Add the following at the top of the Python file

Code:
import CvVoteInfo

in your def, use:

Code:
if (CvVoteInfo.isNoNukes()):
    return false
 
Introduction:

While playing around with BTS Events, I wondered if it was possible to make non-random timed events. After some experimentation I found that it was indeed possible. In this tutorial I will show an example of how it can be achieved.

Explanation:

As I see it (and correct me if I'm wrong) there are 2 tags in the event trigger that determine the randomness of an event being triggered:

<iPercentGamesActive>
<iWeight>

The first determines the percentage that an event is included in a game and the second sets the change of the event occurring in the game. By setting these to the following, I made them non-random.

Code:
<iPercentGamesActive>100</iPercentGamesActive>
<iWeight>-1</iWeight>

This means the event is always included (100%) and is always triggered (-1), providing all the requirements are met.

By setting the <bRecurring> tag to 1, the event will be triggered more than once.

Code:
<bRecurring>1</bRecurring>

The problem now is, that when the requirements are met, the event will trigger each turn. This is where some Python is needed to add a new requirement that isn't possible with the available XML tags.

Let's say you want the event to occur each 10 turns. In the XML for each event trigger there is a tag named <PythonCanDo>. It's this tag you can use to hook in a Python function. In the example below I used:

Code:
<PythonCanDo>canTriggerZeusSpawn</PythonCanDo>

This function called 'canTriggerZeusSpawn' does not exist yet, so you have to add it to CvRandomEventInterface.py

(create a folder Assets/Python/EntryPoints in your mod and copy the default BTS file CvRandomEventInterface.py to that folder)

The function reads as follows:

Code:
def canTriggerZeusSpawn(argsList):
	kTriggeredData = argsList[0]
	turn = kTriggeredData.iTurn
					
	if (turn % 10 == 0):
		return true
	return false

For the mathematically challenged :) , this uses the modulus operator:

18 % 10 = 8
19 % 10 = 9
20 % 10 = 0
21 % 10 = 1
etc.

So, this function will return true every tenth turn and this return value let's the trigger know the event gets fired.

Example:

Some people might remember the Statue of Zeus from CIV3 that gave free units at certain intervals. With the help of what I have explained above, I have recreated this functionality.

First, set the event trigger's requirement:

Code:
<BuildingsRequired>
	<BuildingClass>BUILDINGCLASS_STATUE_OF_ZEUS</BuildingClass>
</BuildingsRequired>
<iNumBuildings>1</iNumBuildings>

This means the event gets triggered for the civ that owns the Statue of Zeus world wonder (only 1 in the game).

Second, set the event

Code:
<UnitClass>UNITCLASS_AXEMAN</UnitClass>
<iNumFreeUnits>4</iNumFreeUnits>

Pretty self-explanatory, but notice that it uses UNITCLASS and not UNIT, which means that civs who have a UU that replaces the axeman, will get 4 of those UU's. For example: if the Greek own the Statue of Zeus, the event will gift 4 phalanxes ("Madness!? This is Sparta!")

Below is a screenshot of all of this in action:



I have added this example as an attachment.

I follow your instruction to change iWeight/iPercentGamesActive to trigger federal reserve event to reduce the inflation. All requiremnts are met (free market and 1000 gold). But this event is not triggered. Can you help me?

The bts tech tree is too short and there is no tech yield and commerce on buildings.I want to add a new tech tree in random events, just like blast furnace,rifled cannon,radar. If the requirments are met, the evnets will trigger immediately. Hopefully BTS will add non-random event option in the next patch.
 
Could you have a promotion added to all units of a unitclass based on having a specific tech or even a specific resource?

For instance if you have ironworking your spearmen, existing and new, would get combat1. Or if you have copper your archers would get drill1? Something to that effect?

I tried to do it in the event system but the event never triggered. I set it up with 100% to percentactive and -1 but nothing. Do I need python for this?
 
Hi. I kinda want to know if it is possible to have specific units spawn at certain times on gold edition. Can this stuff work in multiplayer?
 
Back
Top Bottom