Requesting following features

with the conscription you could do something like this (you would have to define these values first I have no clue)

Code:
if iCulture<=50
   #and then something which means: conscript as if certain player

or something like that. hey what do I know :p

in the API I found something strange... A canSplitEmpire() (bool) What on earth does that do??!!
 
I would like if you still made it simple for me though!
I think you need to decide if you wanna use the random events interface or if we're gonna connect your own events module to the Event Manager instead. Both setups have their benefits and drawbacks. For instance, if you figure out how to make your own random events with Python elements, well, that would be pretty useful, not?

with the conscription you could do something like this (you would have to define these values first I have no clue)

Code:
if iCulture<=50
   #and then something which means: conscript as if certain player
The only value supplied with the getConscriptUnitType callback is the PlayerType:
Code:
	def getConscriptUnitType(self, argsList):
		[COLOR="Red"]iPlayer[/COLOR] = argsList[0]
		iConscriptUnitType = -1 #return this with the value of the UNIT TYPE you want to be conscripted, -1 uses default system
		
		return iConscriptUnitType
So there is no culture to check, unfortunately. :(

in the API I found something strange... A canSplitEmpire() (bool) What on earth does that do??!!
I wouldn't know. But its actually possible to test these methods in the Python console and see what they do... :mischief:
 
The canSplitEmpire function is apparently what is used to determine if a civ can make a colony. It checks from various things like making sure the "no vassals" option is off, there are cities on a continent (i.e. in an area) that doesn't have the capital on it, makes sure the player is not himself a vassal, and that sort of thing.
 
God-Emperor, while we have you on the line: Where would one look in the SDK to find the actual calls to CvGameUtils? Because I'm curious about those argsList tuples and what values they actually store.
 
The callback functions are spread through the various files since they are called inside other C++ functions in order to change what happens.

Fortunately, they all use the same function call so you can search for that: "gDLL->getPythonIFace()->callFunction". That would give you a list of such functions. Alternatively you can search for the name of the callback, which you can separate from various C++ functions with the same name by searching for it in double quies, since the callback names are in double quotes. This is used for some other similar things, but the ones that have a first argument of PYGameModule are apparently all the callbacks in CvGameUtils.py. The name of the callback is the second argument to that call. So they all look something like this:
Code:
	if(GC.getUSE_CAN_TRAIN_CALLBACK())
	{
		CyCity* pyCity = new CyCity((CvCity*)this);
		CyArgsList argsList;
		argsList.add(gDLL->getPythonIFace()->makePythonObject(pyCity));	// pass in city class
		argsList.add(eUnit);
		argsList.add(bContinue);
		argsList.add(bTestVisible);
		argsList.add(bIgnoreCost);
		argsList.add(bIgnoreUpgrades);
		long lResult=0;
		gDLL->getPythonIFace()->callFunction(PYGameModule, "canTrain", argsList.makeFunctionArgs(), &lResult);
		delete pyCity;	// python fxn must not hold on to this pointer 
		if (lResult == 1)
		{
			return true;
		}
	}

This is, fairly obviously, the code that calls the canTrain callback.
First, it checks to see if the callback is activated.
Then it sets up the argument list, which is what ends up in the argList tuple in the Python. In this case, it is a CyCity object, a unit ID, and 4 booleans. This, not surprisingly, matches the code in the BtS CvGameUtils.py:
Code:
	def canTrain(self,argsList):
		pCity = argsList[0]
		eUnit = argsList[1]
		bContinue = argsList[2]
		bTestVisible = argsList[3]
		bIgnoreCost = argsList[4]
		bIgnoreUpgrades = argsList[5]
		return False
Since the canTrain callback will override the DLL's decision, it checks the returned result and if it is true (which is coming through as a 1) then the CvCity::canTrain function just exits with a true, skipping the rest of the function.

That is, in essence, the way most of the callbacks work.
 
Ok, then it would be quite possible to add arguments to callbacks.

Asaf, you could add the CvCity instance as the second argument to the getConscriptUnitType callback... :D

j_mie6: Would something like this be of interest to your mod? (Unless you already disabled all modern Techs manually in the XML. :p)
 
Asaf, you could add the CvCity instance as the second argument to the getConscriptUnitType callback... :D

Done. Will be released when I finish your wish list ;)
 
I already did disable all the techs I didn't want and moved some of them to different eras. (used a mod to disable them and then moved them to 0,0 manually)

thanks god-emperor!
 
[nevermind]
 
ok lol... I forgot to say that I wanted to use my own module so starting with

import [insert imports here]

and continuing from there

it will be named ModEvents.py
 
Code:
from CvPythonExtensions import *
from PyHelpers import *
from Popup import PyPopup

##Sparticus rebellion##
Active = 1
# 1 for on 0 for off
iYear = -3800
popupHeader = "Sparticus"
popupMessage = "Sparticus has invaded southern Italy as revenge for his cruel mistreatment.\n\n A barbarian army will spawn in sourthern Italy"
Year = CyGame.getGameTurnYear()

while Active == 1:
    def showPopup():
      modPopup = PyPopup()
      modPopup.setHeaderString(popupHeader)
      modPopup.setBodyString(popupMessage)
      modPopup.launch()
    if iYear == Year:
        save

this is what I have so far... will the iYear == Year work?
(this is there untill I decide wether to remove multiple speeds...)

save is just a place keeper so I know what I am doing when I go back to it again.

I will add in new constants later when I need them... So, if I was to put TXT_KEY_EVENTS_SPARTICUS in the message would it search my text files for the string?
 
Your script is pretty... messy. You might wanna revisit whatever textbook/guide you have been using on how the while command works and also how functions are defined (with the def commmand). Also, CyGame is the name of a class (imported from CvPythonExtensions at the top). But the getGameTurnYear() method needs to be invoked on an instance of that class. Do you understand the difference?

Its hard to advice at this point... :p

Regarding the variable Year; since the CyGame.getGameTurnYear() returns a integer value (check with the API!) you might wanna call it iYear (to remind you about this fact, as i is shorthand for "integer"). But you have already assigned a value to the name iYear... :crazyeye:
 
well I can just swap iYear and Year around..

as far as I'm concerned the while loop makes it so that everything that is a "child" of it will only happen WHILE something is happening, in this case while active == 1, do the rest of the code. what would you say was wrong with that?

would it work if it was completed (as it is now) and what do I need to change?


BTW I came up with a suggestion to make it much more likely to have byzantium spawn (as it relies on humans and they are very unreliable)... It uses a special event which pops up and tells the player that the senate wants them to conquor byzantium within 30 turns and they will be greatly rewarded (if not punished too) Although the draft code I have I feel is VERY wrong...

EDIT: ah.. I see... I was defining the pop-up (thats what happens when I move things thinking they need to be beneath while and then not realising something different goes there! As well as it being like 6:30 in the morning when I did this lol)

I will get the hang of this! :D
 
In addition to defining a function in the 'while', you might get an infinite loop, which will cause the game to hang.

Unless something in this loop changes the value of 'Active', the loop will run over and over again. Not once per turn or something like that, but without stopping, and the game will never gain control again.

Make sure that either you change the value of 'Active' eventually, or otherwise don't use a loop here and just make sure this code gets called once per turn (or at whatever interval you need it).
 
ah.... I see that problem... but how would I go about making an on/off tag?
 
Use a if statement instead. But you don't put function definition in the body of a if statement. It makes no sense. Put function definition in the __main__ or module level instead (the first indentation level; no indentation).

As I said, your script is pretty messy hard to advice without doing all the work for you. But even then one would need to know what you need.
 
mmm if I was to use

Code:
byzantium = (have not got that far yet... but probs co-ordinates)
iTurn = CyGame.getGameTurnYear()
iEndYear = -3000


if cyCity.getCivilizationType (byzantium) != 28:
        #make pop-up appear#
        while Turn = iEndYear:
                 if cyCity.getCivilizationType (byzantium) == 28:
                          #somehow give reward#

would the cyCity.getCivilizationType (byzantium) == 28 work in standard BtS (as rome is player 28; says in API) and so if byzantium was roman nothing happens?
 
also I changed the code I posted yesterday a little:

Code:
from CvPythonExtensions import *
from PyHelpers import *
from Popup import PyPopup


##Sparticus rebellion##
iTriggerYear = -3800
gc = CyGlobalContext()
eBarbarian = gc.getBARBARIAN_PLAYER()
pyBarbarian = PyPlayer(eBarbarian)
popupHeader = "Sparticus"
popupMessage = "Sparticus has invaded southern Italy as revenge for his cruel mistreatment.\n\n A barbarian army will spawn in sourthern Italy"
iYear = CyGame.getGameTurnYear()
def showPopup():
    modPopup = PyPopup()
    modPopup.setHeaderString(popupHeader)
    modPopup.setBodyString(popupMessage)
    modPopup.launch()


if iTriggerYear == iYear:
    showPopup()

is it fine now?
 
Ok, I realize I'm not being very helpful now. But lets just take it from the top. So you basically wanna spawn some unit(s) on some game turn, right? And you wanna make sure it only happens once in any game? Is it a random turn, a historical date or is the event triggered by something else (like a game event, a random event or having the Slavery civic)?

And you don't wanna use the random events interface to trigger this event of yours? Because figuring out what game event is triggering it would good place to start otherwise...

edit: I didn't see your latest two messages... :p
 
btw the first code posted was for my conquor Byzantium prompt to make humans conquor it so the ERE will have more chance of spawning. post 497

The event I am making that you asked me to try and do is triggered on a specific game turn (currently -3800 but will be changed later) and spawns 3 axes on a certain tile (let's call them 0,1 for the moment) and post 498 is related to that
 
Back
Top Bottom