So I’ve been looking around in the code for a while now and I’ve come up with a couple of questions.
The first: Is there a way to reference and/or change flags/stats on a specific foetus? I know that part of the code is handled in the hardcoding but looking at it all, there has to be some sort of way to reference it.
The second: Is it possible to generate a foetus by providing two sets of DNA (father and mother) manually? For example, skipping the egg fertilization checks entirely? And if so, can you designate who the carrier will be? Oh, and if you can do this, is the timer that decides when birth occurs on the foetus or the mother?
Foetus is not object of Creature class, it’s object of Foetus class. Flags can’t be used with it, but manipulation with DNA is possibe. But it’s DNA, not RNA - so any changes will be passed to the children of future character.
To get access to the gene use this construction:
DNAgene g = CreatureProcessor.getFoetusGene( Creature, foetus_number, “gene.name” );
Ater this you will get reference to specific gene of foetus in variable “g” and can do with it anything, as you can with any other genes. Also check CreatureProcessor class in published partial sources - it has some other related methods.
The second: Is it possible to generate a foetus by providing two sets of DNA (father and mother) manually? For example, skipping the egg fertilization checks entirely? And if so, can you designate who the carrier will be? Oh, and if you can do this, is the timer that decides when birth occurs on the foetus or the mother?
Not exactly. Pregnancy is very complex process. Check scripts of the uterus organ. Check in the CreatureProcessor class.
Who will be carrier it's not a right question. Carrier can't be selected directly. To become pregnant character (object of Creature class) need to:
1. have object "uterus" of Organ class as one of organs. (all scripts related to pregnancy is inside of it.)
2. have ready ova object generated in the uterus.
3. Have some sperm object(s) injected (through special method call of CreatureProcessor class).
4. Call function to check if ova is fetilized and if so - foetus will be created and added to uterus.
All related to this in the uterus (in scripts), and CreatureProcessor class (in sources - methods of this class called form uterus scripts).
Timer - it’s not exactly just one timer, actualy it’s two - one for normal duration of pregnancy, and second to check if enough time passed to live birth. Both timer’s in the foetus, but control of birth start come from uterus organ (It check timers and decide).
I’ve noticed that in the change rates values are expressed like this “1.9E-4” with a chrate of “1.8765656312510454E-4”. Why are they like this and how do you determine the number to use if you wish to modify this?
The “E” in the number fields is the game’s way of handling scientific notation. So, “1.5E7” ~ “1.5 * 10 ^ 7”; + makes the number larger (tens 10s, hundreds 100s, etc.) whereas - makes them smaller (tenths 0.1s, hundredths 0.01s, etc.). If you want to change these numbers, the part to the left of the E should be changed, but only by a small amount. If you look at the projections on the right of a DNA/RNA window, you can see what effect the change has by clicking into another field on the left. Doing that allows the game to check the changes to the input and give you a result.
If that doesn’t work, then x^(1/2) = x^0.5 => Math.pow(x, 0.5), which I know does work, is mathematically equivalent to taking the square root.
If all else fails, and what you’re doing absolutely requires square roots, you could try to implement something like Newton’s Method for solving roots (google it). But at that point you’re almost certainly better off finding another way to do things.
If that doesn’t work, then x^(1/2) = x^0.5 => Math.pow(x, 0.5), which I know does work, is mathematically equivalent to taking the square root.
If all else fails, and what you’re doing absolutely requires square roots, you could try to implement something like Newton’s Method for solving roots (google it). But at that point you’re almost certainly better off finding another way to do things.[/quote]
I’m pretty sure h.coder has a square root function in the game’s code. though i can’t remember the proper method call
What about the legacy contract though? I tried searching through the partial source we have access to and through the script files and I cannot see where the LegacyContract is stored/generated.
[quote=“Gilaf, post:10, topic:904”]Thanks! Math.sqrt() was right on the money.
What about the legacy contract though? I tried searching through the partial source we have access to and through the script files and I cannot see where the LegacyContract is stored/generated.[/quote]
I honestly don’t know. From a quick look it looks like it calls a hard-coded method
[quote=“Dohavocom, post:11, topic:904”][quote=“Gilaf, post:10, topic:904”]Thanks! Math.sqrt() was right on the money.
What about the legacy contract though? I tried searching through the partial source we have access to and through the script files and I cannot see where the LegacyContract is stored/generated.[/quote]
I honestly don’t know. From a quick look it looks like it calls a hard-coded method[/quote]
Yeah, I agree. I’ve been looking through the partial source and all I can find is a reference to where the script calls for it to happen but it doesn’t actually show anything else. So H.Coder, is there a way to override that sort of thing? Do children inherit their parent’s contract types? Any info would be great.
LegacyContract is default hardcoded contract for children of workers (worker normally can’t be without contract, so children to stay with player should have one). It can be freely repaced by normal contract designed in contract editor in the dev mode. It’s also not do anything that can’t be done with scripted contract. Sample to contract change (asume that “c” is character to change contract):
c.removeFromWorkers(); //to remove all old setup.
contract = LoadContract(“commoner_contract”); //already present designed contract from contract’s folder. (This one used for recruirt workers in Kau willage.)
contract.setValue(1000); // setting up price of contract to show in description and partialy return if contract is broken.
c.addToWorkers(contract); //re-adding to workers with new contract.
RemoveMoney(1000); //just adding to workers not do anything to player’s money - there we remove them for sealed contract.
In attachment is source file for WorkerContract class - base class for all contracts. Legacy and agency contracts extends it. Field “custom” game set to “true” if it’s loaded scripted contract. If it false - than contract is harcoded.