is it possible to have a unit have multiple unit classes i.e. a mounted melee unit?
is it possible to have a unit have multiple unit classes i.e. a mounted melee unit?
How do I make .cpp to generate (pseudo)random number within 0 and 1?
As it's not good to have a question as a last reply on last page I will quote myself:
On another note, is it possible to add a trait that would, for example, result in a relations loss(or boost) with all other leaders without modifying the SDK in order to add an XML value? For example, adding a trait that would result in a minus four relations loss with everyone else. (This is for an LP for RPing purposes.)
(1- GC.getGameINLINE().getSorenRandNum(2, "NameYourRandomCallHere"))
I think you'll find the net results of that to be the same as just:
GC.getGameINLINE().getSorenRandNum(2, "NameYourRandomCallHere")
In either case you get only the number 0 or 1, 50% of either. Your version just flips each 0 to a 1 and each 1 to a 0.
The getSorenRandNum(N,"foo") function returns a random number with N possible values. Those values are all integers, start with 0, and don't skip any values therefore the possible results are integers from 0 to N-1.
I'm not sure, but it sounded to me like LuKo wanted floating point values between 0 and 1 rather than an integer that could be 0 or 1. No exact specification was made, so I am going with the half open range [0,1). A good approximation can be made for that via:
fValue = (float)GC.getGameINLINE().getSorenRandNum(10000,"foo")/10000.0
to get values from (and including) 0.0 to about .9999 (roughly, due to the inexact binary representation of the decimal values).
If you want the possibility of getting the value 1 (i.e. the closed range [0,1]) then you'd divide by 9999 instead of 10000.
@The_J and dacubz
I will guess def placeUpgradesTo(self): of CvPediaUnit
Can be done via Python.
I have a small mod component to demonstrate it here.
does anyone know of a mod that makes it so upgrading units gives them appropriate promotions (example, toku upgrading a pikeman to a rifleman yields a city-defender 1 and drill 1 that it should have)
I think you'll find the net results of that to be the same as just:
GC.getGameINLINE().getSorenRandNum(2, "NameYourRandomCallHere")
In either case you get only the number 0 or 1, 50% of either. Your version just flips each 0 to a 1 and each 1 to a 0.
The getSorenRandNum(N,"foo") function returns a random number with N possible values. Those values are all integers, start with 0, and don't skip any values therefore the possible results are integers from 0 to N-1.
I'm not sure, but it sounded to me like LuKo wanted floating point values between 0 and 1 rather than an integer that could be 0 or 1. No exact specification was made, so I am going with the half open range [0,1). A good approximation can be made for that via:
fValue = (float)GC.getGameINLINE().getSorenRandNum(10000,"foo")/10000.0
to get values from (and including) 0.0 to about .9999 (roughly, due to the inexact binary representation of the decimal values).
If you want the possibility of getting the value 1 (i.e. the closed range [0,1]) then you'd divide by 9999 instead of 10000.